Created stable release branch of 2.9

git-svn-id: svn://192.168.202.10@2127 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2014-06-12 20:16:40 +00:00
parent bb7859f67c
commit 225a1addac
2757 changed files with 1856906 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
################ INSTALL
For in-depth installation instructions read the docs/SCRATCH_INSTALL.txt file
For more brief install instructions read the docs/BASE_INSTALL.txt file
For Requirements of astGUIclient/VICIDIAL read the docs/REQUIREMENTS.txt file
For installtion on Ubuntu Linux read the docs/Ubuntu_install.txt
To place the astGUIclient/VICIDIAL files where they belong on the server:
run the install.pl script from this directory:
perl install.pl
If you are upgrading from a previous version, see the UPGRADE file
@@ -0,0 +1,480 @@
<?php
# active_list_refresh.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to serve updates of the live data to the display scripts
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $ADD - ('1','2','3','4','5')
# - $order - ('asc','desc')
# - $format - ('text','table','menu','selectlist','textarea')
# - $bgcolor - ('#123456','white','black','etc...')
# - $txtcolor - ('#654321','black','white','etc...')
# - $txtsize - ('1','2','3','etc...')
# - $selectsize - ('2','3','4','etc...')
# - $selectfontsize - ('8','10','12','etc...')
# - $selectedext - ('cc100')
# - $selectedtrunk - ('Zap/25-1')
# - $selectedlocal - ('SIP/cc100')
# - $textareaheight - ('8','10','12','etc...')
# - $textareawidth - ('8','10','12','etc...')
# - $field_name - ('extension','busyext','extension_xfer','etc...')
#
#
# changes
# 50323-1147 - First build of script
# 50401-1132 - small formatting changes
# 50502-1402 - added field_name as modifiable variable
# 50503-1213 - added session_name checking for extra security
# 50503-1311 - added conferences list
# 50610-1155 - Added NULL check on MySQL results to reduced errors
# 50711-1209 - removed HTTP authentication in favor of user/pass vars
# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1118 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0029 - Converted ereg to preg functions
# 130603-2222 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-0957 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];}
elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];}
if (isset($_GET["order"])) {$order=$_GET["order"];}
elseif (isset($_POST["order"])) {$order=$_POST["order"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];}
elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];}
if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];}
elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];}
if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];}
elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];}
if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];}
elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];}
if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];}
elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];}
if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];}
elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];}
if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];}
elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];}
if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];}
elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];}
if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];}
elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];}
if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];}
elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];}
### security strip all non-alphanumeric characters out of the variables ###
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$ADD=preg_replace("/[^0-9]/","",$ADD);
$order=preg_replace("/[^0-9a-zA-Z]/","",$order);
$format=preg_replace("/[^0-9a-zA-Z]/","",$format);
$bgcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$bgcolor);
$txtcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$txtcolor);
$txtsize=preg_replace("/[^0-9a-zA-Z]/","",$txtsize);
$selectsize=preg_replace("/[^0-9a-zA-Z]/","",$selectsize);
$selectfontsize=preg_replace("/[^0-9a-zA-Z]/","",$selectfontsize);
$selectedext=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedext);
$selectedtrunk=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedtrunk);
$selectedlocal=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedlocal);
$textareaheight=preg_replace("/[^0-9a-zA-Z]/","",$textareaheight);
$textareawidth=preg_replace("/[^0-9a-zA-Z]/","",$textareawidth);
$field_name=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$field_name);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($ADD)) {$ADD="1";}
if (!isset($order)) {$order='desc';}
if (!isset($format)) {$format="text";}
if (!isset($bgcolor)) {$bgcolor='white';}
if (!isset($txtcolor)) {$txtcolor='black';}
if (!isset($txtsize)) {$txtsize='2';}
if (!isset($selectsize)) {$selectsize='4';}
if (!isset($selectfontsize)) {$selectfontsize='10';}
if (!isset($textareaheight)) {$textareaheight='10';}
if (!isset($textareawidth)) {$textareawidth='20';}
$version = '0.0.10';
$build = '130328-0029';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='table')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build ADD: $ADD server_ip: $server_ip-->\n";
echo "<title>Mostrar Lista: ";
if ($ADD==1) {echo "Extensões Ativas";}
if ($ADD==2) {echo "Extensões Ocupadas";}
if ($ADD==3) {echo "Linhas externas";}
if ($ADD==4) {echo "Extensões Locais";}
if ($ADD==5) {echo "Conferências";}
if ($ADD==99999) {echo "HELP";}
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
######################
# ADD=1 display all live extensions on a server
######################
if ($ADD==1)
{
$pt='pt';
if (!$field_name) {$field_name = 'extension';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension,fullname FROM phones where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=2 display all busy extensions on a server
######################
if ($ADD==2)
{
if (!$field_name) {$field_name = 'busyext';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension FROM live_channels where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=3 display all busy outside lines(trunks) on a server
######################
if ($ADD==3)
{
if (!$field_name) {$field_name = 'trunk';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedtrunk") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=4 display all busy Local lines on a server
######################
if ($ADD==4)
{
if (!$field_name) {$field_name = 'local';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_sip_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedlocal") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=5 display all agc-usable conferences on a server
######################
if ($ADD==5)
{
$pt='pt';
if (!$field_name) {$field_name = 'conferences';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT conf_exten,extension FROM conferences where server_ip = '$server_ip' order by conf_exten $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
if ($format=='table') {echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";}
if ($format=='table') {echo "\n</body>\n</html>\n";}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,102 @@
<?php
# audit_comments.php
#
# Copyright (C) 2014 poundteam.com,vicidial.org LICENSE: AGPLv2
#
# This script is designed to display QC audit comments, contributed by poundteam.com
#
# changes:
# 121116-1322 - First build, added to vicidial codebase
# 130802-0957 - Changed to PHP mysqli functions
# 140304-2154 - Enabled special characters in comments
#
require_once("functions.php");
function audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign) {
$audit_comments_active=audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log);
if ($audit_comments_active) {
//Get comment from list
$stmt="select comments from vicidial_list where lead_id='$lead_id' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments2',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if (strlen($row[0]) > 0) {
$comment=$row[0];
//Put comment in comment table
$stmt="INSERT INTO vicidial_comments (lead_id,user_id,list_id,campaign_id,comment) VALUES ('$lead_id','$user','$list_id','$campaign','".mysqli_real_escape_string($link, $comment)."');";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments3',$user,$server_ip,$session_name,$one_mysql_log);
}
$affected=mysqli_affected_rows($link);
if($affected>0) {
$stmt="UPDATE vicidial_list set comments='' where lead_id='$lead_id';";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments4',$user,$server_ip,$session_name,$one_mysql_log);
}
} else {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditCommentsERROR-Comment not moved',$user,$server_ip,$session_name,$one_mysql_log);
echo "\n<!-- 00142-AuditCommentsERROR-Comment not moved -->";
}
}
}
}
function audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log){
$stmt="select count(audit_comments) from vicidial_lists_custom where list_id='$list_id' and audit_comments='1' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments5',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if ($row[0] == '1') {
return true;
} else {
return false;
}
}
function get_audited_comments($lead_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log) {
global $ACcount;
global $ACcomments;
$stmt="select user_id,comment from vicidial_comments where lead_id='$lead_id';";
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"00142-65-AuditComments:$stmt LeadID: $lead_id,$format,$user,$mel,$NOW_TIME,\$link,$server_ip,$session_name,$one_mysql_log",$user,$server_ip,$session_name,$one_mysql_log);
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-69-AuditComments',$user,$server_ip,$session_name,$one_mysql_log);
}
$ACcount=mysqli_num_rows($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-72-AuditComments $ACcount='.$ACcount,$user,$server_ip,$session_name,$one_mysql_log);
if($ACcount>0) {
$i=0;
while ($i < $ACcount) {
$row=mysqli_fetch_row($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-77-AuditComments UserID='.$row[0],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= "UserID: $row[0]\n";
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-79-AuditComments Comment='.$row[1],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= $row[1];
$ACcomments .= "\n----------------------------------\n";
$i++;
}
return true;
} else {
return false;
}
}
?>
@@ -0,0 +1,95 @@
/* calendar icon */
img.tcalIcon {
cursor: pointer;
margin-left: 1px;
vertical-align: middle;
}
/* calendar container element */
div#tcal {
position: absolute;
visibility: hidden;
z-index: 100;
width: 158px;
padding: 2px 0 0 0;
}
/* all tables in calendar */
div#tcal table {
width: 100%;
border: 1px solid silver;
border-collapse: collapse;
background-color: white;
}
/* navigation table */
div#tcal table.ctrl {
border-bottom: 0;
}
/* navigation buttons */
div#tcal table.ctrl td {
width: 15px;
height: 20px;
}
/* month year header */
div#tcal table.ctrl th {
background-color: white;
color: black;
border: 0;
}
/* week days header */
div#tcal th {
border: 1px solid silver;
border-collapse: collapse;
text-align: center;
padding: 3px 0;
font-family: tahoma, verdana, arial;
font-size: 10px;
background-color: gray;
color: white;
}
/* date cells */
div#tcal td {
border: 0;
border-collapse: collapse;
text-align: center;
padding: 2px 0;
font-family: tahoma, verdana, arial;
font-size: 11px;
width: 22px;
cursor: pointer;
}
/* date highlight
in case of conflicting settings order here determines the priority from least to most important */
div#tcal td.othermonth {
color: silver;
}
div#tcal td.weekend {
background-color: #ACD6F5;
}
div#tcal td.today {
border: 1px solid red;
}
div#tcal td.selected {
background-color: #FFB3BE;
}
/* iframe element used to suppress windowed controls in IE5/6 */
iframe#tcalIF {
position: absolute;
visibility: hidden;
z-index: 98;
border: 0;
}
/* transparent shadow */
div#tcalShade {
position: absolute;
visibility: hidden;
z-index: 99;
}
div#tcalShade table {
border: 0;
border-collapse: collapse;
width: 100%;
}
div#tcalShade table td {
border: 0;
border-collapse: collapse;
padding: 0;
}
@@ -0,0 +1,335 @@
// Tigra Calendar v4.0.2 (2009-01-12) Database (yyyy-mm-dd)
// http://www.softcomplex.com/products/tigra_calendar/
// Public Domain Software... You're welcome.
// default settins
var A_TCALDEF = {
'months' : ['Janeiro', 'February', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
'imgpath' : '../agc/images/' // directory with calendar images
}
// date parsing function
function f_tcalParseDate (s_date) {
var re_date = /^\s*(\d{2,4})\-(\d{1,2})\-(\d{1,2})\s*$/;
if (!re_date.exec(s_date))
return alert ("Inválido date: '" + s_date + "'.\nAccepted format is yyyy-mm-dd.")
var n_day = Number(RegExp.$3),
n_month = Number(RegExp.$2),
n_year = Number(RegExp.$1);
if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Inválido month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays = new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Inválido day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);
}
// date generating function
function f_tcalGenerDate (d_date) {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
);
}
// implementation
function tcal (a_cfg, a_tpl) {
// apply default template if not specified
if (!a_tpl)
a_tpl = A_TCALDEF;
// register in global collections
if (!window.A_TCALS)
window.A_TCALS = [];
if (!window.A_TCALSIDX)
window.A_TCALSIDX = [];
this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
window.A_TCALS[this.s_id] = this;
window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
// assign methods
this.f_show = f_tcal_show;
this.f_hide = f_tcal_hide;
this.f_toggle = f_tcalToggle;
this.f_update = f_tcalUpdate;
this.f_relDate = f_tcalRelDate;
this.f_parseDate = f_tcalParseDate;
this.f_generDate = f_tcalGenerDate;
// create calendar icon
this.s_iconId = 'tcalico_' + this.s_id;
this.e_icon = f_getElement(this.s_iconId);
if (!this.e_icon) {
document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
this.e_icon = f_getElement(this.s_iconId);
}
// save received parameters
this.a_cfg = a_cfg;
this.a_tpl = a_tpl;
}
function f_tcal_show (d_date) {
// find input field
if (!this.a_cfg.controlname)
throw("TC: control name is not specified");
if (this.a_cfg.formname) {
var e_form = document.forms[this.a_cfg.formname];
if (!e_form)
throw("TC: form '" + this.a_cfg.formname + "' can not be found");
this.e_input = e_form.elements[this.a_cfg.controlname];
}
else
this.e_input = f_getElement(this.a_cfg.controlname);
if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
// dynamically create HTML elements if needed
this.e_div = f_getElement('tcal');
if (!this.e_div) {
this.e_div = document.createElement("DIV");
this.e_div.id = 'tcal';
document.body.appendChild(this.e_div);
}
this.e_shade = f_getElement('tcalShade');
if (!this.e_shade) {
this.e_shade = document.createElement("DIV");
this.e_shade.id = 'tcalShade';
document.body.appendChild(this.e_shade);
}
this.e_iframe = f_getElement('tcalIF')
if (b_ieFix && !this.e_iframe) {
this.e_iframe = document.createElement("IFRAME");
this.e_iframe.style.filter = 'alpha(opacity=0)';
this.e_iframe.id = 'tcalIF';
this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
document.body.appendChild(this.e_iframe);
}
// hide all calendars
f_tcal_hideAll();
// generate HTML and show calendar
this.e_icon = f_getElement(this.s_iconId);
if (!this.f_update())
return;
this.e_div.style.visibility = 'visible';
this.e_shade.style.visibility = 'visible';
if (this.e_iframe)
this.e_iframe.style.visibility = 'visible';
// change icon and status
this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
this.e_icon.title = 'Close Calendar';
this.b_visible = true;
}
function f_tcal_hide (n_date) {
if (n_date)
this.e_input.value = this.f_generDate(new Date(n_date));
// no action if not visible
if (!this.b_visible)
return;
// hide elements
if (this.e_iframe)
this.e_iframe.style.visibility = 'hidden';
if (this.e_shade)
this.e_shade.style.visibility = 'hidden';
this.e_div.style.visibility = 'hidden';
// change icon and status
this.e_icon = f_getElement(this.s_iconId);
this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
this.e_icon.title = 'Open Calendar';
this.b_visible = false;
}
function f_tcalToggle () {
return this.b_visible ? this.f_hide() : this.f_show();
}
function f_tcalUpdate (d_date) {
var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
var d_selected = this.e_input.value == ''
? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
: this.f_parseDate(this.e_input.value);
// figure out date to display
if (!d_date)
// selected by default
d_date = d_selected;
else if (typeof(d_date) == 'number')
// get from number
d_date = f_tcalResetTime(new Date(d_date));
else if (typeof(d_date) == 'string')
// parse from string
this.f_parseDate(d_date);
if (!d_date) return false;
// first date to display
var d_firstday = new Date(d_date);
d_firstday.setDate(1);
d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
var a_class, s_html = '<table class="ctrl"><tbody><tr>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
+ '</tr></tbody></table><table><tbody><tr class="wd">';
// print weekdays titles
for (var i = 0; i < 7; i++)
s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
s_html += '</tr>' ;
// print calendar table
var n_date, n_month, d_current = new Date(d_firstday);
while (d_current.getMonth() == d_date.getMonth() ||
d_current.getMonth() == d_firstday.getMonth()) {
// print row heder
s_html +='<tr>';
for (var n_wday = 0; n_wday < 7; n_wday++) {
a_class = [];
n_date = d_current.getDate();
n_month = d_current.getMonth();
// other month
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length] = 'othermonth';
// weekend
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length] = 'weekend';
// today
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length] = 'today';
// selected
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length] = 'selected';
s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
d_current.setDate(++n_date);
while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
d_current.setHours(d_current.getHours + 1);
d_current = f_tcalResetTime(d_current);
}
}
// print row footer
s_html +='</tr>';
}
s_html +='</tbody></table>';
// update HTML, positions and sizes
this.e_div.innerHTML = s_html;
var n_width = this.e_div.offsetWidth;
var n_height = this.e_div.offsetHeight;
var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
if (n_left < 0) n_left = 0;
this.e_div.style.left = n_left + 'px';
this.e_div.style.top = n_top + 'px';
this.e_shade.style.width = (n_width + 8) + 'px';
this.e_shade.style.left = (n_left - 1) + 'px';
this.e_shade.style.top = (n_top - 1) + 'px';
this.e_shade.innerHTML = b_ieFix
? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
if (this.e_iframe) {
this.e_iframe.style.left = n_left + 'px';
this.e_iframe.style.top = n_top + 'px';
this.e_iframe.style.width = (n_width + 6) + 'px';
this.e_iframe.style.height = (n_height + 6) +'px';
}
return true;
}
function f_getPosition (e_elemRef, s_coord) {
var n_pos = 0, n_offset,
e_elem = e_elemRef;
while (e_elem) {
n_offset = e_elem["offset" + s_coord];
n_pos += n_offset;
e_elem = e_elem.offsetParent;
}
// margin correction in some browsers
if (b_ieMac)
n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
else if (b_safari)
n_pos -= n_offset;
e_elem = e_elemRef;
while (e_elem != document.body) {
n_offset = e_elem["scroll" + s_coord];
if (n_offset && e_elem.style.overflow == 'scroll')
n_pos -= n_offset;
e_elem = e_elem.parentNode;
}
return n_pos;
}
function f_tcalRelDate (d_date, d_diff, s_units) {
var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
var d_result = new Date(d_date);
d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
if (d_result.getDate() != d_date.getDate())
d_result.setDate(0);
return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
}
function f_tcal_hideAll () {
for (var i = 0; i < window.A_TCALSIDX.length; i++)
window.A_TCALSIDX[i].f_hide();
}
function f_tcalResetTime (d_date) {
d_date.setHours(0);
d_date.setMinutes(0);
d_date.setSeconds(0);
d_date.setMilliseconds(0);
return d_date;
}
f_getElement = document.all ?
function (s_id) { return document.all[s_id] } :
function (s_id) { return document.getElementById(s_id) };
if (document.addEventListener)
window.addEventListener('scroll', f_tcal_hideAll, false);
if (window.attachEvent)
window.attachEvent('onscroll', f_tcal_hideAll);
// global variables
var s_userAgent = navigator.userAgent.toLowerCase(),
re_webkit = /WebKit\/(\d+)/i;
var b_mac = s_userAgent.indexOf('mac') != -1,
b_ie5 = s_userAgent.indexOf('msie 5') != -1,
b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
var b_ieFix = b_ie5 || b_ie6,
b_ieMac = b_mac && b_ie5,
b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
@@ -0,0 +1,201 @@
<?php
# call_log_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the inbound and outbound calls for a specific phone
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
# - $in_limit - ('10','20','50','100',...)
# - $out_limit - ('10','20','50','100',...)
#
#
# changes
# 50406-1013 - First build of script
# 50407-1452 - Added definable limits
# 50503-1236 - added session_name checking for extra security
# 50610-1158 - Added NULL check on MySQL results to reduced errors
# 50711-1202 - removed HTTP authentication in favor of user/pass vars
# 60323-1550 - added option for showing different number dialed in log
# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1202 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0028 - Converted ereg to preg functions
# 130603-2219 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1005 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($in_limit)) {$in_limit="100";}
if (!isset($out_limit)) {$out_limit="100";}
$number_dialed = 'number_dialed';
#$number_dialed = 'extension';
$version = '0.0.10';
$build = '130328-0028';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Registro de Ligações";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten não é válido ou protocolo $protocol não é válido\n";
exit;
}
else
{
##### print outbound calls from the call_log table
$stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$out_calls_count = mysqli_num_rows($rslt);}
echo "$out_calls_count|";
$loop_count=0;
while ($out_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[3] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);}
echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|";
}
echo "\n";
##### print inbound calls from the live_inbound_log table
$stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$in_calls_count = mysqli_num_rows($rslt);}
echo "$in_calls_count|";
$loop_count=0;
while ($in_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[4] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
$callerIDnum = $row[3]; $callerIDname = $row[3];
$callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum);
$callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname);
echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,782 @@
<?php
# conf_exten_check.php version 2.8
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the meetme conference has live channels connected and which they are
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $ACTION - ('refresh','register')
# - $client - ('agc','vdc')
# - $conf_exten - ('8600011',...)
# - $exten - ('123test',...)
# - $auto_dial_level - ('0','1','1.2',...)
# - $campagentstdisp - ('YES',...)
#
# changes
# 50509-1054 - First build of script
# 50511-1112 - Added ability to register a conference room
# 50610-1159 - Added NULL check on MySQL results to reduced errors
# 50706-1429 - script changed to not use HTTP login vars, user/pass instead
# 50706-1525 - Added date-time display for vicidial client display
# 50816-1500 - Added random update to vicidial_live_agents table for vdc users
# 51121-1353 - Altered echo statements for several small PHP speed optimizations
# 60410-1424 - Added ability to grab calls-being-placed and agent status
# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1201 - Added variable filters to close security holes for login form
# 61128-2255 - Added update for manual dial vicidial_live_agents
# 70319-1542 - Added agent disabled display function
# 71122-0205 - Added vicidial_live_agent status output
# 80424-0442 - Added non_latin lookup from system_settings
# 80519-1425 - Added calls-in-queue tally
# 80703-1106 - Added API functionality for Hangup and Dispo
# 81104-0229 - Added mysql error logging capability
# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries
# 90102-1402 - Added check for system and database time synchronization
# 90120-1720 - Added compatibility for API pause/resume and dial a number
# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours
# 90408-0020 - Added API vtiger specific callback activity record ability
# 90508-0727 - Changed to PHP long tags
# 90706-1430 - Fixed AGENTDIRECT calls in queue display count
# 90908-1037 - Added DEAD call logging
# 91130-2022 - Added code for manager override of in-group selection
# 91228-1341 - Added API fields update functions
# 100109-1337 - Fixed Manual dial live call detection
# 100527-0957 - Added send_dtmf, transfer_conference and park_call API functions
# 100727-2209 - Added timer actions for hangup, extension, callmenu and ingroup as well as destination
# 101123-1105 - Added api manual dial queue feature to external_dial function
# 101208-0308 - Moved the Calls in Queue count and other counts outside of the autodial section (issue 406)
# 110610-0059 - Small fix for manual dial calls lasting more than 100 minutes in real-time report
# 120809-2353 - Added external_recording function
# 121028-2305 - Added extra check on session_name to validate agent screen requests
# 130328-0011 - Converted ereg to preg functions
# 130603-2218 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1015 - Changed to use PHP mysqli functions
# 140126-0659 - Added external_pause_code function
#
$version = '2.8-37';
$build = '140126-0659';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=39;
$one_mysql_log=0;
$DB=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
### If you have globals turned off uncomment these lines
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];}
elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];}
if (isset($_GET["client"])) {$client=$_GET["client"];}
elseif (isset($_POST["client"])) {$client=$_POST["client"];}
if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];}
elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];}
elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];}
if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];}
elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^\-_0-9a-zA-Z]/i","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($client)) {$client="agc";}
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_TIME = date("Ymd_His");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$random = (rand(1000000, 9999999) + 10000000);
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build MEETME: $conf_exten server_ip: $server_ip-->\n";
echo "<title>Verificação da Extensão de Conferência";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if ($ACTION == 'refresh')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($conf_exten)<1)
{
$channel_live=0;
echo "Conf Exten $conf_exten não é válido\n";
exit;
}
else
{
if ($client == 'vdc')
{
$Acount=0;
$Scount=0;
$AexternalDEAD=0;
$Aagent_log_id='';
$Acallerid='';
$DEADcustomer=0;
$Astatus='';
$Acampaign_id='';
### see if the agent has a record in the vicidial_live_agents table
$stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Acount=$row[0];
### see if the agent has a record in the vicidial_session_data table
$stmt="SELECT count(*) from vicidial_session_data where user='$user' and server_ip='$server_ip' and session_name='$session_name';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03039',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Scount=$row[0];
if ($Acount > 0)
{
$stmt="SELECT status,callerid,agent_log_id,campaign_id,lead_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Astatus = $row[0];
$Acallerid = $row[1];
$Aagent_log_id = $row[2];
$Acampaign_id = $row[3];
$Alead_id = $row[4];
$api_manual_dial='STANDARD';
$stmt = "SELECT api_manual_dial FROM vicidial_campaigns where campaign_id='$Acampaign_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$vcc_conf_ct = mysqli_num_rows($rslt);
if ($vcc_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$api_manual_dial = $row[0];
}
}
# ### find out if external table shows agent should be disabled
# $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_to_mysqli($stmt, $link);
# $row=mysqli_fetch_row($rslt);
# $AexternalDEAD=$row[0];
##### BEGIN checkligadocalls in queue, number of active calls in the campaign
if ($campagentstdisp == 'YES')
{
$ADsql='';
### grab the status of this agent to display
$stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Alogin=$row[0];
$Acampaign=$row[1];
$AccampSQL=$row[2];
$AccampSQL = preg_replace('/\s\-/','', $AccampSQL);
$AccampSQL = preg_replace('/\s/',"','", $AccampSQL);
if (preg_match('/AGENTDIRECT/i', $AccampSQL))
{
$AccampSQL = preg_replace('/AGENTDIRECT/i','', $AccampSQL);
$ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )";
}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$RingCalls=$row[0];
if ($RingCalls > 0) {$RingCalls = "<font class=\"queue_text_red\">Chamadas na fila: $RingCalls</font>";}
else {$RingCalls = "<font class=\"queue_text\">Chamadas na fila: $RingCalls</font>";}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$DiaLCalls=$row[0];
}
else
{
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
}
##### END checkligadocalls in queue, number of active calls in the campaign
if ($auto_dial_level > 0)
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent isligadois hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03018',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) and (preg_match("/^M/",$Acallerid)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03038',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03019',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03020',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03021',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
else
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent isligadois hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03037',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03030',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03031',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03032',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
### grab the API hangup and API dispo fields in vicidial_live_agents
$stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds,external_dtmf,external_transferconf,external_park,external_timer_action_destination,external_recording,external_pause_code from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$external_hangup = $row[0];
$external_status = $row[1];
$external_pause = $row[2];
$external_dial = $row[3];
$external_update_fields = $row[4];
$external_update_fields_data = $row[5];
$timer_action = $row[6];
$timer_action_message = $row[7];
$timer_action_seconds = $row[8];
$external_dtmf = $row[9];
$external_transferconf = $row[10];
$external_park = $row[11];
$timer_action_destination = $row[12];
$external_recording = $row[13];
$external_pause_code = $row[14];
$MDQ_count=0;
if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') )
{
$stmt="SELECT count(*) FROM vicidial_manual_dial_queue where user='$user' and status='READY';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03033',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_count_record_ct = mysqli_num_rows($rslt);
if ($mdq_count_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_count = $row[0];
}
if ( ($MDQ_count > 0) and (strlen($external_dial) < 16) and ($Astatus=='PAUSED') and ($Alead_id < 1) )
{
$stmt="SELECT mdq_id,external_dial FROM vicidial_manual_dial_queue where user='$user' and status='READY' order by entry_time limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03034',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_record_ct = mysqli_num_rows($rslt);
if ($mdq_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_mdq_id = $row[0];
$MDQ_external_dial = $row[1];
$external_dial = $MDQ_external_dial;
$stmt="UPDATE vicidial_manual_dial_queue SET status='QUEUE' where mdq_id='$MDQ_mdq_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$UMDQaffected_rows_update = mysqli_affected_rows($link);
if ($UMDQaffected_rows_update > 0)
{
$stmt="UPDATE vicidial_live_agents SET external_dial='$MDQ_external_dial' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03036',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMDQaffected_rows_update = mysqli_affected_rows($link);
}
}
}
}
if (strlen($external_status)<1) {$external_status = '::::::::::';}
$web_epoch = date("U");
$stmt="SELECT UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$server_epoch = $row[0];
$db_epoch = $row[1];
$time_diff = ($server_epoch - $db_epoch);
$web_diff = ($db_epoch - $web_epoch);
##### check for in-group change details
$InGroupChangeDetails = '0|||';
$manager_ingroup_set=0;
$stmt="SELECT count(*) FROM vicidial_live_agents where user='$user' and manager_ingroup_set='SET';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03022',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mis_record_ct = mysqli_num_rows($rslt);
if ($mis_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$manager_ingroup_set = $row[0];
}
if ($manager_ingroup_set > 0)
{
$stmt="UPDATE vicidial_live_agents SET closer_campaigns=external_ingroups, manager_ingroup_set='Y' where user='$user' and manager_ingroup_set='SET';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMISaffected_rows_update = mysqli_affected_rows($link);
if ($VLAMISaffected_rows_update > 0)
{
$stmt="SELECT external_ingroups,external_blended,external_igb_set_user,outbound_autodial,dial_method FROM vicidial_live_agents vla, vicidial_campaigns vc where user='$user' and manager_ingroup_set='Y' and vla.campaign_id=vc.campaign_id;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03024',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$migs_record_ct = mysqli_num_rows($rslt);
if ($migs_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_ingroups = $row[0];
$external_blended = $row[1];
$external_igb_set_user = $row[2];
$outbound_autodial = $row[3];
$dial_method = $row[4];
$stmt="SELECT full_name FROM vicidial_users where user='$external_igb_set_user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03025',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mign_record_ct = mysqli_num_rows($rslt);
if ($mign_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_igb_set_name = $row[0];
}
$NEWoutbound_autodial='N';
if ( ($external_blended > 0) and ($dial_method != "INBOUND_MAN") and ($dial_method != "MANUAL") )
{$NEWoutbound_autodial='Y';}
$stmt="UPDATE vicidial_live_agents SET outbound_autodial='$NEWoutbound_autodial' 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,'03026',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMIBaffected_rows_update = mysqli_affected_rows($link);
$InGroupChangeDetails = "1|$external_blended|$external_igb_set_user|$external_igb_set_name";
$stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$Acampaign_id',event_date='$NOW_TIME',blended='$external_blended',closer_campaigns='$external_ingroups',manager_change='$external_igb_set_user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03027',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
}
##### grab the shift information the agent
$stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group = $row[0];
$VU_agent_shift_enforcement_override = $row[1];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$shift_enforcement = $row[0];
$LOGgroup_shiftsSQL = preg_replace('/\s\s/','',$row[1]);
$LOGgroup_shiftsSQL = preg_replace('/\s/',"','",$LOGgroup_shiftsSQL);
$LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')";
### CHECK TO SEE IF agente IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR
$Ashift_logout=0;
if ( ( (preg_match("/ALL/",$shift_enforcement)) and (!preg_match("/OFF|START/",$VU_agent_shift_enforcement_override)) ) or (preg_match("/ALL/",$VU_agent_shift_enforcement_override)) )
{
$shift_ok=0;
if (strlen($LOGgroup_shiftsSQL) < 3)
{$Ashift_logout++;}
else
{
$HHMM = date("Hi");
$wday = date("w");
$stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);}
$shifts_to_print = mysqli_num_rows($rslt);
$o=0;
while ( ($shifts_to_print > $o) and ($shift_ok < 1) )
{
$rowx=mysqli_fetch_row($rslt);
$shift_id = $rowx[0];
$shift_start_time = $rowx[1];
$shift_length = $rowx[2];
$shift_weekdays = $rowx[3];
if (preg_match("/$wday/i",$shift_weekdays))
{
$HHshift_length = substr($shift_length,0,2);
$MMshift_length = substr($shift_length,3,2);
$HHshift_start_time = substr($shift_start_time,0,2);
$MMshift_start_time = substr($shift_start_time,2,2);
$HHshift_end_time = ($HHshift_length + $HHshift_start_time);
$MMshift_end_time = ($MMshift_length + $MMshift_start_time);
if ($MMshift_end_time > 59)
{
$MMshift_end_time = ($MMshift_end_time - 60);
$HHshift_end_time++;
}
if ($HHshift_end_time > 23)
{$HHshift_end_time = ($HHshift_end_time - 24);}
$HHshift_end_time = sprintf("%02s", $HHshift_end_time);
$MMshift_end_time = sprintf("%02s", $MMshift_end_time);
$shift_end_time = "$HHshift_end_time$MMshift_end_time";
if (
( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or
( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or
( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) )
)
{$shift_ok++;}
}
$o++;
}
if ($shift_ok < 1)
{$Ashift_logout++;}
}
}
if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (preg_match("/0\$/i",$StarTtime)) )
{$Alogin='TIME_SYNC';}
if ( ($Acount < 1) or ($Scount < 1) )
{$Alogin='DEAD_VLA';}
if ($AexternalDEAD > 0)
{$Alogin='DEAD_EXTERNAL';}
if ($Ashift_logout > 0)
{$Alogin='SHIFT_LOGOUT';}
if ($external_pause == 'LOGOUT')
{
$Alogin='API_LOGOUT';
$external_pause='';
}
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . "\n";
if (strlen($timer_action) > 3)
{
$stmt="UPDATE vicidial_live_agents SET external_timer_action='' 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,'03028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAETAaffected_rows_update = mysqli_affected_rows($link);
}
}
$total_conf=0;
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$sip_list = mysqli_num_rows($rslt);}
# echo "$sip_list|";
$loop_count=0;
while ($sip_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
# echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
}
$channels_list = ($channels_list + $sip_list);
echo "$channels_list|";
$counter=0;
$countecho='';
while($total_conf > $counter)
{
$counter++;
$countecho = "$countecho$ChannelA[$counter] ~";
# echo "$ChannelA[$counter] ~";
}
echo "$countecho\n";
}
if ($ACTION == 'register')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($conf_exten)<1) || (strlen($exten)<1) )
{
$channel_live=0;
echo "Conf Exten $conf_exten não é válido or Exten $exten não é válido\n";
exit;
}
else
{
$stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);}
}
echo "Conferência $conf_exten já foi registrado para $exten\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect.php version 2.6
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass");
if (!$link)
{
die('MySQL connect ERROR: ' . mysql_error());
}
mysql_select_db("$VARDB_database");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect_mysqli.php version 2.8
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
# 130802-0957 - Changed to PHP mysqli functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysqli_connect("$VARDB_server", "$VARDB_user", "$VARDB_pass", "$VARDB_database", $VARDB_port);
if (!$link)
{
die('MySQL connect ERROR: ' . mysqli_error($link));
}
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,353 @@
<?php
# inbound_popup.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed to open up when a live_inbound call comes in giving the user
# options of what to do with the call or options to lookup the callerID on various web sites
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $uniqueid - ('1234567890.123456',...)
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $ext_context - ('default','demo',...)
# - $ext_priority - ('1','2',...)
# - $voicemail_dump_exten - ('85026666666666')
# - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL)
#
#
# changes
# 50428-1500 - First build of script display only
# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links
# 50503-1244 - added session_name checking for extra security
# 50711-1203 - removed HTTP authentication in favor of user/pass vars
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2215 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1008 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];}
elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];}
if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];}
elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];}
if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];}
elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];}
elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);}
else {$local_web_callerID_URL = '';}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$DO = '-1';
if ( (preg_match("/^Zap/i",$channel)) and (!preg_match("/-/i",$channel)) ) {$channel = "$channel$DO";}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
$forever_stop=0;
$user_abb = "$user$user$user$user";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build UNIQUEID: $uniqueid server_ip: $server_ip-->\n";
?>
<script language="Javascript">
var server_ip = '<?php echo $server_ip ?>';
var epoch_sec = '<?php echo $StarTtime ?>';
var user_abb = '<?php echo $user_abb ?>';
var vmail_box = '<?php echo $vmail_box ?>';
var ext_context = '<?php echo $ext_context ?>';
var ext_priority = '<?php echo $ext_priority ?>';
var voicemail_dump_exten = '<?php echo $voicemail_dump_exten ?>';
var session_name = '<?php echo $session_name ?>';
var user = '<?php echo $user ?>';
var pass = '<?php echo $pass ?>';
// ################################################################################
// Send Hangup command for Live call connected to phone now to Manager
function livehangup_send_hangup(taskvar)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "HLagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
livehangup_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Hangup&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(livehangup_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// Send Redirect command for ringing call to go directly to your voicemail
function liveredirect_send_vmail(taskvar,taskbox)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "RVagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
var mailboxvalue = taskbox;
liveredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Redirect&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID + "&exten=" + voicemail_dump_exten + "" + mailboxvalue + "&ext_context=" + ext_context + "&ext_priority=" + ext_priority;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(liveredirect_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// timeout to deactivate the call action links after 30 segundos
function link_timeout()
{
window.focus();
setTimeout("call_action_link_clear()", 30000);
}
// ################################################################################
// deactivates the call action links
function call_action_link_clear()
{
document.getElementById("callactions").innerHTML = "";
}
</script>
<?php
echo "<title>CHAMADA ENTRANTE";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#CCC2E0\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"link_timeout();\">\n";
echo "<CENTER><H2>CHAMADA ENTRANTE</H2>\n";
echo "<B>$NOW_TIME</B><BR><BR>\n";
}
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($uniqueid)<9)
{
$channel_live=0;
echo "Uniqueid $uniqueid não é válido\n";
exit;
}
else
{
$stmt="SELECT uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,acknowledged,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$channels_list = mysqli_num_rows($rslt);
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt|||||
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
echo "<table width=95% cellpadding=1 cellspacing=3>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Channel: </td><td align=left>$row[1]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>CallerID: </td><td align=left>$row[3]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n";
$phone = preg_replace("/.*\</i","",$row[3]);
$phone = preg_replace("/\>.*/i","",$phone);
$NPA = substr($phone, 0, 3);
$NXX = substr($phone, 3, 3);
$XXXX = substr($phone, 6, 4);
$D='-';
echo "<a href=\"http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&q=$NPA+$NXX+$XXXX&btnG=Search\" target=\"_blank\">GOOGLE</a> - \n";
echo "<a href=\"http://www.anywho.com/qry/wp_rl?npa=$NPA&telephone=$NXX$XXXX\" target=\"_blank\">ANYWHO</a> - \n";
echo "<a href=\"http://www.switchboard.com/bin/cgirlookup.dll?SR=&MEM=1&LNK=32%3A36&type=BOTH&at=$NPA&e=$NXX&n=$XXXX&search.x=55&search.y=20\" target=\"_blank\">SWITCHBOARD</a> - \n";
echo "<a href=\"http://yellowpages.superpages.com/listings.jsp?SRC=&STYPE=&PG=L&CB=&C=&N=&E=&T=&S=&Z=&A=727&X=533&P=8730&AXP=$NPA$NXX$XXXX&R=N&PS=15&search=Find+It\" target=\"_blank\">VERIZON</a> - \n";
echo "<a href=\"http://www.whitepages.com/1014/log_click/search/Reverse_Telefone?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">WHITEPAGES</a> - \n";
echo "<a href=\"http://www.411.com/10742/search/Reverse_Telefone?phone=%28$NPA%29+$NXX$D$XXXX\" target=\"_blank\">411.COM</a> - \n";
echo "<a href=\"http://www.phonenumber.com/10006/search/Reverse_Telefone?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">411.COM</a> - \n";
$local_web_callerID_QUERY_STRING ='';
$local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA";
$local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX";
$local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX";
$local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]";
$local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]";
$local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]";
$local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]";
$local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]";
$local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]";
$local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]";
echo "<a href=\"$local_web_callerID_URL$local_web_callerID_QUERY_STRING\" target=\"_blank\">CUSTOM</a> - \n";
echo "</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Número Discado: </td><td align=left>$row[8]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Notas:</td><td align=left>$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n<span id=\"callactions\">";
echo "<a href=\"#\" onclick=\"livehangup_send_hangup('$row[1]');return false;\">DESLIGAR</a> - \n";
echo "<a href=\"#\" onclick=\"liveredirect_send_vmail('$row[1]','$vmail_box');return false;\">ENVIAR PARA MINHA CAIXA POSTAL</a>\n";
echo "</span></td></tr>\n";
echo "</table>\n";
$stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,284 @@
<?php
# live_exten_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the client channel is live and to what channel it is connected
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50404-1249 - First build of script
# 50406-1402 - added connected trunk lookup
# 50428-1452 - added live_inbound check for exten on 2nd line of output
# 50503-1233 - added session_name checking for extra security
# 50524-1429 - added parked calls count
# 50610-1204 - Added NULL check on MySQL results to reduced errors
# 50711-1204 - removed HTTP authentication in favor of user/pass vars
# 60103-1541 - added favorite extens status display
# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1203 - Added variable filters to close security holes for login form
# 60825-1029 - Fixed translation variable issue ChannelA
# 90508-0727 - Changed to PHP long tags
# 130328-0027 - Converted ereg to preg functions
# 130603-2214 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1522 - Added optional encrypted passwords compatibility
# 130802-1009 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];}
elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];}
if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];}
elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '2.6-13';
$build = '130328-0027';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Verificação de extensões ativas";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
echo "DateTime: $NOW_TIME|";
echo "UnixTime: $StarTtime|";
$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
echo "$row[0]|";
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten não é válido ou protocolo $protocol não é válido\n";
exit;
}
else
{
$stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$ChanneLA[$loop_count] = "$row[0]";
$ChanneLB[$loop_count] = "$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
$counter=0;
while($loop_count > $counter)
{
$counter++;
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $ChanneLA[$counter]|";
}
}
}
}
}
echo "\n";
### check for live_inbound entry
$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
$LIuniqueid = "$row[0]";
$LIchannel = "$row[1]";
$LIcallerid = "$row[3]";
$LIdatetime = "$row[6]";
echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
}
echo "\n";
### if favorites are present do a lookup to see if any are active
if ($favorites_count > 0)
{
$favorites = explode(',',$favorites_list);
$h=0;
$favs_print='';
while ($favorites_count > $h)
{
$fav_extension = explode('/',$favorites[$h]);
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$favs_print .= "$fav_extension[1]: $row[0] ~";
$h++;
}
echo "$favs_print\n";
}
if ($format=='debug') {echo "\n<!-- |$favorites_count|$favorites_list| -->";}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,152 @@
<?php
# park_calls_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the details on the parked calls on the server
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50524-1515 - First build of script
# 50711-1208 - removed HTTP authentication in favor of user/pass vars
# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0024 - Converted ereg to preg functions
# 130603-2213 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1024 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($park_limit)) {$park_limit="1000";}
$version = '0.0.4';
$build = '60619-1205';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Mostrar ligações em espera";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten não é válido ou protocolo $protocol não é válido\n";
exit;
}
else
{
##### print parked calls from the parked_channels table
$stmt="SELECT channel,server_ip,channel_group,extension,parked_by,parked_time from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$park_calls_count = mysqli_num_rows($rslt);
echo "$park_calls_count\n";
$loop_count=0;
while ($park_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,919 @@
<?php
# phone_only.php - the web-based web-phone-only client application
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 110511-1336 - First Build
# 110526-1757 - Added webphone_auto_answer option
# 120223-2124 - Removed logging of good login passwords if webroot writable is enabled
# 130123-1923 - Added ability to use user-login-first options.php option
# 130328-0005 - Converted ereg to preg functions
# 130603-2212 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130718-0946 - Fixed login bug
# 130802-1139 - Changed to PHP mysqli functions
#
$version = '2.8-8p';
$build = '130802-1139';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=73;
$one_mysql_log=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];}
elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
if (!isset($flag_channels))
{
$flag_channels=0;
$flag_string='';
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("[^0-9a-z]","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_pass);
$forever_stop=0;
if ($force_logout)
{
echo "Você fez o logoff. Obrigado\n";
exit;
}
$isdst = date("I");
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$tsNOW_TIME = date("YmdHis");
$FILE_TIME = date("Ymd-His");
$loginDATE = date("Ymd");
$CIDdate = date("ymdHis");
$month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y"));
$past_month_date = date("Y-m-d H:i:s",$month_old);
$minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y"));
$past_minutes_date = date("Y-m-d H:i:s",$minutes_old);
$webphone_width = 460;
$webphone_height = 500;
$PHP_SELF=$_SERVER['PHP_SELF'];
$random = (rand(1000000, 9999999) + 10000000);
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09001',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$vdc_header_date_format = $row[1];
$vdc_customer_date_format = $row[2];
$vdc_header_phone_format = $row[3];
$WeBRooTWritablE = $row[4];
$timeclock_end_of_day = $row[5];
$vtiger_url = $row[6];
$enable_vtiger_integration = $row[7];
$outbound_autodial_active = $row[8];
$enable_second_webform = $row[9];
$user_territories_active = $row[10];
$static_agent_url = $row[11];
$custom_fields_enabled = $row[12];
}
##### END SETTINGS LOOKUP #####
###########################################
##### DEFINABLE SETTINGS AND OPTIONS
###########################################
# set defaults for hard-coded variables
$user_login_first = '0'; # set to 1 to have the vicidial_user login before the telefone de login
$clientDST = '1'; # set to 1 to check for DSTligadoserver for agent time
$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login
$hide_timeclock_link = '0'; # set to 1 to hide the timeclock linkligadothe agent login screen
$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window
$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500
$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770
$webphone_width = 460; # set the webphone frame width
$webphone_height = 500; # set the webphone frame height
$webphone_pad = 0; # set the table cellpadding for the webphone
$webphone_location = 'right'; # set the locationligadothe agent screen 'right' or 'bar'
$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6
$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0
$FORM_COLOR = '#EFEFEF';
$SIDEBAR_COLOR = '#F6F6F6';
# if options file exists, use the override values for the above variables
# see the options-example.php file for more information
if (file_exists('options.php'))
{
require_once('options.php');
}
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/phone_only\.php/i','',$agcPAGE);
if (strlen($static_agent_url) > 5)
{$agcPAGE = $static_agent_url;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../agc/css/style.css" />
<link rel="stylesheet" type="text/css" href="../agc/css/custom.css" />
';
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build -->\n";
echo "<!-- BROWSER: $BROWSER_WIDTH x $BROWSER_HEIGHT $JS_browser_width x $JS_browser_height -->\n";
$stmt="SELECT user_group from vicidial_users where user='$VD_login';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09002',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group=$row[0];
if ($relogin == 'YES')
{
echo "<title>Telefone web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Relogio ponto</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_br/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Brazil <img src=\"../agc/images/br.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefone-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Login do Ramal: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Ramal: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"$phone_pass\" /></td></tr>\n";
echo "<tr><td align=\"right\">Login do Usuário: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Usuário: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ENVIAR\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($user_login_first == 1)
{
if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) )
{
echo "<title>Telefone web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Relogio ponto</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_br/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Brazil <img src=\"../agc/images/br.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefone-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Login do Usuário: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Usuário: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ENVIAR\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) )
{
$stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09073',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$phone_login=$row[0];
$phone_pass=$row[1];
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Telefone web client: Login do Ramal</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Relogio ponto</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_br/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Brazil <img src=\"../agc/images/br.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefone-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Login do Ramal: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Ramal: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ENVIAR\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
}
}
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Telefone web client: Login do Ramal</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Relogio ponto</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_br/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Brazil <img src=\"../agc/images/br.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefone-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Login do Ramal: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Ramal: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ENVIAR\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./vicidial_auth_entries.txt", "a");}
$VDloginDISPLAY=0;
if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) )
{
$VDloginDISPLAY=1;
}
else
{
$auth=0;
$auth_message = user_authorization($VD_login,$VD_pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if($auth>0)
{
##### grab the full name of the agent
$stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,agent_call_log_view_override,agent_choose_blended,agent_lead_search_override from vicidial_users where user='$VD_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09004',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$LOGfullname = $row[0];
$user_level = $row[1];
$VU_user_group = $row[10];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts,agent_status_viewable_groups,agent_status_view_time,agent_call_log_view,agent_xfer_consultative,agent_xfer_dial_override,agent_xfer_vm_transfer,agent_xfer_blind_transfer,agent_xfer_dial_with_customer,agent_xfer_park_customer_dial,agent_fullscreen,webphone_url_override,webphone_dialpad_override,webphone_systemkey_override from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09005',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$agent_fullscreen = $row[12];
$webphone_url = $row[13];
$webphone_dialpad_override = $row[14];
$system_key = $row[15];
if ( ($webphone_dialpad_override != 'DISABLED') and (strlen($webphone_dialpad_override) > 0) )
{$webphone_dialpad = $webphone_dialpad_override;}
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|GOOD|$date|$VD_login|XXXX|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
$user_abb = "$VD_login$VD_login$VD_login$VD_login";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|FAIL|$date|$VD_login|XXXX|$ip|$browser|\n");
fclose($fp);
}
$VDloginDISPLAY=1;
$VDdisplayMESSAGE = "Usuário incorreto, por favor tente novamente<br />";
if ($auth_message == 'LOCK')
{$VDdisplayMESSAGE = "Too many login attempts, try again in 15 minutes<br />";}
}
}
if ($VDloginDISPLAY)
{
echo "<title>Telefone web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Relogio ponto</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_br/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Brazil <img src=\"../agc/images/br.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<input type=\"hidden\" name=\"phone_login\" value=\"$phone_login\" />\n";
echo "<input type=\"hidden\" name=\"phone_pass\" value=\"$phone_pass\" />\n";
echo "<center><br /><b>$VDdisplayMESSAGE</b><br /><br />";
echo "<table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefone-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Login do Usuário: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Usuário: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ENVIAR\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</font></td></tr>\n";
echo "</table>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
$original_phone_login = $phone_login;
# code for parsing load-balanced agent phone allocation where agent interface
# will send multiple phones-table logins so that the script can determine the
# server that has the fewest agents logged into it.
# login: ca101,cb101,cc101
$alias_found=0;
$stmt="select count(*) from phones_alias where alias_id = '$phone_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09006',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_found = "$row[0]";
}
if ($alias_found > 0)
{
$stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09007',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_name = "$row[0]";
$phone_login = "$row[1]";
}
}
$pa=0;
if ( (preg_match('/,/',$phone_login)) and (strlen($phone_login) > 2) )
{
$phoneSQL = "(";
$phones_auto = explode(',',$phone_login);
$phones_auto_ct = count($phones_auto);
while($pa < $phones_auto_ct)
{
if ($pa > 0)
{$phoneSQL .= " or ";}
$desc = ($phones_auto_ct - $pa); # traverse in reverse order
$phoneSQL .= "(login='$phones_auto[$desc]' and pass='$phone_pass')";
$pa++;
}
$phoneSQL .= ")";
}
else {$phoneSQL = "login='$phone_login' and pass='$phone_pass'";}
$authphone=0;
#$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';";
$stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and active_asterisk_server='Y' and phones.server_ip=servers.server_ip;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09008',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$authphone=$row[0];
if (!$authphone)
{
echo "<title>Telefone web client: Login do Ramal Error</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Relogio ponto</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_br/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Brazil <img src=\"../agc/images/br.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\">\n";
echo "<input type=\"hidden\" name=\"VD_login\" value=\"$VD_login\" />\n";
echo "<input type=\"hidden\" name=\"VD_pass\" value=\"$VD_pass\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefone-Only Login Error</td>";
echo "</tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><font size=\"1\"> &nbsp; <br /><font size=\"3\">Desculpe seu login de ramal e senha não estão ativos nesta campanha, por favor tente novamente: <br /> &nbsp;</font></td></tr>\n";
echo "<tr><td align=\"right\">Login do Ramal: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\"></td></tr>\n";
echo "<tr><td align=\"right\">Senha do Ramal: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=10 maxlength=20 value=\"$phone_pass\"></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ENVIAR\" value=\"Submit\" /></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### go through the entered phones to figure out which server has fewest agents
### logged in and use that telefone de login account
if ($pa > 0)
{
$pb=0;
$pb_login='';
$pb_server_ip='';
$pb_count=0;
$pb_log='';
while($pb < $phones_auto_ct)
{
### find the server_ip of each phone_login
$stmtx="SELECT server_ip from phones where login = '$phones_auto[$pb]';";
if ($DB) {echo "|$stmtx|\n";}
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmtx, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09009',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysqli_fetch_row($rslt);
### get number of agents logged in to each server
$stmt="SELECT count(*) from web_client_sessions where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09010',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
### find out whether the server is set to active
$stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' and active_asterisk_server='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09011',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysqli_fetch_row($rslt);
### find out if this server has a twin
$twin_not_live=0;
$stmt="SELECT active_twin_server_ip from servers where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09012',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyy=mysqli_fetch_row($rslt);
if (strlen($rowyy[0]) > 4)
{
### find out whether the twin server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowyy[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09013',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyz=mysqli_fetch_row($rslt);
if ($rowyz[0] < 1) {$twin_not_live=1;}
}
### find out whether the server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09014',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowz=mysqli_fetch_row($rslt);
$pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]|$twin_not_live| ";
if ( ($rowy[0] > 0) and ($rowz[0] > 0) and ($twin_not_live < 1) )
{
if ( ($pb_count >= $row[0]) or (strlen($pb_server_ip) < 4) )
{
$pb_count=$row[0];
$pb_server_ip=$rowx[0];
$phone_login=$phones_auto[$pb];
}
}
$pb++;
}
echo "<!-- Telefones balance selection: $phone_login|$pb_server_ip|$past_minutes_date| |$pb_log -->\n";
}
echo "<title>Telefone web client</title>\n";
$stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,phone_ring_timeout,on_hook_agent,webphone_auto_answer from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$extension=$row[0];
$dialplan_number=$row[1];
$voicemail_id=$row[2];
$phone_ip=$row[3];
$computer_ip=$row[4];
$server_ip=$row[5];
$login=$row[6];
$pass=$row[7];
$status=$row[8];
$active=$row[9];
$phone_type=$row[10];
$fullname=$row[11];
$company=$row[12];
$picture=$row[13];
$messages=$row[14];
$old_messages=$row[15];
$protocol=$row[16];
$local_gmt=$row[17];
$ASTmgrUSERNAME=$row[18];
$ASTmgrSECRET=$row[19];
$login_user=$row[20];
$login_pass=$row[21];
$login_campaign=$row[22];
$park_on_extension=$row[23];
$conf_on_extension=$row[24];
$VICIDiaL_park_on_extension=$row[25];
$VICIDiaL_park_on_filename=$row[26];
$monitor_prefix=$row[27];
$recording_exten=$row[28];
$voicemail_exten=$row[29];
$voicemail_dump_exten=$row[30];
$ext_context=$row[31];
$dtmf_send_extension=$row[32];
$call_out_number_group=$row[33];
$client_browser=$row[34];
$install_directory=$row[35];
$local_web_callerID_URL=$row[36];
$VICIDiaL_web_URL=$row[37];
$AGI_call_logging_enabled=$row[38];
$user_switching_enabled=$row[39];
$conferencing_enabled=$row[40];
$admin_hangup_enabled=$row[41];
$admin_hijack_enabled=$row[42];
$admin_monitor_enabled=$row[43];
$call_parking_enabled=$row[44];
$updater_check_enabled=$row[45];
$AFLogging_enabled=$row[46];
$QUEUE_ACTION_enabled=$row[47];
$CallerID_popup_enabled=$row[48];
$voicemail_button_enabled=$row[49];
$enable_fast_refresh=$row[50];
$fast_refresh_rate=$row[51];
$enable_persistant_mysql=$row[52];
$auto_dial_next_number=$row[53];
$VDstop_rec_after_each_call=$row[54];
$DBX_server=$row[55];
$DBX_database=$row[56];
$DBX_user=$row[57];
$DBX_pass=$row[58];
$DBX_port=$row[59];
$outbound_cid=$row[65];
$enable_sipsak_messages=$row[66];
$conf_secret=$row[72];
$is_webphone=$row[73];
$use_external_server_ip=$row[74];
$codecs_list=$row[75];
$webphone_dialpad=$row[76];
$phone_ring_timeout=$row[77];
$on_hook_agent=$row[78];
$webphone_auto_answer=$row[79];
$no_empty_session_warnings=0;
if ( ($phone_login == 'nophone') or ($on_hook_agent == 'Y') )
{
$no_empty_session_warnings=1;
}
if ($PhonESComPIP == '1')
{
if (strlen($computer_ip) < 4)
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
}
if ($PhonESComPIP == '2')
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09017',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
if ($clientDST)
{
$local_gmt = ($local_gmt + $isdst);
}
if ($protocol == 'EXTERNAL')
{
$protocol = 'Local';
$extension = "$dialplan_number$AT$ext_context";
}
$SIP_user = "$protocol/$extension";
$SIP_user_DiaL = "$protocol/$extension";
if ( (preg_match('/8300/',$dialplan_number)) and (strlen($dialplan_number)<5) and ($protocol == 'Local') )
{
$SIP_user = "$protocol/$extension$VD_login";
}
$session_ext = preg_replace("/[^a-z0-9]/i", "", $extension);
if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);}
$session_rand = (rand(1,9999999) + 10000000);
$session_name = "$StarTtimE$US$session_ext$session_rand";
if ($webform_sessionname)
{$webform_sessionname = "&session_name=$session_name";}
else
{$webform_sessionname = '';}
$stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'phone';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09018',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','phone','$NOW_TIME','$session_name');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09019',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VICIDiaL_is_logged_in=1;
$webphone_content='';
### build Iframe variable content for webphone here
$codecs_list = preg_replace("/ /",'',$codecs_list);
$codecs_list = preg_replace("/-/",'',$codecs_list);
$codecs_list = preg_replace("/&/",'',$codecs_list);
$webphone_server_ip = $server_ip;
if ($use_external_server_ip=='Y')
{
##### find external_server_ip if enabled for this phone account
$stmt="SELECT external_server_ip FROM servers where server_ip='$server_ip' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09020',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$exip_ct = mysqli_num_rows($rslt);
if ($exip_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_server_ip =$row[0];
}
}
if (strlen($webphone_url) < 6)
{
##### find webphone_url in system_settings and generate IFRAME code for it #####
$stmt="SELECT webphone_url FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09021',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wu_ct = mysqli_num_rows($rslt);
if ($wu_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_url =$row[0];
}
}
if (strlen($system_key) < 1)
{
##### find system_key in system_settings if populated #####
$stmt="SELECT webphone_systemkey FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09022',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wsk_ct = mysqli_num_rows($rslt);
if ($wsk_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$system_key =$row[0];
}
}
$webphone_options='INITIAL_LOAD';
if ($webphone_dialpad == 'Y') {$webphone_options .= "--DIALPAD_Y";}
if ($webphone_dialpad == 'N') {$webphone_options .= "--DIALPAD_N";}
if ($webphone_dialpad == 'TOGGLE') {$webphone_options .= "--DIALPAD_TOGGLE";}
if ($webphone_dialpad == 'TOGGLE_OFF') {$webphone_options .= "--DIALPAD_OFF_TOGGLE";}
if ($webphone_auto_answer == 'Y') {$webphone_options .= "--AUTOANSWER_Y";}
if ($webphone_auto_answer == 'N') {$webphone_options .= "--AUTOANSWER_N";}
### base64 encode variables
$b64_phone_login = base64_encode($extension);
$b64_phone_pass = base64_encode($conf_secret);
$b64_session_name = base64_encode($session_name);
$b64_server_ip = base64_encode($webphone_server_ip);
$b64_callerid = base64_encode($outbound_cid);
$b64_protocol = base64_encode($protocol);
$b64_codecs = base64_encode($codecs_list);
$b64_options = base64_encode($webphone_options);
$b64_system_key = base64_encode($system_key);
$WebPhonEurl = "$webphone_url?phone_login=$b64_phone_login&phone_login=$b64_phone_login&phone_pass=$b64_phone_pass&server_ip=$b64_server_ip&callerid=$b64_callerid&protocol=$b64_protocol&codecs=$b64_codecs&options=$b64_options&system_key=$b64_system_key";
if ($webphone_location == 'bar')
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
else
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
if (preg_match('/MSIE/',$browser))
{
$useIE=1;
echo "<!-- client web browser used: MSIE |$browser|$useIE| -->\n";
}
else
{
$useIE=0;
echo "<!-- client web browser used: W3C-Compliant |$browser|$useIE| -->\n";
}
}
}
### SCREEN WIDTH AND HEIGHT CALCULATIONS ###
### DO NOT EDIT! ###
if ($stretch_dimensions > 0)
{
if ($agent_status_view < 1)
{
if ($JS_browser_width >= 510)
{$BROWSER_WIDTH = ($JS_browser_width - 80);}
}
else
{
if ($JS_browser_width >= 730)
{$BROWSER_WIDTH = ($JS_browser_width - 300);}
}
if ($JS_browser_height >= 340)
{$BROWSER_HEIGHT = ($JS_browser_height - 40);}
}
if ($agent_fullscreen=='Y')
{
$BROWSER_WIDTH = ($JS_browser_width - 10);
$BROWSER_HEIGHT = $JS_browser_height;
}
$MASTERwidth=($BROWSER_WIDTH - 340);
$MASTERheight=($BROWSER_HEIGHT - 200);
if ($MASTERwidth < 430) {$MASTERwidth = '430';}
if ($MASTERheight < 300) {$MASTERheight = '300';}
if ($webphone_location == 'bar') {$MASTERwidth = ($MASTERwidth + $webphone_height);}
$CAwidth = ($MASTERwidth + 340); # 770 - cover all (none-in-session, customer hunngup, etc...)
$SBwidth = ($MASTERwidth + 331); # 761 - SideBar starting point
$MNwidth = ($MASTERwidth + 330); # 760 - main frame
$XFwidth = ($MASTERwidth + 320); # 750 - transfer/conference
$HCwidth = ($MASTERwidth + 310); # 740 - hotkeys and callbacks
$CQwidth = ($MASTERwidth + 300); # 730 - calls in queue listings
$AMwidth = ($MASTERwidth + 270); # 700 - refresh links
$SCwidth = ($MASTERwidth + 230); # 670 - live call segundos counter, sidebar link
$PDwidth = ($MASTERwidth + 210); # 650 - preset-dial links
$MUwidth = ($MASTERwidth + 180); # 610 - agent mute
$SSwidth = ($MASTERwidth + 176); # 606 - scroll script
$SDwidth = ($MASTERwidth + 170); # 600 - scroll script, customer data and calls-in-session
$HKwidth = ($MASTERwidth + 20); # 450 - Hotkeys button
$HSwidth = ($MASTERwidth + 1); # 431 - Header spacer
$PBwidth = ($MASTERwidth + 0); # 430 - Presets list
$CLwidth = ($MASTERwidth - 120); # 310 - Calls in queue link
$GHheight = ($MASTERheight + 1260);# 1560 - Gender Hide span
$DBheight = ($MASTERheight + 260); # 560 - Debug span
$WRheight = ($MASTERheight + 160); # 460 - Warning boxes
$CQheight = ($MASTERheight + 140); # 440 - Calls in queue section
$SLheight = ($MASTERheight + 122); # 422 - SideBar link, Agents view link
$QLheight = ($MASTERheight + 112); # 412 - Calls in queue link
$HKheight = ($MASTERheight + 105); # 405 - HotKey active Button
$AMheight = ($MASTERheight + 100); # 400 - Agent mute buttons
$PBheight = ($MASTERheight + 90); # 390 - preset dial links
$MBheight = ($MASTERheight + 65); # 365 - Manual Dial Buttons
$CBheight = ($MASTERheight + 50); # 350 - Agent Callback, pause code, volume control Buttons and agent status
$SSheight = ($MASTERheight + 31); # 331 - script content
$HTheight = ($MASTERheight + 10); # 310 - transfer frame, callback comments and hotkey
$BPheight = ($MASTERheight - 250); # 50 - bottom buffer, Agent Xfer Span
$SCheight = 49; # 49 - segundosligadocall display
$SFheight = 65; # 65 - height of the script and form contents
$SRheight = 69; # 69 - height of the script and form refrech links
if ($webphone_location == 'bar')
{
$SCheight = ($SCheight + $webphone_height);
# $SFheight = ($SFheight + $webphone_height);
$SRheight = ($SRheight + $webphone_height);
}
$AVTheight = '0';
if ($is_webphone) {$AVTheight = '20';}
echo "</head>\n";
$zi=2;
echo "<body bgcolor=\"white\">\n";
echo " Telefone: $original_phone_login - $server_ip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"$PHP_SELF?relogin=YES&session_epoch=1234567890&session_id=&session_name=$session_name&VD_login=$VD_login&phone_login=$original_phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Logout</a><BR>\n";
if ($webphone_location == 'bar')
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;width=".$webphone_width."px;overflow:hidden;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanBAR\"><span id=\"webphonecontent\" style=\"overflow:hidden;\">$webphone_content</span></span>\n";
}
else
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;overflow:scroll;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanDEFAULT\"><table cellpadding=\"$webphone_pad\" cellspacing=\"0\" border=\"0\"><tr><td width=\"5px\" rowspan=\"2\">&nbsp;</td><td align=\"center\"><font class=\"body_text\">
Web Telefone: &nbsp; </font></td></tr><tr><td align=\"center\"><span id=\"webphonecontent\">$webphone_content</span></td></tr></table></span>\n";
}
?>
</body>
</html>
<?php
exit;
?>
@@ -0,0 +1,464 @@
<?php
# timeclock.php - VICIDIAL system user timeclock
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 80523-0134 - First Build
# 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field
# 80525-2351 - Added an audit log that is not to be editable
# 80602-0641 - Fixed status update bug
# 90508-0727 - Changed to PHP long tags
# 100621-1023 - Added admin_web_directory variable
# 130328-0021 - Converted ereg to preg functions
# 130603-2211 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-2010 - Added optional encrypted passwords compatibility
# 130802-1031 - Changed to PHP mysqli functions
# 131208-2155 - Added user log TIMEOUTLOGOUT event status
#
$version = '2.8-10';
$build = '131208-2155';
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$last_action_date = $NOW_TIME;
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/timeclock\.php/i','',$agcPAGE);
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];}
elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["commit"])) {$commit=$_GET["commit"];}
elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];}
if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];}
elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("/[^0-9a-z]/","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^0-9a-zA-Z]/","",$VD_pass);
$VD_campaign=preg_replace("/[^0-9a-zA-Z_]/","",$VD_campaign);
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$stage=preg_replace("/[^0-9a-zA-Z]/","",$stage);
$commit=preg_replace("/[^0-9a-zA-Z]/","",$commit);
$referrer=preg_replace("/[^0-9a-zA-Z]/","",$referrer);
require_once("dbconnect_mysqli.php");
require_once("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,admin_home_url,admin_web_directory FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
$i=0;
while ($i < $qm_conf_ct)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$welcomeURL = $row[1];
$admin_web_directory = $row[2];
$i++;
}
##### END SETTINGS LOOKUP #####
###########################################
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ( ($stage == 'login') or ($stage == 'logout') )
{
### see if user/pass exist for this user in vicidial_users table
$valid_user=0;
$auth_message = user_authorization($user,$pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$valid_user=1;}
print "<!-- vicidial_users active count for $user: |$valid_user| -->\n";
if ($valid_user < 1)
{
### NOT A VALID USER/PASS
$VDdisplayMESSAGE = "O usuário e a senha que você digitou não estão ativos no sistema<BR>Por favor, tente novamente:";
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Relogio ponto</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Relogio ponto </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Login do Usuário: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Senha do Usuário: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ENVIAR VALUE=ENVIAR> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### VALID USER/PASS, CONTINUE
### get name and group for this user
$stmt="SELECT full_name,user_group from vicidial_users where user='$user' and active='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$full_name = $row[0];
$user_group = $row[1];
print "<!-- vicidial_users name and group for $user: |$full_name|$user_group| -->\n";
### get vicidial_timeclock_status record count for this user
$stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$vts_count = $row[0];
$last_action_sec=99;
if ($vts_count > 0)
{
### vicidial_timeclock_status record found, grab status and date of last activity
$stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$status = $row[0];
$event_epoch = $row[1];
$last_action_date = date("Y-m-d H:i:s", $event_epoch);
$last_action_sec = ($StarTtimE - $event_epoch);
if ($last_action_sec > 0)
{
$totTIME_H = ($last_action_sec / 3600);
$totTIME_H_int = round($totTIME_H, 2);
$totTIME_H_int = intval("$totTIME_H");
$totTIME_M = ($totTIME_H - $totTIME_H_int);
$totTIME_M = ($totTIME_M * 60);
$totTIME_M_int = round($totTIME_M, 2);
$totTIME_M_int = intval("$totTIME_M");
$totTIME_S = ($totTIME_M - $totTIME_M_int);
$totTIME_S = ($totTIME_S * 60);
$totTIME_S = round($totTIME_S, 0);
if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";}
if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";}
if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
$totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S";
}
else
{
$totTIME_HMS='0:00:00';
}
print "<!-- vicidial_timeclock_status previous status for $user: |$status|$event_epoch|$last_action_sec| -->\n";
}
else
{
### No vicidial_timeclock_status record found, insert one
$stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$status='START';
$totTIME_HMS='0:00:00';
$affected_rows = mysqli_affected_rows($link);
print "<!-- NOVO vicidial_timeclock_status record inserted for $user: |$affected_rows| -->\n";
}
if ( ($last_action_sec < 30) and ($status != 'START') )
{
### You cannot log in or out within 30 segundos of your last login/logout
$VDdisplayMESSAGE = "Você não pode entrar ou sair dentro de 30 segundos do seu último login ou logout";
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Relogio ponto</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Relogio ponto </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Login do Usuário: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Senha do Usuário: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ENVIAR VALUE=ENVIAR> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($commit == 'YES')
{
if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='login') )
{
$VDdisplayMESSAGE = "Você tem agora registrados em";
$LOGtimeMESSAGE = "Você logou em $NOW_TIME";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- NOVO vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- NOVO vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
}
if ( ($status=='LOGIN') and ($stage=='logout') )
{
$VDdisplayMESSAGE = "Você efetuou logout";
$LOGtimeMESSAGE = "Você saiu em$NOW_TIME<BR>Quantidade de tempo que ficou logado:$totTIME_HMS";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- NOVO vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update last login record in the timeclock log
$stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_log record updated for $user: |$affected_rows| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- NOVO vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
### Update last login record in the timeclock audit log
$stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_audit_log record updated for $user: |$affected_rows| -->\n";
}
if ( ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) )
{echo "ERRO: relogio ponto já registrado:$status|$stage"; exit;}
if ($referrer=='agent')
{$BACKlink = "<A HREF=\"./vicidial.php?pl=$phone_login&pp=$phone_pass&VD_login=$user\"><font color=\"#003333\">VOLTAR para tela de login do Agente</font></A>";}
if ($referrer=='admin')
{$BACKlink = "<A HREF=\"/$admin_web_directory/admin.php\"><font color=\"#003333\">VOLTAR para Administração</font></A>";}
if ($referrer=='welcome')
{$BACKlink = "<A HREF=\"$welcomeURL\"><font color=\"#003333\">VOLTAR para Tela Inicial</font></A>";}
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Relogio ponto</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Relogio ponto </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><B> $BACKlink <BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') )
{
$VDdisplayMESSAGE = "Tempo desde o último login:$totTIME_HMS";
$log_action = 'login';
$button_name = 'LOGIN';
$LOGtimeMESSAGE = "Você saiu pela última vez em:$last_action_date<BR><BR>Clique LOGIN abaixo para entrar";
}
if ($status=='LOGIN')
{
$VDdisplayMESSAGE = "Tempo total desde que entrou no sistema:$totTIME_HMS";
$log_action = 'logout';
$button_name = 'LOGOUT';
$LOGtimeMESSAGE = "Você entrou em: $last_action_date<BR>Tempo total desde que entrou no sistema:$totTIME_HMS<BR><BR>Clique LOGOUT abaixo para sair";
}
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Relogio ponto</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"$log_action\">\n";
echo "<INPUT TYPE=HIDDEN NAME=commit VALUE=\"YES\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=user VALUE=\"$user\">\n";
echo "<INPUT TYPE=HIDDEN NAME=pass VALUE=\"$pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Relogio ponto </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=$button_name VALUE=$button_name> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
else
{
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Relogio ponto</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Relogio ponto </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Login do Usuário: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Senha do Usuário: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ENVIAR VALUE=ENVIAR> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSÃO: $version &nbsp; &nbsp; &nbsp; CONFIGURAÇÃO: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,375 @@
<?php
# vdc_email_display.php - VICIDIAL administration page
#
# Copyright (C) 2013 Matt Florell, Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# This page displays any incoming emails in the Vicidial user interface. It
# also allows the user to download and view any attachments sent in the email,
# and also gives the user the ability to respond to the email and even
# attach files to it. The page also logs all email messages that are sent
# through it to the vicidial_email_log table
#
# changes:
# 121214-2300 - First Build
# 130127-0027 - Better non-latin characters support
# 130328-0007 - Converted ereg to preg functions
# 130603-2210 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1515 - Added optional encrypted passwords compatibility
# 130802-1032 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["attachment_id"])) {$attachment_id=$_GET["attachment_id"];}
elseif (isset($_POST["attachment_id"])) {$attachment_id=$_POST["attachment_id"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];}
elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["sender_email"])) {$sender_email=$_GET["sender_email"];}
elseif (isset($_POST["sender_email"])) {$sender_email=$_POST["sender_email"];}
if (isset($_GET["reply_subject"])) {$reply_subject=$_GET["reply_subject"];}
elseif (isset($_POST["reply_subject"])) {$reply_subject=$_POST["reply_subject"];}
if (isset($_GET["reply_to_address"])) {$reply_to_address=$_GET["reply_to_address"];}
elseif (isset($_POST["reply_to_address"])) {$reply_to_address=$_POST["reply_to_address"];}
if (isset($_GET["reply_from_address"])) {$reply_from_address=$_GET["reply_from_address"];}
elseif (isset($_POST["reply_from_address"])) {$reply_from_address=$_POST["reply_from_address"];}
if (isset($_GET["reply_message"])) {$reply_message=$_GET["reply_message"];}
elseif (isset($_POST["reply_message"])) {$reply_message=$_POST["reply_message"];}
if (isset($_GET["REPLY"])) {$REPLY=$_GET["REPLY"];}
elseif (isset($_POST["REPLY"])) {$REPLY=$_POST["REPLY"];}
$attachment1=$_FILES["attachment1"];
$A1_orig = $_FILES['attachment1']['name'];
$A1_path = $_FILES['attachment1']['tmp_name'];
$A1_type = $_FILES['attachment1']['type'];
$attachment2=$_FILES["attachment2"];
$A2_orig = $_FILES['attachment2']['name'];
$A2_path = $_FILES['attachment2']['tmp_name'];
$A2_type = $_FILES['attachment2']['type'];
$attachment3=$_FILES["attachment3"];
$A3_orig = $_FILES['attachment3']['name'];
$A3_path = $_FILES['attachment3']['tmp_name'];
$A3_type = $_FILES['attachment3']['type'];
$attachment4=$_FILES["attachment4"];
$A4_orig = $_FILES['attachment4']['name'];
$A4_path = $_FILES['attachment4']['tmp_name'];
$A4_type = $_FILES['attachment4']['type'];
$attachment5=$_FILES["attachment5"];
$A5_orig = $_FILES['attachment5']['name'];
$A5_path = $_FILES['attachment5']['tmp_name'];
$A5_type = $_FILES['attachment5']['type'];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "EMAIL"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled,allow_emails FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
$allow_emails = $row[4];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($allow_emails<1)
{
echo "Your system does not have the email setting enabled\n";
exit;
}
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and modify_leads='1';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
$LVAactive=9;
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) ) )
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_email_display.php method=POST name=email_display_form id=email_display_form>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
if ($REPLY)
{
$to = "$reply_to_address";
$from = "$reply_from_address";
$subject ="$reply_subject";
$message = "$reply_message";
$headers = "From: $from";
$attachment_str="";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
for ($i=1; $i<=5; $i++)
{
$attachment_orig_name="A".$i."_orig";
$attachment_path="A".$i."_path";
$LF_orig=$$attachment_orig_name;
$LF_path=$$attachment_path;
#echo "<p>".$$attachment_name."<BR/>".$$attachment_orig_name."<BR/>".$$attachment_path."<BR/><p>";
if ($LF_orig)
{
if (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig))
{
echo "ERROR: Inválido File Name: $LF_orig\n";
exit;
}
else
{
copy($LF_path, "/tmp/$LF_orig");
$file = fopen("/tmp/$LF_orig","rb");
$data = fread($file,filesize("/tmp/$LF_orig"));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$LF_orig\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$LF_orig\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
$attachment_str.="$LF_orig|";
}
}
}
$sendmail = @mail($to, $subject, $message, $headers);
if ($sendmail)
{
$reply_message=preg_replace('/(\"|\||\'|\;)/', '\\\$1', $reply_message);
$log_stmt="INSERT INTO vicidial_email_log(email_row_id, lead_id, email_date, user, email_to, message, campaign_id, attachments) VALUES('$email_row_id', '$lead_id', now(), '$user', '$reply_to_address', '$reply_message', '$campaign', '$attachment_str')";
$log_rslt=mysql_to_mysqli($log_stmt, $link);
echo "<p>mail sent to $to!</p>";
# Hangup the "call"ligadothe agent screen
$stmt="UPDATE vicidial_live_agents set external_hangup='1' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
else
{
echo "<p>mail could not be sent!</p>";
}
exit;
}
if ($lead_id) {
$stmt="select * from vicidial_email_list where lead_id='$lead_id' and direction='INBOUND' and status IN('NEW','INCALL') order by email_date asc";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$email_row_id=$row["email_row_id"];
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_from"], $matches);
if (strlen($matches[0])>0) {
$email_from = substr($matches[0],1,-1);
} else {
$email_from = $row["email_from"];
}
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_to"], $matches);
if (strlen($matches[0])>0) {
$row["email_from"]=preg_replace('/\>/', '&gt;', $row["email_from"]);
$row["email_from"]=preg_replace('/\</', '&lt;', $row["email_from"]);
$email_to = substr($matches[0],1,-1);
} else {
$row["email_to"]=preg_replace('/\>/', '\>', $row["email_to"]);
$email_to = $row["email_to"];
}
$EMAIL_form="<center><TABLE cellspacing=2 cellpadding=2 bgcolor='#CCCCCC' width='500'>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Date received:</td><td align='left' valign='top' width='*'>$row[email_date]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>From:</td><td align='left' valign='top' width='*'>$row[email_from]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Subject:</td><td align='left' valign='top' width='*'>$row[subject]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Message:</td><td align='left' valign='top' width='*'><pre>$row[message]</pre></td></tr>\n";
$att_stmt="select * from inbound_email_attachments where email_row_id='$email_row_id'";
$att_rslt=mysql_to_mysqli($att_stmt, $link);
if (mysqli_num_rows($att_rslt)>0) {
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>anexos:</td><td align='left' valign='top' width='*'><pre>";
while($att_row=mysqli_fetch_array($att_rslt)) {
$EMAIL_form.="<LI><a href='$_SERVER[PHP_SELF]?attachment_id=$att_row[attachment_id]&lead_id=$lead_id'>$att_row[filename]</a>\n";
}
$EMAIL_form.="</pre></td></tr>";
}
$EMAIL_form.="<tr><td colspan='2'><HR></td></tr>";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Response:</td><td align='left' valign='top' width='*'>RE: $row[subject]<input type='hidden' name='reply_subject' value='RE: $row[subject]'></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Reply:<BR><BR><input type='button' name='copy' value='COPY MESSAGE >>>' onClick='CopyMessage($row[email_row_id])'></td><td align='left' valign='top' width='*'><textarea rows='8' cols='50' name='reply_message' id='reply_message'>$reply_message</textarea></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>anexos:</td><td align='left' valign='top' width='*'>";
$EMAIL_form.="<span id='attachment_span1'><input type=file name='attachment1' value='$attachment1'></span><BR/>";
$EMAIL_form.="<span id='attachment_span2'><input type=file name='attachment2'></span><BR/>";
$EMAIL_form.="<span id='attachment_span3'><input type=file name='attachment3'></span><BR/>";
$EMAIL_form.="<span id='attachment_span4'><input type=file name='attachment4'></span><BR/>";
$EMAIL_form.="<span id='attachment_span5'><input type=file name='attachment5'></span>";
$EMAIL_form.="</td></tr>\n";
$EMAIL_form.="<tr><td colspan='2' align='center'><input type='submit' name='REPLY' value='REPLY'></td></tr>";
$EMAIL_form.="</table></center>\n";
$EMAIL_form.="<input type='hidden' name='reply_to_address' value='$email_from'>\n";
$EMAIL_form.="<input type='hidden' name='reply_from_address' value='$email_to'>\n";
$EMAIL_form.="<input type='hidden' name='campaign' value='$campaign'>\n";
$EMAIL_form.="<input type='hidden' name='lead_id' value='$lead_id'>\n";
$EMAIL_form.="<input type='hidden' name='email_row_id' value='$email_row_id'>\n";
$EMAIL_form.="<input type='hidden' name='user' value='$user'>\n";
$EMAIL_form.="<input type='hidden' name='pass' value='$pass'>\n";
}
if ($attachment_id) {
$stmt="select * from inbound_email_attachments where attachment_id='$attachment_id'";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$filename=$row["filename"];
$encoding=$row["file_encoding"];
$file_size=$row["file_size"];
$file_type=$row["file_type"];
$file_contents=$row["file_contents"];
if ($encoding=="base64") {
$file_contents=base64_decode($file_contents);
$file_size=strlen($file_contents);
}
header("Content-length: ".$file_size."");
header("Content-type: ".$file_type."");
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $file_contents;
}
} else {
?>
<html>
<head>
<title>AGENT email frame</title>
</head>
<script language="Javascript">
function ParseFileName()
{
for (var i=1; i<=5; i++)
{
var attachment_field=eval("document.forms[0].attachment"+i);
var endstr=attachment_field.value.lastIndexOf('\\');
if (endstr>-1)
{
endstr++;
var filename=attachment_field.value.substring(endstr);
attachment_field.value=filename;
}
}
}
function CopyMessage()
{
<?php
$row["message"]=preg_replace('/\r|\n/', ' ', $row["message"]);
echo "var message=\"".preg_replace('/\"/', '\\\"', $row["message"])."\";\n";
?>
var msg_array=message.split(" ");
var full_msg="";
var msg_line="> ";
for (var i=0; i<msg_array.length; i++)
{
if (msg_array[i].length>=48)
{
msg_line+=msg_array[i]+" ";
}
if (msg_line.length+msg_array[i].length<50)
{
msg_line+=msg_array[i]+" ";
}
else
{
full_msg+=msg_line+"\n";
msg_line="> "+msg_array[i]+" ";
}
}
full_msg+=msg_line+"\n";
var email_field_value=document.getElementById("reply_message").value+"\n";
email_field_value+=full_msg;
document.getElementById("reply_message").value=email_field_value;
}
</script>
<style type="text/css">
pre { white-space: pre-wrap; }
</style>
<body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get' name="email_display_form" id="email_display_form" onSubmit="if (this.submitted) return false; this.submitted=true" enctype="multipart/form-data">
<?php echo $EMAIL_form; ?>
</form>
</body>
</html>
<?php
}
} else {
echo "ERROR - ID variable missing";
}
?>
@@ -0,0 +1,486 @@
<?php
# vdc_form_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the FORM tab in the agent
# interface, as well as take submission of the form submission when the agent
# dispositions the call
#
# CHANGELOG:
# 100630-1119 - First build of script
# 100703-1124 - Added submit_button,admin_submit fields, which will log to admin log
# 100712-2322 - Added code to log vicidial_list.entry_list_id field if data altered
# 100916-1749 - Added non-lead variable parsing
# 110719-0856 - Added HIDEBLOB type
# 110730-2335 - Added call_id variable
# 111025-1433 - Fixed case sensitivity on list fields
# 120315-1729 - Filtere out single quotes and backslashes from custom fields
# 130328-0012 - Converted ereg to preg functions
# 130402-2256 - Added user_group variable
# 130603-2204 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130615-2155 - Allow qc_enabled user access to this page even if not logged in as an agent
# 130705-1512 - Added optional encrypted passwords compatibility
# 130802-1033 - Changed to PHP mysqli functions
# 140101-2139 - Small fix for admin modify lead page on encrypted password systems
# 140429-2042 - Added TABLEper_call_notes display script variable for form display
#
$version = '2.8-15';
$build = '140429-2042';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["submit_button"])) {$submit_button=$_GET["submit_button"];}
elseif (isset($_POST["submit_button"])) {$submit_button=$_POST["submit_button"];}
if (isset($_GET["admin_submit"])) {$admin_submit=$_GET["admin_submit"];}
elseif (isset($_POST["admin_submit"])) {$admin_submit=$_POST["admin_submit"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "FORM"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|';
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;| /","",$user);
$pass = preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and ( (modify_leads='1') or (qc_enabled='1') );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
if ($custom_fields_enabled < 1)
{
echo "Custom Fields Disabled: |$custom_fields_enabled|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) and ($VUmodify < 1) ) )
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
### BEGIN parse submission of the custom fields form ###
if ($stage=='SUBMIT')
{
$update_sent=0;
$CFoutput='';
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06001',$user,$server_ip,$session_name,$one_mysql_log);}
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{
$update_SQL='';
$VL_update_SQL='';
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06003',$user,$server_ip,$session_name,$one_mysql_log);}
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$new_field_value='';
$form_field_value='';
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$A_field_name[$o] = $rowx[2];
$A_field_type[$o] = $rowx[6];
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_required[$o] = $rowx[12];
$A_field_value[$o] = '';
$field_name_id = $A_field_label[$o];
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$form_field_value = preg_replace("/\'/","",$form_field_value); // remove single-quote
$form_field_value = preg_replace("/\\b/","",$form_field_value); // remove backslashes
if ( ($A_field_type[$o]=='MULTI') or ($A_field_type[$o]=='CHECKBOX') or ($A_field_type[$o]=='RADIO') )
{
$k=0;
$multi_count = count($form_field_value);
$multi_array = $form_field_value;
while ($k < $multi_count)
{
$new_field_value .= "$multi_array[$k],";
$k++;
}
$form_field_value = preg_replace("/,$/","",$new_field_value);
}
if ($A_field_type[$o]=='TIME')
{
if (isset($_GET["MINUTE_$field_name_id"])) {$form_field_valueM=$_GET["MINUTE_$field_name_id"];}
elseif (isset($_POST["MINUTE_$field_name_id"])) {$form_field_valueM=$_POST["MINUTE_$field_name_id"];}
if (isset($_GET["HOUR_$field_name_id"])) {$form_field_valueH=$_GET["HOUR_$field_name_id"];}
elseif (isset($_POST["HOUR_$field_name_id"])) {$form_field_valueH=$_POST["HOUR_$field_name_id"];}
$form_field_value = "$form_field_valueH:$form_field_valueM:00";
}
$A_field_value[$o] = $form_field_value;
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') or ($A_field_type[$o]=='HIDDEN') or ($A_field_type[$o]=='HIDEBLOB') or ($A_field_type[$o]=='READONLY') )
{
$A_field_value[$o]='----IGNORE----';
}
else
{
if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
{
$VL_update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
else
{
$update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
$SUBMIT_output .= "<b>$A_field_name[$o]:</b> $A_field_value[$o]<BR>";
}
$o++;
}
$custom_update_count=0;
if (strlen($update_SQL)>3)
{
$custom_record_lead_count=0;
$stmt="SELECT count(*) from custom_$list_id where lead_id='$lead_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06004',$user,$server_ip,$session_name,$one_mysql_log);}
$fieldleadcount_to_print = mysqli_num_rows($rslt);
if ($fieldleadcount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$custom_record_lead_count = $rowx[0];
}
$update_SQL = preg_replace("/,$/","",$update_SQL);
$custom_table_update_SQL = "INSERT INTO custom_$list_id SET lead_id='$lead_id',$update_SQL;";
if ($custom_record_lead_count > 0)
{$custom_table_update_SQL = "UPDATE custom_$list_id SET $update_SQL where lead_id='$lead_id';";}
$rslt=mysql_to_mysqli($custom_table_update_SQL, $link);
$custom_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$custom_update_count|$custom_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
if (strlen($VL_update_SQL)>3)
{
$custom_update_vl_SQL='';
if ($custom_update_count > 0)
{$custom_update_vl_SQL = "entry_list_id='$list_id',";}
$VL_update_SQL = preg_replace("/,$/","",$VL_update_SQL);
$list_table_update_SQL = "UPDATE vicidial_list SET $custom_update_vl_SQL $VL_update_SQL where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
else
{
if ($custom_update_count > 0)
{
$list_table_update_SQL = "UPDATE vicidial_list SET entry_list_id='$list_id' where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
}
}
if ( ($admin_submit=='YES') and ($update_sent > 0) )
{
### LOG INSERTION Admin Log Table ###
$ip = getenv("REMOTE_ADDR");
$SQL_log = "$list_table_update_SQL|$custom_table_update_SQL|";
$SQL_log = preg_replace('/;/','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY CUSTOM LEAD', event_sql=\"$SQL_log\", event_notes='$custom_update_count|$list_update_count';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
else
{$CFoutput .= "ERROR: no custom list fields table\n";}
echo "Custom Form Output:\n<BR>\n";
echo "$SUBMIT_output";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
}
### END parse submission of the custom fields form ###
else
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Agent Form Display Script";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo " <link rel=\"stylesheet\" href=\"calendar.css\">\n";
echo " <script language=\"Javascript\">\n";
echo " function open_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:close_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help-</a><BR> &nbsp; \";\n";
echo " document.getElementById(taskspan).innerHTML = \"<B>\" + taskhelp + \"</B>\";\n";
echo " document.getElementById(taskspan).style.background = \"#FFFF99\";\n";
echo " }\n";
echo " function close_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \"\";\n";
echo " document.getElementById(taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:open_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help+</a>\";\n";
echo " document.getElementById(taskspan).style.background = \"white\";\n";
echo " }\n";
echo " </script>\n";
echo " <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#" . $bgcolor . "\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"parent.document.getElementById('FORM_LOADED').value='1';\">";
echo "\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=lead_id id=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=list_id id=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "<input type=hidden name=pass id=pass value=\"$pass\">\n";
echo "\n";
require_once("functions.php");
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user);
echo "$CFoutput";
if ($submit_button=='YES')
{
if ($bcrypt=='0')
{echo "<input type=hidden name=bcrypt id=bcrypt value=\"OFF\">\n";}
echo "<input type=hidden name=admin_submit id=admin_submit value=\"YES\">\n";
echo "<BR><BR><input type=submit name=VCformSubmit id=VCformSubmit value=submit>\n";
}
echo "</form></center><BR><BR>\n";
echo "</BODY></HTML>\n";
}
exit;
?>
@@ -0,0 +1,705 @@
<?php
# vdc_script_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the SCRIPT tab in the agent interface
#
# CHANGELOG:
# 90824-1435 - First build of script
# 90827-1548 - Added list override script option
# 91204-1913 - Added recording_filename and recording_id variables
# 91211-1103 - Added user_custom_... variables
# 100116-0702 - Added preset variables
# 100127-1611 - Added ignore_list_script_override option
# 100823-1644 - Added DID variables
# 100902-1344 - Added closecallid, xfercallid, agent_log_id variables
# 110420-1201 - Added web_vars variable
# 110730-2339 - Added call_id variable
# 120227-2017 - Added parsing of IGNORENOSCROLL option in script to force scroll
# 130328-0013 - Converted ereg to preg functions
# 130402-2255 - Added user_group variable
# 130603-2206 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1513 - Added optional encrypted passwords compatibility
# 130802-1035 - Changed to PHP mysqli functions
# 140429-2034 - Added TABLEper_call_notes display script variable
#
$version = '2.8-17';
$build = '140429-2034';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["title"])) {$title=$_GET["title"];}
elseif (isset($_POST["title"])) {$title=$_POST["title"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
if (isset($_GET["gender"])) {$gender=$_GET["gender"];}
elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];}
if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
if (isset($_GET["rank"])) {$rank=$_GET["rank"];}
elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];}
if (isset($_GET["owner"])) {$owner=$_GET["owner"];}
elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
elseif (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
if (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
elseif (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
if (isset($_GET["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_GET["CF_uses_custom_fields"];}
elseif (isset($_POST["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_POST["CF_uses_custom_fields"];}
if (isset($_GET["entry_list_id"])) {$entry_list_id=$_GET["entry_list_id"];}
elseif (isset($_POST["entry_list_id"])) {$entry_list_id=$_POST["entry_list_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["orig_pass"])) {$orig_pass=$_GET["orig_pass"];}
elseif (isset($_POST["orig_pass"])) {$orig_pass=$_POST["orig_pass"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$orig_pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass = preg_replace("/\'|\"|\\\\|;/","",$orig_pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,1,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
exit;
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>VICIDiaL Script Display Script";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if (strlen($in_script) < 1)
{$call_script = $camp_script;}
else
{$call_script = $in_script;}
$ignore_list_script_override='N';
$stmt = "SELECT ignore_list_script_override FROM vicidial_inbound_groups where group_id='$group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$ilso_ct = mysqli_num_rows($rslt);
if ($ilso_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$ignore_list_script_override = $row[0];
}
if ($ignore_list_script_override=='Y')
{$ignore_list_script=1;}
if ($ignore_list_script < 1)
{
$stmt="SELECT agent_script_override from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_script_override = $row[0];
if (strlen($agent_script_override) > 0)
{$call_script = $agent_script_override;}
}
$stmt="SELECT list_name,list_description from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_name = $row[0];
$list_description = $row[1];
$stmt="SELECT script_name,script_text from vicidial_scripts where script_id='$call_script';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$script_name = $row[0];
$script_text = stripslashes($row[1]);
if (preg_match("/iframe\ssrc/i",$script_text))
{
$IFRAME=1;
$lead_id = preg_replace('/\s/i','+',$lead_id);
$vendor_id = preg_replace('/\s/i','+',$vendor_id);
$vendor_lead_code = preg_replace('/\s/i','+',$vendor_lead_code);
$list_id = preg_replace('/\s/i','+',$list_id);
$list_name = preg_replace('/\s/i','+',$list_name);
$list_description = preg_replace('/\s/i','+',$list_description);
$gmt_offset_now = preg_replace('/\s/i','+',$gmt_offset_now);
$phone_code = preg_replace('/\s/i','+',$phone_code);
$phone_number = preg_replace('/\s/i','+',$phone_number);
$title = preg_replace('/\s/i','+',$title);
$first_name = preg_replace('/\s/i','+',$first_name);
$middle_initial = preg_replace('/\s/i','+',$middle_initial);
$last_name = preg_replace('/\s/i','+',$last_name);
$address1 = preg_replace('/\s/i','+',$address1);
$address2 = preg_replace('/\s/i','+',$address2);
$address3 = preg_replace('/\s/i','+',$address3);
$city = preg_replace('/\s/i','+',$city);
$state = preg_replace('/\s/i','+',$state);
$province = preg_replace('/\s/i','+',$province);
$postal_code = preg_replace('/\s/i','+',$postal_code);
$country_code = preg_replace('/\s/i','+',$country_code);
$gender = preg_replace('/\s/i','+',$gender);
$date_of_birth = preg_replace('/\s/i','+',$date_of_birth);
$alt_phone = preg_replace('/\s/i','+',$alt_phone);
$email = preg_replace('/\s/i','+',$email);
$security_phrase = preg_replace('/\s/i','+',$security_phrase);
$comments = preg_replace('/\s/i','+',$comments);
$user = preg_replace('/\s/i','+',$user);
$pass = preg_replace('/\s/i','+',$orig_pass);
$campaign = preg_replace('/\s/i','+',$campaign);
$phone_login = preg_replace('/\s/i','+',$phone_login);
$original_phone_login = preg_replace('/\s/i','+',$original_phone_login);
$phone_pass = preg_replace('/\s/i','+',$phone_pass);
$fronter = preg_replace('/\s/i','+',$fronter);
$closer = preg_replace('/\s/i','+',$closer);
$group = preg_replace('/\s/i','+',$group);
$channel_group = preg_replace('/\s/i','+',$channel_group);
$SQLdate = preg_replace('/\s/i','+',$SQLdate);
$epoch = preg_replace('/\s/i','+',$epoch);
$uniqueid = preg_replace('/\s/i','+',$uniqueid);
$customer_zap_channel = preg_replace('/\s/i','+',$customer_zap_channel);
$customer_server_ip = preg_replace('/\s/i','+',$customer_server_ip);
$server_ip = preg_replace('/\s/i','+',$server_ip);
$SIPexten = preg_replace('/\s/i','+',$SIPexten);
$session_id = preg_replace('/\s/i','+',$session_id);
$phone = preg_replace('/\s/i','+',$phone);
$parked_by = preg_replace('/\s/i','+',$parked_by);
$dispo = preg_replace('/\s/i','+',$dispo);
$dialed_number = preg_replace('/\s/i','+',$dialed_number);
$dialed_label = preg_replace('/\s/i','+',$dialed_label);
$source_id = preg_replace('/\s/i','+',$source_id);
$rank = preg_replace('/\s/i','+',$rank);
$owner = preg_replace('/\s/i','+',$owner);
$camp_script = preg_replace('/\s/i','+',$camp_script);
$in_script = preg_replace('/\s/i','+',$in_script);
$script_width = preg_replace('/\s/i','+',$script_width);
$script_height = preg_replace('/\s/i','+',$script_height);
$fullname = preg_replace('/\s/i','+',$fullname);
$recording_filename = preg_replace('/\s/i','+',$recording_filename);
$recording_id = preg_replace('/\s/i','+',$recording_id);
$user_custom_one = preg_replace('/\s/i','+',$user_custom_one);
$user_custom_two = preg_replace('/\s/i','+',$user_custom_two);
$user_custom_three = preg_replace('/\s/i','+',$user_custom_three);
$user_custom_four = preg_replace('/\s/i','+',$user_custom_four);
$user_custom_five = preg_replace('/\s/i','+',$user_custom_five);
$preset_number_a = preg_replace('/\s/i','+',$preset_number_a);
$preset_number_b = preg_replace('/\s/i','+',$preset_number_b);
$preset_number_c = preg_replace('/\s/i','+',$preset_number_c);
$preset_number_d = preg_replace('/\s/i','+',$preset_number_d);
$preset_number_e = preg_replace('/\s/i','+',$preset_number_e);
$preset_number_f = preg_replace('/\s/i','+',$preset_number_f);
$preset_dtmf_a = preg_replace('/\s/i','+',$preset_dtmf_a);
$preset_dtmf_b = preg_replace('/\s/i','+',$preset_dtmf_b);
$did_id = preg_replace('/\s/i','+',$did_id);
$did_extension = preg_replace('/\s/i','+',$did_extension);
$did_pattern = preg_replace('/\s/i','+',$did_pattern);
$did_description = preg_replace('/\s/i','+',$did_description);
$called_count = preg_replace('/\s/i','+',$called_count);
$web_vars = preg_replace('/\s/i','+',$web_vars);
}
$script_text = preg_replace('/--A--lead_id--B--/i',"$lead_id",$script_text);
$script_text = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$script_text);
$script_text = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$script_text);
$script_text = preg_replace('/--A--list_id--B--/i',"$list_id",$script_text);
$script_text = preg_replace('/--A--list_name--B--/i',"$list_name",$script_text);
$script_text = preg_replace('/--A--list_description--B--/i',"$list_description",$script_text);
$script_text = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$script_text);
$script_text = preg_replace('/--A--phone_code--B--/i',"$phone_code",$script_text);
$script_text = preg_replace('/--A--phone_number--B--/i',"$phone_number",$script_text);
$script_text = preg_replace('/--A--title--B--/i',"$title",$script_text);
$script_text = preg_replace('/--A--first_name--B--/i',"$first_name",$script_text);
$script_text = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$script_text);
$script_text = preg_replace('/--A--last_name--B--/i',"$last_name",$script_text);
$script_text = preg_replace('/--A--address1--B--/i',"$address1",$script_text);
$script_text = preg_replace('/--A--address2--B--/i',"$address2",$script_text);
$script_text = preg_replace('/--A--address3--B--/i',"$address3",$script_text);
$script_text = preg_replace('/--A--city--B--/i',"$city",$script_text);
$script_text = preg_replace('/--A--state--B--/i',"$state",$script_text);
$script_text = preg_replace('/--A--province--B--/i',"$province",$script_text);
$script_text = preg_replace('/--A--postal_code--B--/i',"$postal_code",$script_text);
$script_text = preg_replace('/--A--country_code--B--/i',"$country_code",$script_text);
$script_text = preg_replace('/--A--gender--B--/i',"$gender",$script_text);
$script_text = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$script_text);
$script_text = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$script_text);
$script_text = preg_replace('/--A--email--B--/i',"$email",$script_text);
$script_text = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$script_text);
$script_text = preg_replace('/--A--comments--B--/i',"$comments",$script_text);
$script_text = preg_replace('/--A--user--B--/i',"$user",$script_text);
$script_text = preg_replace('/--A--pass--B--/i',"$pass",$script_text);
$script_text = preg_replace('/--A--campaign--B--/i',"$campaign",$script_text);
$script_text = preg_replace('/--A--phone_login--B--/i',"$phone_login",$script_text);
$script_text = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$script_text);
$script_text = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$script_text);
$script_text = preg_replace('/--A--fronter--B--/i',"$fronter",$script_text);
$script_text = preg_replace('/--A--closer--B--/i',"$closer",$script_text);
$script_text = preg_replace('/--A--group--B--/i',"$group",$script_text);
$script_text = preg_replace('/--A--channel_group--B--/i',"$channel_group",$script_text);
$script_text = preg_replace('/--A--SQLdate--B--/i',"$SQLdate",$script_text);
$script_text = preg_replace('/--A--epoch--B--/i',"$epoch",$script_text);
$script_text = preg_replace('/--A--uniqueid--B--/i',"$uniqueid",$script_text);
$script_text = preg_replace('/--A--customer_zap_channel--B--/i',"$customer_zap_channel",$script_text);
$script_text = preg_replace('/--A--customer_server_ip--B--/i',"$customer_server_ip",$script_text);
$script_text = preg_replace('/--A--server_ip--B--/i',"$server_ip",$script_text);
$script_text = preg_replace('/--A--SIPexten--B--/i',"$SIPexten",$script_text);
$script_text = preg_replace('/--A--session_id--B--/i',"$session_id",$script_text);
$script_text = preg_replace('/--A--phone--B--/i',"$phone",$script_text);
$script_text = preg_replace('/--A--parked_by--B--/i',"$parked_by",$script_text);
$script_text = preg_replace('/--A--dispo--B--/i',"$dispo",$script_text);
$script_text = preg_replace('/--A--dialed_number--B--/i',"$dialed_number",$script_text);
$script_text = preg_replace('/--A--dialed_label--B--/i',"$dialed_label",$script_text);
$script_text = preg_replace('/--A--source_id--B--/i',"$source_id",$script_text);
$script_text = preg_replace('/--A--rank--B--/i',"$rank",$script_text);
$script_text = preg_replace('/--A--owner--B--/i',"$owner",$script_text);
$script_text = preg_replace('/--A--camp_script--B--/i',"$camp_script",$script_text);
$script_text = preg_replace('/--A--in_script--B--/i',"$in_script",$script_text);
$script_text = preg_replace('/--A--script_width--B--/i',"$script_width",$script_text);
$script_text = preg_replace('/--A--script_height--B--/i',"$script_height",$script_text);
$script_text = preg_replace('/--A--fullname--B--/i',"$fullname",$script_text);
$script_text = preg_replace('/--A--recording_filename--B--/i',"$recording_filename",$script_text);
$script_text = preg_replace('/--A--recording_id--B--/i',"$recording_id",$script_text);
$script_text = preg_replace('/--A--user_custom_one--B--/i',"$user_custom_one",$script_text);
$script_text = preg_replace('/--A--user_custom_two--B--/i',"$user_custom_two",$script_text);
$script_text = preg_replace('/--A--user_custom_three--B--/i',"$user_custom_three",$script_text);
$script_text = preg_replace('/--A--user_custom_four--B--/i',"$user_custom_four",$script_text);
$script_text = preg_replace('/--A--user_custom_five--B--/i',"$user_custom_five",$script_text);
$script_text = preg_replace('/--A--preset_number_a--B--/i',"$preset_number_a",$script_text);
$script_text = preg_replace('/--A--preset_number_b--B--/i',"$preset_number_b",$script_text);
$script_text = preg_replace('/--A--preset_number_c--B--/i',"$preset_number_c",$script_text);
$script_text = preg_replace('/--A--preset_number_d--B--/i',"$preset_number_d",$script_text);
$script_text = preg_replace('/--A--preset_number_e--B--/i',"$preset_number_e",$script_text);
$script_text = preg_replace('/--A--preset_number_f--B--/i',"$preset_number_f",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_a--B--/i',"$preset_dtmf_a",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_b--B--/i',"$preset_dtmf_b",$script_text);
$script_text = preg_replace('/--A--did_id--B--/i',"$did_id",$script_text);
$script_text = preg_replace('/--A--did_extension--B--/i',"$did_extension",$script_text);
$script_text = preg_replace('/--A--did_pattern--B--/i',"$did_pattern",$script_text);
$script_text = preg_replace('/--A--did_description--B--/i',"$did_description",$script_text);
$script_text = preg_replace('/--A--closecallid--B--/i',"$closecallid",$script_text);
$script_text = preg_replace('/--A--xfercallid--B--/i',"$xfercallid",$script_text);
$script_text = preg_replace('/--A--agent_log_id--B--/i',"$agent_log_id",$script_text);
$script_text = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$script_text);
$script_text = preg_replace('/--A--call_id--B--/i',"$call_id",$script_text);
$script_text = preg_replace('/--A--user_group--B--/i',"$user_group",$script_text);
$script_text = preg_replace('/--A--called_count--B--/i',"$called_count",$script_text);
$script_text = preg_replace('/--A--web_vars--B--/i',"$web_vars",$script_text);
if ($CF_uses_custom_fields=='Y')
{
### find the names of all custom fields, if any
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('vendor_lead_code','source_id','list_id','gmt_offset_now','called_since_last_reset','phone_code','phone_number','title','first_name','middle_initial','last_name','address1','address2','address3','city','state','province','postal_code','country_code','gender','date_of_birth','alt_phone','email','security_phrase','comments','called_count','last_local_call_time','rank','owner');";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$cffn_ct = mysqli_num_rows($rslt);
$d=0;
while ($cffn_ct > $d)
{
$row=mysqli_fetch_row($rslt);
$field_name_id = $row[0];
$field_name_tag = "--A--" . $field_name_id . "--B--";
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$script_text = preg_replace("/$field_name_tag/i","$form_field_value",$script_text);
if ($DB) {echo "$d|$field_name_id|$field_name_tag|$form_field_value|<br>\n";}
$d++;
}
}
$NOTESout='';
if (preg_match('/--A--TABLEper_call_notes--B--/i',$script_text))
{
### BEGIN Gather Call Log and notes ###
if ($hide_call_log_info!='Y')
{
if ($search != 'logfirst')
{$NOTESout .= "CALL LOG FOR THIS LEAD:<br>\n";}
$NOTESout .= "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>";
$NOTESout .= "<TR>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:10px;font-family:sans-serif;\"><B> &nbsp; # &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; DATE/TIME &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; AGENT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; LENGTH &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; STATUS &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; PHONE &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; CAMPAIGN &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; IN/OUT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; ALT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; HANGUP &nbsp; </font></TD>";
# $NOTESout .= "</TR><TR>";
# $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\" COLSPAN=9><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; FULL NAME &nbsp; </font></TD>";
$NOTESout .= "</TR>";
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$out_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$out_logs_to_print|$stmt|";}
$g=0;
$u=0;
while ($out_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = $row[3];
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLalt_dial[$g] = $row[9];
$ALLuniqueid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLin_out[$g] = "OUT-AUTO";
if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";}
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLuniqueid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$out_notes_to_print = mysqli_num_rows($rslt);
if ($out_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$in_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$in_logs_to_print|$stmt|";}
$u=0;
while ($in_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = ($row[3] - $row[9]);
if ($ALLlength_in_sec[$g] < 0) {$ALLlength_in_sec[$g]=0;}
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLuniqueid[$g] = $row[10];
$ALLclosecallid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLalt_dial[$g] = "MAIN";
$ALLin_out[$g] = "IN";
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLclosecallid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$in_notes_to_print = mysqli_num_rows($rslt);
if ($in_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
if ($g > 0)
{sort($ALLsort, SORT_NUMERIC);}
else
{$NOTESout .= "<tr bgcolor=white><td colspan=11 align=center>No calls found</td></tr>";}
$u=0;
while ($g > $u)
{
$sort_split = explode("-----",$ALLsort[$u]);
$i = $sort_split[1];
if (preg_match("/1$|3$|5$|7$|9$/i", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$phone_number_display = $ALLphone_number[$i];
if ($disable_alter_custphone == 'HIDE')
{$phone_number_display = 'XXXXXXXXXX';}
$u++;
$NOTESout .= "<tr $bgcolor>";
$NOTESout .= "<td><font size=1>$u</td>";
$NOTESout .= "<td align=right><font size=2>$ALLcall_date[$i]</td>";
$NOTESout .= "<td align=right><font size=2> $ALLuser[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLlength_in_sec[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLstatus[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLphone_code[$i] $phone_number_display </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLcampaign_id[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLin_out[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLalt_dial[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLhangup_reason[$i] </td>\n";
$NOTESout .= "</TR><TR>";
$NOTESout .= "<td></td>";
$NOTESout .= "<TD $bgcolor COLSPAN=9 align=left><font style=\"font-size:11px;font-family:sans-serif;\"> $Allcall_notes[$i] </font></TD>";
$NOTESout .= "</tr>\n";
}
$NOTESout .= "</TABLE>";
$NOTESout .= "<BR>";
}
### END Gather Call Log and notes ###
}
$script_text = preg_replace("/\n/i","<BR>",$script_text);
$script_text = preg_replace('/--A--TABLEper_call_notes--B--/i',"$NOTESout",$script_text);
$script_text = stripslashes($script_text);
echo "<!-- IFRAME$IFRAME -->\n";
echo "<!-- $script_id -->\n";
echo "<TABLE WIDTH=$script_width><TR><TD>\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "<div class=\"scroll_script\" id=\"NewScriptContents\">";}
echo "<center><B>$script_name</B><BR></center>\n";
echo "$script_text\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "</div>";}
echo "</TD></TR></TABLE>\n";
exit;
?>
@@ -0,0 +1,646 @@
<?php
# vdc_script_notes.php
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed open in the SCRIPT tab in the agent interface through
# an IFRAME. It will create a new record for every SUBMIT
#
# Example of a ViciDial agent SCRIPT using this script:
# <iframe src="./vdc_script_notes.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&pass=--A--pass--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&rank=--A--rank--B--&owner=--A--owner--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="--A--script_width--B--" height="--A--script_height--B--" STYLE="z-index:17"> </iframe>
#
# CHANGELOG:
# 100215-0744 - First build of script
# 100622-2230 - Added field labels
# 130328-0020 - Converted ereg to preg functions
# 130603-2203 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1037 - Changed to PHP mysqli functions
#
$version = '2.8-5';
$build = '130802-1037';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
elseif (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
if (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
elseif (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
elseif (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
if (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
elseif (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
if (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
elseif (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
if (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
elseif (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
if (isset($_POST["title"])) {$title=$_POST["title"];}
elseif (isset($_GET["title"])) {$title=$_GET["title"];}
if (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
elseif (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
if (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
elseif (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
if (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
elseif (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
if (isset($_POST["address1"])) {$address1=$_POST["address1"];}
elseif (isset($_GET["address1"])) {$address1=$_GET["address1"];}
if (isset($_POST["address2"])) {$address2=$_POST["address2"];}
elseif (isset($_GET["address2"])) {$address2=$_GET["address2"];}
if (isset($_POST["address3"])) {$address3=$_POST["address3"];}
elseif (isset($_GET["address3"])) {$address3=$_GET["address3"];}
if (isset($_POST["city"])) {$city=$_POST["city"];}
elseif (isset($_GET["city"])) {$city=$_GET["city"];}
if (isset($_POST["state"])) {$state=$_POST["state"];}
elseif (isset($_GET["state"])) {$state=$_GET["state"];}
if (isset($_POST["province"])) {$province=$_POST["province"];}
elseif (isset($_GET["province"])) {$province=$_GET["province"];}
if (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
elseif (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
if (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
elseif (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
if (isset($_POST["gender"])) {$gender=$_POST["gender"];}
elseif (isset($_GET["gender"])) {$gender=$_GET["gender"];}
if (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
elseif (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
if (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
elseif (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
if (isset($_POST["email"])) {$email=$_POST["email"];}
elseif (isset($_GET["email"])) {$email=$_GET["email"];}
if (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
elseif (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
if (isset($_POST["comments"])) {$comments=$_POST["comments"];}
elseif (isset($_GET["comments"])) {$comments=$_GET["comments"];}
if (isset($_POST["user"])) {$user=$_POST["user"];}
elseif (isset($_GET["user"])) {$user=$_GET["user"];}
if (isset($_POST["pass"])) {$pass=$_POST["pass"];}
elseif (isset($_GET["pass"])) {$pass=$_GET["pass"];}
if (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
elseif (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
if (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
elseif (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
if (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
elseif (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
if (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
elseif (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
if (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
elseif (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
if (isset($_POST["closer"])) {$closer=$_POST["closer"];}
elseif (isset($_GET["closer"])) {$closer=$_GET["closer"];}
if (isset($_POST["group"])) {$group=$_POST["group"];}
elseif (isset($_GET["group"])) {$group=$_GET["group"];}
if (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
elseif (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
if (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
elseif (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
if (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
elseif (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
if (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
elseif (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
if (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
elseif (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
if (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
elseif (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
if (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
elseif (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
if (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
elseif (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
if (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
elseif (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
if (isset($_POST["phone"])) {$phone=$_POST["phone"];}
elseif (isset($_GET["phone"])) {$phone=$_GET["phone"];}
if (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
elseif (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
if (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
elseif (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
if (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
elseif (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
if (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
elseif (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
if (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
elseif (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
if (isset($_POST["rank"])) {$rank=$_POST["rank"];}
elseif (isset($_GET["rank"])) {$rank=$_GET["rank"];}
if (isset($_POST["owner"])) {$owner=$_POST["owner"];}
elseif (isset($_GET["owner"])) {$owner=$_GET["owner"];}
if (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
elseif (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
if (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
elseif (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
if (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
elseif (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
if (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
elseif (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
if (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
elseif (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
if (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
elseif (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
if (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
elseif (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
if (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
elseif (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
if (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
elseif (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
if (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
elseif (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
if (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
elseif (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
if (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
elseif (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
if (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
elseif (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
if (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
elseif (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
if (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
elseif (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
if (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
elseif (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
if (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
elseif (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
if (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
elseif (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
if (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
elseif (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
if (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
elseif (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
if (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
elseif (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
if (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
elseif (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
if (isset($_POST["DB"])) {$DB=$_POST["DB"];}
elseif (isset($_GET["DB"])) {$DB=$_GET["DB"];}
if (isset($_POST["process"])) {$process=$_POST["process"];}
elseif (isset($_GET["process"])) {$process=$_GET["process"];}
if (isset($_POST["vicidial_id"])) {$vicidial_id=$_POST["vicidial_id"];}
elseif (isset($_GET["vicidial_id"])) {$vicidial_id=$_GET["vicidial_id"];}
if (isset($_POST["call_date"])) {$call_date=$_POST["call_date"];}
elseif (isset($_GET["call_date"])) {$call_date=$_GET["call_date"];}
if (isset($_POST["order_id"])) {$order_id=$_POST["order_id"];}
elseif (isset($_GET["order_id"])) {$order_id=$_GET["order_id"];}
if (isset($_POST["appointment_date"])) {$appointment_date=$_POST["appointment_date"];}
elseif (isset($_GET["appointment_date"])) {$appointment_date=$_GET["appointment_date"];}
if (isset($_POST["appointment_time"])) {$appointment_time=$_POST["appointment_time"];}
elseif (isset($_GET["appointment_time"])) {$appointment_time=$_GET["appointment_time"];}
if (isset($_POST["call_notes"])) {$call_notes=$_POST["call_notes"];}
elseif (isset($_GET["call_notes"])) {$call_notes=$_GET["call_notes"];}
if (isset($_POST["notesid"])) {$notesid=$_POST["notesid"];}
elseif (isset($_GET["notesid"])) {$notesid=$_GET["notesid"];}
if ($notesid < 100)
{$notesid=0;}
if (strlen($vicidial_id) < 1)
{$vicidial_id = $uniqueid;}
if (strlen($appointment_time) < 1)
{$appointment_time = '12:00:00';}
$appointment_timeARRAY = explode(":",$appointment_time);
$appointment_hour = $appointment_timeARRAY[0];
$appointment_min = $appointment_timeARRAY[1];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
if (strlen($call_date) < 1)
{$call_date = $NOW_TIME;}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^-_0-9a-zA-Z]/","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass = preg_replace("/\'|\"|\\\\|;/","",$pass);
}
if ($DB > 0)
{
echo "<BR>$lead_id|$entry_date|$modify_date|$status|$user|$vendor_lead_code|$source_id|$list_id|$gmt_offset_now|$called_since_last_reset|$phone_code|$phone_number|$title|$first_name|$middle_initial|$last_name|$address1|$address2|$address3|$city|$state|$province|$postal_code|$country_code|$gender|$date_of_birth|$alt_phone|$email|$security_phrase|$comments|$called_count|$last_local_call_time|$rank|$owner|\n<BR>";
}
### BEGIN find any custom field labels ###
$label_title = 'Title';
$label_first_name = 'Nome';
$label_middle_initial = 'MI';
$label_last_name = 'Last';
$label_address1 = 'Endereço1';
$label_address2 = 'Endereço2';
$label_address3 = 'Endereço3';
$label_city = 'Cidade';
$label_state = 'State';
$label_province = 'Bairro';
$label_postal_code = 'CEP';
$label_vendor_lead_code = 'Vendedor';
$label_gender = 'Gender';
$label_phone_number = 'Telefone';
$label_phone_code = 'Codigo de Área';
$label_alt_phone = 'Telefone Alternativo';
$label_security_phrase = 'Mostrar';
$label_email = 'Email';
$label_comments = 'Comments';
$stmt="SELECT label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments from system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if (strlen($row[0])>0) {$label_title = $row[0];}
if (strlen($row[1])>0) {$label_first_name = $row[1];}
if (strlen($row[2])>0) {$label_middle_initial = $row[2];}
if (strlen($row[3])>0) {$label_last_name = $row[3];}
if (strlen($row[4])>0) {$label_address1 = $row[4];}
if (strlen($row[5])>0) {$label_address2 = $row[5];}
if (strlen($row[6])>0) {$label_address3 = $row[6];}
if (strlen($row[7])>0) {$label_city = $row[7];}
if (strlen($row[8])>0) {$label_state = $row[8];}
if (strlen($row[9])>0) {$label_province = $row[9];}
if (strlen($row[10])>0) {$label_postal_code = $row[10];}
if (strlen($row[11])>0) {$label_vendor_lead_code = $row[11];}
if (strlen($row[12])>0) {$label_gender = $row[12];}
if (strlen($row[13])>0) {$label_phone_number = $row[13];}
if (strlen($row[14])>0) {$label_phone_code = $row[14];}
if (strlen($row[15])>0) {$label_alt_phone = $row[15];}
if (strlen($row[16])>0) {$label_security_phrase = $row[16];}
if (strlen($row[17])>0) {$label_email = $row[17];}
if (strlen($row[18])>0) {$label_comments = $row[18];}
### END find any custom field labels ###
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
echo "<HTML>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Notas Agente";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo "<link rel=\"stylesheet\" href=\"calendar.css\">\n";
?>
<?php
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
if ($process > 0)
{
#Update vicidial_list record
$stmt="UPDATE vicidial_list SET vendor_lead_code='$vendor_lead_code',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',phone_code='$phone_code',phone_number='$phone_number',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',rank='$rank',owner='$owner' where lead_id='$lead_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
#Update the agent screen with new data
$stmt="UPDATE vicidial_live_agents set external_update_fields='1',external_update_fields_data='vendor_lead_code,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,phone_code,phone_number,gender,date_of_birth,alt_phone,email,security_phrase,comments,rank,owner' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
if ($notesid < 100)
{
# Insert into vicidial_call_notes
$stmt="INSERT INTO vicidial_call_notes set lead_id='$lead_id',vicidial_id='$vicidial_id',call_date='$call_date',order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$notesid = mysqli_insert_id($link);
}
else
{
# update vicidial_call_notes record
$stmt="UPDATE vicidial_call_notes set order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes' where notesid='$notesid';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
echo "<BR><b>Data Changes Accepted</b><BR><BR>";
}
$URLarray = explode("?", $PHP_SELF);
$URLsubmit = $URLarray[0];
?>
<TABLE Border=0 CELLPADDING=0 CELLSPACING=2 WIDTH=450>
<TR><TD COLSPAN=2 ALIGN=CENTER>
<FORM METHOD=POST NAME=vsn ID=vsn ACTION="<?php echo $URLsubmit ?>">
<input type=hidden name=DB id=DB value=<?php echo $DB ?>>
<input type=hidden name=process id=process value=1>
<input type=hidden name=lead_id id=lead_id value="<?php echo $lead_id ?>">
<input type=hidden name=user id=user value="<?php echo $user ?>">
<input type=hidden name=pass id=user value="<?php echo $pass ?>">
<input type=hidden name=notesid id=notesid value="<?php echo $notesid ?>">
<input type=hidden name=vendor_id id=vendor_id value="<?php echo $vendor_id ?>">
<input type=hidden name=title id=title value="<?php echo $title ?>">
<input type=hidden name=middle_initial id=middle_initial value="<?php echo $middle_initial ?>">
<input type=hidden name=province id=province value="<?php echo $middle_initial ?>">
<input type=hidden name=phone_code id=phone_code value="<?php echo $phone_code ?>">
<input type=hidden name=gender id=gender value="<?php echo $gender ?>">
<input type=hidden name=date_of_birth id=date_of_birth value="<?php echo $date_of_birth ?>">
<input type=hidden name=alt_phone id=alt_phone value="<?php echo $alt_phone ?>">
<input type=hidden name=email id=email value="<?php echo $email ?>">
<input type=hidden name=security_phrase id=security_phrase value="<?php echo $security_phrase ?>">
<input type=hidden name=comments id=comments value="<?php echo $comments ?>">
<input type=hidden name=rank id=rank value="<?php echo $rank ?>">
<input type=hidden name=owner id=owner value="<?php echo $owner ?>">
</TD></TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Vendedor: </TD><TD ALIGN=LEFT><input type=text name=vendor_id id=vendor_id size=20 maxlength=20 value="<?php echo $vendor_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Source ID: </TD><TD ALIGN=LEFT>$source_id<input type=hidden name=source_id id=source_id value="<?php echo $source_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Title: </TD><TD ALIGN=LEFT><input type=text name=title id=title size=5 maxlength=4 value="<?php echo $title ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_first_name ?>: </TD><TD ALIGN=LEFT><input type=text name=first_name id=first_name size=30 maxlength=30 value="<?php echo $first_name ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Middle Initial: </TD><TD ALIGN=LEFT><input type=text name=middle_initial id=middle_initial size=2 maxlength=1 value="<?php echo $middle_initial ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_last_name ?>: </TD><TD ALIGN=LEFT><input type=text name=last_name id=last_name size=30 maxlength=30 value="<?php echo $last_name ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address1 ?>: </TD><TD ALIGN=LEFT><input type=text name=address1 id=address1 size=30 maxlength=100 value="<?php echo $address1 ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address2 ?>: </TD><TD ALIGN=LEFT><input type=text name=address2 id=address2 size=30 maxlength=100 value="<?php echo $address2 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address3 ?>: </TD><TD ALIGN=LEFT><input type=text name=address3 id=address3 size=30 maxlength=100 value="<?php echo $address3 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_city ?>: </TD><TD ALIGN=LEFT><input type=text name=city id=city size=30 maxlength=50 value="<?php echo $city ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_state ?>: </TD><TD ALIGN=LEFT>
<SELECT name="state" id=state>
<OPTION value="<?php echo $state ?>" selected><?php echo $state ?></OPTION>
<OPTGROUP label="United Estados">
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AK">Alaska</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="CA">California</OPTION>
<OPTION value="CO">Colorado</OPTION>
<OPTION value="CT">Connecticut</OPTION>
<OPTION value="DE">Delaware</OPTION>
<OPTION value="FL">Florida</OPTION>
<OPTION value="GA">Georgia</OPTION>
<OPTION value="HI">Hawaii</OPTION>
<OPTION value="ID">Idaho</OPTION>
<OPTION value="IL">Illinois</OPTION>
<OPTION value="IN">Indiana</OPTION>
<OPTION value="IA">Iowa</OPTION>
<OPTION value="KS">Kansas</OPTION>
<OPTION value="KY">Kentucky</OPTION>
<OPTION value="LA">Louisiana</OPTION>
<OPTION value="ME">Maine</OPTION>
<OPTION value="MD">Maryland</OPTION>
<OPTION value="MA">Massachusetts</OPTION>
<OPTION value="MI">Michigan</OPTION>
<OPTION value="MN">Minnesota</OPTION>
<OPTION value="MS">Mississippi</OPTION>
<OPTION value="MO">Missouri</OPTION>
<OPTION value="MT">Montana</OPTION>
<OPTION value="NE">Nebraska</OPTION>
<OPTION value="NV">Nevada</OPTION>
<OPTION value="NH">New Hampshire</OPTION>
<OPTION value="NJ">New Jersey</OPTION>
<OPTION value="NM">New Mexico</OPTION>
<OPTION value="NY">New York</OPTION>
<OPTION value="NC">North Carolina</OPTION>
<OPTION value="ND">North Dakota</OPTION>
<OPTION value="OH">Ohio</OPTION>
<OPTION value="OK">Oklahoma</OPTION>
<OPTION value="OR">Oregon</OPTION>
<OPTION value="PA">Pennsylvania</OPTION>
<OPTION value="RI">Rhode Island</OPTION>
<OPTION value="SC">South Carolina</OPTION>
<OPTION value="SD">South Dakota</OPTION>
<OPTION value="TN">Tennessee</OPTION>
<OPTION value="TX">Texas</OPTION>
<OPTION value="UT">Utah</OPTION>
<OPTION value="VT">Vermont</OPTION>
<OPTION value="VA">Virginia</OPTION>
<OPTION value="WA">Washington</OPTION>
<OPTION value="DC">Washington, DC</OPTION>
<OPTION value="WV">West Virginia</OPTION>
<OPTION value="WI">Wisconsin</OPTION>
<OPTION value="WY">Wyoming</OPTION>
</OPTGROUP>
<!--
<OPTGROUP label="Canada">
<OPTION value="AB">ALBERTA</OPTION>
<OPTION value="NT">NORTHWEST TERRITORY</OPTION>
<OPTION value="BC">BRITISH COLUMBIA</OPTION>
<OPTION value="ON">ONTARIO</OPTION>
<OPTION value="LB">LABRADOR</OPTION>
<OPTION value="PE">PRINCE EDWARDISLAND</OPTION>
<OPTION value="MB">MANITOBA</OPTION>
<OPTION value="PQ">QUEBEC</OPTION>
<OPTION value="NB">NEW BRUNSWICK</OPTION>
<OPTION value="SK">SASKATCHEWAN</OPTION>
<OPTION value="NF">NEWFOUNDLAND</OPTION>
<OPTION value="YT">YUKON TERRITORY</OPTION>
<OPTION value="NS">NOVA SCOTIA</OPTION>
</OPTGROUP>
-->
</SELECT> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Bairro: </TD><TD ALIGN=LEFT><input type=text name=province id=province size=20 maxlength=50 value="<?php echo $province ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_postal_code ?>: </TD><TD ALIGN=LEFT><input type=text name=postal_code id=postal_code size=6 maxlength=5 value="<?php echo $postal_code ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Telefone Code: </TD><TD ALIGN=LEFT><input type=text name=phone_code id=phone_code size=10 maxlength=10 value="<?php echo $phone_code ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_phone_number ?>: </TD><TD ALIGN=LEFT><input type=text name=phone_number id=phone_number size=18 maxlength=18 value="<?php echo $phone_number ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Sexo:</TD><TD ALIGN=LEFT><input type=text name=gender id=gender size=2 maxlength=1 value="<?php echo $gender ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Data de Nascimento:</TD><TD ALIGN=LEFT><input type=text name=date_if_birth id=date_if_birth size=12 maxlength=12 value="<?php echo $date_of_birth ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Telefone Alternativo: </TD><TD ALIGN=LEFT><input type=text name=alt_phone id=alt_phone size=12 maxlength=12 value="<?php echo $alt_phone ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Email: </TD><TD ALIGN=LEFT><input type=text name=email id=email size=30 maxlength=70 value="<?php echo $email ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Mostrar: </TD><TD ALIGN=LEFT><input type=text name=security_phrase id=security_phrase size=30 maxlength=100 value="<?php echo $security_phrase ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Comentários:</TD><TD ALIGN=LEFT><input type=text name=comments id=comments size=40 maxlength=255 value="<?php echo $comments ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Rank: </TD><TD ALIGN=LEFT><input type=text name=rank id=rank size=5 maxlength=5 value="<?php echo $rank ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Owner: </TD><TD ALIGN=LEFT><input type=text name=owner id=owner size=20 maxlength=20 value="<?php echo $owner ?>"> *</TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Order ID: </TD><TD ALIGN=LEFT><input type=text name=order_id id=order_id size=20 maxlength=20 value="<?php echo $order_id ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Appointment Date/Time: </TD><TD ALIGN=LEFT><input type=text name=appointment_date id=appointment_date size=10 maxlength=10 value="<?php echo $appointment_date ?>">
<script language="JavaScript">
var o_cal = new tcal ({
// form name
'formname': 'vsn',
// input name
'controlname': 'appointment_date'
});
o_cal.a_tpl.yearscroll = false;
// o_cal.a_tpl.weekstart = 1; // Monday week start
</script>
<input type=hidden name=appointment_time id=appointment_time value="<?php echo $appointment_time ?>">
<SELECT name=appointment_hour id=appointment_hour>
<option>00</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<OPTION value="<?php echo $appointment_hour ?>" selected><?php echo $appointment_hour ?></OPTION>
</SELECT>
<SELECT name=appointment_min id=appointment_min>
<option>00</option>
<option>05</option>
<option>10</option>
<option>15</option>
<option>20</option>
<option>25</option>
<option>30</option>
<option>35</option>
<option>40</option>
<option>45</option>
<option>50</option>
<option>55</option>
<OPTION value="<?php echo $appointment_min ?>" selected><?php echo $appointment_min ?></OPTION>
</SELECT>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=2>Appointment Notas:<BR><TEXTAREA NAME=call_notes ID=call_notes ROWS=5 COLS=50><?php echo $call_notes ?></TEXTAREA></font><br>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=1>Please click ENVIAR to commit the changes, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * denotes required fields</font><br>
</TD>
</TR>
<TR BGCOLOR=white>
<TD ALIGN=CENTER COLSPAN=2>
<SCRIPT LANGUAGE="JavaScript">
function submit_form()
{
var appointment_hourFORM = document.getElementById('appointment_hour');
var appointment_hourVALUE = appointment_hourFORM[appointment_hourFORM.selectedIndex].text;
var appointment_minFORM = document.getElementById('appointment_min');
var appointment_minVALUE = appointment_minFORM[appointment_minFORM.selectedIndex].text;
document.vsn.appointment_time.value = appointment_hourVALUE + ":" + appointment_minVALUE + ":00";
document.vsn.submit();
}
</SCRIPT>
<input type=button value="ENVIAR" name=smt id=smt onClick="submit_form()">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</B></FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,145 @@
<?php
# voicemail_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to check whether the voicemail box on the server defined has new and old messages
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
#
#
# changes
# 50422-1147 - First build of script
# 50503-1241 - added session_name checking for extra security
# 50711-1201 - removed HTTP authentication in favor of user/pass vars
# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1204 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2202 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1038 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Usuário/Senha: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSÃO: $version CONFIGURAÇÃO: $build VMBOX: $vmail_box server_ip: $server_ip-->\n";
echo "<title>Verificar caixa postal";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$MT[0]='';
$row=''; $rowx='';
if (strlen($vmail_box)<1)
{
$channel_live=0;
echo "Caixa Postal $vmail_box não é válido\n";
exit;
}
else
{
$stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$vmails_list = mysqli_num_rows($rslt);
$loop_count=0;
while ($vmails_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0]|$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tempo de execução do script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,480 @@
<?php
# active_list_refresh.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to serve updates of the live data to the display scripts
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $ADD - ('1','2','3','4','5')
# - $order - ('asc','desc')
# - $format - ('text','table','menu','selectlist','textarea')
# - $bgcolor - ('#123456','white','black','etc...')
# - $txtcolor - ('#654321','black','white','etc...')
# - $txtsize - ('1','2','3','etc...')
# - $selectsize - ('2','3','4','etc...')
# - $selectfontsize - ('8','10','12','etc...')
# - $selectedext - ('cc100')
# - $selectedtrunk - ('Zap/25-1')
# - $selectedlocal - ('SIP/cc100')
# - $textareaheight - ('8','10','12','etc...')
# - $textareawidth - ('8','10','12','etc...')
# - $field_name - ('extension','busyext','extension_xfer','etc...')
#
#
# changes
# 50323-1147 - First build of script
# 50401-1132 - small formatting changes
# 50502-1402 - added field_name as modifiable variable
# 50503-1213 - added session_name checking for extra security
# 50503-1311 - added conferences list
# 50610-1155 - Added NULL check on MySQL results to reduced errors
# 50711-1209 - removed HTTP authentication in favor of user/pass vars
# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1118 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0029 - Converted ereg to preg functions
# 130603-2222 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-0957 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];}
elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];}
if (isset($_GET["order"])) {$order=$_GET["order"];}
elseif (isset($_POST["order"])) {$order=$_POST["order"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];}
elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];}
if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];}
elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];}
if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];}
elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];}
if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];}
elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];}
if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];}
elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];}
if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];}
elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];}
if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];}
elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];}
if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];}
elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];}
if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];}
elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];}
if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];}
elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];}
### security strip all non-alphanumeric characters out of the variables ###
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$ADD=preg_replace("/[^0-9]/","",$ADD);
$order=preg_replace("/[^0-9a-zA-Z]/","",$order);
$format=preg_replace("/[^0-9a-zA-Z]/","",$format);
$bgcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$bgcolor);
$txtcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$txtcolor);
$txtsize=preg_replace("/[^0-9a-zA-Z]/","",$txtsize);
$selectsize=preg_replace("/[^0-9a-zA-Z]/","",$selectsize);
$selectfontsize=preg_replace("/[^0-9a-zA-Z]/","",$selectfontsize);
$selectedext=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedext);
$selectedtrunk=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedtrunk);
$selectedlocal=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedlocal);
$textareaheight=preg_replace("/[^0-9a-zA-Z]/","",$textareaheight);
$textareawidth=preg_replace("/[^0-9a-zA-Z]/","",$textareawidth);
$field_name=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$field_name);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($ADD)) {$ADD="1";}
if (!isset($order)) {$order='desc';}
if (!isset($format)) {$format="text";}
if (!isset($bgcolor)) {$bgcolor='white';}
if (!isset($txtcolor)) {$txtcolor='black';}
if (!isset($txtsize)) {$txtsize='2';}
if (!isset($selectsize)) {$selectsize='4';}
if (!isset($selectfontsize)) {$selectfontsize='10';}
if (!isset($textareaheight)) {$textareaheight='10';}
if (!isset($textareawidth)) {$textareawidth='20';}
$version = '0.0.10';
$build = '130328-0029';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='table')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build ADD: $ADD server_ip: $server_ip-->\n";
echo "<title>Liste Display: ";
if ($ADD==1) {echo "Live Nebenstellen";}
if ($ADD==2) {echo "Besetzte Nebenstellen";}
if ($ADD==3) {echo "Amtsleitungen";}
if ($ADD==4) {echo "Lokale Nebenstellen";}
if ($ADD==5) {echo "Konferenzen";}
if ($ADD==99999) {echo "HELP";}
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
######################
# ADD=1 display all live extensions on a server
######################
if ($ADD==1)
{
$pt='pt';
if (!$field_name) {$field_name = 'extension';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension,fullname FROM phones where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=2 display all busy extensions on a server
######################
if ($ADD==2)
{
if (!$field_name) {$field_name = 'busyext';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension FROM live_channels where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=3 display all busy outside lines(trunks) on a server
######################
if ($ADD==3)
{
if (!$field_name) {$field_name = 'trunk';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedtrunk") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=4 display all busy Local lines on a server
######################
if ($ADD==4)
{
if (!$field_name) {$field_name = 'local';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_sip_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedlocal") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=5 display all agc-usable conferences on a server
######################
if ($ADD==5)
{
$pt='pt';
if (!$field_name) {$field_name = 'conferences';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT conf_exten,extension FROM conferences where server_ip = '$server_ip' order by conf_exten $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
if ($format=='table') {echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";}
if ($format=='table') {echo "\n</body>\n</html>\n";}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,102 @@
<?php
# audit_comments.php
#
# Copyright (C) 2014 poundteam.com,vicidial.org LICENSE: AGPLv2
#
# This script is designed to display QC audit comments, contributed by poundteam.com
#
# changes:
# 121116-1322 - First build, added to vicidial codebase
# 130802-0957 - Changed to PHP mysqli functions
# 140304-2154 - Enabled special characters in comments
#
require_once("functions.php");
function audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign) {
$audit_comments_active=audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log);
if ($audit_comments_active) {
//Get comment from list
$stmt="select comments from vicidial_list where lead_id='$lead_id' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments2',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if (strlen($row[0]) > 0) {
$comment=$row[0];
//Put comment in comment table
$stmt="INSERT INTO vicidial_comments (lead_id,user_id,list_id,campaign_id,comment) VALUES ('$lead_id','$user','$list_id','$campaign','".mysqli_real_escape_string($link, $comment)."');";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments3',$user,$server_ip,$session_name,$one_mysql_log);
}
$affected=mysqli_affected_rows($link);
if($affected>0) {
$stmt="UPDATE vicidial_list set comments='' where lead_id='$lead_id';";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments4',$user,$server_ip,$session_name,$one_mysql_log);
}
} else {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditCommentsERROR-Comment not moved',$user,$server_ip,$session_name,$one_mysql_log);
echo "\n<!-- 00142-AuditCommentsERROR-Comment not moved -->";
}
}
}
}
function audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log){
$stmt="select count(audit_comments) from vicidial_lists_custom where list_id='$list_id' and audit_comments='1' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments5',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if ($row[0] == '1') {
return true;
} else {
return false;
}
}
function get_audited_comments($lead_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log) {
global $ACcount;
global $ACcomments;
$stmt="select user_id,comment from vicidial_comments where lead_id='$lead_id';";
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"00142-65-AuditComments:$stmt LeadID: $lead_id,$format,$user,$mel,$NOW_TIME,\$link,$server_ip,$session_name,$one_mysql_log",$user,$server_ip,$session_name,$one_mysql_log);
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-69-AuditComments',$user,$server_ip,$session_name,$one_mysql_log);
}
$ACcount=mysqli_num_rows($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-72-AuditComments $ACcount='.$ACcount,$user,$server_ip,$session_name,$one_mysql_log);
if($ACcount>0) {
$i=0;
while ($i < $ACcount) {
$row=mysqli_fetch_row($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-77-AuditComments UserID='.$row[0],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= "UserID: $row[0]\n";
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-79-AuditComments Comment='.$row[1],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= $row[1];
$ACcomments .= "\n----------------------------------\n";
$i++;
}
return true;
} else {
return false;
}
}
?>
@@ -0,0 +1,95 @@
/* calendar icon */
img.tcalIcon {
cursor: pointer;
margin-left: 1px;
vertical-align: middle;
}
/* calendar container element */
div#tcal {
position: absolute;
visibility: hidden;
z-index: 100;
width: 158px;
padding: 2px 0 0 0;
}
/* all tables in calendar */
div#tcal table {
width: 100%;
border: 1px solid silver;
border-collapse: collapse;
background-color: white;
}
/* navigation table */
div#tcal table.ctrl {
border-bottom: 0;
}
/* navigation buttons */
div#tcal table.ctrl td {
width: 15px;
height: 20px;
}
/* month year header */
div#tcal table.ctrl th {
background-color: white;
color: black;
border: 0;
}
/* week days header */
div#tcal th {
border: 1px solid silver;
border-collapse: collapse;
text-align: center;
padding: 3px 0;
font-family: tahoma, verdana, arial;
font-size: 10px;
background-color: gray;
color: white;
}
/* date cells */
div#tcal td {
border: 0;
border-collapse: collapse;
text-align: center;
padding: 2px 0;
font-family: tahoma, verdana, arial;
font-size: 11px;
width: 22px;
cursor: pointer;
}
/* date highlight
in case of conflicting settings order here determines the priority from least to most important */
div#tcal td.othermonth {
color: silver;
}
div#tcal td.weekend {
background-color: #ACD6F5;
}
div#tcal td.today {
border: 1px solid red;
}
div#tcal td.selected {
background-color: #FFB3BE;
}
/* iframe element used to suppress windowed controls in IE5/6 */
iframe#tcalIF {
position: absolute;
visibility: hidden;
z-index: 98;
border: 0;
}
/* transparent shadow */
div#tcalShade {
position: absolute;
visibility: hidden;
z-index: 99;
}
div#tcalShade table {
border: 0;
border-collapse: collapse;
width: 100%;
}
div#tcalShade table td {
border: 0;
border-collapse: collapse;
padding: 0;
}
@@ -0,0 +1,335 @@
// Tigra Calendar v4.0.2 (2009-01-12) Database (yyyy-mm-dd)
// http://www.softcomplex.com/products/tigra_calendar/
// Public Domain Software... You're welcome.
// default settins
var A_TCALDEF = {
'months' : ['Januar', 'February', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
'imgpath' : '../agc/images/' // directory with calendar images
}
// date parsing function
function f_tcalParseDate (s_date) {
var re_date = /^\s*(\d{2,4})\-(\d{1,2})\-(\d{1,2})\s*$/;
if (!re_date.exec(s_date))
return alert ("Unzulässig date: '" + s_date + "'.\nAccepted format is yyyy-mm-dd.")
var n_day = Number(RegExp.$3),
n_month = Number(RegExp.$2),
n_year = Number(RegExp.$1);
if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Unzulässig month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays = new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Unzulässig day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);
}
// date generating function
function f_tcalGenerDate (d_date) {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
);
}
// implementation
function tcal (a_cfg, a_tpl) {
// apply default template if not specified
if (!a_tpl)
a_tpl = A_TCALDEF;
// register in global collections
if (!window.A_TCALS)
window.A_TCALS = [];
if (!window.A_TCALSIDX)
window.A_TCALSIDX = [];
this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
window.A_TCALS[this.s_id] = this;
window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
// assign methods
this.f_show = f_tcal_show;
this.f_hide = f_tcal_hide;
this.f_toggle = f_tcalToggle;
this.f_update = f_tcalUpdate;
this.f_relDate = f_tcalRelDate;
this.f_parseDate = f_tcalParseDate;
this.f_generDate = f_tcalGenerDate;
// create calendar icon
this.s_iconId = 'tcalico_' + this.s_id;
this.e_icon = f_getElement(this.s_iconId);
if (!this.e_icon) {
document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
this.e_icon = f_getElement(this.s_iconId);
}
// save received parameters
this.a_cfg = a_cfg;
this.a_tpl = a_tpl;
}
function f_tcal_show (d_date) {
// find input field
if (!this.a_cfg.controlname)
throw("TC: control name is not specified");
if (this.a_cfg.formname) {
var e_form = document.forms[this.a_cfg.formname];
if (!e_form)
throw("TC: form '" + this.a_cfg.formname + "' can not be found");
this.e_input = e_form.elements[this.a_cfg.controlname];
}
else
this.e_input = f_getElement(this.a_cfg.controlname);
if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
// dynamically create HTML elements if needed
this.e_div = f_getElement('tcal');
if (!this.e_div) {
this.e_div = document.createElement("DIV");
this.e_div.id = 'tcal';
document.body.appendChild(this.e_div);
}
this.e_shade = f_getElement('tcalShade');
if (!this.e_shade) {
this.e_shade = document.createElement("DIV");
this.e_shade.id = 'tcalShade';
document.body.appendChild(this.e_shade);
}
this.e_iframe = f_getElement('tcalIF')
if (b_ieFix && !this.e_iframe) {
this.e_iframe = document.createElement("IFRAME");
this.e_iframe.style.filter = 'alpha(opacity=0)';
this.e_iframe.id = 'tcalIF';
this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
document.body.appendChild(this.e_iframe);
}
// hide all calendars
f_tcal_hideAll();
// generate HTML and show calendar
this.e_icon = f_getElement(this.s_iconId);
if (!this.f_update())
return;
this.e_div.style.visibility = 'visible';
this.e_shade.style.visibility = 'visible';
if (this.e_iframe)
this.e_iframe.style.visibility = 'visible';
// change icon and status
this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
this.e_icon.title = 'Close Calendar';
this.b_visible = true;
}
function f_tcal_hide (n_date) {
if (n_date)
this.e_input.value = this.f_generDate(new Date(n_date));
// no action if not visible
if (!this.b_visible)
return;
// hide elements
if (this.e_iframe)
this.e_iframe.style.visibility = 'hidden';
if (this.e_shade)
this.e_shade.style.visibility = 'hidden';
this.e_div.style.visibility = 'hidden';
// change icon and status
this.e_icon = f_getElement(this.s_iconId);
this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
this.e_icon.title = 'Open Calendar';
this.b_visible = false;
}
function f_tcalToggle () {
return this.b_visible ? this.f_hide() : this.f_show();
}
function f_tcalUpdate (d_date) {
var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
var d_selected = this.e_input.value == ''
? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
: this.f_parseDate(this.e_input.value);
// figure out date to display
if (!d_date)
// selected by default
d_date = d_selected;
else if (typeof(d_date) == 'number')
// get from number
d_date = f_tcalResetTime(new Date(d_date));
else if (typeof(d_date) == 'string')
// parse from string
this.f_parseDate(d_date);
if (!d_date) return false;
// first date to display
var d_firstday = new Date(d_date);
d_firstday.setDate(1);
d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
var a_class, s_html = '<table class="ctrl"><tbody><tr>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
+ '</tr></tbody></table><table><tbody><tr class="wd">';
// print weekdays titles
for (var i = 0; i < 7; i++)
s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
s_html += '</tr>' ;
// print calendar table
var n_date, n_month, d_current = new Date(d_firstday);
while (d_current.getMonth() == d_date.getMonth() ||
d_current.getMonth() == d_firstday.getMonth()) {
// print row heder
s_html +='<tr>';
for (var n_wday = 0; n_wday < 7; n_wday++) {
a_class = [];
n_date = d_current.getDate();
n_month = d_current.getMonth();
// other month
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length] = 'othermonth';
// weekend
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length] = 'weekend';
// today
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length] = 'today';
// selected
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length] = 'selected';
s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
d_current.setDate(++n_date);
while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
d_current.setHours(d_current.getHours + 1);
d_current = f_tcalResetTime(d_current);
}
}
// print row footer
s_html +='</tr>';
}
s_html +='</tbody></table>';
// update HTML, positions and sizes
this.e_div.innerHTML = s_html;
var n_width = this.e_div.offsetWidth;
var n_height = this.e_div.offsetHeight;
var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
if (n_left < 0) n_left = 0;
this.e_div.style.left = n_left + 'px';
this.e_div.style.top = n_top + 'px';
this.e_shade.style.width = (n_width + 8) + 'px';
this.e_shade.style.left = (n_left - 1) + 'px';
this.e_shade.style.top = (n_top - 1) + 'px';
this.e_shade.innerHTML = b_ieFix
? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
if (this.e_iframe) {
this.e_iframe.style.left = n_left + 'px';
this.e_iframe.style.top = n_top + 'px';
this.e_iframe.style.width = (n_width + 6) + 'px';
this.e_iframe.style.height = (n_height + 6) +'px';
}
return true;
}
function f_getPosition (e_elemRef, s_coord) {
var n_pos = 0, n_offset,
e_elem = e_elemRef;
while (e_elem) {
n_offset = e_elem["offset" + s_coord];
n_pos += n_offset;
e_elem = e_elem.offsetParent;
}
// margin correction in some browsers
if (b_ieMac)
n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
else if (b_safari)
n_pos -= n_offset;
e_elem = e_elemRef;
while (e_elem != document.body) {
n_offset = e_elem["scroll" + s_coord];
if (n_offset && e_elem.style.overflow == 'scroll')
n_pos -= n_offset;
e_elem = e_elem.parentNode;
}
return n_pos;
}
function f_tcalRelDate (d_date, d_diff, s_units) {
var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
var d_result = new Date(d_date);
d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
if (d_result.getDate() != d_date.getDate())
d_result.setDate(0);
return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
}
function f_tcal_hideAll () {
for (var i = 0; i < window.A_TCALSIDX.length; i++)
window.A_TCALSIDX[i].f_hide();
}
function f_tcalResetTime (d_date) {
d_date.setHours(0);
d_date.setMinutes(0);
d_date.setSeconds(0);
d_date.setMilliseconds(0);
return d_date;
}
f_getElement = document.all ?
function (s_id) { return document.all[s_id] } :
function (s_id) { return document.getElementById(s_id) };
if (document.addEventListener)
window.addEventListener('scroll', f_tcal_hideAll, false);
if (window.attachEvent)
window.attachEvent('onscroll', f_tcal_hideAll);
// global variables
var s_userAgent = navigator.userAgent.toLowerCase(),
re_webkit = /WebKit\/(\d+)/i;
var b_mac = s_userAgent.indexOf('mac') != -1,
b_ie5 = s_userAgent.indexOf('msie 5') != -1,
b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
var b_ieFix = b_ie5 || b_ie6,
b_ieMac = b_mac && b_ie5,
b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
@@ -0,0 +1,201 @@
<?php
# call_log_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the inbound and outbound calls for a specific phone
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
# - $in_limit - ('10','20','50','100',...)
# - $out_limit - ('10','20','50','100',...)
#
#
# changes
# 50406-1013 - First build of script
# 50407-1452 - Added definable limits
# 50503-1236 - added session_name checking for extra security
# 50610-1158 - Added NULL check on MySQL results to reduced errors
# 50711-1202 - removed HTTP authentication in favor of user/pass vars
# 60323-1550 - added option for showing different number dialed in log
# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1202 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0028 - Converted ereg to preg functions
# 130603-2219 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1005 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($in_limit)) {$in_limit="100";}
if (!isset($out_limit)) {$out_limit="100";}
$number_dialed = 'number_dialed';
#$number_dialed = 'extension';
$version = '0.0.10';
$build = '130328-0028';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Anruf Log Anzeige";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten ist unzulässig oder Protokoll $protocol ist unzulässig\n";
exit;
}
else
{
##### print outbound calls from the call_log table
$stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$out_calls_count = mysqli_num_rows($rslt);}
echo "$out_calls_count|";
$loop_count=0;
while ($out_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[3] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);}
echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|";
}
echo "\n";
##### print inbound calls from the live_inbound_log table
$stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$in_calls_count = mysqli_num_rows($rslt);}
echo "$in_calls_count|";
$loop_count=0;
while ($in_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[4] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
$callerIDnum = $row[3]; $callerIDname = $row[3];
$callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum);
$callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname);
echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,782 @@
<?php
# conf_exten_check.php version 2.8
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the meetme conference has live channels connected and which they are
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $ACTION - ('refresh','register')
# - $client - ('agc','vdc')
# - $conf_exten - ('8600011',...)
# - $exten - ('123test',...)
# - $auto_dial_level - ('0','1','1.2',...)
# - $campagentstdisp - ('YES',...)
#
# changes
# 50509-1054 - First build of script
# 50511-1112 - Added ability to register a conference room
# 50610-1159 - Added NULL check on MySQL results to reduced errors
# 50706-1429 - script changed to not use HTTP login vars, user/pass instead
# 50706-1525 - Added date-time display for vicidial client display
# 50816-1500 - Added random update to vicidial_live_agents table for vdc users
# 51121-1353 - Altered echo statements for several small PHP speed optimizations
# 60410-1424 - Added ability to grab calls-being-placed and agent status
# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1201 - Added variable filters to close security holes for login form
# 61128-2255 - Added update for manual dial vicidial_live_agents
# 70319-1542 - Added agent disabled display function
# 71122-0205 - Added vicidial_live_agent status output
# 80424-0442 - Added non_latin lookup from system_settings
# 80519-1425 - Added calls-in-queue tally
# 80703-1106 - Added API functionality for Hangup and Dispo
# 81104-0229 - Added mysql error logging capability
# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries
# 90102-1402 - Added check for system and database time synchronization
# 90120-1720 - Added compatibility for API pause/resume and dial a number
# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours
# 90408-0020 - Added API vtiger specific callback activity record ability
# 90508-0727 - Changed to PHP long tags
# 90706-1430 - Fixed AGENTDIRECT calls in queue display count
# 90908-1037 - Added DEAD call logging
# 91130-2022 - Added code for manager override of in-group selection
# 91228-1341 - Added API fields update functions
# 100109-1337 - Fixed Manual dial live call detection
# 100527-0957 - Added send_dtmf, transfer_conference and park_call API functions
# 100727-2209 - Added timer actions for hangup, extension, callmenu and ingroup as well as destination
# 101123-1105 - Added api manual dial queue feature to external_dial function
# 101208-0308 - Moved the Calls in Queue count and other counts outside of the autodial section (issue 406)
# 110610-0059 - Small fix for manual dial calls lasting more than 100 minutes in real-time report
# 120809-2353 - Added external_recording function
# 121028-2305 - Added extra check on session_name to validate agent screen requests
# 130328-0011 - Converted ereg to preg functions
# 130603-2218 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1015 - Changed to use PHP mysqli functions
# 140126-0659 - Added external_pause_code function
#
$version = '2.8-37';
$build = '140126-0659';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=39;
$one_mysql_log=0;
$DB=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
### If you have globals turned off uncomment these lines
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];}
elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];}
if (isset($_GET["client"])) {$client=$_GET["client"];}
elseif (isset($_POST["client"])) {$client=$_POST["client"];}
if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];}
elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];}
elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];}
if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];}
elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^\-_0-9a-zA-Z]/i","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($client)) {$client="agc";}
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_TIME = date("Ymd_His");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$random = (rand(1000000, 9999999) + 10000000);
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build MEETME: $conf_exten server_ip: $server_ip-->\n";
echo "<title>Conf Extension Check";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if ($ACTION == 'refresh')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($conf_exten)<1)
{
$channel_live=0;
echo "Conf Exten $conf_exten ist unzulässig\n";
exit;
}
else
{
if ($client == 'vdc')
{
$Acount=0;
$Scount=0;
$AexternalDEAD=0;
$Aagent_log_id='';
$Acallerid='';
$DEADcustomer=0;
$Astatus='';
$Acampaign_id='';
### see if the agent has a record in the vicidial_live_agents table
$stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Acount=$row[0];
### see if the agent has a record in the vicidial_session_data table
$stmt="SELECT count(*) from vicidial_session_data where user='$user' and server_ip='$server_ip' and session_name='$session_name';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03039',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Scount=$row[0];
if ($Acount > 0)
{
$stmt="SELECT status,callerid,agent_log_id,campaign_id,lead_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Astatus = $row[0];
$Acallerid = $row[1];
$Aagent_log_id = $row[2];
$Acampaign_id = $row[3];
$Alead_id = $row[4];
$api_manual_dial='STANDARD';
$stmt = "SELECT api_manual_dial FROM vicidial_campaigns where campaign_id='$Acampaign_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$vcc_conf_ct = mysqli_num_rows($rslt);
if ($vcc_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$api_manual_dial = $row[0];
}
}
# ### find out if external table shows agent should be disabled
# $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_to_mysqli($stmt, $link);
# $row=mysqli_fetch_row($rslt);
# $AexternalDEAD=$row[0];
##### BEGIN check an calls in queue, number of active calls in the campaign
if ($campagentstdisp == 'YES')
{
$ADsql='';
### grab the status of this agent to display
$stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Alogin=$row[0];
$Acampaign=$row[1];
$AccampSQL=$row[2];
$AccampSQL = preg_replace('/\s\-/','', $AccampSQL);
$AccampSQL = preg_replace('/\s/',"','", $AccampSQL);
if (preg_match('/AGENTDIRECT/i', $AccampSQL))
{
$AccampSQL = preg_replace('/AGENTDIRECT/i','', $AccampSQL);
$ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )";
}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$RingCalls=$row[0];
if ($RingCalls > 0) {$RingCalls = "<font class=\"queue_text_red\">Wartende Anrufe: $RingCalls</font>";}
else {$RingCalls = "<font class=\"queue_text\">Wartende Anrufe: $RingCalls</font>";}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$DiaLCalls=$row[0];
}
else
{
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
}
##### END check an calls in queue, number of active calls in the campaign
if ($auto_dial_level > 0)
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent is an is hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03018',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) and (preg_match("/^M/",$Acallerid)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03038',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03019',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03020',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03021',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
else
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent is an is hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03037',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03030',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03031',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03032',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
### grab the API hangup and API dispo fields in vicidial_live_agents
$stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds,external_dtmf,external_transferconf,external_park,external_timer_action_destination,external_recording,external_pause_code from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$external_hangup = $row[0];
$external_status = $row[1];
$external_pause = $row[2];
$external_dial = $row[3];
$external_update_fields = $row[4];
$external_update_fields_data = $row[5];
$timer_action = $row[6];
$timer_action_message = $row[7];
$timer_action_seconds = $row[8];
$external_dtmf = $row[9];
$external_transferconf = $row[10];
$external_park = $row[11];
$timer_action_destination = $row[12];
$external_recording = $row[13];
$external_pause_code = $row[14];
$MDQ_count=0;
if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') )
{
$stmt="SELECT count(*) FROM vicidial_manual_dial_queue where user='$user' and status='READY';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03033',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_count_record_ct = mysqli_num_rows($rslt);
if ($mdq_count_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_count = $row[0];
}
if ( ($MDQ_count > 0) and (strlen($external_dial) < 16) and ($Astatus=='PAUSED') and ($Alead_id < 1) )
{
$stmt="SELECT mdq_id,external_dial FROM vicidial_manual_dial_queue where user='$user' and status='READY' order by entry_time limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03034',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_record_ct = mysqli_num_rows($rslt);
if ($mdq_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_mdq_id = $row[0];
$MDQ_external_dial = $row[1];
$external_dial = $MDQ_external_dial;
$stmt="UPDATE vicidial_manual_dial_queue SET status='QUEUE' where mdq_id='$MDQ_mdq_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$UMDQaffected_rows_update = mysqli_affected_rows($link);
if ($UMDQaffected_rows_update > 0)
{
$stmt="UPDATE vicidial_live_agents SET external_dial='$MDQ_external_dial' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03036',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMDQaffected_rows_update = mysqli_affected_rows($link);
}
}
}
}
if (strlen($external_status)<1) {$external_status = '::::::::::';}
$web_epoch = date("U");
$stmt="SELECT UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$server_epoch = $row[0];
$db_epoch = $row[1];
$time_diff = ($server_epoch - $db_epoch);
$web_diff = ($db_epoch - $web_epoch);
##### check for in-group change details
$InGroupChangeDetails = '0|||';
$manager_ingroup_set=0;
$stmt="SELECT count(*) FROM vicidial_live_agents where user='$user' and manager_ingroup_set='SET';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03022',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mis_record_ct = mysqli_num_rows($rslt);
if ($mis_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$manager_ingroup_set = $row[0];
}
if ($manager_ingroup_set > 0)
{
$stmt="UPDATE vicidial_live_agents SET closer_campaigns=external_ingroups, manager_ingroup_set='Y' where user='$user' and manager_ingroup_set='SET';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMISaffected_rows_update = mysqli_affected_rows($link);
if ($VLAMISaffected_rows_update > 0)
{
$stmt="SELECT external_ingroups,external_blended,external_igb_set_user,outbound_autodial,dial_method FROM vicidial_live_agents vla, vicidial_campaigns vc where user='$user' and manager_ingroup_set='Y' and vla.campaign_id=vc.campaign_id;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03024',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$migs_record_ct = mysqli_num_rows($rslt);
if ($migs_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_ingroups = $row[0];
$external_blended = $row[1];
$external_igb_set_user = $row[2];
$outbound_autodial = $row[3];
$dial_method = $row[4];
$stmt="SELECT full_name FROM vicidial_users where user='$external_igb_set_user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03025',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mign_record_ct = mysqli_num_rows($rslt);
if ($mign_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_igb_set_name = $row[0];
}
$NEWoutbound_autodial='N';
if ( ($external_blended > 0) and ($dial_method != "INBOUND_MAN") and ($dial_method != "MANUAL") )
{$NEWoutbound_autodial='Y';}
$stmt="UPDATE vicidial_live_agents SET outbound_autodial='$NEWoutbound_autodial' 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,'03026',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMIBaffected_rows_update = mysqli_affected_rows($link);
$InGroupChangeDetails = "1|$external_blended|$external_igb_set_user|$external_igb_set_name";
$stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$Acampaign_id',event_date='$NOW_TIME',blended='$external_blended',closer_campaigns='$external_ingroups',manager_change='$external_igb_set_user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03027',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
}
##### grab the shift information the agent
$stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group = $row[0];
$VU_agent_shift_enforcement_override = $row[1];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$shift_enforcement = $row[0];
$LOGgroup_shiftsSQL = preg_replace('/\s\s/','',$row[1]);
$LOGgroup_shiftsSQL = preg_replace('/\s/',"','",$LOGgroup_shiftsSQL);
$LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')";
### CHECK TO SEE IF Agent IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR
$Ashift_logout=0;
if ( ( (preg_match("/ALL/",$shift_enforcement)) and (!preg_match("/OFF|START/",$VU_agent_shift_enforcement_override)) ) or (preg_match("/ALL/",$VU_agent_shift_enforcement_override)) )
{
$shift_ok=0;
if (strlen($LOGgroup_shiftsSQL) < 3)
{$Ashift_logout++;}
else
{
$HHMM = date("Hi");
$wday = date("w");
$stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);}
$shifts_to_print = mysqli_num_rows($rslt);
$o=0;
while ( ($shifts_to_print > $o) and ($shift_ok < 1) )
{
$rowx=mysqli_fetch_row($rslt);
$shift_id = $rowx[0];
$shift_start_time = $rowx[1];
$shift_length = $rowx[2];
$shift_weekdays = $rowx[3];
if (preg_match("/$wday/i",$shift_weekdays))
{
$HHshift_length = substr($shift_length,0,2);
$MMshift_length = substr($shift_length,3,2);
$HHshift_start_time = substr($shift_start_time,0,2);
$MMshift_start_time = substr($shift_start_time,2,2);
$HHshift_end_time = ($HHshift_length + $HHshift_start_time);
$MMshift_end_time = ($MMshift_length + $MMshift_start_time);
if ($MMshift_end_time > 59)
{
$MMshift_end_time = ($MMshift_end_time - 60);
$HHshift_end_time++;
}
if ($HHshift_end_time > 23)
{$HHshift_end_time = ($HHshift_end_time - 24);}
$HHshift_end_time = sprintf("%02s", $HHshift_end_time);
$MMshift_end_time = sprintf("%02s", $MMshift_end_time);
$shift_end_time = "$HHshift_end_time$MMshift_end_time";
if (
( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or
( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or
( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) )
)
{$shift_ok++;}
}
$o++;
}
if ($shift_ok < 1)
{$Ashift_logout++;}
}
}
if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (preg_match("/0\$/i",$StarTtime)) )
{$Alogin='TIME_SYNC';}
if ( ($Acount < 1) or ($Scount < 1) )
{$Alogin='DEAD_VLA';}
if ($AexternalDEAD > 0)
{$Alogin='DEAD_EXTERNAL';}
if ($Ashift_logout > 0)
{$Alogin='SHIFT_LOGOUT';}
if ($external_pause == 'LOGOUT')
{
$Alogin='API_LOGOUT';
$external_pause='';
}
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . "\n";
if (strlen($timer_action) > 3)
{
$stmt="UPDATE vicidial_live_agents SET external_timer_action='' 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,'03028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAETAaffected_rows_update = mysqli_affected_rows($link);
}
}
$total_conf=0;
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$sip_list = mysqli_num_rows($rslt);}
# echo "$sip_list|";
$loop_count=0;
while ($sip_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
# echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
}
$channels_list = ($channels_list + $sip_list);
echo "$channels_list|";
$counter=0;
$countecho='';
while($total_conf > $counter)
{
$counter++;
$countecho = "$countecho$ChannelA[$counter] ~";
# echo "$ChannelA[$counter] ~";
}
echo "$countecho\n";
}
if ($ACTION == 'register')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($conf_exten)<1) || (strlen($exten)<1) )
{
$channel_live=0;
echo "Conf Exten $conf_exten ist unzulässig or Exten $exten ist unzulässig\n";
exit;
}
else
{
$stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);}
}
echo "Konferenz $conf_exten wurde registriert bei $exten\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect.php version 2.6
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass");
if (!$link)
{
die('MySQL connect ERROR: ' . mysql_error());
}
mysql_select_db("$VARDB_database");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect_mysqli.php version 2.8
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
# 130802-0957 - Changed to PHP mysqli functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysqli_connect("$VARDB_server", "$VARDB_user", "$VARDB_pass", "$VARDB_database", $VARDB_port);
if (!$link)
{
die('MySQL connect ERROR: ' . mysqli_error($link));
}
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,353 @@
<?php
# inbound_popup.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed to open up when a live_inbound call comes in giving the user
# options of what to do with the call or options to lookup the callerID on various web sites
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $uniqueid - ('1234567890.123456',...)
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $ext_context - ('default','demo',...)
# - $ext_priority - ('1','2',...)
# - $voicemail_dump_exten - ('85026666666666')
# - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL)
#
#
# changes
# 50428-1500 - First build of script display only
# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links
# 50503-1244 - added session_name checking for extra security
# 50711-1203 - removed HTTP authentication in favor of user/pass vars
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2215 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1008 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];}
elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];}
if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];}
elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];}
if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];}
elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];}
elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);}
else {$local_web_callerID_URL = '';}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$DO = '-1';
if ( (preg_match("/^Zap/i",$channel)) and (!preg_match("/-/i",$channel)) ) {$channel = "$channel$DO";}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
$forever_stop=0;
$user_abb = "$user$user$user$user";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build UNIQUEID: $uniqueid server_ip: $server_ip-->\n";
?>
<script language="Javascript">
var server_ip = '<?php echo $server_ip ?>';
var epoch_sec = '<?php echo $StarTtime ?>';
var user_abb = '<?php echo $user_abb ?>';
var vmail_box = '<?php echo $vmail_box ?>';
var ext_context = '<?php echo $ext_context ?>';
var ext_priority = '<?php echo $ext_priority ?>';
var voicemail_dump_exten = '<?php echo $voicemail_dump_exten ?>';
var session_name = '<?php echo $session_name ?>';
var user = '<?php echo $user ?>';
var pass = '<?php echo $pass ?>';
// ################################################################################
// Send Hangup command for Live call connected to phone now to Manager
function livehangup_send_hangup(taskvar)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "HLagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
livehangup_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Hangup&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(livehangup_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// Send Redirect command for ringing call to go directly to your voicemail
function liveredirect_send_vmail(taskvar,taskbox)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "RVagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
var mailboxvalue = taskbox;
liveredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Redirect&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID + "&exten=" + voicemail_dump_exten + "" + mailboxvalue + "&ext_context=" + ext_context + "&ext_priority=" + ext_priority;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(liveredirect_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// timeout to deactivate the call action links after 30 Sekunden
function link_timeout()
{
window.focus();
setTimeout("call_action_link_clear()", 30000);
}
// ################################################################################
// deactivates the call action links
function call_action_link_clear()
{
document.getElementById("callactions").innerHTML = "";
}
</script>
<?php
echo "<title>LIVE INBOUND ANRUF";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#CCC2E0\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"link_timeout();\">\n";
echo "<CENTER><H2>LIVE INBOUND ANRUF</H2>\n";
echo "<B>$NOW_TIME</B><BR><BR>\n";
}
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($uniqueid)<9)
{
$channel_live=0;
echo "Uniqueid $uniqueid ist unzulässig\n";
exit;
}
else
{
$stmt="SELECT uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,acknowledged,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$channels_list = mysqli_num_rows($rslt);
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt|||||
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
echo "<table width=95% cellpadding=1 cellspacing=3>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Channel: </td><td align=left>$row[1]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>CallerID: </td><td align=left>$row[3]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n";
$phone = preg_replace("/.*\</i","",$row[3]);
$phone = preg_replace("/\>.*/i","",$phone);
$NPA = substr($phone, 0, 3);
$NXX = substr($phone, 3, 3);
$XXXX = substr($phone, 6, 4);
$D='-';
echo "<a href=\"http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&q=$NPA+$NXX+$XXXX&btnG=Search\" target=\"_blank\">GOOGLE</a> - \n";
echo "<a href=\"http://www.anywho.com/qry/wp_rl?npa=$NPA&telephone=$NXX$XXXX\" target=\"_blank\">ANYWHO</a> - \n";
echo "<a href=\"http://www.switchboard.com/bin/cgirlookup.dll?SR=&MEM=1&LNK=32%3A36&type=BOTH&at=$NPA&e=$NXX&n=$XXXX&search.x=55&search.y=20\" target=\"_blank\">SWITCHBOARD</a> - \n";
echo "<a href=\"http://yellowpages.superpages.com/listings.jsp?SRC=&STYPE=&PG=L&CB=&C=&N=&E=&T=&S=&Z=&A=727&X=533&P=8730&AXP=$NPA$NXX$XXXX&R=N&PS=15&search=Find+It\" target=\"_blank\">VERIZON</a> - \n";
echo "<a href=\"http://www.whitepages.com/1014/log_click/search/Reverse_Telefon?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">WHITEPAGES</a> - \n";
echo "<a href=\"http://www.411.com/10742/search/Reverse_Telefon?phone=%28$NPA%29+$NXX$D$XXXX\" target=\"_blank\">411.COM</a> - \n";
echo "<a href=\"http://www.phonenumber.com/10006/search/Reverse_Telefon?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">411.COM</a> - \n";
$local_web_callerID_QUERY_STRING ='';
$local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA";
$local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX";
$local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX";
$local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]";
$local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]";
$local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]";
$local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]";
$local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]";
$local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]";
$local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]";
echo "<a href=\"$local_web_callerID_URL$local_web_callerID_QUERY_STRING\" target=\"_blank\">CUSTOM</a> - \n";
echo "</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Gewählte Nummer: </td><td align=left>$row[8]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Notizen: </td><td align=left>$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n<span id=\"callactions\">";
echo "<a href=\"#\" onclick=\"livehangup_send_hangup('$row[1]');return false;\">AUFLEGEN</a> - \n";
echo "<a href=\"#\" onclick=\"liveredirect_send_vmail('$row[1]','$vmail_box');return false;\">AN MEINE VOICEMAILBOX SENDEN</a>\n";
echo "</span></td></tr>\n";
echo "</table>\n";
$stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,284 @@
<?php
# live_exten_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the client channel is live and to what channel it is connected
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50404-1249 - First build of script
# 50406-1402 - added connected trunk lookup
# 50428-1452 - added live_inbound check for exten on 2nd line of output
# 50503-1233 - added session_name checking for extra security
# 50524-1429 - added parked calls count
# 50610-1204 - Added NULL check on MySQL results to reduced errors
# 50711-1204 - removed HTTP authentication in favor of user/pass vars
# 60103-1541 - added favorite extens status display
# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1203 - Added variable filters to close security holes for login form
# 60825-1029 - Fixed translation variable issue ChannelA
# 90508-0727 - Changed to PHP long tags
# 130328-0027 - Converted ereg to preg functions
# 130603-2214 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1522 - Added optional encrypted passwords compatibility
# 130802-1009 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];}
elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];}
if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];}
elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '2.6-13';
$build = '130328-0027';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Aktive Nebenstelle überprüfen";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
echo "DateTime: $NOW_TIME|";
echo "UnixTime: $StarTtime|";
$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
echo "$row[0]|";
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten ist unzulässig oder Protokoll $protocol ist unzulässig\n";
exit;
}
else
{
$stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$ChanneLA[$loop_count] = "$row[0]";
$ChanneLB[$loop_count] = "$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
$counter=0;
while($loop_count > $counter)
{
$counter++;
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $ChanneLA[$counter]|";
}
}
}
}
}
echo "\n";
### check for live_inbound entry
$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
$LIuniqueid = "$row[0]";
$LIchannel = "$row[1]";
$LIcallerid = "$row[3]";
$LIdatetime = "$row[6]";
echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
}
echo "\n";
### if favorites are present do a lookup to see if any are active
if ($favorites_count > 0)
{
$favorites = explode(',',$favorites_list);
$h=0;
$favs_print='';
while ($favorites_count > $h)
{
$fav_extension = explode('/',$favorites[$h]);
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$favs_print .= "$fav_extension[1]: $row[0] ~";
$h++;
}
echo "$favs_print\n";
}
if ($format=='debug') {echo "\n<!-- |$favorites_count|$favorites_list| -->";}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,152 @@
<?php
# park_calls_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the details on the parked calls on the server
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50524-1515 - First build of script
# 50711-1208 - removed HTTP authentication in favor of user/pass vars
# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0024 - Converted ereg to preg functions
# 130603-2213 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1024 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($park_limit)) {$park_limit="1000";}
$version = '0.0.4';
$build = '60619-1205';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Geparkte Anruf anzeigen";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten ist unzulässig oder Protokoll $protocol ist unzulässig\n";
exit;
}
else
{
##### print parked calls from the parked_channels table
$stmt="SELECT channel,server_ip,channel_group,extension,parked_by,parked_time from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$park_calls_count = mysqli_num_rows($rslt);
echo "$park_calls_count\n";
$loop_count=0;
while ($park_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,919 @@
<?php
# phone_only.php - the web-based web-phone-only client application
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 110511-1336 - First Build
# 110526-1757 - Added webphone_auto_answer option
# 120223-2124 - Removed logging of good login passwords if webroot writable is enabled
# 130123-1923 - Added ability to use user-login-first options.php option
# 130328-0005 - Converted ereg to preg functions
# 130603-2212 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130718-0946 - Fixed login bug
# 130802-1139 - Changed to PHP mysqli functions
#
$version = '2.8-8p';
$build = '130802-1139';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=73;
$one_mysql_log=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];}
elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
if (!isset($flag_channels))
{
$flag_channels=0;
$flag_string='';
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("[^0-9a-z]","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_pass);
$forever_stop=0;
if ($force_logout)
{
echo "Sie haben sich abgemeldet. Danke\n";
exit;
}
$isdst = date("I");
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$tsNOW_TIME = date("YmdHis");
$FILE_TIME = date("Ymd-His");
$loginDATE = date("Ymd");
$CIDdate = date("ymdHis");
$month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y"));
$past_month_date = date("Y-m-d H:i:s",$month_old);
$minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y"));
$past_minutes_date = date("Y-m-d H:i:s",$minutes_old);
$webphone_width = 460;
$webphone_height = 500;
$PHP_SELF=$_SERVER['PHP_SELF'];
$random = (rand(1000000, 9999999) + 10000000);
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09001',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$vdc_header_date_format = $row[1];
$vdc_customer_date_format = $row[2];
$vdc_header_phone_format = $row[3];
$WeBRooTWritablE = $row[4];
$timeclock_end_of_day = $row[5];
$vtiger_url = $row[6];
$enable_vtiger_integration = $row[7];
$outbound_autodial_active = $row[8];
$enable_second_webform = $row[9];
$user_territories_active = $row[10];
$static_agent_url = $row[11];
$custom_fields_enabled = $row[12];
}
##### END SETTINGS LOOKUP #####
###########################################
##### DEFINABLE SETTINGS AND OPTIONS
###########################################
# set defaults for hard-coded variables
$user_login_first = '0'; # set to 1 to have the vicidial_user login before the Telefon anmelden
$clientDST = '1'; # set to 1 to check for DST an server for agent time
$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login
$hide_timeclock_link = '0'; # set to 1 to hide the timeclock link an the agent login screen
$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window
$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500
$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770
$webphone_width = 460; # set the webphone frame width
$webphone_height = 500; # set the webphone frame height
$webphone_pad = 0; # set the table cellpadding for the webphone
$webphone_location = 'right'; # set the location an the agent screen 'right' or 'bar'
$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6
$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0
$FORM_COLOR = '#EFEFEF';
$SIDEBAR_COLOR = '#F6F6F6';
# if options file exists, use the override values for the above variables
# see the options-example.php file for more information
if (file_exists('options.php'))
{
require_once('options.php');
}
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/phone_only\.php/i','',$agcPAGE);
if (strlen($static_agent_url) > 5)
{$agcPAGE = $static_agent_url;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../agc/css/style.css" />
<link rel="stylesheet" type="text/css" href="../agc/css/custom.css" />
';
echo "<!-- VERSION: $version BUILD: $build -->\n";
echo "<!-- BROWSER: $BROWSER_WIDTH x $BROWSER_HEIGHT $JS_browser_width x $JS_browser_height -->\n";
$stmt="SELECT user_group from vicidial_users where user='$VD_login';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09002',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group=$row[0];
if ($relogin == 'YES')
{
echo "<title>Telefon web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Stechuhr</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_de/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Deutsch <img src=\"../agc/images/de.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"$phone_pass\" /></td></tr>\n";
echo "<tr><td align=\"right\">Benutzer Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Benutzer Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ÜBERNEHMEN\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($user_login_first == 1)
{
if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) )
{
echo "<title>Telefon web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Stechuhr</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_de/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Deutsch <img src=\"../agc/images/de.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Benutzer Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Benutzer Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ÜBERNEHMEN\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) )
{
$stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09073',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$phone_login=$row[0];
$phone_pass=$row[1];
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Telefon web client: Telefon Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Stechuhr</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_de/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Deutsch <img src=\"../agc/images/de.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ÜBERNEHMEN\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
}
}
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Telefon web client: Telefon Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Stechuhr</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_de/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Deutsch <img src=\"../agc/images/de.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ÜBERNEHMEN\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./vicidial_auth_entries.txt", "a");}
$VDloginDISPLAY=0;
if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) )
{
$VDloginDISPLAY=1;
}
else
{
$auth=0;
$auth_message = user_authorization($VD_login,$VD_pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if($auth>0)
{
##### grab the full name of the agent
$stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,agent_call_log_view_override,agent_choose_blended,agent_lead_search_override from vicidial_users where user='$VD_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09004',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$LOGfullname = $row[0];
$user_level = $row[1];
$VU_user_group = $row[10];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts,agent_status_viewable_groups,agent_status_view_time,agent_call_log_view,agent_xfer_consultative,agent_xfer_dial_override,agent_xfer_vm_transfer,agent_xfer_blind_transfer,agent_xfer_dial_with_customer,agent_xfer_park_customer_dial,agent_fullscreen,webphone_url_override,webphone_dialpad_override,webphone_systemkey_override from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09005',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$agent_fullscreen = $row[12];
$webphone_url = $row[13];
$webphone_dialpad_override = $row[14];
$system_key = $row[15];
if ( ($webphone_dialpad_override != 'DISABLED') and (strlen($webphone_dialpad_override) > 0) )
{$webphone_dialpad = $webphone_dialpad_override;}
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|GOOD|$date|$VD_login|XXXX|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
$user_abb = "$VD_login$VD_login$VD_login$VD_login";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|FAIL|$date|$VD_login|XXXX|$ip|$browser|\n");
fclose($fp);
}
$VDloginDISPLAY=1;
$VDdisplayMESSAGE = "Falsches Passwort, versuchen sie es bitte noch einmal<br />";
if ($auth_message == 'LOCK')
{$VDdisplayMESSAGE = "Too many login attempts, try again in 15 minutes<br />";}
}
}
if ($VDloginDISPLAY)
{
echo "<title>Telefon web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Stechuhr</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_de/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Deutsch <img src=\"../agc/images/de.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<input type=\"hidden\" name=\"phone_login\" value=\"$phone_login\" />\n";
echo "<input type=\"hidden\" name=\"phone_pass\" value=\"$phone_pass\" />\n";
echo "<center><br /><b>$VDdisplayMESSAGE</b><br /><br />";
echo "<table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Benutzer Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Benutzer Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ÜBERNEHMEN\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
$original_phone_login = $phone_login;
# code for parsing load-balanced agent phone allocation where agent interface
# will send multiple phones-table logins so that the script can determine the
# server that has the fewest agents logged into it.
# login: ca101,cb101,cc101
$alias_found=0;
$stmt="select count(*) from phones_alias where alias_id = '$phone_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09006',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_found = "$row[0]";
}
if ($alias_found > 0)
{
$stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09007',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_name = "$row[0]";
$phone_login = "$row[1]";
}
}
$pa=0;
if ( (preg_match('/,/',$phone_login)) and (strlen($phone_login) > 2) )
{
$phoneSQL = "(";
$phones_auto = explode(',',$phone_login);
$phones_auto_ct = count($phones_auto);
while($pa < $phones_auto_ct)
{
if ($pa > 0)
{$phoneSQL .= " or ";}
$desc = ($phones_auto_ct - $pa); # traverse in reverse order
$phoneSQL .= "(login='$phones_auto[$desc]' and pass='$phone_pass')";
$pa++;
}
$phoneSQL .= ")";
}
else {$phoneSQL = "login='$phone_login' and pass='$phone_pass'";}
$authphone=0;
#$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';";
$stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and active_asterisk_server='Y' and phones.server_ip=servers.server_ip;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09008',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$authphone=$row[0];
if (!$authphone)
{
echo "<title>Telefon web client: Telefon Login Error</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Stechuhr</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_de/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Deutsch <img src=\"../agc/images/de.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\">\n";
echo "<input type=\"hidden\" name=\"VD_login\" value=\"$VD_login\" />\n";
echo "<input type=\"hidden\" name=\"VD_pass\" value=\"$VD_pass\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login Error</td>";
echo "</tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><font size=\"1\"> &nbsp; <br /><font size=\"3\">Ihr Telefon Login ist nicht aktiv, bitte versuchen sie es noch einmal: <br /> &nbsp;</font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\"></td></tr>\n";
echo "<tr><td align=\"right\">Telefon Passwort: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=10 maxlength=20 value=\"$phone_pass\"></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ÜBERNEHMEN\" value=\"Submit\" /></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### go through the entered phones to figure out which server has fewest agents
### logged in and use that Telefon anmelden account
if ($pa > 0)
{
$pb=0;
$pb_login='';
$pb_server_ip='';
$pb_count=0;
$pb_log='';
while($pb < $phones_auto_ct)
{
### find the server_ip of each phone_login
$stmtx="SELECT server_ip from phones where login = '$phones_auto[$pb]';";
if ($DB) {echo "|$stmtx|\n";}
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmtx, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09009',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysqli_fetch_row($rslt);
### get number of agents logged in to each server
$stmt="SELECT count(*) from web_client_sessions where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09010',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
### find out whether the server is set to active
$stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' and active_asterisk_server='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09011',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysqli_fetch_row($rslt);
### find out if this server has a twin
$twin_not_live=0;
$stmt="SELECT active_twin_server_ip from servers where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09012',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyy=mysqli_fetch_row($rslt);
if (strlen($rowyy[0]) > 4)
{
### find out whether the twin server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowyy[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09013',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyz=mysqli_fetch_row($rslt);
if ($rowyz[0] < 1) {$twin_not_live=1;}
}
### find out whether the server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09014',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowz=mysqli_fetch_row($rslt);
$pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]|$twin_not_live| ";
if ( ($rowy[0] > 0) and ($rowz[0] > 0) and ($twin_not_live < 1) )
{
if ( ($pb_count >= $row[0]) or (strlen($pb_server_ip) < 4) )
{
$pb_count=$row[0];
$pb_server_ip=$rowx[0];
$phone_login=$phones_auto[$pb];
}
}
$pb++;
}
echo "<!-- Telefons balance selection: $phone_login|$pb_server_ip|$past_minutes_date| |$pb_log -->\n";
}
echo "<title>Telefon web client</title>\n";
$stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,phone_ring_timeout,on_hook_agent,webphone_auto_answer from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$extension=$row[0];
$dialplan_number=$row[1];
$voicemail_id=$row[2];
$phone_ip=$row[3];
$computer_ip=$row[4];
$server_ip=$row[5];
$login=$row[6];
$pass=$row[7];
$status=$row[8];
$active=$row[9];
$phone_type=$row[10];
$fullname=$row[11];
$company=$row[12];
$picture=$row[13];
$messages=$row[14];
$old_messages=$row[15];
$protocol=$row[16];
$local_gmt=$row[17];
$ASTmgrUSERNAME=$row[18];
$ASTmgrSECRET=$row[19];
$login_user=$row[20];
$login_pass=$row[21];
$login_campaign=$row[22];
$park_on_extension=$row[23];
$conf_on_extension=$row[24];
$VICIDiaL_park_on_extension=$row[25];
$VICIDiaL_park_on_filename=$row[26];
$monitor_prefix=$row[27];
$recording_exten=$row[28];
$voicemail_exten=$row[29];
$voicemail_dump_exten=$row[30];
$ext_context=$row[31];
$dtmf_send_extension=$row[32];
$call_out_number_group=$row[33];
$client_browser=$row[34];
$install_directory=$row[35];
$local_web_callerID_URL=$row[36];
$VICIDiaL_web_URL=$row[37];
$AGI_call_logging_enabled=$row[38];
$user_switching_enabled=$row[39];
$conferencing_enabled=$row[40];
$admin_hangup_enabled=$row[41];
$admin_hijack_enabled=$row[42];
$admin_monitor_enabled=$row[43];
$call_parking_enabled=$row[44];
$updater_check_enabled=$row[45];
$AFLogging_enabled=$row[46];
$QUEUE_ACTION_enabled=$row[47];
$CallerID_popup_enabled=$row[48];
$voicemail_button_enabled=$row[49];
$enable_fast_refresh=$row[50];
$fast_refresh_rate=$row[51];
$enable_persistant_mysql=$row[52];
$auto_dial_next_number=$row[53];
$VDstop_rec_after_each_call=$row[54];
$DBX_server=$row[55];
$DBX_database=$row[56];
$DBX_user=$row[57];
$DBX_pass=$row[58];
$DBX_port=$row[59];
$outbound_cid=$row[65];
$enable_sipsak_messages=$row[66];
$conf_secret=$row[72];
$is_webphone=$row[73];
$use_external_server_ip=$row[74];
$codecs_list=$row[75];
$webphone_dialpad=$row[76];
$phone_ring_timeout=$row[77];
$on_hook_agent=$row[78];
$webphone_auto_answer=$row[79];
$no_empty_session_warnings=0;
if ( ($phone_login == 'nophone') or ($on_hook_agent == 'Y') )
{
$no_empty_session_warnings=1;
}
if ($PhonESComPIP == '1')
{
if (strlen($computer_ip) < 4)
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
}
if ($PhonESComPIP == '2')
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09017',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
if ($clientDST)
{
$local_gmt = ($local_gmt + $isdst);
}
if ($protocol == 'EXTERNAL')
{
$protocol = 'Local';
$extension = "$dialplan_number$AT$ext_context";
}
$SIP_user = "$protocol/$extension";
$SIP_user_DiaL = "$protocol/$extension";
if ( (preg_match('/8300/',$dialplan_number)) and (strlen($dialplan_number)<5) and ($protocol == 'Local') )
{
$SIP_user = "$protocol/$extension$VD_login";
}
$session_ext = preg_replace("/[^a-z0-9]/i", "", $extension);
if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);}
$session_rand = (rand(1,9999999) + 10000000);
$session_name = "$StarTtimE$US$session_ext$session_rand";
if ($webform_sessionname)
{$webform_sessionname = "&session_name=$session_name";}
else
{$webform_sessionname = '';}
$stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'phone';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09018',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','phone','$NOW_TIME','$session_name');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09019',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VICIDiaL_is_logged_in=1;
$webphone_content='';
### build Iframe variable content for webphone here
$codecs_list = preg_replace("/ /",'',$codecs_list);
$codecs_list = preg_replace("/-/",'',$codecs_list);
$codecs_list = preg_replace("/&/",'',$codecs_list);
$webphone_server_ip = $server_ip;
if ($use_external_server_ip=='Y')
{
##### find external_server_ip if enabled for this phone account
$stmt="SELECT external_server_ip FROM servers where server_ip='$server_ip' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09020',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$exip_ct = mysqli_num_rows($rslt);
if ($exip_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_server_ip =$row[0];
}
}
if (strlen($webphone_url) < 6)
{
##### find webphone_url in system_settings and generate IFRAME code for it #####
$stmt="SELECT webphone_url FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09021',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wu_ct = mysqli_num_rows($rslt);
if ($wu_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_url =$row[0];
}
}
if (strlen($system_key) < 1)
{
##### find system_key in system_settings if populated #####
$stmt="SELECT webphone_systemkey FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09022',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wsk_ct = mysqli_num_rows($rslt);
if ($wsk_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$system_key =$row[0];
}
}
$webphone_options='INITIAL_LOAD';
if ($webphone_dialpad == 'Y') {$webphone_options .= "--DIALPAD_Y";}
if ($webphone_dialpad == 'N') {$webphone_options .= "--DIALPAD_N";}
if ($webphone_dialpad == 'TOGGLE') {$webphone_options .= "--DIALPAD_TOGGLE";}
if ($webphone_dialpad == 'TOGGLE_OFF') {$webphone_options .= "--DIALPAD_OFF_TOGGLE";}
if ($webphone_auto_answer == 'Y') {$webphone_options .= "--AUTOANSWER_Y";}
if ($webphone_auto_answer == 'N') {$webphone_options .= "--AUTOANSWER_N";}
### base64 encode variables
$b64_phone_login = base64_encode($extension);
$b64_phone_pass = base64_encode($conf_secret);
$b64_session_name = base64_encode($session_name);
$b64_server_ip = base64_encode($webphone_server_ip);
$b64_callerid = base64_encode($outbound_cid);
$b64_protocol = base64_encode($protocol);
$b64_codecs = base64_encode($codecs_list);
$b64_options = base64_encode($webphone_options);
$b64_system_key = base64_encode($system_key);
$WebPhonEurl = "$webphone_url?phone_login=$b64_phone_login&phone_login=$b64_phone_login&phone_pass=$b64_phone_pass&server_ip=$b64_server_ip&callerid=$b64_callerid&protocol=$b64_protocol&codecs=$b64_codecs&options=$b64_options&system_key=$b64_system_key";
if ($webphone_location == 'bar')
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
else
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
if (preg_match('/MSIE/',$browser))
{
$useIE=1;
echo "<!-- client web browser used: MSIE |$browser|$useIE| -->\n";
}
else
{
$useIE=0;
echo "<!-- client web browser used: W3C-Compliant |$browser|$useIE| -->\n";
}
}
}
### SCREEN WIDTH AND HEIGHT CALCULATIONS ###
### DO NOT EDIT! ###
if ($stretch_dimensions > 0)
{
if ($agent_status_view < 1)
{
if ($JS_browser_width >= 510)
{$BROWSER_WIDTH = ($JS_browser_width - 80);}
}
else
{
if ($JS_browser_width >= 730)
{$BROWSER_WIDTH = ($JS_browser_width - 300);}
}
if ($JS_browser_height >= 340)
{$BROWSER_HEIGHT = ($JS_browser_height - 40);}
}
if ($agent_fullscreen=='Y')
{
$BROWSER_WIDTH = ($JS_browser_width - 10);
$BROWSER_HEIGHT = $JS_browser_height;
}
$MASTERwidth=($BROWSER_WIDTH - 340);
$MASTERheight=($BROWSER_HEIGHT - 200);
if ($MASTERwidth < 430) {$MASTERwidth = '430';}
if ($MASTERheight < 300) {$MASTERheight = '300';}
if ($webphone_location == 'bar') {$MASTERwidth = ($MASTERwidth + $webphone_height);}
$CAwidth = ($MASTERwidth + 340); # 770 - cover all (none-in-session, customer hunngup, etc...)
$SBwidth = ($MASTERwidth + 331); # 761 - SideBar starting point
$MNwidth = ($MASTERwidth + 330); # 760 - main frame
$XFwidth = ($MASTERwidth + 320); # 750 - transfer/conference
$HCwidth = ($MASTERwidth + 310); # 740 - hotkeys and callbacks
$CQwidth = ($MASTERwidth + 300); # 730 - calls in queue listings
$AMwidth = ($MASTERwidth + 270); # 700 - refresh links
$SCwidth = ($MASTERwidth + 230); # 670 - live call Sekunden counter, sidebar link
$PDwidth = ($MASTERwidth + 210); # 650 - preset-dial links
$MUwidth = ($MASTERwidth + 180); # 610 - agent mute
$SSwidth = ($MASTERwidth + 176); # 606 - scroll script
$SDwidth = ($MASTERwidth + 170); # 600 - scroll script, customer data and calls-in-session
$HKwidth = ($MASTERwidth + 20); # 450 - Hotkeys button
$HSwidth = ($MASTERwidth + 1); # 431 - Header spacer
$PBwidth = ($MASTERwidth + 0); # 430 - Presets list
$CLwidth = ($MASTERwidth - 120); # 310 - Calls in queue link
$GHheight = ($MASTERheight + 1260);# 1560 - Gender Hide span
$DBheight = ($MASTERheight + 260); # 560 - Debug span
$WRheight = ($MASTERheight + 160); # 460 - Warning boxes
$CQheight = ($MASTERheight + 140); # 440 - Calls in queue section
$SLheight = ($MASTERheight + 122); # 422 - SideBar link, Agents view link
$QLheight = ($MASTERheight + 112); # 412 - Calls in queue link
$HKheight = ($MASTERheight + 105); # 405 - HotKey active Button
$AMheight = ($MASTERheight + 100); # 400 - Agent mute buttons
$PBheight = ($MASTERheight + 90); # 390 - preset dial links
$MBheight = ($MASTERheight + 65); # 365 - Manual Dial Buttons
$CBheight = ($MASTERheight + 50); # 350 - Agent Callback, pause code, volume control Buttons and agent status
$SSheight = ($MASTERheight + 31); # 331 - script content
$HTheight = ($MASTERheight + 10); # 310 - transfer frame, callback comments and hotkey
$BPheight = ($MASTERheight - 250); # 50 - bottom buffer, Agent Xfer Span
$SCheight = 49; # 49 - Sekunden an call display
$SFheight = 65; # 65 - height of the script and form contents
$SRheight = 69; # 69 - height of the script and form refrech links
if ($webphone_location == 'bar')
{
$SCheight = ($SCheight + $webphone_height);
# $SFheight = ($SFheight + $webphone_height);
$SRheight = ($SRheight + $webphone_height);
}
$AVTheight = '0';
if ($is_webphone) {$AVTheight = '20';}
echo "</head>\n";
$zi=2;
echo "<body bgcolor=\"white\">\n";
echo " Telefon: $original_phone_login - $server_ip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"$PHP_SELF?relogin=YES&session_epoch=1234567890&session_id=&session_name=$session_name&VD_login=$VD_login&phone_login=$original_phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Logout</a><BR>\n";
if ($webphone_location == 'bar')
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;width=".$webphone_width."px;overflow:hidden;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanBAR\"><span id=\"webphonecontent\" style=\"overflow:hidden;\">$webphone_content</span></span>\n";
}
else
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;overflow:scroll;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanDEFAULT\"><table cellpadding=\"$webphone_pad\" cellspacing=\"0\" border=\"0\"><tr><td width=\"5px\" rowspan=\"2\">&nbsp;</td><td align=\"center\"><font class=\"body_text\">
Web Telefon: &nbsp; </font></td></tr><tr><td align=\"center\"><span id=\"webphonecontent\">$webphone_content</span></td></tr></table></span>\n";
}
?>
</body>
</html>
<?php
exit;
?>
@@ -0,0 +1,464 @@
<?php
# timeclock.php - VICIDIAL system user timeclock
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 80523-0134 - First Build
# 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field
# 80525-2351 - Added an audit log that is not to be editable
# 80602-0641 - Fixed status update bug
# 90508-0727 - Changed to PHP long tags
# 100621-1023 - Added admin_web_directory variable
# 130328-0021 - Converted ereg to preg functions
# 130603-2211 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-2010 - Added optional encrypted passwords compatibility
# 130802-1031 - Changed to PHP mysqli functions
# 131208-2155 - Added user log TIMEOUTLOGOUT event status
#
$version = '2.8-10';
$build = '131208-2155';
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$last_action_date = $NOW_TIME;
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/timeclock\.php/i','',$agcPAGE);
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];}
elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["commit"])) {$commit=$_GET["commit"];}
elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];}
if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];}
elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("/[^0-9a-z]/","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^0-9a-zA-Z]/","",$VD_pass);
$VD_campaign=preg_replace("/[^0-9a-zA-Z_]/","",$VD_campaign);
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$stage=preg_replace("/[^0-9a-zA-Z]/","",$stage);
$commit=preg_replace("/[^0-9a-zA-Z]/","",$commit);
$referrer=preg_replace("/[^0-9a-zA-Z]/","",$referrer);
require_once("dbconnect_mysqli.php");
require_once("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,admin_home_url,admin_web_directory FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
$i=0;
while ($i < $qm_conf_ct)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$welcomeURL = $row[1];
$admin_web_directory = $row[2];
$i++;
}
##### END SETTINGS LOOKUP #####
###########################################
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ( ($stage == 'login') or ($stage == 'logout') )
{
### see if user/pass exist for this user in vicidial_users table
$valid_user=0;
$auth_message = user_authorization($user,$pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$valid_user=1;}
print "<!-- vicidial_users active count for $user: |$valid_user| -->\n";
if ($valid_user < 1)
{
### NOT A VALID USER/PASS
$VDdisplayMESSAGE = "Diese Benutzer und Passwort Kombination ist nicht gültig<BR>Bitte noch einmal:";
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Stechuhr</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Stechuhr </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Benutzer Login: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Benutzer Passwort: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ÜBERNEHMEN VALUE=ÜBERNEHMEN> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### VALID USER/PASS, CONTINUE
### get name and group for this user
$stmt="SELECT full_name,user_group from vicidial_users where user='$user' and active='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$full_name = $row[0];
$user_group = $row[1];
print "<!-- vicidial_users name and group for $user: |$full_name|$user_group| -->\n";
### get vicidial_timeclock_status record count for this user
$stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$vts_count = $row[0];
$last_action_sec=99;
if ($vts_count > 0)
{
### vicidial_timeclock_status record found, grab status and date of last activity
$stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$status = $row[0];
$event_epoch = $row[1];
$last_action_date = date("Y-m-d H:i:s", $event_epoch);
$last_action_sec = ($StarTtimE - $event_epoch);
if ($last_action_sec > 0)
{
$totTIME_H = ($last_action_sec / 3600);
$totTIME_H_int = round($totTIME_H, 2);
$totTIME_H_int = intval("$totTIME_H");
$totTIME_M = ($totTIME_H - $totTIME_H_int);
$totTIME_M = ($totTIME_M * 60);
$totTIME_M_int = round($totTIME_M, 2);
$totTIME_M_int = intval("$totTIME_M");
$totTIME_S = ($totTIME_M - $totTIME_M_int);
$totTIME_S = ($totTIME_S * 60);
$totTIME_S = round($totTIME_S, 0);
if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";}
if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";}
if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
$totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S";
}
else
{
$totTIME_HMS='0:00:00';
}
print "<!-- vicidial_timeclock_status previous status for $user: |$status|$event_epoch|$last_action_sec| -->\n";
}
else
{
### No vicidial_timeclock_status record found, insert one
$stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$status='START';
$totTIME_HMS='0:00:00';
$affected_rows = mysqli_affected_rows($link);
print "<!-- NEU vicidial_timeclock_status record inserted for $user: |$affected_rows| -->\n";
}
if ( ($last_action_sec < 30) and ($status != 'START') )
{
### You cannot log in or out within 30 Sekunden of your last login/logout
$VDdisplayMESSAGE = "Bitte warten Sie wenigstens 30 Sekunden zwischen dem an- und abmelden und umgekehrt";
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Stechuhr</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Stechuhr </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Benutzer Login: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Benutzer Passwort: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ÜBERNEHMEN VALUE=ÜBERNEHMEN> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($commit == 'YES')
{
if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='login') )
{
$VDdisplayMESSAGE = "Sie haben jetzt Angemeldete";
$LOGtimeMESSAGE = "Sie sind angemeldet an $NOW_TIME";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- NEU vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- NEU vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
}
if ( ($status=='LOGIN') and ($stage=='logout') )
{
$VDdisplayMESSAGE = "Sie sind jetzt abgemeldet";
$LOGtimeMESSAGE = "Abgemeldet um $NOW_TIME<BR>Zeit die sie angemeldet waren: $totTIME_HMS";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- NEU vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update last login record in the timeclock log
$stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_log record updated for $user: |$affected_rows| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- NEU vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
### Update last login record in the timeclock audit log
$stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_audit_log record updated for $user: |$affected_rows| -->\n";
}
if ( ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) )
{echo "FEHLER: Stechuhreintrag wurde bereits gemacht: $status|$stage"; exit;}
if ($referrer=='agent')
{$BACKlink = "<A HREF=\"./vicidial.php?pl=$phone_login&pp=$phone_pass&VD_login=$user\"><font color=\"#003333\">ZURÜCK zur Benutzeranmeldung</font></A>";}
if ($referrer=='admin')
{$BACKlink = "<A HREF=\"/$admin_web_directory/admin.php\"><font color=\"#003333\">ZURÜCK zur Administration</font></A>";}
if ($referrer=='welcome')
{$BACKlink = "<A HREF=\"$welcomeURL\"><font color=\"#003333\">ZURÜCK zur Einstiegsseite</font></A>";}
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Stechuhr</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Stechuhr </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><B> $BACKlink <BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') )
{
$VDdisplayMESSAGE = "Zeit seit Sie das letzte mal angemeldet waren: $totTIME_HMS";
$log_action = 'login';
$button_name = 'LOGIN';
$LOGtimeMESSAGE = "Zuletzt ausgelogged um: $last_action_date<BR><BR>Klicken Sie unten auf LOGIN um sich anzumelden";
}
if ($status=='LOGIN')
{
$VDdisplayMESSAGE = "Zeit die Sie bereits angemeldet sind: $totTIME_HMS";
$log_action = 'logout';
$button_name = 'LOGOUT';
$LOGtimeMESSAGE = "Angemeldet seit: $last_action_date<BR>Zeit die Sie bereits angemeldet sind: $totTIME_HMS<BR><BR>Klicken Sie unten auf LOGOUT um sich abzumelden";
}
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Stechuhr</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"$log_action\">\n";
echo "<INPUT TYPE=HIDDEN NAME=commit VALUE=\"YES\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=user VALUE=\"$user\">\n";
echo "<INPUT TYPE=HIDDEN NAME=pass VALUE=\"$pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Stechuhr </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=$button_name VALUE=$button_name> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
else
{
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Stechuhr</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Stechuhr </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Benutzer Login: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Benutzer Passwort: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ÜBERNEHMEN VALUE=ÜBERNEHMEN> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,375 @@
<?php
# vdc_email_display.php - VICIDIAL administration page
#
# Copyright (C) 2013 Matt Florell, Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# This page displays any incoming emails in the Vicidial user interface. It
# also allows the user to download and view any attachments sent in the email,
# and also gives the user the ability to respond to the email and even
# attach files to it. The page also logs all email messages that are sent
# through it to the vicidial_email_log table
#
# changes:
# 121214-2300 - First Build
# 130127-0027 - Better non-latin characters support
# 130328-0007 - Converted ereg to preg functions
# 130603-2210 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1515 - Added optional encrypted passwords compatibility
# 130802-1032 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["attachment_id"])) {$attachment_id=$_GET["attachment_id"];}
elseif (isset($_POST["attachment_id"])) {$attachment_id=$_POST["attachment_id"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];}
elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["sender_email"])) {$sender_email=$_GET["sender_email"];}
elseif (isset($_POST["sender_email"])) {$sender_email=$_POST["sender_email"];}
if (isset($_GET["reply_subject"])) {$reply_subject=$_GET["reply_subject"];}
elseif (isset($_POST["reply_subject"])) {$reply_subject=$_POST["reply_subject"];}
if (isset($_GET["reply_to_address"])) {$reply_to_address=$_GET["reply_to_address"];}
elseif (isset($_POST["reply_to_address"])) {$reply_to_address=$_POST["reply_to_address"];}
if (isset($_GET["reply_from_address"])) {$reply_from_address=$_GET["reply_from_address"];}
elseif (isset($_POST["reply_from_address"])) {$reply_from_address=$_POST["reply_from_address"];}
if (isset($_GET["reply_message"])) {$reply_message=$_GET["reply_message"];}
elseif (isset($_POST["reply_message"])) {$reply_message=$_POST["reply_message"];}
if (isset($_GET["REPLY"])) {$REPLY=$_GET["REPLY"];}
elseif (isset($_POST["REPLY"])) {$REPLY=$_POST["REPLY"];}
$attachment1=$_FILES["attachment1"];
$A1_orig = $_FILES['attachment1']['name'];
$A1_path = $_FILES['attachment1']['tmp_name'];
$A1_type = $_FILES['attachment1']['type'];
$attachment2=$_FILES["attachment2"];
$A2_orig = $_FILES['attachment2']['name'];
$A2_path = $_FILES['attachment2']['tmp_name'];
$A2_type = $_FILES['attachment2']['type'];
$attachment3=$_FILES["attachment3"];
$A3_orig = $_FILES['attachment3']['name'];
$A3_path = $_FILES['attachment3']['tmp_name'];
$A3_type = $_FILES['attachment3']['type'];
$attachment4=$_FILES["attachment4"];
$A4_orig = $_FILES['attachment4']['name'];
$A4_path = $_FILES['attachment4']['tmp_name'];
$A4_type = $_FILES['attachment4']['type'];
$attachment5=$_FILES["attachment5"];
$A5_orig = $_FILES['attachment5']['name'];
$A5_path = $_FILES['attachment5']['tmp_name'];
$A5_type = $_FILES['attachment5']['type'];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "EMAIL"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled,allow_emails FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
$allow_emails = $row[4];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($allow_emails<1)
{
echo "Your system does not have the email setting enabled\n";
exit;
}
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and modify_leads='1';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
$LVAactive=9;
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) ) )
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_email_display.php method=POST name=email_display_form id=email_display_form>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
if ($REPLY)
{
$to = "$reply_to_address";
$from = "$reply_from_address";
$subject ="$reply_subject";
$message = "$reply_message";
$headers = "From: $from";
$attachment_str="";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
for ($i=1; $i<=5; $i++)
{
$attachment_orig_name="A".$i."_orig";
$attachment_path="A".$i."_path";
$LF_orig=$$attachment_orig_name;
$LF_path=$$attachment_path;
#echo "<p>".$$attachment_name."<BR/>".$$attachment_orig_name."<BR/>".$$attachment_path."<BR/><p>";
if ($LF_orig)
{
if (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig))
{
echo "ERROR: Unzulässig File Name: $LF_orig\n";
exit;
}
else
{
copy($LF_path, "/tmp/$LF_orig");
$file = fopen("/tmp/$LF_orig","rb");
$data = fread($file,filesize("/tmp/$LF_orig"));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$LF_orig\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$LF_orig\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
$attachment_str.="$LF_orig|";
}
}
}
$sendmail = @mail($to, $subject, $message, $headers);
if ($sendmail)
{
$reply_message=preg_replace('/(\"|\||\'|\;)/', '\\\$1', $reply_message);
$log_stmt="INSERT INTO vicidial_email_log(email_row_id, lead_id, email_date, user, email_to, message, campaign_id, attachments) VALUES('$email_row_id', '$lead_id', now(), '$user', '$reply_to_address', '$reply_message', '$campaign', '$attachment_str')";
$log_rslt=mysql_to_mysqli($log_stmt, $link);
echo "<p>mail sent to $to!</p>";
# Hangup the "call" an the agent screen
$stmt="UPDATE vicidial_live_agents set external_hangup='1' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
else
{
echo "<p>mail could not be sent!</p>";
}
exit;
}
if ($lead_id) {
$stmt="select * from vicidial_email_list where lead_id='$lead_id' and direction='INBOUND' and status IN('NEW','INCALL') order by email_date asc";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$email_row_id=$row["email_row_id"];
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_from"], $matches);
if (strlen($matches[0])>0) {
$email_from = substr($matches[0],1,-1);
} else {
$email_from = $row["email_from"];
}
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_to"], $matches);
if (strlen($matches[0])>0) {
$row["email_from"]=preg_replace('/\>/', '&gt;', $row["email_from"]);
$row["email_from"]=preg_replace('/\</', '&lt;', $row["email_from"]);
$email_to = substr($matches[0],1,-1);
} else {
$row["email_to"]=preg_replace('/\>/', '\>', $row["email_to"]);
$email_to = $row["email_to"];
}
$EMAIL_form="<center><TABLE cellspacing=2 cellpadding=2 bgcolor='#CCCCCC' width='500'>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Date received:</td><td align='left' valign='top' width='*'>$row[email_date]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>From:</td><td align='left' valign='top' width='*'>$row[email_from]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Subject:</td><td align='left' valign='top' width='*'>$row[subject]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Message:</td><td align='left' valign='top' width='*'><pre>$row[message]</pre></td></tr>\n";
$att_stmt="select * from inbound_email_attachments where email_row_id='$email_row_id'";
$att_rslt=mysql_to_mysqli($att_stmt, $link);
if (mysqli_num_rows($att_rslt)>0) {
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Zubehör:</td><td align='left' valign='top' width='*'><pre>";
while($att_row=mysqli_fetch_array($att_rslt)) {
$EMAIL_form.="<LI><a href='$_SERVER[PHP_SELF]?attachment_id=$att_row[attachment_id]&lead_id=$lead_id'>$att_row[filename]</a>\n";
}
$EMAIL_form.="</pre></td></tr>";
}
$EMAIL_form.="<tr><td colspan='2'><HR></td></tr>";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Response:</td><td align='left' valign='top' width='*'>RE: $row[subject]<input type='hidden' name='reply_subject' value='RE: $row[subject]'></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Reply:<BR><BR><input type='button' name='copy' value='COPY MESSAGE >>>' onClick='CopyMessage($row[email_row_id])'></td><td align='left' valign='top' width='*'><textarea rows='8' cols='50' name='reply_message' id='reply_message'>$reply_message</textarea></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Zubehör:</td><td align='left' valign='top' width='*'>";
$EMAIL_form.="<span id='attachment_span1'><input type=file name='attachment1' value='$attachment1'></span><BR/>";
$EMAIL_form.="<span id='attachment_span2'><input type=file name='attachment2'></span><BR/>";
$EMAIL_form.="<span id='attachment_span3'><input type=file name='attachment3'></span><BR/>";
$EMAIL_form.="<span id='attachment_span4'><input type=file name='attachment4'></span><BR/>";
$EMAIL_form.="<span id='attachment_span5'><input type=file name='attachment5'></span>";
$EMAIL_form.="</td></tr>\n";
$EMAIL_form.="<tr><td colspan='2' align='center'><input type='submit' name='REPLY' value='REPLY'></td></tr>";
$EMAIL_form.="</table></center>\n";
$EMAIL_form.="<input type='hidden' name='reply_to_address' value='$email_from'>\n";
$EMAIL_form.="<input type='hidden' name='reply_from_address' value='$email_to'>\n";
$EMAIL_form.="<input type='hidden' name='campaign' value='$campaign'>\n";
$EMAIL_form.="<input type='hidden' name='lead_id' value='$lead_id'>\n";
$EMAIL_form.="<input type='hidden' name='email_row_id' value='$email_row_id'>\n";
$EMAIL_form.="<input type='hidden' name='user' value='$user'>\n";
$EMAIL_form.="<input type='hidden' name='pass' value='$pass'>\n";
}
if ($attachment_id) {
$stmt="select * from inbound_email_attachments where attachment_id='$attachment_id'";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$filename=$row["filename"];
$encoding=$row["file_encoding"];
$file_size=$row["file_size"];
$file_type=$row["file_type"];
$file_contents=$row["file_contents"];
if ($encoding=="base64") {
$file_contents=base64_decode($file_contents);
$file_size=strlen($file_contents);
}
header("Content-length: ".$file_size."");
header("Content-type: ".$file_type."");
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $file_contents;
}
} else {
?>
<html>
<head>
<title>AGENT email frame</title>
</head>
<script language="Javascript">
function ParseFileName()
{
for (var i=1; i<=5; i++)
{
var attachment_field=eval("document.forms[0].attachment"+i);
var endstr=attachment_field.value.lastIndexOf('\\');
if (endstr>-1)
{
endstr++;
var filename=attachment_field.value.substring(endstr);
attachment_field.value=filename;
}
}
}
function CopyMessage()
{
<?php
$row["message"]=preg_replace('/\r|\n/', ' ', $row["message"]);
echo "var message=\"".preg_replace('/\"/', '\\\"', $row["message"])."\";\n";
?>
var msg_array=message.split(" ");
var full_msg="";
var msg_line="> ";
for (var i=0; i<msg_array.length; i++)
{
if (msg_array[i].length>=48)
{
msg_line+=msg_array[i]+" ";
}
if (msg_line.length+msg_array[i].length<50)
{
msg_line+=msg_array[i]+" ";
}
else
{
full_msg+=msg_line+"\n";
msg_line="> "+msg_array[i]+" ";
}
}
full_msg+=msg_line+"\n";
var email_field_value=document.getElementById("reply_message").value+"\n";
email_field_value+=full_msg;
document.getElementById("reply_message").value=email_field_value;
}
</script>
<style type="text/css">
pre { white-space: pre-wrap; }
</style>
<body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get' name="email_display_form" id="email_display_form" onSubmit="if (this.submitted) return false; this.submitted=true" enctype="multipart/form-data">
<?php echo $EMAIL_form; ?>
</form>
</body>
</html>
<?php
}
} else {
echo "ERROR - ID variable missing";
}
?>
@@ -0,0 +1,486 @@
<?php
# vdc_form_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the FORM tab in the agent
# interface, as well as take submission of the form submission when the agent
# dispositions the call
#
# CHANGELOG:
# 100630-1119 - First build of script
# 100703-1124 - Added submit_button,admin_submit fields, which will log to admin log
# 100712-2322 - Added code to log vicidial_list.entry_list_id field if data altered
# 100916-1749 - Added non-lead variable parsing
# 110719-0856 - Added HIDEBLOB type
# 110730-2335 - Added call_id variable
# 111025-1433 - Fixed case sensitivity on list fields
# 120315-1729 - Filtere out single quotes and backslashes from custom fields
# 130328-0012 - Converted ereg to preg functions
# 130402-2256 - Added user_group variable
# 130603-2204 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130615-2155 - Allow qc_enabled user access to this page even if not logged in as an agent
# 130705-1512 - Added optional encrypted passwords compatibility
# 130802-1033 - Changed to PHP mysqli functions
# 140101-2139 - Small fix for admin modify lead page on encrypted password systems
# 140429-2042 - Added TABLEper_call_notes display script variable for form display
#
$version = '2.8-15';
$build = '140429-2042';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["submit_button"])) {$submit_button=$_GET["submit_button"];}
elseif (isset($_POST["submit_button"])) {$submit_button=$_POST["submit_button"];}
if (isset($_GET["admin_submit"])) {$admin_submit=$_GET["admin_submit"];}
elseif (isset($_POST["admin_submit"])) {$admin_submit=$_POST["admin_submit"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "FORM"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|';
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;| /","",$user);
$pass = preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and ( (modify_leads='1') or (qc_enabled='1') );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
if ($custom_fields_enabled < 1)
{
echo "Custom Fields Disabled: |$custom_fields_enabled|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) and ($VUmodify < 1) ) )
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
### BEGIN parse submission of the custom fields form ###
if ($stage=='SUBMIT')
{
$update_sent=0;
$CFoutput='';
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06001',$user,$server_ip,$session_name,$one_mysql_log);}
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{
$update_SQL='';
$VL_update_SQL='';
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06003',$user,$server_ip,$session_name,$one_mysql_log);}
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$new_field_value='';
$form_field_value='';
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$A_field_name[$o] = $rowx[2];
$A_field_type[$o] = $rowx[6];
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_required[$o] = $rowx[12];
$A_field_value[$o] = '';
$field_name_id = $A_field_label[$o];
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$form_field_value = preg_replace("/\'/","",$form_field_value); // remove single-quote
$form_field_value = preg_replace("/\\b/","",$form_field_value); // remove backslashes
if ( ($A_field_type[$o]=='MULTI') or ($A_field_type[$o]=='CHECKBOX') or ($A_field_type[$o]=='RADIO') )
{
$k=0;
$multi_count = count($form_field_value);
$multi_array = $form_field_value;
while ($k < $multi_count)
{
$new_field_value .= "$multi_array[$k],";
$k++;
}
$form_field_value = preg_replace("/,$/","",$new_field_value);
}
if ($A_field_type[$o]=='TIME')
{
if (isset($_GET["MINUTE_$field_name_id"])) {$form_field_valueM=$_GET["MINUTE_$field_name_id"];}
elseif (isset($_POST["MINUTE_$field_name_id"])) {$form_field_valueM=$_POST["MINUTE_$field_name_id"];}
if (isset($_GET["HOUR_$field_name_id"])) {$form_field_valueH=$_GET["HOUR_$field_name_id"];}
elseif (isset($_POST["HOUR_$field_name_id"])) {$form_field_valueH=$_POST["HOUR_$field_name_id"];}
$form_field_value = "$form_field_valueH:$form_field_valueM:00";
}
$A_field_value[$o] = $form_field_value;
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') or ($A_field_type[$o]=='HIDDEN') or ($A_field_type[$o]=='HIDEBLOB') or ($A_field_type[$o]=='READONLY') )
{
$A_field_value[$o]='----IGNORE----';
}
else
{
if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
{
$VL_update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
else
{
$update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
$SUBMIT_output .= "<b>$A_field_name[$o]:</b> $A_field_value[$o]<BR>";
}
$o++;
}
$custom_update_count=0;
if (strlen($update_SQL)>3)
{
$custom_record_lead_count=0;
$stmt="SELECT count(*) from custom_$list_id where lead_id='$lead_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06004',$user,$server_ip,$session_name,$one_mysql_log);}
$fieldleadcount_to_print = mysqli_num_rows($rslt);
if ($fieldleadcount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$custom_record_lead_count = $rowx[0];
}
$update_SQL = preg_replace("/,$/","",$update_SQL);
$custom_table_update_SQL = "INSERT INTO custom_$list_id SET lead_id='$lead_id',$update_SQL;";
if ($custom_record_lead_count > 0)
{$custom_table_update_SQL = "UPDATE custom_$list_id SET $update_SQL where lead_id='$lead_id';";}
$rslt=mysql_to_mysqli($custom_table_update_SQL, $link);
$custom_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$custom_update_count|$custom_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
if (strlen($VL_update_SQL)>3)
{
$custom_update_vl_SQL='';
if ($custom_update_count > 0)
{$custom_update_vl_SQL = "entry_list_id='$list_id',";}
$VL_update_SQL = preg_replace("/,$/","",$VL_update_SQL);
$list_table_update_SQL = "UPDATE vicidial_list SET $custom_update_vl_SQL $VL_update_SQL where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
else
{
if ($custom_update_count > 0)
{
$list_table_update_SQL = "UPDATE vicidial_list SET entry_list_id='$list_id' where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
}
}
if ( ($admin_submit=='YES') and ($update_sent > 0) )
{
### LOG INSERTION Admin Log Table ###
$ip = getenv("REMOTE_ADDR");
$SQL_log = "$list_table_update_SQL|$custom_table_update_SQL|";
$SQL_log = preg_replace('/;/','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY CUSTOM LEAD', event_sql=\"$SQL_log\", event_notes='$custom_update_count|$list_update_count';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
else
{$CFoutput .= "ERROR: no custom list fields table\n";}
echo "Custom Form Output:\n<BR>\n";
echo "$SUBMIT_output";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
}
### END parse submission of the custom fields form ###
else
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Agent Form Display Script";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo " <link rel=\"stylesheet\" href=\"calendar.css\">\n";
echo " <script language=\"Javascript\">\n";
echo " function open_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:close_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help-</a><BR> &nbsp; \";\n";
echo " document.getElementById(taskspan).innerHTML = \"<B>\" + taskhelp + \"</B>\";\n";
echo " document.getElementById(taskspan).style.background = \"#FFFF99\";\n";
echo " }\n";
echo " function close_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \"\";\n";
echo " document.getElementById(taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:open_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help+</a>\";\n";
echo " document.getElementById(taskspan).style.background = \"white\";\n";
echo " }\n";
echo " </script>\n";
echo " <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#" . $bgcolor . "\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"parent.document.getElementById('FORM_LOADED').value='1';\">";
echo "\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=lead_id id=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=list_id id=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "<input type=hidden name=pass id=pass value=\"$pass\">\n";
echo "\n";
require_once("functions.php");
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user);
echo "$CFoutput";
if ($submit_button=='YES')
{
if ($bcrypt=='0')
{echo "<input type=hidden name=bcrypt id=bcrypt value=\"OFF\">\n";}
echo "<input type=hidden name=admin_submit id=admin_submit value=\"YES\">\n";
echo "<BR><BR><input type=submit name=VCformSubmit id=VCformSubmit value=submit>\n";
}
echo "</form></center><BR><BR>\n";
echo "</BODY></HTML>\n";
}
exit;
?>
@@ -0,0 +1,705 @@
<?php
# vdc_script_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the SCRIPT tab in the agent interface
#
# CHANGELOG:
# 90824-1435 - First build of script
# 90827-1548 - Added list override script option
# 91204-1913 - Added recording_filename and recording_id variables
# 91211-1103 - Added user_custom_... variables
# 100116-0702 - Added preset variables
# 100127-1611 - Added ignore_list_script_override option
# 100823-1644 - Added DID variables
# 100902-1344 - Added closecallid, xfercallid, agent_log_id variables
# 110420-1201 - Added web_vars variable
# 110730-2339 - Added call_id variable
# 120227-2017 - Added parsing of IGNORENOSCROLL option in script to force scroll
# 130328-0013 - Converted ereg to preg functions
# 130402-2255 - Added user_group variable
# 130603-2206 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1513 - Added optional encrypted passwords compatibility
# 130802-1035 - Changed to PHP mysqli functions
# 140429-2034 - Added TABLEper_call_notes display script variable
#
$version = '2.8-17';
$build = '140429-2034';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["title"])) {$title=$_GET["title"];}
elseif (isset($_POST["title"])) {$title=$_POST["title"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
if (isset($_GET["gender"])) {$gender=$_GET["gender"];}
elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];}
if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
if (isset($_GET["rank"])) {$rank=$_GET["rank"];}
elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];}
if (isset($_GET["owner"])) {$owner=$_GET["owner"];}
elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
elseif (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
if (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
elseif (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
if (isset($_GET["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_GET["CF_uses_custom_fields"];}
elseif (isset($_POST["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_POST["CF_uses_custom_fields"];}
if (isset($_GET["entry_list_id"])) {$entry_list_id=$_GET["entry_list_id"];}
elseif (isset($_POST["entry_list_id"])) {$entry_list_id=$_POST["entry_list_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["orig_pass"])) {$orig_pass=$_GET["orig_pass"];}
elseif (isset($_POST["orig_pass"])) {$orig_pass=$_POST["orig_pass"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$orig_pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass = preg_replace("/\'|\"|\\\\|;/","",$orig_pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,1,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
exit;
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>VICIDiaL Script Display Script";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if (strlen($in_script) < 1)
{$call_script = $camp_script;}
else
{$call_script = $in_script;}
$ignore_list_script_override='N';
$stmt = "SELECT ignore_list_script_override FROM vicidial_inbound_groups where group_id='$group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$ilso_ct = mysqli_num_rows($rslt);
if ($ilso_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$ignore_list_script_override = $row[0];
}
if ($ignore_list_script_override=='Y')
{$ignore_list_script=1;}
if ($ignore_list_script < 1)
{
$stmt="SELECT agent_script_override from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_script_override = $row[0];
if (strlen($agent_script_override) > 0)
{$call_script = $agent_script_override;}
}
$stmt="SELECT list_name,list_description from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_name = $row[0];
$list_description = $row[1];
$stmt="SELECT script_name,script_text from vicidial_scripts where script_id='$call_script';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$script_name = $row[0];
$script_text = stripslashes($row[1]);
if (preg_match("/iframe\ssrc/i",$script_text))
{
$IFRAME=1;
$lead_id = preg_replace('/\s/i','+',$lead_id);
$vendor_id = preg_replace('/\s/i','+',$vendor_id);
$vendor_lead_code = preg_replace('/\s/i','+',$vendor_lead_code);
$list_id = preg_replace('/\s/i','+',$list_id);
$list_name = preg_replace('/\s/i','+',$list_name);
$list_description = preg_replace('/\s/i','+',$list_description);
$gmt_offset_now = preg_replace('/\s/i','+',$gmt_offset_now);
$phone_code = preg_replace('/\s/i','+',$phone_code);
$phone_number = preg_replace('/\s/i','+',$phone_number);
$title = preg_replace('/\s/i','+',$title);
$first_name = preg_replace('/\s/i','+',$first_name);
$middle_initial = preg_replace('/\s/i','+',$middle_initial);
$last_name = preg_replace('/\s/i','+',$last_name);
$address1 = preg_replace('/\s/i','+',$address1);
$address2 = preg_replace('/\s/i','+',$address2);
$address3 = preg_replace('/\s/i','+',$address3);
$city = preg_replace('/\s/i','+',$city);
$state = preg_replace('/\s/i','+',$state);
$province = preg_replace('/\s/i','+',$province);
$postal_code = preg_replace('/\s/i','+',$postal_code);
$country_code = preg_replace('/\s/i','+',$country_code);
$gender = preg_replace('/\s/i','+',$gender);
$date_of_birth = preg_replace('/\s/i','+',$date_of_birth);
$alt_phone = preg_replace('/\s/i','+',$alt_phone);
$email = preg_replace('/\s/i','+',$email);
$security_phrase = preg_replace('/\s/i','+',$security_phrase);
$comments = preg_replace('/\s/i','+',$comments);
$user = preg_replace('/\s/i','+',$user);
$pass = preg_replace('/\s/i','+',$orig_pass);
$campaign = preg_replace('/\s/i','+',$campaign);
$phone_login = preg_replace('/\s/i','+',$phone_login);
$original_phone_login = preg_replace('/\s/i','+',$original_phone_login);
$phone_pass = preg_replace('/\s/i','+',$phone_pass);
$fronter = preg_replace('/\s/i','+',$fronter);
$closer = preg_replace('/\s/i','+',$closer);
$group = preg_replace('/\s/i','+',$group);
$channel_group = preg_replace('/\s/i','+',$channel_group);
$SQLdate = preg_replace('/\s/i','+',$SQLdate);
$epoch = preg_replace('/\s/i','+',$epoch);
$uniqueid = preg_replace('/\s/i','+',$uniqueid);
$customer_zap_channel = preg_replace('/\s/i','+',$customer_zap_channel);
$customer_server_ip = preg_replace('/\s/i','+',$customer_server_ip);
$server_ip = preg_replace('/\s/i','+',$server_ip);
$SIPexten = preg_replace('/\s/i','+',$SIPexten);
$session_id = preg_replace('/\s/i','+',$session_id);
$phone = preg_replace('/\s/i','+',$phone);
$parked_by = preg_replace('/\s/i','+',$parked_by);
$dispo = preg_replace('/\s/i','+',$dispo);
$dialed_number = preg_replace('/\s/i','+',$dialed_number);
$dialed_label = preg_replace('/\s/i','+',$dialed_label);
$source_id = preg_replace('/\s/i','+',$source_id);
$rank = preg_replace('/\s/i','+',$rank);
$owner = preg_replace('/\s/i','+',$owner);
$camp_script = preg_replace('/\s/i','+',$camp_script);
$in_script = preg_replace('/\s/i','+',$in_script);
$script_width = preg_replace('/\s/i','+',$script_width);
$script_height = preg_replace('/\s/i','+',$script_height);
$fullname = preg_replace('/\s/i','+',$fullname);
$recording_filename = preg_replace('/\s/i','+',$recording_filename);
$recording_id = preg_replace('/\s/i','+',$recording_id);
$user_custom_one = preg_replace('/\s/i','+',$user_custom_one);
$user_custom_two = preg_replace('/\s/i','+',$user_custom_two);
$user_custom_three = preg_replace('/\s/i','+',$user_custom_three);
$user_custom_four = preg_replace('/\s/i','+',$user_custom_four);
$user_custom_five = preg_replace('/\s/i','+',$user_custom_five);
$preset_number_a = preg_replace('/\s/i','+',$preset_number_a);
$preset_number_b = preg_replace('/\s/i','+',$preset_number_b);
$preset_number_c = preg_replace('/\s/i','+',$preset_number_c);
$preset_number_d = preg_replace('/\s/i','+',$preset_number_d);
$preset_number_e = preg_replace('/\s/i','+',$preset_number_e);
$preset_number_f = preg_replace('/\s/i','+',$preset_number_f);
$preset_dtmf_a = preg_replace('/\s/i','+',$preset_dtmf_a);
$preset_dtmf_b = preg_replace('/\s/i','+',$preset_dtmf_b);
$did_id = preg_replace('/\s/i','+',$did_id);
$did_extension = preg_replace('/\s/i','+',$did_extension);
$did_pattern = preg_replace('/\s/i','+',$did_pattern);
$did_description = preg_replace('/\s/i','+',$did_description);
$called_count = preg_replace('/\s/i','+',$called_count);
$web_vars = preg_replace('/\s/i','+',$web_vars);
}
$script_text = preg_replace('/--A--lead_id--B--/i',"$lead_id",$script_text);
$script_text = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$script_text);
$script_text = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$script_text);
$script_text = preg_replace('/--A--list_id--B--/i',"$list_id",$script_text);
$script_text = preg_replace('/--A--list_name--B--/i',"$list_name",$script_text);
$script_text = preg_replace('/--A--list_description--B--/i',"$list_description",$script_text);
$script_text = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$script_text);
$script_text = preg_replace('/--A--phone_code--B--/i',"$phone_code",$script_text);
$script_text = preg_replace('/--A--phone_number--B--/i',"$phone_number",$script_text);
$script_text = preg_replace('/--A--title--B--/i',"$title",$script_text);
$script_text = preg_replace('/--A--first_name--B--/i',"$first_name",$script_text);
$script_text = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$script_text);
$script_text = preg_replace('/--A--last_name--B--/i',"$last_name",$script_text);
$script_text = preg_replace('/--A--address1--B--/i',"$address1",$script_text);
$script_text = preg_replace('/--A--address2--B--/i',"$address2",$script_text);
$script_text = preg_replace('/--A--address3--B--/i',"$address3",$script_text);
$script_text = preg_replace('/--A--city--B--/i',"$city",$script_text);
$script_text = preg_replace('/--A--state--B--/i',"$state",$script_text);
$script_text = preg_replace('/--A--province--B--/i',"$province",$script_text);
$script_text = preg_replace('/--A--postal_code--B--/i',"$postal_code",$script_text);
$script_text = preg_replace('/--A--country_code--B--/i',"$country_code",$script_text);
$script_text = preg_replace('/--A--gender--B--/i',"$gender",$script_text);
$script_text = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$script_text);
$script_text = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$script_text);
$script_text = preg_replace('/--A--email--B--/i',"$email",$script_text);
$script_text = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$script_text);
$script_text = preg_replace('/--A--comments--B--/i',"$comments",$script_text);
$script_text = preg_replace('/--A--user--B--/i',"$user",$script_text);
$script_text = preg_replace('/--A--pass--B--/i',"$pass",$script_text);
$script_text = preg_replace('/--A--campaign--B--/i',"$campaign",$script_text);
$script_text = preg_replace('/--A--phone_login--B--/i',"$phone_login",$script_text);
$script_text = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$script_text);
$script_text = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$script_text);
$script_text = preg_replace('/--A--fronter--B--/i',"$fronter",$script_text);
$script_text = preg_replace('/--A--closer--B--/i',"$closer",$script_text);
$script_text = preg_replace('/--A--group--B--/i',"$group",$script_text);
$script_text = preg_replace('/--A--channel_group--B--/i',"$channel_group",$script_text);
$script_text = preg_replace('/--A--SQLdate--B--/i',"$SQLdate",$script_text);
$script_text = preg_replace('/--A--epoch--B--/i',"$epoch",$script_text);
$script_text = preg_replace('/--A--uniqueid--B--/i',"$uniqueid",$script_text);
$script_text = preg_replace('/--A--customer_zap_channel--B--/i',"$customer_zap_channel",$script_text);
$script_text = preg_replace('/--A--customer_server_ip--B--/i',"$customer_server_ip",$script_text);
$script_text = preg_replace('/--A--server_ip--B--/i',"$server_ip",$script_text);
$script_text = preg_replace('/--A--SIPexten--B--/i',"$SIPexten",$script_text);
$script_text = preg_replace('/--A--session_id--B--/i',"$session_id",$script_text);
$script_text = preg_replace('/--A--phone--B--/i',"$phone",$script_text);
$script_text = preg_replace('/--A--parked_by--B--/i',"$parked_by",$script_text);
$script_text = preg_replace('/--A--dispo--B--/i',"$dispo",$script_text);
$script_text = preg_replace('/--A--dialed_number--B--/i',"$dialed_number",$script_text);
$script_text = preg_replace('/--A--dialed_label--B--/i',"$dialed_label",$script_text);
$script_text = preg_replace('/--A--source_id--B--/i',"$source_id",$script_text);
$script_text = preg_replace('/--A--rank--B--/i',"$rank",$script_text);
$script_text = preg_replace('/--A--owner--B--/i',"$owner",$script_text);
$script_text = preg_replace('/--A--camp_script--B--/i',"$camp_script",$script_text);
$script_text = preg_replace('/--A--in_script--B--/i',"$in_script",$script_text);
$script_text = preg_replace('/--A--script_width--B--/i',"$script_width",$script_text);
$script_text = preg_replace('/--A--script_height--B--/i',"$script_height",$script_text);
$script_text = preg_replace('/--A--fullname--B--/i',"$fullname",$script_text);
$script_text = preg_replace('/--A--recording_filename--B--/i',"$recording_filename",$script_text);
$script_text = preg_replace('/--A--recording_id--B--/i',"$recording_id",$script_text);
$script_text = preg_replace('/--A--user_custom_one--B--/i',"$user_custom_one",$script_text);
$script_text = preg_replace('/--A--user_custom_two--B--/i',"$user_custom_two",$script_text);
$script_text = preg_replace('/--A--user_custom_three--B--/i',"$user_custom_three",$script_text);
$script_text = preg_replace('/--A--user_custom_four--B--/i',"$user_custom_four",$script_text);
$script_text = preg_replace('/--A--user_custom_five--B--/i',"$user_custom_five",$script_text);
$script_text = preg_replace('/--A--preset_number_a--B--/i',"$preset_number_a",$script_text);
$script_text = preg_replace('/--A--preset_number_b--B--/i',"$preset_number_b",$script_text);
$script_text = preg_replace('/--A--preset_number_c--B--/i',"$preset_number_c",$script_text);
$script_text = preg_replace('/--A--preset_number_d--B--/i',"$preset_number_d",$script_text);
$script_text = preg_replace('/--A--preset_number_e--B--/i',"$preset_number_e",$script_text);
$script_text = preg_replace('/--A--preset_number_f--B--/i',"$preset_number_f",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_a--B--/i',"$preset_dtmf_a",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_b--B--/i',"$preset_dtmf_b",$script_text);
$script_text = preg_replace('/--A--did_id--B--/i',"$did_id",$script_text);
$script_text = preg_replace('/--A--did_extension--B--/i',"$did_extension",$script_text);
$script_text = preg_replace('/--A--did_pattern--B--/i',"$did_pattern",$script_text);
$script_text = preg_replace('/--A--did_description--B--/i',"$did_description",$script_text);
$script_text = preg_replace('/--A--closecallid--B--/i',"$closecallid",$script_text);
$script_text = preg_replace('/--A--xfercallid--B--/i',"$xfercallid",$script_text);
$script_text = preg_replace('/--A--agent_log_id--B--/i',"$agent_log_id",$script_text);
$script_text = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$script_text);
$script_text = preg_replace('/--A--call_id--B--/i',"$call_id",$script_text);
$script_text = preg_replace('/--A--user_group--B--/i',"$user_group",$script_text);
$script_text = preg_replace('/--A--called_count--B--/i',"$called_count",$script_text);
$script_text = preg_replace('/--A--web_vars--B--/i',"$web_vars",$script_text);
if ($CF_uses_custom_fields=='Y')
{
### find the names of all custom fields, if any
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('vendor_lead_code','source_id','list_id','gmt_offset_now','called_since_last_reset','phone_code','phone_number','title','first_name','middle_initial','last_name','address1','address2','address3','city','state','province','postal_code','country_code','gender','date_of_birth','alt_phone','email','security_phrase','comments','called_count','last_local_call_time','rank','owner');";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$cffn_ct = mysqli_num_rows($rslt);
$d=0;
while ($cffn_ct > $d)
{
$row=mysqli_fetch_row($rslt);
$field_name_id = $row[0];
$field_name_tag = "--A--" . $field_name_id . "--B--";
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$script_text = preg_replace("/$field_name_tag/i","$form_field_value",$script_text);
if ($DB) {echo "$d|$field_name_id|$field_name_tag|$form_field_value|<br>\n";}
$d++;
}
}
$NOTESout='';
if (preg_match('/--A--TABLEper_call_notes--B--/i',$script_text))
{
### BEGIN Gather Call Log and notes ###
if ($hide_call_log_info!='Y')
{
if ($search != 'logfirst')
{$NOTESout .= "CALL LOG FOR THIS LEAD:<br>\n";}
$NOTESout .= "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>";
$NOTESout .= "<TR>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:10px;font-family:sans-serif;\"><B> &nbsp; # &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; DATE/TIME &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; AGENT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; LENGTH &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; STATUS &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; PHONE &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; CAMPAIGN &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; IN/OUT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; ALT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; HANGUP &nbsp; </font></TD>";
# $NOTESout .= "</TR><TR>";
# $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\" COLSPAN=9><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; FULL NAME &nbsp; </font></TD>";
$NOTESout .= "</TR>";
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$out_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$out_logs_to_print|$stmt|";}
$g=0;
$u=0;
while ($out_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = $row[3];
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLalt_dial[$g] = $row[9];
$ALLuniqueid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLin_out[$g] = "OUT-AUTO";
if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";}
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLuniqueid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$out_notes_to_print = mysqli_num_rows($rslt);
if ($out_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$in_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$in_logs_to_print|$stmt|";}
$u=0;
while ($in_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = ($row[3] - $row[9]);
if ($ALLlength_in_sec[$g] < 0) {$ALLlength_in_sec[$g]=0;}
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLuniqueid[$g] = $row[10];
$ALLclosecallid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLalt_dial[$g] = "MAIN";
$ALLin_out[$g] = "IN";
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLclosecallid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$in_notes_to_print = mysqli_num_rows($rslt);
if ($in_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
if ($g > 0)
{sort($ALLsort, SORT_NUMERIC);}
else
{$NOTESout .= "<tr bgcolor=white><td colspan=11 align=center>No calls found</td></tr>";}
$u=0;
while ($g > $u)
{
$sort_split = explode("-----",$ALLsort[$u]);
$i = $sort_split[1];
if (preg_match("/1$|3$|5$|7$|9$/i", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$phone_number_display = $ALLphone_number[$i];
if ($disable_alter_custphone == 'HIDE')
{$phone_number_display = 'XXXXXXXXXX';}
$u++;
$NOTESout .= "<tr $bgcolor>";
$NOTESout .= "<td><font size=1>$u</td>";
$NOTESout .= "<td align=right><font size=2>$ALLcall_date[$i]</td>";
$NOTESout .= "<td align=right><font size=2> $ALLuser[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLlength_in_sec[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLstatus[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLphone_code[$i] $phone_number_display </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLcampaign_id[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLin_out[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLalt_dial[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLhangup_reason[$i] </td>\n";
$NOTESout .= "</TR><TR>";
$NOTESout .= "<td></td>";
$NOTESout .= "<TD $bgcolor COLSPAN=9 align=left><font style=\"font-size:11px;font-family:sans-serif;\"> $Allcall_notes[$i] </font></TD>";
$NOTESout .= "</tr>\n";
}
$NOTESout .= "</TABLE>";
$NOTESout .= "<BR>";
}
### END Gather Call Log and notes ###
}
$script_text = preg_replace("/\n/i","<BR>",$script_text);
$script_text = preg_replace('/--A--TABLEper_call_notes--B--/i',"$NOTESout",$script_text);
$script_text = stripslashes($script_text);
echo "<!-- IFRAME$IFRAME -->\n";
echo "<!-- $script_id -->\n";
echo "<TABLE WIDTH=$script_width><TR><TD>\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "<div class=\"scroll_script\" id=\"NewScriptContents\">";}
echo "<center><B>$script_name</B><BR></center>\n";
echo "$script_text\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "</div>";}
echo "</TD></TR></TABLE>\n";
exit;
?>
@@ -0,0 +1,646 @@
<?php
# vdc_script_notes.php
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed open in the SCRIPT tab in the agent interface through
# an IFRAME. It will create a new record for every SUBMIT
#
# Example of a ViciDial agent SCRIPT using this script:
# <iframe src="./vdc_script_notes.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&pass=--A--pass--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&rank=--A--rank--B--&owner=--A--owner--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="--A--script_width--B--" height="--A--script_height--B--" STYLE="z-index:17"> </iframe>
#
# CHANGELOG:
# 100215-0744 - First build of script
# 100622-2230 - Added field labels
# 130328-0020 - Converted ereg to preg functions
# 130603-2203 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1037 - Changed to PHP mysqli functions
#
$version = '2.8-5';
$build = '130802-1037';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
elseif (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
if (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
elseif (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
elseif (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
if (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
elseif (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
if (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
elseif (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
if (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
elseif (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
if (isset($_POST["title"])) {$title=$_POST["title"];}
elseif (isset($_GET["title"])) {$title=$_GET["title"];}
if (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
elseif (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
if (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
elseif (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
if (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
elseif (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
if (isset($_POST["address1"])) {$address1=$_POST["address1"];}
elseif (isset($_GET["address1"])) {$address1=$_GET["address1"];}
if (isset($_POST["address2"])) {$address2=$_POST["address2"];}
elseif (isset($_GET["address2"])) {$address2=$_GET["address2"];}
if (isset($_POST["address3"])) {$address3=$_POST["address3"];}
elseif (isset($_GET["address3"])) {$address3=$_GET["address3"];}
if (isset($_POST["city"])) {$city=$_POST["city"];}
elseif (isset($_GET["city"])) {$city=$_GET["city"];}
if (isset($_POST["state"])) {$state=$_POST["state"];}
elseif (isset($_GET["state"])) {$state=$_GET["state"];}
if (isset($_POST["province"])) {$province=$_POST["province"];}
elseif (isset($_GET["province"])) {$province=$_GET["province"];}
if (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
elseif (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
if (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
elseif (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
if (isset($_POST["gender"])) {$gender=$_POST["gender"];}
elseif (isset($_GET["gender"])) {$gender=$_GET["gender"];}
if (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
elseif (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
if (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
elseif (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
if (isset($_POST["email"])) {$email=$_POST["email"];}
elseif (isset($_GET["email"])) {$email=$_GET["email"];}
if (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
elseif (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
if (isset($_POST["comments"])) {$comments=$_POST["comments"];}
elseif (isset($_GET["comments"])) {$comments=$_GET["comments"];}
if (isset($_POST["user"])) {$user=$_POST["user"];}
elseif (isset($_GET["user"])) {$user=$_GET["user"];}
if (isset($_POST["pass"])) {$pass=$_POST["pass"];}
elseif (isset($_GET["pass"])) {$pass=$_GET["pass"];}
if (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
elseif (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
if (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
elseif (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
if (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
elseif (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
if (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
elseif (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
if (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
elseif (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
if (isset($_POST["closer"])) {$closer=$_POST["closer"];}
elseif (isset($_GET["closer"])) {$closer=$_GET["closer"];}
if (isset($_POST["group"])) {$group=$_POST["group"];}
elseif (isset($_GET["group"])) {$group=$_GET["group"];}
if (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
elseif (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
if (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
elseif (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
if (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
elseif (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
if (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
elseif (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
if (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
elseif (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
if (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
elseif (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
if (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
elseif (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
if (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
elseif (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
if (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
elseif (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
if (isset($_POST["phone"])) {$phone=$_POST["phone"];}
elseif (isset($_GET["phone"])) {$phone=$_GET["phone"];}
if (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
elseif (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
if (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
elseif (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
if (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
elseif (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
if (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
elseif (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
if (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
elseif (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
if (isset($_POST["rank"])) {$rank=$_POST["rank"];}
elseif (isset($_GET["rank"])) {$rank=$_GET["rank"];}
if (isset($_POST["owner"])) {$owner=$_POST["owner"];}
elseif (isset($_GET["owner"])) {$owner=$_GET["owner"];}
if (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
elseif (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
if (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
elseif (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
if (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
elseif (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
if (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
elseif (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
if (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
elseif (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
if (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
elseif (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
if (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
elseif (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
if (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
elseif (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
if (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
elseif (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
if (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
elseif (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
if (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
elseif (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
if (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
elseif (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
if (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
elseif (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
if (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
elseif (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
if (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
elseif (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
if (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
elseif (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
if (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
elseif (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
if (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
elseif (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
if (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
elseif (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
if (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
elseif (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
if (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
elseif (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
if (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
elseif (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
if (isset($_POST["DB"])) {$DB=$_POST["DB"];}
elseif (isset($_GET["DB"])) {$DB=$_GET["DB"];}
if (isset($_POST["process"])) {$process=$_POST["process"];}
elseif (isset($_GET["process"])) {$process=$_GET["process"];}
if (isset($_POST["vicidial_id"])) {$vicidial_id=$_POST["vicidial_id"];}
elseif (isset($_GET["vicidial_id"])) {$vicidial_id=$_GET["vicidial_id"];}
if (isset($_POST["call_date"])) {$call_date=$_POST["call_date"];}
elseif (isset($_GET["call_date"])) {$call_date=$_GET["call_date"];}
if (isset($_POST["order_id"])) {$order_id=$_POST["order_id"];}
elseif (isset($_GET["order_id"])) {$order_id=$_GET["order_id"];}
if (isset($_POST["appointment_date"])) {$appointment_date=$_POST["appointment_date"];}
elseif (isset($_GET["appointment_date"])) {$appointment_date=$_GET["appointment_date"];}
if (isset($_POST["appointment_time"])) {$appointment_time=$_POST["appointment_time"];}
elseif (isset($_GET["appointment_time"])) {$appointment_time=$_GET["appointment_time"];}
if (isset($_POST["call_notes"])) {$call_notes=$_POST["call_notes"];}
elseif (isset($_GET["call_notes"])) {$call_notes=$_GET["call_notes"];}
if (isset($_POST["notesid"])) {$notesid=$_POST["notesid"];}
elseif (isset($_GET["notesid"])) {$notesid=$_GET["notesid"];}
if ($notesid < 100)
{$notesid=0;}
if (strlen($vicidial_id) < 1)
{$vicidial_id = $uniqueid;}
if (strlen($appointment_time) < 1)
{$appointment_time = '12:00:00';}
$appointment_timeARRAY = explode(":",$appointment_time);
$appointment_hour = $appointment_timeARRAY[0];
$appointment_min = $appointment_timeARRAY[1];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
if (strlen($call_date) < 1)
{$call_date = $NOW_TIME;}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^-_0-9a-zA-Z]/","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass = preg_replace("/\'|\"|\\\\|;/","",$pass);
}
if ($DB > 0)
{
echo "<BR>$lead_id|$entry_date|$modify_date|$status|$user|$vendor_lead_code|$source_id|$list_id|$gmt_offset_now|$called_since_last_reset|$phone_code|$phone_number|$title|$first_name|$middle_initial|$last_name|$address1|$address2|$address3|$city|$state|$province|$postal_code|$country_code|$gender|$date_of_birth|$alt_phone|$email|$security_phrase|$comments|$called_count|$last_local_call_time|$rank|$owner|\n<BR>";
}
### BEGIN find any custom field labels ###
$label_title = 'Title';
$label_first_name = 'Vorname';
$label_middle_initial = 'MI';
$label_last_name = 'Last';
$label_address1 = 'Adresse1';
$label_address2 = 'Adresse2';
$label_address3 = 'Adresse3';
$label_city = 'Stadt';
$label_state = 'State';
$label_province = 'Region';
$label_postal_code = 'Postleitzahl';
$label_vendor_lead_code = 'Anbieter ID';
$label_gender = 'Gender';
$label_phone_number = 'Telefon';
$label_phone_code = 'LandesCode';
$label_alt_phone = 'Alternative Telefonnummer';
$label_security_phrase = 'Zeigen';
$label_email = 'Email';
$label_comments = 'Comments';
$stmt="SELECT label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments from system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if (strlen($row[0])>0) {$label_title = $row[0];}
if (strlen($row[1])>0) {$label_first_name = $row[1];}
if (strlen($row[2])>0) {$label_middle_initial = $row[2];}
if (strlen($row[3])>0) {$label_last_name = $row[3];}
if (strlen($row[4])>0) {$label_address1 = $row[4];}
if (strlen($row[5])>0) {$label_address2 = $row[5];}
if (strlen($row[6])>0) {$label_address3 = $row[6];}
if (strlen($row[7])>0) {$label_city = $row[7];}
if (strlen($row[8])>0) {$label_state = $row[8];}
if (strlen($row[9])>0) {$label_province = $row[9];}
if (strlen($row[10])>0) {$label_postal_code = $row[10];}
if (strlen($row[11])>0) {$label_vendor_lead_code = $row[11];}
if (strlen($row[12])>0) {$label_gender = $row[12];}
if (strlen($row[13])>0) {$label_phone_number = $row[13];}
if (strlen($row[14])>0) {$label_phone_code = $row[14];}
if (strlen($row[15])>0) {$label_alt_phone = $row[15];}
if (strlen($row[16])>0) {$label_security_phrase = $row[16];}
if (strlen($row[17])>0) {$label_email = $row[17];}
if (strlen($row[18])>0) {$label_comments = $row[18];}
### END find any custom field labels ###
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
echo "<HTML>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Agent-Hinweise";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo "<link rel=\"stylesheet\" href=\"calendar.css\">\n";
?>
<?php
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
if ($process > 0)
{
#Update vicidial_list record
$stmt="UPDATE vicidial_list SET vendor_lead_code='$vendor_lead_code',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',phone_code='$phone_code',phone_number='$phone_number',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',rank='$rank',owner='$owner' where lead_id='$lead_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
#Update the agent screen with new data
$stmt="UPDATE vicidial_live_agents set external_update_fields='1',external_update_fields_data='vendor_lead_code,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,phone_code,phone_number,gender,date_of_birth,alt_phone,email,security_phrase,comments,rank,owner' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
if ($notesid < 100)
{
# Insert into vicidial_call_notes
$stmt="INSERT INTO vicidial_call_notes set lead_id='$lead_id',vicidial_id='$vicidial_id',call_date='$call_date',order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$notesid = mysqli_insert_id($link);
}
else
{
# update vicidial_call_notes record
$stmt="UPDATE vicidial_call_notes set order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes' where notesid='$notesid';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
echo "<BR><b>Data Changes Accepted</b><BR><BR>";
}
$URLarray = explode("?", $PHP_SELF);
$URLsubmit = $URLarray[0];
?>
<TABLE Border=0 CELLPADDING=0 CELLSPACING=2 WIDTH=450>
<TR><TD COLSPAN=2 ALIGN=CENTER>
<FORM METHOD=POST NAME=vsn ID=vsn ACTION="<?php echo $URLsubmit ?>">
<input type=hidden name=DB id=DB value=<?php echo $DB ?>>
<input type=hidden name=process id=process value=1>
<input type=hidden name=lead_id id=lead_id value="<?php echo $lead_id ?>">
<input type=hidden name=user id=user value="<?php echo $user ?>">
<input type=hidden name=pass id=user value="<?php echo $pass ?>">
<input type=hidden name=notesid id=notesid value="<?php echo $notesid ?>">
<input type=hidden name=vendor_id id=vendor_id value="<?php echo $vendor_id ?>">
<input type=hidden name=title id=title value="<?php echo $title ?>">
<input type=hidden name=middle_initial id=middle_initial value="<?php echo $middle_initial ?>">
<input type=hidden name=province id=province value="<?php echo $middle_initial ?>">
<input type=hidden name=phone_code id=phone_code value="<?php echo $phone_code ?>">
<input type=hidden name=gender id=gender value="<?php echo $gender ?>">
<input type=hidden name=date_of_birth id=date_of_birth value="<?php echo $date_of_birth ?>">
<input type=hidden name=alt_phone id=alt_phone value="<?php echo $alt_phone ?>">
<input type=hidden name=email id=email value="<?php echo $email ?>">
<input type=hidden name=security_phrase id=security_phrase value="<?php echo $security_phrase ?>">
<input type=hidden name=comments id=comments value="<?php echo $comments ?>">
<input type=hidden name=rank id=rank value="<?php echo $rank ?>">
<input type=hidden name=owner id=owner value="<?php echo $owner ?>">
</TD></TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Anbieter ID: </TD><TD ALIGN=LEFT><input type=text name=vendor_id id=vendor_id size=20 maxlength=20 value="<?php echo $vendor_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Source ID: </TD><TD ALIGN=LEFT>$source_id<input type=hidden name=source_id id=source_id value="<?php echo $source_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Title: </TD><TD ALIGN=LEFT><input type=text name=title id=title size=5 maxlength=4 value="<?php echo $title ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_first_name ?>: </TD><TD ALIGN=LEFT><input type=text name=first_name id=first_name size=30 maxlength=30 value="<?php echo $first_name ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Middle Initial: </TD><TD ALIGN=LEFT><input type=text name=middle_initial id=middle_initial size=2 maxlength=1 value="<?php echo $middle_initial ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_last_name ?>: </TD><TD ALIGN=LEFT><input type=text name=last_name id=last_name size=30 maxlength=30 value="<?php echo $last_name ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address1 ?>: </TD><TD ALIGN=LEFT><input type=text name=address1 id=address1 size=30 maxlength=100 value="<?php echo $address1 ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address2 ?>: </TD><TD ALIGN=LEFT><input type=text name=address2 id=address2 size=30 maxlength=100 value="<?php echo $address2 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address3 ?>: </TD><TD ALIGN=LEFT><input type=text name=address3 id=address3 size=30 maxlength=100 value="<?php echo $address3 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_city ?>: </TD><TD ALIGN=LEFT><input type=text name=city id=city size=30 maxlength=50 value="<?php echo $city ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_state ?>: </TD><TD ALIGN=LEFT>
<SELECT name="state" id=state>
<OPTION value="<?php echo $state ?>" selected><?php echo $state ?></OPTION>
<OPTGROUP label="United Bundeslands">
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AK">Alaska</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="CA">California</OPTION>
<OPTION value="CO">Colorado</OPTION>
<OPTION value="CT">Connecticut</OPTION>
<OPTION value="DE">Delaware</OPTION>
<OPTION value="FL">Florida</OPTION>
<OPTION value="GA">Georgia</OPTION>
<OPTION value="HI">Hawaii</OPTION>
<OPTION value="ID">Idaho</OPTION>
<OPTION value="IL">Illinois</OPTION>
<OPTION value="IN">Indiana</OPTION>
<OPTION value="IA">Iowa</OPTION>
<OPTION value="KS">Kansas</OPTION>
<OPTION value="KY">Kentucky</OPTION>
<OPTION value="LA">Louisiana</OPTION>
<OPTION value="ME">Maine</OPTION>
<OPTION value="MD">Maryland</OPTION>
<OPTION value="MA">Massachusetts</OPTION>
<OPTION value="MI">Michigan</OPTION>
<OPTION value="MN">Minnesota</OPTION>
<OPTION value="MS">Mississippi</OPTION>
<OPTION value="MO">Missouri</OPTION>
<OPTION value="MT">Montana</OPTION>
<OPTION value="NE">Nebraska</OPTION>
<OPTION value="NV">Nevada</OPTION>
<OPTION value="NH">New Hampshire</OPTION>
<OPTION value="NJ">New Jersey</OPTION>
<OPTION value="NM">New Mexico</OPTION>
<OPTION value="NY">New York</OPTION>
<OPTION value="NC">North Carolina</OPTION>
<OPTION value="ND">North Dakota</OPTION>
<OPTION value="OH">Ohio</OPTION>
<OPTION value="OK">Oklahoma</OPTION>
<OPTION value="OR">Oregon</OPTION>
<OPTION value="PA">Pennsylvania</OPTION>
<OPTION value="RI">Rhode Island</OPTION>
<OPTION value="SC">South Carolina</OPTION>
<OPTION value="SD">South Dakota</OPTION>
<OPTION value="TN">Tennessee</OPTION>
<OPTION value="TX">Texas</OPTION>
<OPTION value="UT">Utah</OPTION>
<OPTION value="VT">Vermont</OPTION>
<OPTION value="VA">Virginia</OPTION>
<OPTION value="WA">Washington</OPTION>
<OPTION value="DC">Washington, DC</OPTION>
<OPTION value="WV">West Virginia</OPTION>
<OPTION value="WI">Wisconsin</OPTION>
<OPTION value="WY">Wyoming</OPTION>
</OPTGROUP>
<!--
<OPTGROUP label="Canada">
<OPTION value="AB">ALBERTA</OPTION>
<OPTION value="NT">NORTHWEST TERRITORY</OPTION>
<OPTION value="BC">BRITISH COLUMBIA</OPTION>
<OPTION value="ON">ONTARIO</OPTION>
<OPTION value="LB">LABRADOR</OPTION>
<OPTION value="PE">PRINCE EDWARDISLAND</OPTION>
<OPTION value="MB">MANITOBA</OPTION>
<OPTION value="PQ">QUEBEC</OPTION>
<OPTION value="NB">NEW BRUNSWICK</OPTION>
<OPTION value="SK">SASKATCHEWAN</OPTION>
<OPTION value="NF">NEWFOUNDLAND</OPTION>
<OPTION value="YT">YUKON TERRITORY</OPTION>
<OPTION value="NS">NOVA SCOTIA</OPTION>
</OPTGROUP>
-->
</SELECT> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Region: </TD><TD ALIGN=LEFT><input type=text name=province id=province size=20 maxlength=50 value="<?php echo $province ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_postal_code ?>: </TD><TD ALIGN=LEFT><input type=text name=postal_code id=postal_code size=6 maxlength=5 value="<?php echo $postal_code ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Telefon Code: </TD><TD ALIGN=LEFT><input type=text name=phone_code id=phone_code size=10 maxlength=10 value="<?php echo $phone_code ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_phone_number ?>: </TD><TD ALIGN=LEFT><input type=text name=phone_number id=phone_number size=18 maxlength=18 value="<?php echo $phone_number ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Geschlecht: </TD><TD ALIGN=LEFT><input type=text name=gender id=gender size=2 maxlength=1 value="<?php echo $gender ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Geburtstag: </TD><TD ALIGN=LEFT><input type=text name=date_if_birth id=date_if_birth size=12 maxlength=12 value="<?php echo $date_of_birth ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Alternative Telefonnummer: </TD><TD ALIGN=LEFT><input type=text name=alt_phone id=alt_phone size=12 maxlength=12 value="<?php echo $alt_phone ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Email: </TD><TD ALIGN=LEFT><input type=text name=email id=email size=30 maxlength=70 value="<?php echo $email ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Zeigen: </TD><TD ALIGN=LEFT><input type=text name=security_phrase id=security_phrase size=30 maxlength=100 value="<?php echo $security_phrase ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Anmerkungen:</TD><TD ALIGN=LEFT><input type=text name=comments id=comments size=40 maxlength=255 value="<?php echo $comments ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Rank: </TD><TD ALIGN=LEFT><input type=text name=rank id=rank size=5 maxlength=5 value="<?php echo $rank ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Owner: </TD><TD ALIGN=LEFT><input type=text name=owner id=owner size=20 maxlength=20 value="<?php echo $owner ?>"> *</TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Order ID: </TD><TD ALIGN=LEFT><input type=text name=order_id id=order_id size=20 maxlength=20 value="<?php echo $order_id ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Appointment Date/Time: </TD><TD ALIGN=LEFT><input type=text name=appointment_date id=appointment_date size=10 maxlength=10 value="<?php echo $appointment_date ?>">
<script language="JavaScript">
var o_cal = new tcal ({
// form name
'formname': 'vsn',
// input name
'controlname': 'appointment_date'
});
o_cal.a_tpl.yearscroll = false;
// o_cal.a_tpl.weekstart = 1; // Monday week start
</script>
<input type=hidden name=appointment_time id=appointment_time value="<?php echo $appointment_time ?>">
<SELECT name=appointment_hour id=appointment_hour>
<option>00</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<OPTION value="<?php echo $appointment_hour ?>" selected><?php echo $appointment_hour ?></OPTION>
</SELECT>
<SELECT name=appointment_min id=appointment_min>
<option>00</option>
<option>05</option>
<option>10</option>
<option>15</option>
<option>20</option>
<option>25</option>
<option>30</option>
<option>35</option>
<option>40</option>
<option>45</option>
<option>50</option>
<option>55</option>
<OPTION value="<?php echo $appointment_min ?>" selected><?php echo $appointment_min ?></OPTION>
</SELECT>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=2>Appointment Anmerkungen:<BR><TEXTAREA NAME=call_notes ID=call_notes ROWS=5 COLS=50><?php echo $call_notes ?></TEXTAREA></font><br>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=1>Please click ÜBERNEHMEN to commit the changes, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * denotes required fields</font><br>
</TD>
</TR>
<TR BGCOLOR=white>
<TD ALIGN=CENTER COLSPAN=2>
<SCRIPT LANGUAGE="JavaScript">
function submit_form()
{
var appointment_hourFORM = document.getElementById('appointment_hour');
var appointment_hourVALUE = appointment_hourFORM[appointment_hourFORM.selectedIndex].text;
var appointment_minFORM = document.getElementById('appointment_min');
var appointment_minVALUE = appointment_minFORM[appointment_minFORM.selectedIndex].text;
document.vsn.appointment_time.value = appointment_hourVALUE + ":" + appointment_minVALUE + ":00";
document.vsn.submit();
}
</SCRIPT>
<input type=button value="ÜBERNEHMEN" name=smt id=smt onClick="submit_form()">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</B></FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,145 @@
<?php
# voicemail_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to check whether the voicemail box on the server defined has new and old messages
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
#
#
# changes
# 50422-1147 - First build of script
# 50503-1241 - added session_name checking for extra security
# 50711-1201 - removed HTTP authentication in favor of user/pass vars
# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1204 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2202 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1038 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Unzulässig Username/Passwort: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Unzulässig session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build VMBOX: $vmail_box server_ip: $server_ip-->\n";
echo "<title>Voicemail Check";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$MT[0]='';
$row=''; $rowx='';
if (strlen($vmail_box)<1)
{
$channel_live=0;
echo "Voicemailbox $vmail_box ist unzulässig\n";
exit;
}
else
{
$stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$vmails_list = mysqli_num_rows($rslt);
$loop_count=0;
while ($vmails_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0]|$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- Scriptlaufzeit: $RUNtime Sekunden -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,480 @@
<?php
# active_list_refresh.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to serve updates of the live data to the display scripts
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $ADD - ('1','2','3','4','5')
# - $order - ('asc','desc')
# - $format - ('text','table','menu','selectlist','textarea')
# - $bgcolor - ('#123456','white','black','etc...')
# - $txtcolor - ('#654321','black','white','etc...')
# - $txtsize - ('1','2','3','etc...')
# - $selectsize - ('2','3','4','etc...')
# - $selectfontsize - ('8','10','12','etc...')
# - $selectedext - ('cc100')
# - $selectedtrunk - ('Zap/25-1')
# - $selectedlocal - ('SIP/cc100')
# - $textareaheight - ('8','10','12','etc...')
# - $textareawidth - ('8','10','12','etc...')
# - $field_name - ('extension','busyext','extension_xfer','etc...')
#
#
# changes
# 50323-1147 - First build of script
# 50401-1132 - small formatting changes
# 50502-1402 - added field_name as modifiable variable
# 50503-1213 - added session_name checking for extra security
# 50503-1311 - added conferences list
# 50610-1155 - Added NULL check on MySQL results to reduced errors
# 50711-1209 - removed HTTP authentication in favor of user/pass vars
# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1118 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0029 - Converted ereg to preg functions
# 130603-2222 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-0957 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];}
elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];}
if (isset($_GET["order"])) {$order=$_GET["order"];}
elseif (isset($_POST["order"])) {$order=$_POST["order"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];}
elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];}
if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];}
elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];}
if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];}
elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];}
if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];}
elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];}
if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];}
elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];}
if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];}
elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];}
if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];}
elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];}
if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];}
elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];}
if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];}
elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];}
if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];}
elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];}
### security strip all non-alphanumeric characters out of the variables ###
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$ADD=preg_replace("/[^0-9]/","",$ADD);
$order=preg_replace("/[^0-9a-zA-Z]/","",$order);
$format=preg_replace("/[^0-9a-zA-Z]/","",$format);
$bgcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$bgcolor);
$txtcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$txtcolor);
$txtsize=preg_replace("/[^0-9a-zA-Z]/","",$txtsize);
$selectsize=preg_replace("/[^0-9a-zA-Z]/","",$selectsize);
$selectfontsize=preg_replace("/[^0-9a-zA-Z]/","",$selectfontsize);
$selectedext=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedext);
$selectedtrunk=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedtrunk);
$selectedlocal=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedlocal);
$textareaheight=preg_replace("/[^0-9a-zA-Z]/","",$textareaheight);
$textareawidth=preg_replace("/[^0-9a-zA-Z]/","",$textareawidth);
$field_name=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$field_name);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($ADD)) {$ADD="1";}
if (!isset($order)) {$order='desc';}
if (!isset($format)) {$format="text";}
if (!isset($bgcolor)) {$bgcolor='white';}
if (!isset($txtcolor)) {$txtcolor='black';}
if (!isset($txtsize)) {$txtsize='2';}
if (!isset($selectsize)) {$selectsize='4';}
if (!isset($selectfontsize)) {$selectfontsize='10';}
if (!isset($textareaheight)) {$textareaheight='10';}
if (!isset($textareawidth)) {$textareawidth='20';}
$version = '0.0.10';
$build = '130328-0029';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='table')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build ADD: $ADD server_ip: $server_ip-->\n";
echo "<title>Display liste: ";
if ($ADD==1) {echo "Aktive forbindelser";}
if ($ADD==2) {echo "Forbindelser der er optagat";}
if ($ADD==3) {echo "Externe linjer";}
if ($ADD==4) {echo "Lokalforbindelser";}
if ($ADD==5) {echo "konferencer";}
if ($ADD==99999) {echo "HELP";}
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
######################
# ADD=1 display all live extensions on a server
######################
if ($ADD==1)
{
$pt='pt';
if (!$field_name) {$field_name = 'extension';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension,fullname FROM phones where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=2 display all busy extensions on a server
######################
if ($ADD==2)
{
if (!$field_name) {$field_name = 'busyext';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension FROM live_channels where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=3 display all busy outside lines(trunks) on a server
######################
if ($ADD==3)
{
if (!$field_name) {$field_name = 'trunk';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedtrunk") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=4 display all busy Local lines on a server
######################
if ($ADD==4)
{
if (!$field_name) {$field_name = 'local';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_sip_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedlocal") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=5 display all agc-usable conferences on a server
######################
if ($ADD==5)
{
$pt='pt';
if (!$field_name) {$field_name = 'conferences';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT conf_exten,extension FROM conferences where server_ip = '$server_ip' order by conf_exten $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
if ($format=='table') {echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";}
if ($format=='table') {echo "\n</body>\n</html>\n";}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,102 @@
<?php
# audit_comments.php
#
# Copyright (C) 2014 poundteam.com,vicidial.org LICENSE: AGPLv2
#
# This script is designed to display QC audit comments, contributed by poundteam.com
#
# changes:
# 121116-1322 - First build, added to vicidial codebase
# 130802-0957 - Changed to PHP mysqli functions
# 140304-2154 - Enabled special characters in comments
#
require_once("functions.php");
function audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign) {
$audit_comments_active=audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log);
if ($audit_comments_active) {
//Get comment from list
$stmt="select comments from vicidial_list where lead_id='$lead_id' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments2',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if (strlen($row[0]) > 0) {
$comment=$row[0];
//Put comment in comment table
$stmt="INSERT INTO vicidial_comments (lead_id,user_id,list_id,campaign_id,comment) VALUES ('$lead_id','$user','$list_id','$campaign','".mysqli_real_escape_string($link, $comment)."');";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments3',$user,$server_ip,$session_name,$one_mysql_log);
}
$affected=mysqli_affected_rows($link);
if($affected>0) {
$stmt="UPDATE vicidial_list set comments='' where lead_id='$lead_id';";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments4',$user,$server_ip,$session_name,$one_mysql_log);
}
} else {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditCommentsERROR-Comment not moved',$user,$server_ip,$session_name,$one_mysql_log);
echo "\n<!-- 00142-AuditCommentsERROR-Comment not moved -->";
}
}
}
}
function audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log){
$stmt="select count(audit_comments) from vicidial_lists_custom where list_id='$list_id' and audit_comments='1' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments5',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if ($row[0] == '1') {
return true;
} else {
return false;
}
}
function get_audited_comments($lead_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log) {
global $ACcount;
global $ACcomments;
$stmt="select user_id,comment from vicidial_comments where lead_id='$lead_id';";
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"00142-65-AuditComments:$stmt LeadID: $lead_id,$format,$user,$mel,$NOW_TIME,\$link,$server_ip,$session_name,$one_mysql_log",$user,$server_ip,$session_name,$one_mysql_log);
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-69-AuditComments',$user,$server_ip,$session_name,$one_mysql_log);
}
$ACcount=mysqli_num_rows($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-72-AuditComments $ACcount='.$ACcount,$user,$server_ip,$session_name,$one_mysql_log);
if($ACcount>0) {
$i=0;
while ($i < $ACcount) {
$row=mysqli_fetch_row($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-77-AuditComments UserID='.$row[0],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= "UserID: $row[0]\n";
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-79-AuditComments Comment='.$row[1],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= $row[1];
$ACcomments .= "\n----------------------------------\n";
$i++;
}
return true;
} else {
return false;
}
}
?>
@@ -0,0 +1,95 @@
/* calendar icon */
img.tcalIcon {
cursor: pointer;
margin-left: 1px;
vertical-align: middle;
}
/* calendar container element */
div#tcal {
position: absolute;
visibility: hidden;
z-index: 100;
width: 158px;
padding: 2px 0 0 0;
}
/* all tables in calendar */
div#tcal table {
width: 100%;
border: 1px solid silver;
border-collapse: collapse;
background-color: white;
}
/* navigation table */
div#tcal table.ctrl {
border-bottom: 0;
}
/* navigation buttons */
div#tcal table.ctrl td {
width: 15px;
height: 20px;
}
/* month year header */
div#tcal table.ctrl th {
background-color: white;
color: black;
border: 0;
}
/* week days header */
div#tcal th {
border: 1px solid silver;
border-collapse: collapse;
text-align: center;
padding: 3px 0;
font-family: tahoma, verdana, arial;
font-size: 10px;
background-color: gray;
color: white;
}
/* date cells */
div#tcal td {
border: 0;
border-collapse: collapse;
text-align: center;
padding: 2px 0;
font-family: tahoma, verdana, arial;
font-size: 11px;
width: 22px;
cursor: pointer;
}
/* date highlight
in case of conflicting settings order here determines the priority from least to most important */
div#tcal td.othermonth {
color: silver;
}
div#tcal td.weekend {
background-color: #ACD6F5;
}
div#tcal td.today {
border: 1px solid red;
}
div#tcal td.selected {
background-color: #FFB3BE;
}
/* iframe element used to suppress windowed controls in IE5/6 */
iframe#tcalIF {
position: absolute;
visibility: hidden;
z-index: 98;
border: 0;
}
/* transparent shadow */
div#tcalShade {
position: absolute;
visibility: hidden;
z-index: 99;
}
div#tcalShade table {
border: 0;
border-collapse: collapse;
width: 100%;
}
div#tcalShade table td {
border: 0;
border-collapse: collapse;
padding: 0;
}
@@ -0,0 +1,335 @@
// Tigra Calendar v4.0.2 (2009-01-12) Database (yyyy-mm-dd)
// http://www.softcomplex.com/products/tigra_calendar/
// Public Domain Software... You're welcome.
// default settins
var A_TCALDEF = {
'months' : ['Januar', 'February', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
'imgpath' : '../agc/images/' // directory with calendar images
}
// date parsing function
function f_tcalParseDate (s_date) {
var re_date = /^\s*(\d{2,4})\-(\d{1,2})\-(\d{1,2})\s*$/;
if (!re_date.exec(s_date))
return alert ("Ikke gyldigt date: '" + s_date + "'.\nAccepted format is yyyy-mm-dd.")
var n_day = Number(RegExp.$3),
n_month = Number(RegExp.$2),
n_year = Number(RegExp.$1);
if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Ikke gyldigt month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays = new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Ikke gyldigt day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);
}
// date generating function
function f_tcalGenerDate (d_date) {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
);
}
// implementation
function tcal (a_cfg, a_tpl) {
// apply default template if not specified
if (!a_tpl)
a_tpl = A_TCALDEF;
// register in global collections
if (!window.A_TCALS)
window.A_TCALS = [];
if (!window.A_TCALSIDX)
window.A_TCALSIDX = [];
this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
window.A_TCALS[this.s_id] = this;
window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
// assign methods
this.f_show = f_tcal_show;
this.f_hide = f_tcal_hide;
this.f_toggle = f_tcalToggle;
this.f_update = f_tcalUpdate;
this.f_relDate = f_tcalRelDate;
this.f_parseDate = f_tcalParseDate;
this.f_generDate = f_tcalGenerDate;
// create calendar icon
this.s_iconId = 'tcalico_' + this.s_id;
this.e_icon = f_getElement(this.s_iconId);
if (!this.e_icon) {
document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
this.e_icon = f_getElement(this.s_iconId);
}
// save received parameters
this.a_cfg = a_cfg;
this.a_tpl = a_tpl;
}
function f_tcal_show (d_date) {
// find input field
if (!this.a_cfg.controlname)
throw("TC: control name is not specified");
if (this.a_cfg.formname) {
var e_form = document.forms[this.a_cfg.formname];
if (!e_form)
throw("TC: form '" + this.a_cfg.formname + "' can not be found");
this.e_input = e_form.elements[this.a_cfg.controlname];
}
else
this.e_input = f_getElement(this.a_cfg.controlname);
if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
// dynamically create HTML elements if needed
this.e_div = f_getElement('tcal');
if (!this.e_div) {
this.e_div = document.createElement("DIV");
this.e_div.id = 'tcal';
document.body.appendChild(this.e_div);
}
this.e_shade = f_getElement('tcalShade');
if (!this.e_shade) {
this.e_shade = document.createElement("DIV");
this.e_shade.id = 'tcalShade';
document.body.appendChild(this.e_shade);
}
this.e_iframe = f_getElement('tcalIF')
if (b_ieFix && !this.e_iframe) {
this.e_iframe = document.createElement("IFRAME");
this.e_iframe.style.filter = 'alpha(opacity=0)';
this.e_iframe.id = 'tcalIF';
this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
document.body.appendChild(this.e_iframe);
}
// hide all calendars
f_tcal_hideAll();
// generate HTML and show calendar
this.e_icon = f_getElement(this.s_iconId);
if (!this.f_update())
return;
this.e_div.style.visibility = 'visible';
this.e_shade.style.visibility = 'visible';
if (this.e_iframe)
this.e_iframe.style.visibility = 'visible';
// change icon and status
this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
this.e_icon.title = 'Close Calendar';
this.b_visible = true;
}
function f_tcal_hide (n_date) {
if (n_date)
this.e_input.value = this.f_generDate(new Date(n_date));
// no action if not visible
if (!this.b_visible)
return;
// hide elements
if (this.e_iframe)
this.e_iframe.style.visibility = 'hidden';
if (this.e_shade)
this.e_shade.style.visibility = 'hidden';
this.e_div.style.visibility = 'hidden';
// change icon and status
this.e_icon = f_getElement(this.s_iconId);
this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
this.e_icon.title = 'Open Calendar';
this.b_visible = false;
}
function f_tcalToggle () {
return this.b_visible ? this.f_hide() : this.f_show();
}
function f_tcalUpdate (d_date) {
var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
var d_selected = this.e_input.value == ''
? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
: this.f_parseDate(this.e_input.value);
// figure out date to display
if (!d_date)
// selected by default
d_date = d_selected;
else if (typeof(d_date) == 'number')
// get from number
d_date = f_tcalResetTime(new Date(d_date));
else if (typeof(d_date) == 'string')
// parse from string
this.f_parseDate(d_date);
if (!d_date) return false;
// first date to display
var d_firstday = new Date(d_date);
d_firstday.setDate(1);
d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
var a_class, s_html = '<table class="ctrl"><tbody><tr>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
+ '</tr></tbody></table><table><tbody><tr class="wd">';
// print weekdays titles
for (var i = 0; i < 7; i++)
s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
s_html += '</tr>' ;
// print calendar table
var n_date, n_month, d_current = new Date(d_firstday);
while (d_current.getMonth() == d_date.getMonth() ||
d_current.getMonth() == d_firstday.getMonth()) {
// print row heder
s_html +='<tr>';
for (var n_wday = 0; n_wday < 7; n_wday++) {
a_class = [];
n_date = d_current.getDate();
n_month = d_current.getMonth();
// other month
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length] = 'othermonth';
// weekend
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length] = 'weekend';
// today
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length] = 'today';
// selected
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length] = 'selected';
s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
d_current.setDate(++n_date);
while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
d_current.setHours(d_current.getHours + 1);
d_current = f_tcalResetTime(d_current);
}
}
// print row footer
s_html +='</tr>';
}
s_html +='</tbody></table>';
// update HTML, positions and sizes
this.e_div.innerHTML = s_html;
var n_width = this.e_div.offsetWidth;
var n_height = this.e_div.offsetHeight;
var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
if (n_left < 0) n_left = 0;
this.e_div.style.left = n_left + 'px';
this.e_div.style.top = n_top + 'px';
this.e_shade.style.width = (n_width + 8) + 'px';
this.e_shade.style.left = (n_left - 1) + 'px';
this.e_shade.style.top = (n_top - 1) + 'px';
this.e_shade.innerHTML = b_ieFix
? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
if (this.e_iframe) {
this.e_iframe.style.left = n_left + 'px';
this.e_iframe.style.top = n_top + 'px';
this.e_iframe.style.width = (n_width + 6) + 'px';
this.e_iframe.style.height = (n_height + 6) +'px';
}
return true;
}
function f_getPosition (e_elemRef, s_coord) {
var n_pos = 0, n_offset,
e_elem = e_elemRef;
while (e_elem) {
n_offset = e_elem["offset" + s_coord];
n_pos += n_offset;
e_elem = e_elem.offsetParent;
}
// margin correction in some browsers
if (b_ieMac)
n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
else if (b_safari)
n_pos -= n_offset;
e_elem = e_elemRef;
while (e_elem != document.body) {
n_offset = e_elem["scroll" + s_coord];
if (n_offset && e_elem.style.overflow == 'scroll')
n_pos -= n_offset;
e_elem = e_elem.parentNode;
}
return n_pos;
}
function f_tcalRelDate (d_date, d_diff, s_units) {
var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
var d_result = new Date(d_date);
d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
if (d_result.getDate() != d_date.getDate())
d_result.setDate(0);
return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
}
function f_tcal_hideAll () {
for (var i = 0; i < window.A_TCALSIDX.length; i++)
window.A_TCALSIDX[i].f_hide();
}
function f_tcalResetTime (d_date) {
d_date.setHours(0);
d_date.setMinutes(0);
d_date.setSeconds(0);
d_date.setMilliseconds(0);
return d_date;
}
f_getElement = document.all ?
function (s_id) { return document.all[s_id] } :
function (s_id) { return document.getElementById(s_id) };
if (document.addEventListener)
window.addEventListener('scroll', f_tcal_hideAll, false);
if (window.attachEvent)
window.attachEvent('onscroll', f_tcal_hideAll);
// global variables
var s_userAgent = navigator.userAgent.toLowerCase(),
re_webkit = /WebKit\/(\d+)/i;
var b_mac = s_userAgent.indexOf('mac') != -1,
b_ie5 = s_userAgent.indexOf('msie 5') != -1,
b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
var b_ieFix = b_ie5 || b_ie6,
b_ieMac = b_mac && b_ie5,
b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
@@ -0,0 +1,201 @@
<?php
# call_log_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the inbound and outbound calls for a specific phone
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
# - $in_limit - ('10','20','50','100',...)
# - $out_limit - ('10','20','50','100',...)
#
#
# changes
# 50406-1013 - First build of script
# 50407-1452 - Added definable limits
# 50503-1236 - added session_name checking for extra security
# 50610-1158 - Added NULL check on MySQL results to reduced errors
# 50711-1202 - removed HTTP authentication in favor of user/pass vars
# 60323-1550 - added option for showing different number dialed in log
# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1202 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0028 - Converted ereg to preg functions
# 130603-2219 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1005 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($in_limit)) {$in_limit="100";}
if (!isset($out_limit)) {$out_limit="100";}
$number_dialed = 'number_dialed';
#$number_dialed = 'extension';
$version = '0.0.10';
$build = '130328-0028';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Visning af opkaldslog";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten er ikke valid eller protokol $protocol er ikke valid\n";
exit;
}
else
{
##### print outbound calls from the call_log table
$stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$out_calls_count = mysqli_num_rows($rslt);}
echo "$out_calls_count|";
$loop_count=0;
while ($out_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[3] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);}
echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|";
}
echo "\n";
##### print inbound calls from the live_inbound_log table
$stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$in_calls_count = mysqli_num_rows($rslt);}
echo "$in_calls_count|";
$loop_count=0;
while ($in_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[4] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
$callerIDnum = $row[3]; $callerIDname = $row[3];
$callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum);
$callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname);
echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,782 @@
<?php
# conf_exten_check.php version 2.8
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the meetme conference has live channels connected and which they are
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $ACTION - ('refresh','register')
# - $client - ('agc','vdc')
# - $conf_exten - ('8600011',...)
# - $exten - ('123test',...)
# - $auto_dial_level - ('0','1','1.2',...)
# - $campagentstdisp - ('YES',...)
#
# changes
# 50509-1054 - First build of script
# 50511-1112 - Added ability to register a conference room
# 50610-1159 - Added NULL check on MySQL results to reduced errors
# 50706-1429 - script changed to not use HTTP login vars, user/pass instead
# 50706-1525 - Added date-time display for vicidial client display
# 50816-1500 - Added random update to vicidial_live_agents table for vdc users
# 51121-1353 - Altered echo statements for several small PHP speed optimizations
# 60410-1424 - Added ability to grab calls-being-placed and agent status
# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1201 - Added variable filters to close security holes for login form
# 61128-2255 - Added update for manual dial vicidial_live_agents
# 70319-1542 - Added agent disabled display function
# 71122-0205 - Added vicidial_live_agent status output
# 80424-0442 - Added non_latin lookup from system_settings
# 80519-1425 - Added calls-in-queue tally
# 80703-1106 - Added API functionality for Hangup and Dispo
# 81104-0229 - Added mysql error logging capability
# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries
# 90102-1402 - Added check for system and database time synchronization
# 90120-1720 - Added compatibility for API pause/resume and dial a number
# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours
# 90408-0020 - Added API vtiger specific callback activity record ability
# 90508-0727 - Changed to PHP long tags
# 90706-1430 - Fixed AGENTDIRECT calls in queue display count
# 90908-1037 - Added DEAD call logging
# 91130-2022 - Added code for manager override of in-group selection
# 91228-1341 - Added API fields update functions
# 100109-1337 - Fixed Manual dial live call detection
# 100527-0957 - Added send_dtmf, transfer_conference and park_call API functions
# 100727-2209 - Added timer actions for hangup, extension, callmenu and ingroup as well as destination
# 101123-1105 - Added api manual dial queue feature to external_dial function
# 101208-0308 - Moved the Calls in Queue count and other counts outside of the autodial section (issue 406)
# 110610-0059 - Small fix for manual dial calls lasting more than 100 minutes in real-time report
# 120809-2353 - Added external_recording function
# 121028-2305 - Added extra check on session_name to validate agent screen requests
# 130328-0011 - Converted ereg to preg functions
# 130603-2218 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1015 - Changed to use PHP mysqli functions
# 140126-0659 - Added external_pause_code function
#
$version = '2.8-37';
$build = '140126-0659';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=39;
$one_mysql_log=0;
$DB=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
### If you have globals turned off uncomment these lines
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];}
elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];}
if (isset($_GET["client"])) {$client=$_GET["client"];}
elseif (isset($_POST["client"])) {$client=$_POST["client"];}
if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];}
elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];}
elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];}
if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];}
elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^\-_0-9a-zA-Z]/i","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($client)) {$client="agc";}
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_TIME = date("Ymd_His");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$random = (rand(1000000, 9999999) + 10000000);
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build MEETME: $conf_exten server_ip: $server_ip-->\n";
echo "<title>check conf forbindelser";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if ($ACTION == 'refresh')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($conf_exten)<1)
{
$channel_live=0;
echo "Conf Exten $conf_exten er ikke valid\n";
exit;
}
else
{
if ($client == 'vdc')
{
$Acount=0;
$Scount=0;
$AexternalDEAD=0;
$Aagent_log_id='';
$Acallerid='';
$DEADcustomer=0;
$Astatus='';
$Acampaign_id='';
### see if the agent has a record in the vicidial_live_agents table
$stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Acount=$row[0];
### see if the agent has a record in the vicidial_session_data table
$stmt="SELECT count(*) from vicidial_session_data where user='$user' and server_ip='$server_ip' and session_name='$session_name';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03039',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Scount=$row[0];
if ($Acount > 0)
{
$stmt="SELECT status,callerid,agent_log_id,campaign_id,lead_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Astatus = $row[0];
$Acallerid = $row[1];
$Aagent_log_id = $row[2];
$Acampaign_id = $row[3];
$Alead_id = $row[4];
$api_manual_dial='STANDARD';
$stmt = "SELECT api_manual_dial FROM vicidial_campaigns where campaign_id='$Acampaign_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$vcc_conf_ct = mysqli_num_rows($rslt);
if ($vcc_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$api_manual_dial = $row[0];
}
}
# ### find out if external table shows agent should be disabled
# $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_to_mysqli($stmt, $link);
# $row=mysqli_fetch_row($rslt);
# $AexternalDEAD=$row[0];
##### BEGIN check på calls in queue, number of active calls in the campaign
if ($campagentstdisp == 'YES')
{
$ADsql='';
### grab the status of this agent to display
$stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Alogin=$row[0];
$Acampaign=$row[1];
$AccampSQL=$row[2];
$AccampSQL = preg_replace('/\s\-/','', $AccampSQL);
$AccampSQL = preg_replace('/\s/',"','", $AccampSQL);
if (preg_match('/AGENTDIRECT/i', $AccampSQL))
{
$AccampSQL = preg_replace('/AGENTDIRECT/i','', $AccampSQL);
$ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )";
}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$RingCalls=$row[0];
if ($RingCalls > 0) {$RingCalls = "<font class=\"queue_text_red\">Samtaler i kø: $RingCalls</font>";}
else {$RingCalls = "<font class=\"queue_text\">Samtaler i kø: $RingCalls</font>";}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$DiaLCalls=$row[0];
}
else
{
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
}
##### END check på calls in queue, number of active calls in the campaign
if ($auto_dial_level > 0)
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent is på is hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03018',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) and (preg_match("/^M/",$Acallerid)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03038',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03019',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03020',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03021',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
else
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent is på is hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03037',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03030',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03031',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03032',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
### grab the API hangup and API dispo fields in vicidial_live_agents
$stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds,external_dtmf,external_transferconf,external_park,external_timer_action_destination,external_recording,external_pause_code from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$external_hangup = $row[0];
$external_status = $row[1];
$external_pause = $row[2];
$external_dial = $row[3];
$external_update_fields = $row[4];
$external_update_fields_data = $row[5];
$timer_action = $row[6];
$timer_action_message = $row[7];
$timer_action_seconds = $row[8];
$external_dtmf = $row[9];
$external_transferconf = $row[10];
$external_park = $row[11];
$timer_action_destination = $row[12];
$external_recording = $row[13];
$external_pause_code = $row[14];
$MDQ_count=0;
if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') )
{
$stmt="SELECT count(*) FROM vicidial_manual_dial_queue where user='$user' and status='READY';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03033',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_count_record_ct = mysqli_num_rows($rslt);
if ($mdq_count_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_count = $row[0];
}
if ( ($MDQ_count > 0) and (strlen($external_dial) < 16) and ($Astatus=='PAUSED') and ($Alead_id < 1) )
{
$stmt="SELECT mdq_id,external_dial FROM vicidial_manual_dial_queue where user='$user' and status='READY' order by entry_time limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03034',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_record_ct = mysqli_num_rows($rslt);
if ($mdq_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_mdq_id = $row[0];
$MDQ_external_dial = $row[1];
$external_dial = $MDQ_external_dial;
$stmt="UPDATE vicidial_manual_dial_queue SET status='QUEUE' where mdq_id='$MDQ_mdq_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$UMDQaffected_rows_update = mysqli_affected_rows($link);
if ($UMDQaffected_rows_update > 0)
{
$stmt="UPDATE vicidial_live_agents SET external_dial='$MDQ_external_dial' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03036',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMDQaffected_rows_update = mysqli_affected_rows($link);
}
}
}
}
if (strlen($external_status)<1) {$external_status = '::::::::::';}
$web_epoch = date("U");
$stmt="SELECT UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$server_epoch = $row[0];
$db_epoch = $row[1];
$time_diff = ($server_epoch - $db_epoch);
$web_diff = ($db_epoch - $web_epoch);
##### check for in-group change details
$InGroupChangeDetails = '0|||';
$manager_ingroup_set=0;
$stmt="SELECT count(*) FROM vicidial_live_agents where user='$user' and manager_ingroup_set='SET';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03022',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mis_record_ct = mysqli_num_rows($rslt);
if ($mis_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$manager_ingroup_set = $row[0];
}
if ($manager_ingroup_set > 0)
{
$stmt="UPDATE vicidial_live_agents SET closer_campaigns=external_ingroups, manager_ingroup_set='Y' where user='$user' and manager_ingroup_set='SET';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMISaffected_rows_update = mysqli_affected_rows($link);
if ($VLAMISaffected_rows_update > 0)
{
$stmt="SELECT external_ingroups,external_blended,external_igb_set_user,outbound_autodial,dial_method FROM vicidial_live_agents vla, vicidial_campaigns vc where user='$user' and manager_ingroup_set='Y' and vla.campaign_id=vc.campaign_id;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03024',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$migs_record_ct = mysqli_num_rows($rslt);
if ($migs_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_ingroups = $row[0];
$external_blended = $row[1];
$external_igb_set_user = $row[2];
$outbound_autodial = $row[3];
$dial_method = $row[4];
$stmt="SELECT full_name FROM vicidial_users where user='$external_igb_set_user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03025',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mign_record_ct = mysqli_num_rows($rslt);
if ($mign_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_igb_set_name = $row[0];
}
$NEWoutbound_autodial='N';
if ( ($external_blended > 0) and ($dial_method != "INBOUND_MAN") and ($dial_method != "MANUAL") )
{$NEWoutbound_autodial='Y';}
$stmt="UPDATE vicidial_live_agents SET outbound_autodial='$NEWoutbound_autodial' 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,'03026',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMIBaffected_rows_update = mysqli_affected_rows($link);
$InGroupChangeDetails = "1|$external_blended|$external_igb_set_user|$external_igb_set_name";
$stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$Acampaign_id',event_date='$NOW_TIME',blended='$external_blended',closer_campaigns='$external_ingroups',manager_change='$external_igb_set_user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03027',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
}
##### grab the shift information the agent
$stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group = $row[0];
$VU_agent_shift_enforcement_override = $row[1];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$shift_enforcement = $row[0];
$LOGgroup_shiftsSQL = preg_replace('/\s\s/','',$row[1]);
$LOGgroup_shiftsSQL = preg_replace('/\s/',"','",$LOGgroup_shiftsSQL);
$LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')";
### CHECK TO SEE IF agent IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR
$Ashift_logout=0;
if ( ( (preg_match("/ALL/",$shift_enforcement)) and (!preg_match("/OFF|START/",$VU_agent_shift_enforcement_override)) ) or (preg_match("/ALL/",$VU_agent_shift_enforcement_override)) )
{
$shift_ok=0;
if (strlen($LOGgroup_shiftsSQL) < 3)
{$Ashift_logout++;}
else
{
$HHMM = date("Hi");
$wday = date("w");
$stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);}
$shifts_to_print = mysqli_num_rows($rslt);
$o=0;
while ( ($shifts_to_print > $o) and ($shift_ok < 1) )
{
$rowx=mysqli_fetch_row($rslt);
$shift_id = $rowx[0];
$shift_start_time = $rowx[1];
$shift_length = $rowx[2];
$shift_weekdays = $rowx[3];
if (preg_match("/$wday/i",$shift_weekdays))
{
$HHshift_length = substr($shift_length,0,2);
$MMshift_length = substr($shift_length,3,2);
$HHshift_start_time = substr($shift_start_time,0,2);
$MMshift_start_time = substr($shift_start_time,2,2);
$HHshift_end_time = ($HHshift_length + $HHshift_start_time);
$MMshift_end_time = ($MMshift_length + $MMshift_start_time);
if ($MMshift_end_time > 59)
{
$MMshift_end_time = ($MMshift_end_time - 60);
$HHshift_end_time++;
}
if ($HHshift_end_time > 23)
{$HHshift_end_time = ($HHshift_end_time - 24);}
$HHshift_end_time = sprintf("%02s", $HHshift_end_time);
$MMshift_end_time = sprintf("%02s", $MMshift_end_time);
$shift_end_time = "$HHshift_end_time$MMshift_end_time";
if (
( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or
( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or
( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) )
)
{$shift_ok++;}
}
$o++;
}
if ($shift_ok < 1)
{$Ashift_logout++;}
}
}
if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (preg_match("/0\$/i",$StarTtime)) )
{$Alogin='TIME_SYNC';}
if ( ($Acount < 1) or ($Scount < 1) )
{$Alogin='DEAD_VLA';}
if ($AexternalDEAD > 0)
{$Alogin='DEAD_EXTERNAL';}
if ($Ashift_logout > 0)
{$Alogin='SHIFT_LOGOUT';}
if ($external_pause == 'LOGOUT')
{
$Alogin='API_LOGOUT';
$external_pause='';
}
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . "\n";
if (strlen($timer_action) > 3)
{
$stmt="UPDATE vicidial_live_agents SET external_timer_action='' 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,'03028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAETAaffected_rows_update = mysqli_affected_rows($link);
}
}
$total_conf=0;
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$sip_list = mysqli_num_rows($rslt);}
# echo "$sip_list|";
$loop_count=0;
while ($sip_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
# echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
}
$channels_list = ($channels_list + $sip_list);
echo "$channels_list|";
$counter=0;
$countecho='';
while($total_conf > $counter)
{
$counter++;
$countecho = "$countecho$ChannelA[$counter] ~";
# echo "$ChannelA[$counter] ~";
}
echo "$countecho\n";
}
if ($ACTION == 'register')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($conf_exten)<1) || (strlen($exten)<1) )
{
$channel_live=0;
echo "Conf Exten $conf_exten er ikke valid or Exten $exten er ikke valid\n";
exit;
}
else
{
$stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);}
}
echo "konference $conf_exten er registrerat til $exten\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect.php version 2.6
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass");
if (!$link)
{
die('MySQL connect ERROR: ' . mysql_error());
}
mysql_select_db("$VARDB_database");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect_mysqli.php version 2.8
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
# 130802-0957 - Changed to PHP mysqli functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysqli_connect("$VARDB_server", "$VARDB_user", "$VARDB_pass", "$VARDB_database", $VARDB_port);
if (!$link)
{
die('MySQL connect ERROR: ' . mysqli_error($link));
}
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,353 @@
<?php
# inbound_popup.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed to open up when a live_inbound call comes in giving the user
# options of what to do with the call or options to lookup the callerID on various web sites
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $uniqueid - ('1234567890.123456',...)
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $ext_context - ('default','demo',...)
# - $ext_priority - ('1','2',...)
# - $voicemail_dump_exten - ('85026666666666')
# - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL)
#
#
# changes
# 50428-1500 - First build of script display only
# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links
# 50503-1244 - added session_name checking for extra security
# 50711-1203 - removed HTTP authentication in favor of user/pass vars
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2215 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1008 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];}
elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];}
if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];}
elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];}
if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];}
elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];}
elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);}
else {$local_web_callerID_URL = '';}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$DO = '-1';
if ( (preg_match("/^Zap/i",$channel)) and (!preg_match("/-/i",$channel)) ) {$channel = "$channel$DO";}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
$forever_stop=0;
$user_abb = "$user$user$user$user";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build UNIQUEID: $uniqueid server_ip: $server_ip-->\n";
?>
<script language="Javascript">
var server_ip = '<?php echo $server_ip ?>';
var epoch_sec = '<?php echo $StarTtime ?>';
var user_abb = '<?php echo $user_abb ?>';
var vmail_box = '<?php echo $vmail_box ?>';
var ext_context = '<?php echo $ext_context ?>';
var ext_priority = '<?php echo $ext_priority ?>';
var voicemail_dump_exten = '<?php echo $voicemail_dump_exten ?>';
var session_name = '<?php echo $session_name ?>';
var user = '<?php echo $user ?>';
var pass = '<?php echo $pass ?>';
// ################################################################################
// Send Hangup command for Live call connected to phone now to Manager
function livehangup_send_hangup(taskvar)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "HLagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
livehangup_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Hangup&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(livehangup_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// Send Redirect command for ringing call to go directly to your voicemail
function liveredirect_send_vmail(taskvar,taskbox)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "RVagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
var mailboxvalue = taskbox;
liveredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Redirect&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID + "&exten=" + voicemail_dump_exten + "" + mailboxvalue + "&ext_context=" + ext_context + "&ext_priority=" + ext_priority;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(liveredirect_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// timeout to deactivate the call action links after 30 sekunder
function link_timeout()
{
window.focus();
setTimeout("call_action_link_clear()", 30000);
}
// ################################################################################
// deactivates the call action links
function call_action_link_clear()
{
document.getElementById("callactions").innerHTML = "";
}
</script>
<?php
echo "<title>PÅGÅENDE INKOMMEDE OPKALD";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#CCC2E0\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"link_timeout();\">\n";
echo "<CENTER><H2>PÅGÅENDE INKOMMEDE OPKALD</H2>\n";
echo "<B>$NOW_TIME</B><BR><BR>\n";
}
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($uniqueid)<9)
{
$channel_live=0;
echo "Uniqueid $uniqueid er ikke valid\n";
exit;
}
else
{
$stmt="SELECT uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,acknowledged,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$channels_list = mysqli_num_rows($rslt);
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt|||||
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
echo "<table width=95% cellpadding=1 cellspacing=3>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Channel: </td><td align=left>$row[1]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>CallerID: </td><td align=left>$row[3]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n";
$phone = preg_replace("/.*\</i","",$row[3]);
$phone = preg_replace("/\>.*/i","",$phone);
$NPA = substr($phone, 0, 3);
$NXX = substr($phone, 3, 3);
$XXXX = substr($phone, 6, 4);
$D='-';
echo "<a href=\"http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&q=$NPA+$NXX+$XXXX&btnG=Search\" target=\"_blank\">GOOGLE</a> - \n";
echo "<a href=\"http://www.anywho.com/qry/wp_rl?npa=$NPA&telephone=$NXX$XXXX\" target=\"_blank\">ANYWHO</a> - \n";
echo "<a href=\"http://www.switchboard.com/bin/cgirlookup.dll?SR=&MEM=1&LNK=32%3A36&type=BOTH&at=$NPA&e=$NXX&n=$XXXX&search.x=55&search.y=20\" target=\"_blank\">SWITCHBOARD</a> - \n";
echo "<a href=\"http://yellowpages.superpages.com/listings.jsp?SRC=&STYPE=&PG=L&CB=&C=&N=&E=&T=&S=&Z=&A=727&X=533&P=8730&AXP=$NPA$NXX$XXXX&R=N&PS=15&search=Find+It\" target=\"_blank\">VERIZON</a> - \n";
echo "<a href=\"http://www.whitepages.com/1014/log_click/search/Reverse_Telefon?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">WHITEPAGES</a> - \n";
echo "<a href=\"http://www.411.com/10742/search/Reverse_Telefon?phone=%28$NPA%29+$NXX$D$XXXX\" target=\"_blank\">411.COM</a> - \n";
echo "<a href=\"http://www.phonenumber.com/10006/search/Reverse_Telefon?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">411.COM</a> - \n";
$local_web_callerID_QUERY_STRING ='';
$local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA";
$local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX";
$local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX";
$local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]";
$local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]";
$local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]";
$local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]";
$local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]";
$local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]";
$local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]";
echo "<a href=\"$local_web_callerID_URL$local_web_callerID_QUERY_STRING\" target=\"_blank\">CUSTOM</a> - \n";
echo "</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Opkaldt nummer: </td><td align=left>$row[8]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Notat:</td><td align=left>$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n<span id=\"callactions\">";
echo "<a href=\"#\" onclick=\"livehangup_send_hangup('$row[1]');return false;\">LÆGPÅ</a> - \n";
echo "<a href=\"#\" onclick=\"liveredirect_send_vmail('$row[1]','$vmail_box');return false;\">SEND TIL MIN VOICEMAIL</a>\n";
echo "</span></td></tr>\n";
echo "</table>\n";
$stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,284 @@
<?php
# live_exten_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the client channel is live and to what channel it is connected
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50404-1249 - First build of script
# 50406-1402 - added connected trunk lookup
# 50428-1452 - added live_inbound check for exten on 2nd line of output
# 50503-1233 - added session_name checking for extra security
# 50524-1429 - added parked calls count
# 50610-1204 - Added NULL check on MySQL results to reduced errors
# 50711-1204 - removed HTTP authentication in favor of user/pass vars
# 60103-1541 - added favorite extens status display
# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1203 - Added variable filters to close security holes for login form
# 60825-1029 - Fixed translation variable issue ChannelA
# 90508-0727 - Changed to PHP long tags
# 130328-0027 - Converted ereg to preg functions
# 130603-2214 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1522 - Added optional encrypted passwords compatibility
# 130802-1009 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];}
elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];}
if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];}
elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '2.6-13';
$build = '130328-0027';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Check aktive forbindelser";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
echo "DateTime: $NOW_TIME|";
echo "UnixTime: $StarTtime|";
$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
echo "$row[0]|";
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten er ikke valid eller protokol $protocol er ikke valid\n";
exit;
}
else
{
$stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$ChanneLA[$loop_count] = "$row[0]";
$ChanneLB[$loop_count] = "$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
$counter=0;
while($loop_count > $counter)
{
$counter++;
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $ChanneLA[$counter]|";
}
}
}
}
}
echo "\n";
### check for live_inbound entry
$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
$LIuniqueid = "$row[0]";
$LIchannel = "$row[1]";
$LIcallerid = "$row[3]";
$LIdatetime = "$row[6]";
echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
}
echo "\n";
### if favorites are present do a lookup to see if any are active
if ($favorites_count > 0)
{
$favorites = explode(',',$favorites_list);
$h=0;
$favs_print='';
while ($favorites_count > $h)
{
$fav_extension = explode('/',$favorites[$h]);
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$favs_print .= "$fav_extension[1]: $row[0] ~";
$h++;
}
echo "$favs_print\n";
}
if ($format=='debug') {echo "\n<!-- |$favorites_count|$favorites_list| -->";}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,152 @@
<?php
# park_calls_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the details on the parked calls on the server
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50524-1515 - First build of script
# 50711-1208 - removed HTTP authentication in favor of user/pass vars
# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0024 - Converted ereg to preg functions
# 130603-2213 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1024 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($park_limit)) {$park_limit="1000";}
$version = '0.0.4';
$build = '60619-1205';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>OPKALD SAT PÅ VENT";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten er ikke valid eller protokol $protocol er ikke valid\n";
exit;
}
else
{
##### print parked calls from the parked_channels table
$stmt="SELECT channel,server_ip,channel_group,extension,parked_by,parked_time from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$park_calls_count = mysqli_num_rows($rslt);
echo "$park_calls_count\n";
$loop_count=0;
while ($park_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,919 @@
<?php
# phone_only.php - the web-based web-phone-only client application
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 110511-1336 - First Build
# 110526-1757 - Added webphone_auto_answer option
# 120223-2124 - Removed logging of good login passwords if webroot writable is enabled
# 130123-1923 - Added ability to use user-login-first options.php option
# 130328-0005 - Converted ereg to preg functions
# 130603-2212 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130718-0946 - Fixed login bug
# 130802-1139 - Changed to PHP mysqli functions
#
$version = '2.8-8p';
$build = '130802-1139';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=73;
$one_mysql_log=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];}
elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
if (!isset($flag_channels))
{
$flag_channels=0;
$flag_string='';
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("[^0-9a-z]","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_pass);
$forever_stop=0;
if ($force_logout)
{
echo "Du er nu logget ud. Tak\n";
exit;
}
$isdst = date("I");
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$tsNOW_TIME = date("YmdHis");
$FILE_TIME = date("Ymd-His");
$loginDATE = date("Ymd");
$CIDdate = date("ymdHis");
$month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y"));
$past_month_date = date("Y-m-d H:i:s",$month_old);
$minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y"));
$past_minutes_date = date("Y-m-d H:i:s",$minutes_old);
$webphone_width = 460;
$webphone_height = 500;
$PHP_SELF=$_SERVER['PHP_SELF'];
$random = (rand(1000000, 9999999) + 10000000);
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09001',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$vdc_header_date_format = $row[1];
$vdc_customer_date_format = $row[2];
$vdc_header_phone_format = $row[3];
$WeBRooTWritablE = $row[4];
$timeclock_end_of_day = $row[5];
$vtiger_url = $row[6];
$enable_vtiger_integration = $row[7];
$outbound_autodial_active = $row[8];
$enable_second_webform = $row[9];
$user_territories_active = $row[10];
$static_agent_url = $row[11];
$custom_fields_enabled = $row[12];
}
##### END SETTINGS LOOKUP #####
###########################################
##### DEFINABLE SETTINGS AND OPTIONS
###########################################
# set defaults for hard-coded variables
$user_login_first = '0'; # set to 1 to have the vicidial_user login before the telefon login
$clientDST = '1'; # set to 1 to check for DST på server for agent time
$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login
$hide_timeclock_link = '0'; # set to 1 to hide the timeclock link på the agent login screen
$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window
$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500
$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770
$webphone_width = 460; # set the webphone frame width
$webphone_height = 500; # set the webphone frame height
$webphone_pad = 0; # set the table cellpadding for the webphone
$webphone_location = 'right'; # set the location på the agent screen 'right' or 'bar'
$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6
$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0
$FORM_COLOR = '#EFEFEF';
$SIDEBAR_COLOR = '#F6F6F6';
# if options file exists, use the override values for the above variables
# see the options-example.php file for more information
if (file_exists('options.php'))
{
require_once('options.php');
}
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/phone_only\.php/i','',$agcPAGE);
if (strlen($static_agent_url) > 5)
{$agcPAGE = $static_agent_url;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../agc/css/style.css" />
<link rel="stylesheet" type="text/css" href="../agc/css/custom.css" />
';
echo "<!-- VERSION: $version BUILD: $build -->\n";
echo "<!-- BROWSER: $BROWSER_WIDTH x $BROWSER_HEIGHT $JS_browser_width x $JS_browser_height -->\n";
$stmt="SELECT user_group from vicidial_users where user='$VD_login';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09002',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group=$row[0];
if ($relogin == 'YES')
{
echo "<title>Telefon web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\">Stempelklokke</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_dk/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Dansk <img src=\"../agc/images/dk.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Telefon password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"$phone_pass\" /></td></tr>\n";
echo "<tr><td align=\"right\">Bruger login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Bruger password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"INDSEND\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($user_login_first == 1)
{
if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) )
{
echo "<title>Telefon web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\">Stempelklokke</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_dk/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Dansk <img src=\"../agc/images/dk.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Bruger login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Bruger password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"INDSEND\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) )
{
$stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09073',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$phone_login=$row[0];
$phone_pass=$row[1];
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Telefon web client: Telefon login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\">Stempelklokke</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_dk/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Dansk <img src=\"../agc/images/dk.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Telefon password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"INDSEND\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
}
}
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Telefon web client: Telefon login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\">Stempelklokke</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_dk/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Dansk <img src=\"../agc/images/dk.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Telefon password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"INDSEND\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./vicidial_auth_entries.txt", "a");}
$VDloginDISPLAY=0;
if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) )
{
$VDloginDISPLAY=1;
}
else
{
$auth=0;
$auth_message = user_authorization($VD_login,$VD_pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if($auth>0)
{
##### grab the full name of the agent
$stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,agent_call_log_view_override,agent_choose_blended,agent_lead_search_override from vicidial_users where user='$VD_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09004',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$LOGfullname = $row[0];
$user_level = $row[1];
$VU_user_group = $row[10];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts,agent_status_viewable_groups,agent_status_view_time,agent_call_log_view,agent_xfer_consultative,agent_xfer_dial_override,agent_xfer_vm_transfer,agent_xfer_blind_transfer,agent_xfer_dial_with_customer,agent_xfer_park_customer_dial,agent_fullscreen,webphone_url_override,webphone_dialpad_override,webphone_systemkey_override from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09005',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$agent_fullscreen = $row[12];
$webphone_url = $row[13];
$webphone_dialpad_override = $row[14];
$system_key = $row[15];
if ( ($webphone_dialpad_override != 'DISABLED') and (strlen($webphone_dialpad_override) > 0) )
{$webphone_dialpad = $webphone_dialpad_override;}
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|GOOD|$date|$VD_login|XXXX|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
$user_abb = "$VD_login$VD_login$VD_login$VD_login";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|FAIL|$date|$VD_login|XXXX|$ip|$browser|\n");
fclose($fp);
}
$VDloginDISPLAY=1;
$VDdisplayMESSAGE = "login er inkorrekt, prøv igen<br />";
if ($auth_message == 'LOCK')
{$VDdisplayMESSAGE = "Too many login attempts, try again in 15 minutes<br />";}
}
}
if ($VDloginDISPLAY)
{
echo "<title>Telefon web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\">Stempelklokke</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_dk/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Dansk <img src=\"../agc/images/dk.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<input type=\"hidden\" name=\"phone_login\" value=\"$phone_login\" />\n";
echo "<input type=\"hidden\" name=\"phone_pass\" value=\"$phone_pass\" />\n";
echo "<center><br /><b>$VDdisplayMESSAGE</b><br /><br />";
echo "<table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Bruger login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Bruger password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"INDSEND\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
$original_phone_login = $phone_login;
# code for parsing load-balanced agent phone allocation where agent interface
# will send multiple phones-table logins so that the script can determine the
# server that has the fewest agents logged into it.
# login: ca101,cb101,cc101
$alias_found=0;
$stmt="select count(*) from phones_alias where alias_id = '$phone_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09006',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_found = "$row[0]";
}
if ($alias_found > 0)
{
$stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09007',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_name = "$row[0]";
$phone_login = "$row[1]";
}
}
$pa=0;
if ( (preg_match('/,/',$phone_login)) and (strlen($phone_login) > 2) )
{
$phoneSQL = "(";
$phones_auto = explode(',',$phone_login);
$phones_auto_ct = count($phones_auto);
while($pa < $phones_auto_ct)
{
if ($pa > 0)
{$phoneSQL .= " or ";}
$desc = ($phones_auto_ct - $pa); # traverse in reverse order
$phoneSQL .= "(login='$phones_auto[$desc]' and pass='$phone_pass')";
$pa++;
}
$phoneSQL .= ")";
}
else {$phoneSQL = "login='$phone_login' and pass='$phone_pass'";}
$authphone=0;
#$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';";
$stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and active_asterisk_server='Y' and phones.server_ip=servers.server_ip;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09008',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$authphone=$row[0];
if (!$authphone)
{
echo "<title>Telefon web client: Telefon login Error</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\">Stempelklokke</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_dk/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Dansk <img src=\"../agc/images/dk.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\">\n";
echo "<input type=\"hidden\" name=\"VD_login\" value=\"$VD_login\" />\n";
echo "<input type=\"hidden\" name=\"VD_pass\" value=\"$VD_pass\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Telefon-Only Login Error</td>";
echo "</tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><font size=\"1\"> &nbsp; <br /><font size=\"3\">Beklager din telefonlogin/password er ikke aktive på dette system, prøv igen: <br /> &nbsp;</font></td></tr>\n";
echo "<tr><td align=\"right\">Telefon login: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\"></td></tr>\n";
echo "<tr><td align=\"right\">Telefon password: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=10 maxlength=20 value=\"$phone_pass\"></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"INDSEND\" value=\"Submit\" /></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### go through the entered phones to figure out which server has fewest agents
### logged in and use that telefon login account
if ($pa > 0)
{
$pb=0;
$pb_login='';
$pb_server_ip='';
$pb_count=0;
$pb_log='';
while($pb < $phones_auto_ct)
{
### find the server_ip of each phone_login
$stmtx="SELECT server_ip from phones where login = '$phones_auto[$pb]';";
if ($DB) {echo "|$stmtx|\n";}
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmtx, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09009',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysqli_fetch_row($rslt);
### get number of agents logged in to each server
$stmt="SELECT count(*) from web_client_sessions where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09010',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
### find out whether the server is set to active
$stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' and active_asterisk_server='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09011',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysqli_fetch_row($rslt);
### find out if this server has a twin
$twin_not_live=0;
$stmt="SELECT active_twin_server_ip from servers where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09012',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyy=mysqli_fetch_row($rslt);
if (strlen($rowyy[0]) > 4)
{
### find out whether the twin server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowyy[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09013',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyz=mysqli_fetch_row($rslt);
if ($rowyz[0] < 1) {$twin_not_live=1;}
}
### find out whether the server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09014',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowz=mysqli_fetch_row($rslt);
$pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]|$twin_not_live| ";
if ( ($rowy[0] > 0) and ($rowz[0] > 0) and ($twin_not_live < 1) )
{
if ( ($pb_count >= $row[0]) or (strlen($pb_server_ip) < 4) )
{
$pb_count=$row[0];
$pb_server_ip=$rowx[0];
$phone_login=$phones_auto[$pb];
}
}
$pb++;
}
echo "<!-- Telefons balance selection: $phone_login|$pb_server_ip|$past_minutes_date| |$pb_log -->\n";
}
echo "<title>Telefon web client</title>\n";
$stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,phone_ring_timeout,on_hook_agent,webphone_auto_answer from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$extension=$row[0];
$dialplan_number=$row[1];
$voicemail_id=$row[2];
$phone_ip=$row[3];
$computer_ip=$row[4];
$server_ip=$row[5];
$login=$row[6];
$pass=$row[7];
$status=$row[8];
$active=$row[9];
$phone_type=$row[10];
$fullname=$row[11];
$company=$row[12];
$picture=$row[13];
$messages=$row[14];
$old_messages=$row[15];
$protocol=$row[16];
$local_gmt=$row[17];
$ASTmgrUSERNAME=$row[18];
$ASTmgrSECRET=$row[19];
$login_user=$row[20];
$login_pass=$row[21];
$login_campaign=$row[22];
$park_on_extension=$row[23];
$conf_on_extension=$row[24];
$VICIDiaL_park_on_extension=$row[25];
$VICIDiaL_park_on_filename=$row[26];
$monitor_prefix=$row[27];
$recording_exten=$row[28];
$voicemail_exten=$row[29];
$voicemail_dump_exten=$row[30];
$ext_context=$row[31];
$dtmf_send_extension=$row[32];
$call_out_number_group=$row[33];
$client_browser=$row[34];
$install_directory=$row[35];
$local_web_callerID_URL=$row[36];
$VICIDiaL_web_URL=$row[37];
$AGI_call_logging_enabled=$row[38];
$user_switching_enabled=$row[39];
$conferencing_enabled=$row[40];
$admin_hangup_enabled=$row[41];
$admin_hijack_enabled=$row[42];
$admin_monitor_enabled=$row[43];
$call_parking_enabled=$row[44];
$updater_check_enabled=$row[45];
$AFLogging_enabled=$row[46];
$QUEUE_ACTION_enabled=$row[47];
$CallerID_popup_enabled=$row[48];
$voicemail_button_enabled=$row[49];
$enable_fast_refresh=$row[50];
$fast_refresh_rate=$row[51];
$enable_persistant_mysql=$row[52];
$auto_dial_next_number=$row[53];
$VDstop_rec_after_each_call=$row[54];
$DBX_server=$row[55];
$DBX_database=$row[56];
$DBX_user=$row[57];
$DBX_pass=$row[58];
$DBX_port=$row[59];
$outbound_cid=$row[65];
$enable_sipsak_messages=$row[66];
$conf_secret=$row[72];
$is_webphone=$row[73];
$use_external_server_ip=$row[74];
$codecs_list=$row[75];
$webphone_dialpad=$row[76];
$phone_ring_timeout=$row[77];
$on_hook_agent=$row[78];
$webphone_auto_answer=$row[79];
$no_empty_session_warnings=0;
if ( ($phone_login == 'nophone') or ($on_hook_agent == 'Y') )
{
$no_empty_session_warnings=1;
}
if ($PhonESComPIP == '1')
{
if (strlen($computer_ip) < 4)
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
}
if ($PhonESComPIP == '2')
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09017',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
if ($clientDST)
{
$local_gmt = ($local_gmt + $isdst);
}
if ($protocol == 'EXTERNAL')
{
$protocol = 'Local';
$extension = "$dialplan_number$AT$ext_context";
}
$SIP_user = "$protocol/$extension";
$SIP_user_DiaL = "$protocol/$extension";
if ( (preg_match('/8300/',$dialplan_number)) and (strlen($dialplan_number)<5) and ($protocol == 'Local') )
{
$SIP_user = "$protocol/$extension$VD_login";
}
$session_ext = preg_replace("/[^a-z0-9]/i", "", $extension);
if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);}
$session_rand = (rand(1,9999999) + 10000000);
$session_name = "$StarTtimE$US$session_ext$session_rand";
if ($webform_sessionname)
{$webform_sessionname = "&session_name=$session_name";}
else
{$webform_sessionname = '';}
$stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'phone';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09018',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','phone','$NOW_TIME','$session_name');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09019',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VICIDiaL_is_logged_in=1;
$webphone_content='';
### build Iframe variable content for webphone here
$codecs_list = preg_replace("/ /",'',$codecs_list);
$codecs_list = preg_replace("/-/",'',$codecs_list);
$codecs_list = preg_replace("/&/",'',$codecs_list);
$webphone_server_ip = $server_ip;
if ($use_external_server_ip=='Y')
{
##### find external_server_ip if enabled for this phone account
$stmt="SELECT external_server_ip FROM servers where server_ip='$server_ip' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09020',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$exip_ct = mysqli_num_rows($rslt);
if ($exip_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_server_ip =$row[0];
}
}
if (strlen($webphone_url) < 6)
{
##### find webphone_url in system_settings and generate IFRAME code for it #####
$stmt="SELECT webphone_url FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09021',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wu_ct = mysqli_num_rows($rslt);
if ($wu_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_url =$row[0];
}
}
if (strlen($system_key) < 1)
{
##### find system_key in system_settings if populated #####
$stmt="SELECT webphone_systemkey FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09022',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wsk_ct = mysqli_num_rows($rslt);
if ($wsk_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$system_key =$row[0];
}
}
$webphone_options='INITIAL_LOAD';
if ($webphone_dialpad == 'Y') {$webphone_options .= "--DIALPAD_Y";}
if ($webphone_dialpad == 'N') {$webphone_options .= "--DIALPAD_N";}
if ($webphone_dialpad == 'TOGGLE') {$webphone_options .= "--DIALPAD_TOGGLE";}
if ($webphone_dialpad == 'TOGGLE_OFF') {$webphone_options .= "--DIALPAD_OFF_TOGGLE";}
if ($webphone_auto_answer == 'Y') {$webphone_options .= "--AUTOANSWER_Y";}
if ($webphone_auto_answer == 'N') {$webphone_options .= "--AUTOANSWER_N";}
### base64 encode variables
$b64_phone_login = base64_encode($extension);
$b64_phone_pass = base64_encode($conf_secret);
$b64_session_name = base64_encode($session_name);
$b64_server_ip = base64_encode($webphone_server_ip);
$b64_callerid = base64_encode($outbound_cid);
$b64_protocol = base64_encode($protocol);
$b64_codecs = base64_encode($codecs_list);
$b64_options = base64_encode($webphone_options);
$b64_system_key = base64_encode($system_key);
$WebPhonEurl = "$webphone_url?phone_login=$b64_phone_login&phone_login=$b64_phone_login&phone_pass=$b64_phone_pass&server_ip=$b64_server_ip&callerid=$b64_callerid&protocol=$b64_protocol&codecs=$b64_codecs&options=$b64_options&system_key=$b64_system_key";
if ($webphone_location == 'bar')
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
else
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
if (preg_match('/MSIE/',$browser))
{
$useIE=1;
echo "<!-- client web browser used: MSIE |$browser|$useIE| -->\n";
}
else
{
$useIE=0;
echo "<!-- client web browser used: W3C-Compliant |$browser|$useIE| -->\n";
}
}
}
### SCREEN WIDTH AND HEIGHT CALCULATIONS ###
### DO NOT EDIT! ###
if ($stretch_dimensions > 0)
{
if ($agent_status_view < 1)
{
if ($JS_browser_width >= 510)
{$BROWSER_WIDTH = ($JS_browser_width - 80);}
}
else
{
if ($JS_browser_width >= 730)
{$BROWSER_WIDTH = ($JS_browser_width - 300);}
}
if ($JS_browser_height >= 340)
{$BROWSER_HEIGHT = ($JS_browser_height - 40);}
}
if ($agent_fullscreen=='Y')
{
$BROWSER_WIDTH = ($JS_browser_width - 10);
$BROWSER_HEIGHT = $JS_browser_height;
}
$MASTERwidth=($BROWSER_WIDTH - 340);
$MASTERheight=($BROWSER_HEIGHT - 200);
if ($MASTERwidth < 430) {$MASTERwidth = '430';}
if ($MASTERheight < 300) {$MASTERheight = '300';}
if ($webphone_location == 'bar') {$MASTERwidth = ($MASTERwidth + $webphone_height);}
$CAwidth = ($MASTERwidth + 340); # 770 - cover all (none-in-session, customer hunngup, etc...)
$SBwidth = ($MASTERwidth + 331); # 761 - SideBar starting point
$MNwidth = ($MASTERwidth + 330); # 760 - main frame
$XFwidth = ($MASTERwidth + 320); # 750 - transfer/conference
$HCwidth = ($MASTERwidth + 310); # 740 - hotkeys and callbacks
$CQwidth = ($MASTERwidth + 300); # 730 - calls in queue listings
$AMwidth = ($MASTERwidth + 270); # 700 - refresh links
$SCwidth = ($MASTERwidth + 230); # 670 - live call sekunder counter, sidebar link
$PDwidth = ($MASTERwidth + 210); # 650 - preset-dial links
$MUwidth = ($MASTERwidth + 180); # 610 - agent mute
$SSwidth = ($MASTERwidth + 176); # 606 - scroll script
$SDwidth = ($MASTERwidth + 170); # 600 - scroll script, customer data and calls-in-session
$HKwidth = ($MASTERwidth + 20); # 450 - Hotkeys button
$HSwidth = ($MASTERwidth + 1); # 431 - Header spacer
$PBwidth = ($MASTERwidth + 0); # 430 - Presets list
$CLwidth = ($MASTERwidth - 120); # 310 - Calls in queue link
$GHheight = ($MASTERheight + 1260);# 1560 - Gender Hide span
$DBheight = ($MASTERheight + 260); # 560 - Debug span
$WRheight = ($MASTERheight + 160); # 460 - Warning boxes
$CQheight = ($MASTERheight + 140); # 440 - Calls in queue section
$SLheight = ($MASTERheight + 122); # 422 - SideBar link, Agents view link
$QLheight = ($MASTERheight + 112); # 412 - Calls in queue link
$HKheight = ($MASTERheight + 105); # 405 - HotKey active Button
$AMheight = ($MASTERheight + 100); # 400 - Agent mute buttons
$PBheight = ($MASTERheight + 90); # 390 - preset dial links
$MBheight = ($MASTERheight + 65); # 365 - Manual Dial Buttons
$CBheight = ($MASTERheight + 50); # 350 - Agent Callback, pause code, volume control Buttons and agent status
$SSheight = ($MASTERheight + 31); # 331 - script content
$HTheight = ($MASTERheight + 10); # 310 - transfer frame, callback comments and hotkey
$BPheight = ($MASTERheight - 250); # 50 - bottom buffer, Agent Xfer Span
$SCheight = 49; # 49 - sekunder på call display
$SFheight = 65; # 65 - height of the script and form contents
$SRheight = 69; # 69 - height of the script and form refrech links
if ($webphone_location == 'bar')
{
$SCheight = ($SCheight + $webphone_height);
# $SFheight = ($SFheight + $webphone_height);
$SRheight = ($SRheight + $webphone_height);
}
$AVTheight = '0';
if ($is_webphone) {$AVTheight = '20';}
echo "</head>\n";
$zi=2;
echo "<body bgcolor=\"white\">\n";
echo " Telefon: $original_phone_login - $server_ip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"$PHP_SELF?relogin=YES&session_epoch=1234567890&session_id=&session_name=$session_name&VD_login=$VD_login&phone_login=$original_phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Logout</a><BR>\n";
if ($webphone_location == 'bar')
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;width=".$webphone_width."px;overflow:hidden;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanBAR\"><span id=\"webphonecontent\" style=\"overflow:hidden;\">$webphone_content</span></span>\n";
}
else
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;overflow:scroll;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanDEFAULT\"><table cellpadding=\"$webphone_pad\" cellspacing=\"0\" border=\"0\"><tr><td width=\"5px\" rowspan=\"2\">&nbsp;</td><td align=\"center\"><font class=\"body_text\">
Web Telefon: &nbsp; </font></td></tr><tr><td align=\"center\"><span id=\"webphonecontent\">$webphone_content</span></td></tr></table></span>\n";
}
?>
</body>
</html>
<?php
exit;
?>
@@ -0,0 +1,464 @@
<?php
# timeclock.php - VICIDIAL system user timeclock
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 80523-0134 - First Build
# 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field
# 80525-2351 - Added an audit log that is not to be editable
# 80602-0641 - Fixed status update bug
# 90508-0727 - Changed to PHP long tags
# 100621-1023 - Added admin_web_directory variable
# 130328-0021 - Converted ereg to preg functions
# 130603-2211 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-2010 - Added optional encrypted passwords compatibility
# 130802-1031 - Changed to PHP mysqli functions
# 131208-2155 - Added user log TIMEOUTLOGOUT event status
#
$version = '2.8-10';
$build = '131208-2155';
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$last_action_date = $NOW_TIME;
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/timeclock\.php/i','',$agcPAGE);
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];}
elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["commit"])) {$commit=$_GET["commit"];}
elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];}
if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];}
elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("/[^0-9a-z]/","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^0-9a-zA-Z]/","",$VD_pass);
$VD_campaign=preg_replace("/[^0-9a-zA-Z_]/","",$VD_campaign);
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$stage=preg_replace("/[^0-9a-zA-Z]/","",$stage);
$commit=preg_replace("/[^0-9a-zA-Z]/","",$commit);
$referrer=preg_replace("/[^0-9a-zA-Z]/","",$referrer);
require_once("dbconnect_mysqli.php");
require_once("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,admin_home_url,admin_web_directory FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
$i=0;
while ($i < $qm_conf_ct)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$welcomeURL = $row[1];
$admin_web_directory = $row[2];
$i++;
}
##### END SETTINGS LOOKUP #####
###########################################
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ( ($stage == 'login') or ($stage == 'logout') )
{
### see if user/pass exist for this user in vicidial_users table
$valid_user=0;
$auth_message = user_authorization($user,$pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$valid_user=1;}
print "<!-- vicidial_users active count for $user: |$valid_user| -->\n";
if ($valid_user < 1)
{
### NOT A VALID USER/PASS
$VDdisplayMESSAGE = "Brugernavnet og passwordet er ikke aktivt på dette system<BR>Prøv venligst igen:";
echo"<HTML><HEAD>\n";
echo"<TITLE>AgentStempelklokke</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B>Stempelklokke </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Bruger login: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Bruger password: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=INDSEND VALUE=INDSEND> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### VALID USER/PASS, CONTINUE
### get name and group for this user
$stmt="SELECT full_name,user_group from vicidial_users where user='$user' and active='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$full_name = $row[0];
$user_group = $row[1];
print "<!-- vicidial_users name and group for $user: |$full_name|$user_group| -->\n";
### get vicidial_timeclock_status record count for this user
$stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$vts_count = $row[0];
$last_action_sec=99;
if ($vts_count > 0)
{
### vicidial_timeclock_status record found, grab status and date of last activity
$stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$status = $row[0];
$event_epoch = $row[1];
$last_action_date = date("Y-m-d H:i:s", $event_epoch);
$last_action_sec = ($StarTtimE - $event_epoch);
if ($last_action_sec > 0)
{
$totTIME_H = ($last_action_sec / 3600);
$totTIME_H_int = round($totTIME_H, 2);
$totTIME_H_int = intval("$totTIME_H");
$totTIME_M = ($totTIME_H - $totTIME_H_int);
$totTIME_M = ($totTIME_M * 60);
$totTIME_M_int = round($totTIME_M, 2);
$totTIME_M_int = intval("$totTIME_M");
$totTIME_S = ($totTIME_M - $totTIME_M_int);
$totTIME_S = ($totTIME_S * 60);
$totTIME_S = round($totTIME_S, 0);
if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";}
if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";}
if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
$totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S";
}
else
{
$totTIME_HMS='0:00:00';
}
print "<!-- vicidial_timeclock_status previous status for $user: |$status|$event_epoch|$last_action_sec| -->\n";
}
else
{
### No vicidial_timeclock_status record found, insert one
$stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$status='START';
$totTIME_HMS='0:00:00';
$affected_rows = mysqli_affected_rows($link);
print "<!-- NY vicidial_timeclock_status record inserted for $user: |$affected_rows| -->\n";
}
if ( ($last_action_sec < 30) and ($status != 'START') )
{
### You cannot log in or out within 30 sekunder of your last login/logout
$VDdisplayMESSAGE = "Du kan ikke logge ind eller ud inden 30 sekunder efter dit sidste indlog/udlog";
echo"<HTML><HEAD>\n";
echo"<TITLE>AgentStempelklokke</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B>Stempelklokke </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Bruger login: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Bruger password: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=INDSEND VALUE=INDSEND> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($commit == 'YES')
{
if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='login') )
{
$VDdisplayMESSAGE = "Du har nu logget ind";
$LOGtimeMESSAGE = "Du er logget ind på $NOW_TIME";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- NY vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- NY vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
}
if ( ($status=='LOGIN') and ($stage=='logout') )
{
$VDdisplayMESSAGE = "Du har nu logget ud";
$LOGtimeMESSAGE = "Du loggede ud:$NOW_TIME<BR>Tid som du har været indlogget:$totTIME_HMS";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- NY vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update last login record in the timeclock log
$stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_log record updated for $user: |$affected_rows| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- NY vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
### Update last login record in the timeclock audit log
$stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_audit_log record updated for $user: |$affected_rows| -->\n";
}
if ( ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) )
{echo "Fejl: stempelklokken er allerede aktiv :$status|$stage"; exit;}
if ($referrer=='agent')
{$BACKlink = "<A HREF=\"./vicidial.php?pl=$phone_login&pp=$phone_pass&VD_login=$user\"><font color=\"#003333\">TILBAGE til Agent påloggning</font></A>";}
if ($referrer=='admin')
{$BACKlink = "<A HREF=\"/$admin_web_directory/admin.php\"><font color=\"#003333\">TILBAGE til administration</font></A>";}
if ($referrer=='welcome')
{$BACKlink = "<A HREF=\"$welcomeURL\"><font color=\"#003333\">TILBAGE til Velkomst skærm</font></A>";}
echo"<HTML><HEAD>\n";
echo"<TITLE>AgentStempelklokke</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B>Stempelklokke </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><B> $BACKlink <BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') )
{
$VDdisplayMESSAGE = "Tid siden sidste login:$totTIME_HMS";
$log_action = 'login';
$button_name = 'LOGIN';
$LOGtimeMESSAGE = "Sist loggede du ud:$last_action_date<BR><BR>Klik LOGIN forneden for at logge på";
}
if ($status=='LOGIN')
{
$VDdisplayMESSAGE = "Tid du har været indlogget:$totTIME_HMS";
$log_action = 'logout';
$button_name = 'LOGOUT';
$LOGtimeMESSAGE = "Du loggede ind: $last_action_date<BR>Tid du har været indlogget:$totTIME_HMS<BR><BR>Klik LOGOUT forneden for at logge ud";
}
echo"<HTML><HEAD>\n";
echo"<TITLE>AgentStempelklokke</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"$log_action\">\n";
echo "<INPUT TYPE=HIDDEN NAME=commit VALUE=\"YES\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=user VALUE=\"$user\">\n";
echo "<INPUT TYPE=HIDDEN NAME=pass VALUE=\"$pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B>Stempelklokke </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=$button_name VALUE=$button_name> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
else
{
echo"<HTML><HEAD>\n";
echo"<TITLE>AgentStempelklokke</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B>Stempelklokke </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Bruger login: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Bruger password: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=INDSEND VALUE=INDSEND> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>VERSION: $version &nbsp; &nbsp; &nbsp; BUILD: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,375 @@
<?php
# vdc_email_display.php - VICIDIAL administration page
#
# Copyright (C) 2013 Matt Florell, Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# This page displays any incoming emails in the Vicidial user interface. It
# also allows the user to download and view any attachments sent in the email,
# and also gives the user the ability to respond to the email and even
# attach files to it. The page also logs all email messages that are sent
# through it to the vicidial_email_log table
#
# changes:
# 121214-2300 - First Build
# 130127-0027 - Better non-latin characters support
# 130328-0007 - Converted ereg to preg functions
# 130603-2210 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1515 - Added optional encrypted passwords compatibility
# 130802-1032 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["attachment_id"])) {$attachment_id=$_GET["attachment_id"];}
elseif (isset($_POST["attachment_id"])) {$attachment_id=$_POST["attachment_id"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];}
elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["sender_email"])) {$sender_email=$_GET["sender_email"];}
elseif (isset($_POST["sender_email"])) {$sender_email=$_POST["sender_email"];}
if (isset($_GET["reply_subject"])) {$reply_subject=$_GET["reply_subject"];}
elseif (isset($_POST["reply_subject"])) {$reply_subject=$_POST["reply_subject"];}
if (isset($_GET["reply_to_address"])) {$reply_to_address=$_GET["reply_to_address"];}
elseif (isset($_POST["reply_to_address"])) {$reply_to_address=$_POST["reply_to_address"];}
if (isset($_GET["reply_from_address"])) {$reply_from_address=$_GET["reply_from_address"];}
elseif (isset($_POST["reply_from_address"])) {$reply_from_address=$_POST["reply_from_address"];}
if (isset($_GET["reply_message"])) {$reply_message=$_GET["reply_message"];}
elseif (isset($_POST["reply_message"])) {$reply_message=$_POST["reply_message"];}
if (isset($_GET["REPLY"])) {$REPLY=$_GET["REPLY"];}
elseif (isset($_POST["REPLY"])) {$REPLY=$_POST["REPLY"];}
$attachment1=$_FILES["attachment1"];
$A1_orig = $_FILES['attachment1']['name'];
$A1_path = $_FILES['attachment1']['tmp_name'];
$A1_type = $_FILES['attachment1']['type'];
$attachment2=$_FILES["attachment2"];
$A2_orig = $_FILES['attachment2']['name'];
$A2_path = $_FILES['attachment2']['tmp_name'];
$A2_type = $_FILES['attachment2']['type'];
$attachment3=$_FILES["attachment3"];
$A3_orig = $_FILES['attachment3']['name'];
$A3_path = $_FILES['attachment3']['tmp_name'];
$A3_type = $_FILES['attachment3']['type'];
$attachment4=$_FILES["attachment4"];
$A4_orig = $_FILES['attachment4']['name'];
$A4_path = $_FILES['attachment4']['tmp_name'];
$A4_type = $_FILES['attachment4']['type'];
$attachment5=$_FILES["attachment5"];
$A5_orig = $_FILES['attachment5']['name'];
$A5_path = $_FILES['attachment5']['tmp_name'];
$A5_type = $_FILES['attachment5']['type'];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "EMAIL"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled,allow_emails FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
$allow_emails = $row[4];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($allow_emails<1)
{
echo "Your system does not have the email setting enabled\n";
exit;
}
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and modify_leads='1';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
$LVAactive=9;
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) ) )
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_email_display.php method=POST name=email_display_form id=email_display_form>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
if ($REPLY)
{
$to = "$reply_to_address";
$from = "$reply_from_address";
$subject ="$reply_subject";
$message = "$reply_message";
$headers = "From: $from";
$attachment_str="";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
for ($i=1; $i<=5; $i++)
{
$attachment_orig_name="A".$i."_orig";
$attachment_path="A".$i."_path";
$LF_orig=$$attachment_orig_name;
$LF_path=$$attachment_path;
#echo "<p>".$$attachment_name."<BR/>".$$attachment_orig_name."<BR/>".$$attachment_path."<BR/><p>";
if ($LF_orig)
{
if (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig))
{
echo "ERROR: Ikke gyldigt File Name: $LF_orig\n";
exit;
}
else
{
copy($LF_path, "/tmp/$LF_orig");
$file = fopen("/tmp/$LF_orig","rb");
$data = fread($file,filesize("/tmp/$LF_orig"));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$LF_orig\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$LF_orig\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
$attachment_str.="$LF_orig|";
}
}
}
$sendmail = @mail($to, $subject, $message, $headers);
if ($sendmail)
{
$reply_message=preg_replace('/(\"|\||\'|\;)/', '\\\$1', $reply_message);
$log_stmt="INSERT INTO vicidial_email_log(email_row_id, lead_id, email_date, user, email_to, message, campaign_id, attachments) VALUES('$email_row_id', '$lead_id', now(), '$user', '$reply_to_address', '$reply_message', '$campaign', '$attachment_str')";
$log_rslt=mysql_to_mysqli($log_stmt, $link);
echo "<p>mail sent to $to!</p>";
# Hangup the "call" på the agent screen
$stmt="UPDATE vicidial_live_agents set external_hangup='1' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
else
{
echo "<p>mail could not be sent!</p>";
}
exit;
}
if ($lead_id) {
$stmt="select * from vicidial_email_list where lead_id='$lead_id' and direction='INBOUND' and status IN('NEW','INCALL') order by email_date asc";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$email_row_id=$row["email_row_id"];
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_from"], $matches);
if (strlen($matches[0])>0) {
$email_from = substr($matches[0],1,-1);
} else {
$email_from = $row["email_from"];
}
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_to"], $matches);
if (strlen($matches[0])>0) {
$row["email_from"]=preg_replace('/\>/', '&gt;', $row["email_from"]);
$row["email_from"]=preg_replace('/\</', '&lt;', $row["email_from"]);
$email_to = substr($matches[0],1,-1);
} else {
$row["email_to"]=preg_replace('/\>/', '\>', $row["email_to"]);
$email_to = $row["email_to"];
}
$EMAIL_form="<center><TABLE cellspacing=2 cellpadding=2 bgcolor='#CCCCCC' width='500'>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Date received:</td><td align='left' valign='top' width='*'>$row[email_date]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>From:</td><td align='left' valign='top' width='*'>$row[email_from]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Subject:</td><td align='left' valign='top' width='*'>$row[subject]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Message:</td><td align='left' valign='top' width='*'><pre>$row[message]</pre></td></tr>\n";
$att_stmt="select * from inbound_email_attachments where email_row_id='$email_row_id'";
$att_rslt=mysql_to_mysqli($att_stmt, $link);
if (mysqli_num_rows($att_rslt)>0) {
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>vedhæftede filer:</td><td align='left' valign='top' width='*'><pre>";
while($att_row=mysqli_fetch_array($att_rslt)) {
$EMAIL_form.="<LI><a href='$_SERVER[PHP_SELF]?attachment_id=$att_row[attachment_id]&lead_id=$lead_id'>$att_row[filename]</a>\n";
}
$EMAIL_form.="</pre></td></tr>";
}
$EMAIL_form.="<tr><td colspan='2'><HR></td></tr>";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Response:</td><td align='left' valign='top' width='*'>RE: $row[subject]<input type='hidden' name='reply_subject' value='RE: $row[subject]'></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Reply:<BR><BR><input type='button' name='copy' value='COPY MESSAGE >>>' onClick='CopyMessage($row[email_row_id])'></td><td align='left' valign='top' width='*'><textarea rows='8' cols='50' name='reply_message' id='reply_message'>$reply_message</textarea></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>vedhæftede filer:</td><td align='left' valign='top' width='*'>";
$EMAIL_form.="<span id='attachment_span1'><input type=file name='attachment1' value='$attachment1'></span><BR/>";
$EMAIL_form.="<span id='attachment_span2'><input type=file name='attachment2'></span><BR/>";
$EMAIL_form.="<span id='attachment_span3'><input type=file name='attachment3'></span><BR/>";
$EMAIL_form.="<span id='attachment_span4'><input type=file name='attachment4'></span><BR/>";
$EMAIL_form.="<span id='attachment_span5'><input type=file name='attachment5'></span>";
$EMAIL_form.="</td></tr>\n";
$EMAIL_form.="<tr><td colspan='2' align='center'><input type='submit' name='REPLY' value='REPLY'></td></tr>";
$EMAIL_form.="</table></center>\n";
$EMAIL_form.="<input type='hidden' name='reply_to_address' value='$email_from'>\n";
$EMAIL_form.="<input type='hidden' name='reply_from_address' value='$email_to'>\n";
$EMAIL_form.="<input type='hidden' name='campaign' value='$campaign'>\n";
$EMAIL_form.="<input type='hidden' name='lead_id' value='$lead_id'>\n";
$EMAIL_form.="<input type='hidden' name='email_row_id' value='$email_row_id'>\n";
$EMAIL_form.="<input type='hidden' name='user' value='$user'>\n";
$EMAIL_form.="<input type='hidden' name='pass' value='$pass'>\n";
}
if ($attachment_id) {
$stmt="select * from inbound_email_attachments where attachment_id='$attachment_id'";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$filename=$row["filename"];
$encoding=$row["file_encoding"];
$file_size=$row["file_size"];
$file_type=$row["file_type"];
$file_contents=$row["file_contents"];
if ($encoding=="base64") {
$file_contents=base64_decode($file_contents);
$file_size=strlen($file_contents);
}
header("Content-length: ".$file_size."");
header("Content-type: ".$file_type."");
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $file_contents;
}
} else {
?>
<html>
<head>
<title>AGENT email frame</title>
</head>
<script language="Javascript">
function ParseFileName()
{
for (var i=1; i<=5; i++)
{
var attachment_field=eval("document.forms[0].attachment"+i);
var endstr=attachment_field.value.lastIndexOf('\\');
if (endstr>-1)
{
endstr++;
var filename=attachment_field.value.substring(endstr);
attachment_field.value=filename;
}
}
}
function CopyMessage()
{
<?php
$row["message"]=preg_replace('/\r|\n/', ' ', $row["message"]);
echo "var message=\"".preg_replace('/\"/', '\\\"', $row["message"])."\";\n";
?>
var msg_array=message.split(" ");
var full_msg="";
var msg_line="> ";
for (var i=0; i<msg_array.length; i++)
{
if (msg_array[i].length>=48)
{
msg_line+=msg_array[i]+" ";
}
if (msg_line.length+msg_array[i].length<50)
{
msg_line+=msg_array[i]+" ";
}
else
{
full_msg+=msg_line+"\n";
msg_line="> "+msg_array[i]+" ";
}
}
full_msg+=msg_line+"\n";
var email_field_value=document.getElementById("reply_message").value+"\n";
email_field_value+=full_msg;
document.getElementById("reply_message").value=email_field_value;
}
</script>
<style type="text/css">
pre { white-space: pre-wrap; }
</style>
<body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get' name="email_display_form" id="email_display_form" onSubmit="if (this.submitted) return false; this.submitted=true" enctype="multipart/form-data">
<?php echo $EMAIL_form; ?>
</form>
</body>
</html>
<?php
}
} else {
echo "ERROR - ID variable missing";
}
?>
@@ -0,0 +1,486 @@
<?php
# vdc_form_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the FORM tab in the agent
# interface, as well as take submission of the form submission when the agent
# dispositions the call
#
# CHANGELOG:
# 100630-1119 - First build of script
# 100703-1124 - Added submit_button,admin_submit fields, which will log to admin log
# 100712-2322 - Added code to log vicidial_list.entry_list_id field if data altered
# 100916-1749 - Added non-lead variable parsing
# 110719-0856 - Added HIDEBLOB type
# 110730-2335 - Added call_id variable
# 111025-1433 - Fixed case sensitivity on list fields
# 120315-1729 - Filtere out single quotes and backslashes from custom fields
# 130328-0012 - Converted ereg to preg functions
# 130402-2256 - Added user_group variable
# 130603-2204 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130615-2155 - Allow qc_enabled user access to this page even if not logged in as an agent
# 130705-1512 - Added optional encrypted passwords compatibility
# 130802-1033 - Changed to PHP mysqli functions
# 140101-2139 - Small fix for admin modify lead page on encrypted password systems
# 140429-2042 - Added TABLEper_call_notes display script variable for form display
#
$version = '2.8-15';
$build = '140429-2042';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["submit_button"])) {$submit_button=$_GET["submit_button"];}
elseif (isset($_POST["submit_button"])) {$submit_button=$_POST["submit_button"];}
if (isset($_GET["admin_submit"])) {$admin_submit=$_GET["admin_submit"];}
elseif (isset($_POST["admin_submit"])) {$admin_submit=$_POST["admin_submit"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "FORM"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|';
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;| /","",$user);
$pass = preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and ( (modify_leads='1') or (qc_enabled='1') );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
if ($custom_fields_enabled < 1)
{
echo "Custom Fields Disabled: |$custom_fields_enabled|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) and ($VUmodify < 1) ) )
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
### BEGIN parse submission of the custom fields form ###
if ($stage=='SUBMIT')
{
$update_sent=0;
$CFoutput='';
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06001',$user,$server_ip,$session_name,$one_mysql_log);}
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{
$update_SQL='';
$VL_update_SQL='';
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06003',$user,$server_ip,$session_name,$one_mysql_log);}
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$new_field_value='';
$form_field_value='';
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$A_field_name[$o] = $rowx[2];
$A_field_type[$o] = $rowx[6];
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_required[$o] = $rowx[12];
$A_field_value[$o] = '';
$field_name_id = $A_field_label[$o];
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$form_field_value = preg_replace("/\'/","",$form_field_value); // remove single-quote
$form_field_value = preg_replace("/\\b/","",$form_field_value); // remove backslashes
if ( ($A_field_type[$o]=='MULTI') or ($A_field_type[$o]=='CHECKBOX') or ($A_field_type[$o]=='RADIO') )
{
$k=0;
$multi_count = count($form_field_value);
$multi_array = $form_field_value;
while ($k < $multi_count)
{
$new_field_value .= "$multi_array[$k],";
$k++;
}
$form_field_value = preg_replace("/,$/","",$new_field_value);
}
if ($A_field_type[$o]=='TIME')
{
if (isset($_GET["MINUTE_$field_name_id"])) {$form_field_valueM=$_GET["MINUTE_$field_name_id"];}
elseif (isset($_POST["MINUTE_$field_name_id"])) {$form_field_valueM=$_POST["MINUTE_$field_name_id"];}
if (isset($_GET["HOUR_$field_name_id"])) {$form_field_valueH=$_GET["HOUR_$field_name_id"];}
elseif (isset($_POST["HOUR_$field_name_id"])) {$form_field_valueH=$_POST["HOUR_$field_name_id"];}
$form_field_value = "$form_field_valueH:$form_field_valueM:00";
}
$A_field_value[$o] = $form_field_value;
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') or ($A_field_type[$o]=='HIDDEN') or ($A_field_type[$o]=='HIDEBLOB') or ($A_field_type[$o]=='READONLY') )
{
$A_field_value[$o]='----IGNORE----';
}
else
{
if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
{
$VL_update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
else
{
$update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
$SUBMIT_output .= "<b>$A_field_name[$o]:</b> $A_field_value[$o]<BR>";
}
$o++;
}
$custom_update_count=0;
if (strlen($update_SQL)>3)
{
$custom_record_lead_count=0;
$stmt="SELECT count(*) from custom_$list_id where lead_id='$lead_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06004',$user,$server_ip,$session_name,$one_mysql_log);}
$fieldleadcount_to_print = mysqli_num_rows($rslt);
if ($fieldleadcount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$custom_record_lead_count = $rowx[0];
}
$update_SQL = preg_replace("/,$/","",$update_SQL);
$custom_table_update_SQL = "INSERT INTO custom_$list_id SET lead_id='$lead_id',$update_SQL;";
if ($custom_record_lead_count > 0)
{$custom_table_update_SQL = "UPDATE custom_$list_id SET $update_SQL where lead_id='$lead_id';";}
$rslt=mysql_to_mysqli($custom_table_update_SQL, $link);
$custom_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$custom_update_count|$custom_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
if (strlen($VL_update_SQL)>3)
{
$custom_update_vl_SQL='';
if ($custom_update_count > 0)
{$custom_update_vl_SQL = "entry_list_id='$list_id',";}
$VL_update_SQL = preg_replace("/,$/","",$VL_update_SQL);
$list_table_update_SQL = "UPDATE vicidial_list SET $custom_update_vl_SQL $VL_update_SQL where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
else
{
if ($custom_update_count > 0)
{
$list_table_update_SQL = "UPDATE vicidial_list SET entry_list_id='$list_id' where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
}
}
if ( ($admin_submit=='YES') and ($update_sent > 0) )
{
### LOG INSERTION Admin Log Table ###
$ip = getenv("REMOTE_ADDR");
$SQL_log = "$list_table_update_SQL|$custom_table_update_SQL|";
$SQL_log = preg_replace('/;/','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY CUSTOM LEAD', event_sql=\"$SQL_log\", event_notes='$custom_update_count|$list_update_count';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
else
{$CFoutput .= "ERROR: no custom list fields table\n";}
echo "Custom Form Output:\n<BR>\n";
echo "$SUBMIT_output";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
}
### END parse submission of the custom fields form ###
else
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Agent Form Display Script";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo " <link rel=\"stylesheet\" href=\"calendar.css\">\n";
echo " <script language=\"Javascript\">\n";
echo " function open_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:close_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help-</a><BR> &nbsp; \";\n";
echo " document.getElementById(taskspan).innerHTML = \"<B>\" + taskhelp + \"</B>\";\n";
echo " document.getElementById(taskspan).style.background = \"#FFFF99\";\n";
echo " }\n";
echo " function close_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \"\";\n";
echo " document.getElementById(taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:open_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help+</a>\";\n";
echo " document.getElementById(taskspan).style.background = \"white\";\n";
echo " }\n";
echo " </script>\n";
echo " <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#" . $bgcolor . "\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"parent.document.getElementById('FORM_LOADED').value='1';\">";
echo "\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=lead_id id=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=list_id id=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "<input type=hidden name=pass id=pass value=\"$pass\">\n";
echo "\n";
require_once("functions.php");
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user);
echo "$CFoutput";
if ($submit_button=='YES')
{
if ($bcrypt=='0')
{echo "<input type=hidden name=bcrypt id=bcrypt value=\"OFF\">\n";}
echo "<input type=hidden name=admin_submit id=admin_submit value=\"YES\">\n";
echo "<BR><BR><input type=submit name=VCformSubmit id=VCformSubmit value=submit>\n";
}
echo "</form></center><BR><BR>\n";
echo "</BODY></HTML>\n";
}
exit;
?>
@@ -0,0 +1,705 @@
<?php
# vdc_script_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the SCRIPT tab in the agent interface
#
# CHANGELOG:
# 90824-1435 - First build of script
# 90827-1548 - Added list override script option
# 91204-1913 - Added recording_filename and recording_id variables
# 91211-1103 - Added user_custom_... variables
# 100116-0702 - Added preset variables
# 100127-1611 - Added ignore_list_script_override option
# 100823-1644 - Added DID variables
# 100902-1344 - Added closecallid, xfercallid, agent_log_id variables
# 110420-1201 - Added web_vars variable
# 110730-2339 - Added call_id variable
# 120227-2017 - Added parsing of IGNORENOSCROLL option in script to force scroll
# 130328-0013 - Converted ereg to preg functions
# 130402-2255 - Added user_group variable
# 130603-2206 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1513 - Added optional encrypted passwords compatibility
# 130802-1035 - Changed to PHP mysqli functions
# 140429-2034 - Added TABLEper_call_notes display script variable
#
$version = '2.8-17';
$build = '140429-2034';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["title"])) {$title=$_GET["title"];}
elseif (isset($_POST["title"])) {$title=$_POST["title"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
if (isset($_GET["gender"])) {$gender=$_GET["gender"];}
elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];}
if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
if (isset($_GET["rank"])) {$rank=$_GET["rank"];}
elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];}
if (isset($_GET["owner"])) {$owner=$_GET["owner"];}
elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
elseif (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
if (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
elseif (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
if (isset($_GET["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_GET["CF_uses_custom_fields"];}
elseif (isset($_POST["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_POST["CF_uses_custom_fields"];}
if (isset($_GET["entry_list_id"])) {$entry_list_id=$_GET["entry_list_id"];}
elseif (isset($_POST["entry_list_id"])) {$entry_list_id=$_POST["entry_list_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["orig_pass"])) {$orig_pass=$_GET["orig_pass"];}
elseif (isset($_POST["orig_pass"])) {$orig_pass=$_POST["orig_pass"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$orig_pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass = preg_replace("/\'|\"|\\\\|;/","",$orig_pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,1,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
exit;
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>VICIDiaL Script Display Script";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if (strlen($in_script) < 1)
{$call_script = $camp_script;}
else
{$call_script = $in_script;}
$ignore_list_script_override='N';
$stmt = "SELECT ignore_list_script_override FROM vicidial_inbound_groups where group_id='$group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$ilso_ct = mysqli_num_rows($rslt);
if ($ilso_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$ignore_list_script_override = $row[0];
}
if ($ignore_list_script_override=='Y')
{$ignore_list_script=1;}
if ($ignore_list_script < 1)
{
$stmt="SELECT agent_script_override from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_script_override = $row[0];
if (strlen($agent_script_override) > 0)
{$call_script = $agent_script_override;}
}
$stmt="SELECT list_name,list_description from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_name = $row[0];
$list_description = $row[1];
$stmt="SELECT script_name,script_text from vicidial_scripts where script_id='$call_script';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$script_name = $row[0];
$script_text = stripslashes($row[1]);
if (preg_match("/iframe\ssrc/i",$script_text))
{
$IFRAME=1;
$lead_id = preg_replace('/\s/i','+',$lead_id);
$vendor_id = preg_replace('/\s/i','+',$vendor_id);
$vendor_lead_code = preg_replace('/\s/i','+',$vendor_lead_code);
$list_id = preg_replace('/\s/i','+',$list_id);
$list_name = preg_replace('/\s/i','+',$list_name);
$list_description = preg_replace('/\s/i','+',$list_description);
$gmt_offset_now = preg_replace('/\s/i','+',$gmt_offset_now);
$phone_code = preg_replace('/\s/i','+',$phone_code);
$phone_number = preg_replace('/\s/i','+',$phone_number);
$title = preg_replace('/\s/i','+',$title);
$first_name = preg_replace('/\s/i','+',$first_name);
$middle_initial = preg_replace('/\s/i','+',$middle_initial);
$last_name = preg_replace('/\s/i','+',$last_name);
$address1 = preg_replace('/\s/i','+',$address1);
$address2 = preg_replace('/\s/i','+',$address2);
$address3 = preg_replace('/\s/i','+',$address3);
$city = preg_replace('/\s/i','+',$city);
$state = preg_replace('/\s/i','+',$state);
$province = preg_replace('/\s/i','+',$province);
$postal_code = preg_replace('/\s/i','+',$postal_code);
$country_code = preg_replace('/\s/i','+',$country_code);
$gender = preg_replace('/\s/i','+',$gender);
$date_of_birth = preg_replace('/\s/i','+',$date_of_birth);
$alt_phone = preg_replace('/\s/i','+',$alt_phone);
$email = preg_replace('/\s/i','+',$email);
$security_phrase = preg_replace('/\s/i','+',$security_phrase);
$comments = preg_replace('/\s/i','+',$comments);
$user = preg_replace('/\s/i','+',$user);
$pass = preg_replace('/\s/i','+',$orig_pass);
$campaign = preg_replace('/\s/i','+',$campaign);
$phone_login = preg_replace('/\s/i','+',$phone_login);
$original_phone_login = preg_replace('/\s/i','+',$original_phone_login);
$phone_pass = preg_replace('/\s/i','+',$phone_pass);
$fronter = preg_replace('/\s/i','+',$fronter);
$closer = preg_replace('/\s/i','+',$closer);
$group = preg_replace('/\s/i','+',$group);
$channel_group = preg_replace('/\s/i','+',$channel_group);
$SQLdate = preg_replace('/\s/i','+',$SQLdate);
$epoch = preg_replace('/\s/i','+',$epoch);
$uniqueid = preg_replace('/\s/i','+',$uniqueid);
$customer_zap_channel = preg_replace('/\s/i','+',$customer_zap_channel);
$customer_server_ip = preg_replace('/\s/i','+',$customer_server_ip);
$server_ip = preg_replace('/\s/i','+',$server_ip);
$SIPexten = preg_replace('/\s/i','+',$SIPexten);
$session_id = preg_replace('/\s/i','+',$session_id);
$phone = preg_replace('/\s/i','+',$phone);
$parked_by = preg_replace('/\s/i','+',$parked_by);
$dispo = preg_replace('/\s/i','+',$dispo);
$dialed_number = preg_replace('/\s/i','+',$dialed_number);
$dialed_label = preg_replace('/\s/i','+',$dialed_label);
$source_id = preg_replace('/\s/i','+',$source_id);
$rank = preg_replace('/\s/i','+',$rank);
$owner = preg_replace('/\s/i','+',$owner);
$camp_script = preg_replace('/\s/i','+',$camp_script);
$in_script = preg_replace('/\s/i','+',$in_script);
$script_width = preg_replace('/\s/i','+',$script_width);
$script_height = preg_replace('/\s/i','+',$script_height);
$fullname = preg_replace('/\s/i','+',$fullname);
$recording_filename = preg_replace('/\s/i','+',$recording_filename);
$recording_id = preg_replace('/\s/i','+',$recording_id);
$user_custom_one = preg_replace('/\s/i','+',$user_custom_one);
$user_custom_two = preg_replace('/\s/i','+',$user_custom_two);
$user_custom_three = preg_replace('/\s/i','+',$user_custom_three);
$user_custom_four = preg_replace('/\s/i','+',$user_custom_four);
$user_custom_five = preg_replace('/\s/i','+',$user_custom_five);
$preset_number_a = preg_replace('/\s/i','+',$preset_number_a);
$preset_number_b = preg_replace('/\s/i','+',$preset_number_b);
$preset_number_c = preg_replace('/\s/i','+',$preset_number_c);
$preset_number_d = preg_replace('/\s/i','+',$preset_number_d);
$preset_number_e = preg_replace('/\s/i','+',$preset_number_e);
$preset_number_f = preg_replace('/\s/i','+',$preset_number_f);
$preset_dtmf_a = preg_replace('/\s/i','+',$preset_dtmf_a);
$preset_dtmf_b = preg_replace('/\s/i','+',$preset_dtmf_b);
$did_id = preg_replace('/\s/i','+',$did_id);
$did_extension = preg_replace('/\s/i','+',$did_extension);
$did_pattern = preg_replace('/\s/i','+',$did_pattern);
$did_description = preg_replace('/\s/i','+',$did_description);
$called_count = preg_replace('/\s/i','+',$called_count);
$web_vars = preg_replace('/\s/i','+',$web_vars);
}
$script_text = preg_replace('/--A--lead_id--B--/i',"$lead_id",$script_text);
$script_text = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$script_text);
$script_text = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$script_text);
$script_text = preg_replace('/--A--list_id--B--/i',"$list_id",$script_text);
$script_text = preg_replace('/--A--list_name--B--/i',"$list_name",$script_text);
$script_text = preg_replace('/--A--list_description--B--/i',"$list_description",$script_text);
$script_text = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$script_text);
$script_text = preg_replace('/--A--phone_code--B--/i',"$phone_code",$script_text);
$script_text = preg_replace('/--A--phone_number--B--/i',"$phone_number",$script_text);
$script_text = preg_replace('/--A--title--B--/i',"$title",$script_text);
$script_text = preg_replace('/--A--first_name--B--/i',"$first_name",$script_text);
$script_text = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$script_text);
$script_text = preg_replace('/--A--last_name--B--/i',"$last_name",$script_text);
$script_text = preg_replace('/--A--address1--B--/i',"$address1",$script_text);
$script_text = preg_replace('/--A--address2--B--/i',"$address2",$script_text);
$script_text = preg_replace('/--A--address3--B--/i',"$address3",$script_text);
$script_text = preg_replace('/--A--city--B--/i',"$city",$script_text);
$script_text = preg_replace('/--A--state--B--/i',"$state",$script_text);
$script_text = preg_replace('/--A--province--B--/i',"$province",$script_text);
$script_text = preg_replace('/--A--postal_code--B--/i',"$postal_code",$script_text);
$script_text = preg_replace('/--A--country_code--B--/i',"$country_code",$script_text);
$script_text = preg_replace('/--A--gender--B--/i',"$gender",$script_text);
$script_text = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$script_text);
$script_text = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$script_text);
$script_text = preg_replace('/--A--email--B--/i',"$email",$script_text);
$script_text = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$script_text);
$script_text = preg_replace('/--A--comments--B--/i',"$comments",$script_text);
$script_text = preg_replace('/--A--user--B--/i',"$user",$script_text);
$script_text = preg_replace('/--A--pass--B--/i',"$pass",$script_text);
$script_text = preg_replace('/--A--campaign--B--/i',"$campaign",$script_text);
$script_text = preg_replace('/--A--phone_login--B--/i',"$phone_login",$script_text);
$script_text = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$script_text);
$script_text = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$script_text);
$script_text = preg_replace('/--A--fronter--B--/i',"$fronter",$script_text);
$script_text = preg_replace('/--A--closer--B--/i',"$closer",$script_text);
$script_text = preg_replace('/--A--group--B--/i',"$group",$script_text);
$script_text = preg_replace('/--A--channel_group--B--/i',"$channel_group",$script_text);
$script_text = preg_replace('/--A--SQLdate--B--/i',"$SQLdate",$script_text);
$script_text = preg_replace('/--A--epoch--B--/i',"$epoch",$script_text);
$script_text = preg_replace('/--A--uniqueid--B--/i',"$uniqueid",$script_text);
$script_text = preg_replace('/--A--customer_zap_channel--B--/i',"$customer_zap_channel",$script_text);
$script_text = preg_replace('/--A--customer_server_ip--B--/i',"$customer_server_ip",$script_text);
$script_text = preg_replace('/--A--server_ip--B--/i',"$server_ip",$script_text);
$script_text = preg_replace('/--A--SIPexten--B--/i',"$SIPexten",$script_text);
$script_text = preg_replace('/--A--session_id--B--/i',"$session_id",$script_text);
$script_text = preg_replace('/--A--phone--B--/i',"$phone",$script_text);
$script_text = preg_replace('/--A--parked_by--B--/i',"$parked_by",$script_text);
$script_text = preg_replace('/--A--dispo--B--/i',"$dispo",$script_text);
$script_text = preg_replace('/--A--dialed_number--B--/i',"$dialed_number",$script_text);
$script_text = preg_replace('/--A--dialed_label--B--/i',"$dialed_label",$script_text);
$script_text = preg_replace('/--A--source_id--B--/i',"$source_id",$script_text);
$script_text = preg_replace('/--A--rank--B--/i',"$rank",$script_text);
$script_text = preg_replace('/--A--owner--B--/i',"$owner",$script_text);
$script_text = preg_replace('/--A--camp_script--B--/i',"$camp_script",$script_text);
$script_text = preg_replace('/--A--in_script--B--/i',"$in_script",$script_text);
$script_text = preg_replace('/--A--script_width--B--/i',"$script_width",$script_text);
$script_text = preg_replace('/--A--script_height--B--/i',"$script_height",$script_text);
$script_text = preg_replace('/--A--fullname--B--/i',"$fullname",$script_text);
$script_text = preg_replace('/--A--recording_filename--B--/i',"$recording_filename",$script_text);
$script_text = preg_replace('/--A--recording_id--B--/i',"$recording_id",$script_text);
$script_text = preg_replace('/--A--user_custom_one--B--/i',"$user_custom_one",$script_text);
$script_text = preg_replace('/--A--user_custom_two--B--/i',"$user_custom_two",$script_text);
$script_text = preg_replace('/--A--user_custom_three--B--/i',"$user_custom_three",$script_text);
$script_text = preg_replace('/--A--user_custom_four--B--/i',"$user_custom_four",$script_text);
$script_text = preg_replace('/--A--user_custom_five--B--/i',"$user_custom_five",$script_text);
$script_text = preg_replace('/--A--preset_number_a--B--/i',"$preset_number_a",$script_text);
$script_text = preg_replace('/--A--preset_number_b--B--/i',"$preset_number_b",$script_text);
$script_text = preg_replace('/--A--preset_number_c--B--/i',"$preset_number_c",$script_text);
$script_text = preg_replace('/--A--preset_number_d--B--/i',"$preset_number_d",$script_text);
$script_text = preg_replace('/--A--preset_number_e--B--/i',"$preset_number_e",$script_text);
$script_text = preg_replace('/--A--preset_number_f--B--/i',"$preset_number_f",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_a--B--/i',"$preset_dtmf_a",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_b--B--/i',"$preset_dtmf_b",$script_text);
$script_text = preg_replace('/--A--did_id--B--/i',"$did_id",$script_text);
$script_text = preg_replace('/--A--did_extension--B--/i',"$did_extension",$script_text);
$script_text = preg_replace('/--A--did_pattern--B--/i',"$did_pattern",$script_text);
$script_text = preg_replace('/--A--did_description--B--/i',"$did_description",$script_text);
$script_text = preg_replace('/--A--closecallid--B--/i',"$closecallid",$script_text);
$script_text = preg_replace('/--A--xfercallid--B--/i',"$xfercallid",$script_text);
$script_text = preg_replace('/--A--agent_log_id--B--/i',"$agent_log_id",$script_text);
$script_text = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$script_text);
$script_text = preg_replace('/--A--call_id--B--/i',"$call_id",$script_text);
$script_text = preg_replace('/--A--user_group--B--/i',"$user_group",$script_text);
$script_text = preg_replace('/--A--called_count--B--/i',"$called_count",$script_text);
$script_text = preg_replace('/--A--web_vars--B--/i',"$web_vars",$script_text);
if ($CF_uses_custom_fields=='Y')
{
### find the names of all custom fields, if any
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('vendor_lead_code','source_id','list_id','gmt_offset_now','called_since_last_reset','phone_code','phone_number','title','first_name','middle_initial','last_name','address1','address2','address3','city','state','province','postal_code','country_code','gender','date_of_birth','alt_phone','email','security_phrase','comments','called_count','last_local_call_time','rank','owner');";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$cffn_ct = mysqli_num_rows($rslt);
$d=0;
while ($cffn_ct > $d)
{
$row=mysqli_fetch_row($rslt);
$field_name_id = $row[0];
$field_name_tag = "--A--" . $field_name_id . "--B--";
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$script_text = preg_replace("/$field_name_tag/i","$form_field_value",$script_text);
if ($DB) {echo "$d|$field_name_id|$field_name_tag|$form_field_value|<br>\n";}
$d++;
}
}
$NOTESout='';
if (preg_match('/--A--TABLEper_call_notes--B--/i',$script_text))
{
### BEGIN Gather Call Log and notes ###
if ($hide_call_log_info!='Y')
{
if ($search != 'logfirst')
{$NOTESout .= "CALL LOG FOR THIS LEAD:<br>\n";}
$NOTESout .= "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>";
$NOTESout .= "<TR>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:10px;font-family:sans-serif;\"><B> &nbsp; # &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; DATE/TIME &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; AGENT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; LENGTH &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; STATUS &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; PHONE &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; CAMPAIGN &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; IN/OUT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; ALT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; HANGUP &nbsp; </font></TD>";
# $NOTESout .= "</TR><TR>";
# $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\" COLSPAN=9><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; FULL NAME &nbsp; </font></TD>";
$NOTESout .= "</TR>";
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$out_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$out_logs_to_print|$stmt|";}
$g=0;
$u=0;
while ($out_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = $row[3];
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLalt_dial[$g] = $row[9];
$ALLuniqueid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLin_out[$g] = "OUT-AUTO";
if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";}
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLuniqueid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$out_notes_to_print = mysqli_num_rows($rslt);
if ($out_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$in_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$in_logs_to_print|$stmt|";}
$u=0;
while ($in_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = ($row[3] - $row[9]);
if ($ALLlength_in_sec[$g] < 0) {$ALLlength_in_sec[$g]=0;}
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLuniqueid[$g] = $row[10];
$ALLclosecallid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLalt_dial[$g] = "MAIN";
$ALLin_out[$g] = "IN";
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLclosecallid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$in_notes_to_print = mysqli_num_rows($rslt);
if ($in_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
if ($g > 0)
{sort($ALLsort, SORT_NUMERIC);}
else
{$NOTESout .= "<tr bgcolor=white><td colspan=11 align=center>No calls found</td></tr>";}
$u=0;
while ($g > $u)
{
$sort_split = explode("-----",$ALLsort[$u]);
$i = $sort_split[1];
if (preg_match("/1$|3$|5$|7$|9$/i", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$phone_number_display = $ALLphone_number[$i];
if ($disable_alter_custphone == 'HIDE')
{$phone_number_display = 'XXXXXXXXXX';}
$u++;
$NOTESout .= "<tr $bgcolor>";
$NOTESout .= "<td><font size=1>$u</td>";
$NOTESout .= "<td align=right><font size=2>$ALLcall_date[$i]</td>";
$NOTESout .= "<td align=right><font size=2> $ALLuser[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLlength_in_sec[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLstatus[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLphone_code[$i] $phone_number_display </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLcampaign_id[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLin_out[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLalt_dial[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLhangup_reason[$i] </td>\n";
$NOTESout .= "</TR><TR>";
$NOTESout .= "<td></td>";
$NOTESout .= "<TD $bgcolor COLSPAN=9 align=left><font style=\"font-size:11px;font-family:sans-serif;\"> $Allcall_notes[$i] </font></TD>";
$NOTESout .= "</tr>\n";
}
$NOTESout .= "</TABLE>";
$NOTESout .= "<BR>";
}
### END Gather Call Log and notes ###
}
$script_text = preg_replace("/\n/i","<BR>",$script_text);
$script_text = preg_replace('/--A--TABLEper_call_notes--B--/i',"$NOTESout",$script_text);
$script_text = stripslashes($script_text);
echo "<!-- IFRAME$IFRAME -->\n";
echo "<!-- $script_id -->\n";
echo "<TABLE WIDTH=$script_width><TR><TD>\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "<div class=\"scroll_script\" id=\"NewScriptContents\">";}
echo "<center><B>$script_name</B><BR></center>\n";
echo "$script_text\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "</div>";}
echo "</TD></TR></TABLE>\n";
exit;
?>
@@ -0,0 +1,646 @@
<?php
# vdc_script_notes.php
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed open in the SCRIPT tab in the agent interface through
# an IFRAME. It will create a new record for every SUBMIT
#
# Example of a ViciDial agent SCRIPT using this script:
# <iframe src="./vdc_script_notes.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&pass=--A--pass--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&rank=--A--rank--B--&owner=--A--owner--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="--A--script_width--B--" height="--A--script_height--B--" STYLE="z-index:17"> </iframe>
#
# CHANGELOG:
# 100215-0744 - First build of script
# 100622-2230 - Added field labels
# 130328-0020 - Converted ereg to preg functions
# 130603-2203 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1037 - Changed to PHP mysqli functions
#
$version = '2.8-5';
$build = '130802-1037';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
elseif (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
if (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
elseif (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
elseif (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
if (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
elseif (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
if (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
elseif (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
if (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
elseif (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
if (isset($_POST["title"])) {$title=$_POST["title"];}
elseif (isset($_GET["title"])) {$title=$_GET["title"];}
if (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
elseif (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
if (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
elseif (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
if (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
elseif (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
if (isset($_POST["address1"])) {$address1=$_POST["address1"];}
elseif (isset($_GET["address1"])) {$address1=$_GET["address1"];}
if (isset($_POST["address2"])) {$address2=$_POST["address2"];}
elseif (isset($_GET["address2"])) {$address2=$_GET["address2"];}
if (isset($_POST["address3"])) {$address3=$_POST["address3"];}
elseif (isset($_GET["address3"])) {$address3=$_GET["address3"];}
if (isset($_POST["city"])) {$city=$_POST["city"];}
elseif (isset($_GET["city"])) {$city=$_GET["city"];}
if (isset($_POST["state"])) {$state=$_POST["state"];}
elseif (isset($_GET["state"])) {$state=$_GET["state"];}
if (isset($_POST["province"])) {$province=$_POST["province"];}
elseif (isset($_GET["province"])) {$province=$_GET["province"];}
if (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
elseif (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
if (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
elseif (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
if (isset($_POST["gender"])) {$gender=$_POST["gender"];}
elseif (isset($_GET["gender"])) {$gender=$_GET["gender"];}
if (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
elseif (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
if (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
elseif (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
if (isset($_POST["email"])) {$email=$_POST["email"];}
elseif (isset($_GET["email"])) {$email=$_GET["email"];}
if (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
elseif (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
if (isset($_POST["comments"])) {$comments=$_POST["comments"];}
elseif (isset($_GET["comments"])) {$comments=$_GET["comments"];}
if (isset($_POST["user"])) {$user=$_POST["user"];}
elseif (isset($_GET["user"])) {$user=$_GET["user"];}
if (isset($_POST["pass"])) {$pass=$_POST["pass"];}
elseif (isset($_GET["pass"])) {$pass=$_GET["pass"];}
if (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
elseif (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
if (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
elseif (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
if (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
elseif (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
if (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
elseif (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
if (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
elseif (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
if (isset($_POST["closer"])) {$closer=$_POST["closer"];}
elseif (isset($_GET["closer"])) {$closer=$_GET["closer"];}
if (isset($_POST["group"])) {$group=$_POST["group"];}
elseif (isset($_GET["group"])) {$group=$_GET["group"];}
if (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
elseif (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
if (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
elseif (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
if (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
elseif (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
if (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
elseif (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
if (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
elseif (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
if (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
elseif (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
if (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
elseif (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
if (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
elseif (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
if (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
elseif (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
if (isset($_POST["phone"])) {$phone=$_POST["phone"];}
elseif (isset($_GET["phone"])) {$phone=$_GET["phone"];}
if (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
elseif (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
if (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
elseif (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
if (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
elseif (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
if (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
elseif (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
if (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
elseif (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
if (isset($_POST["rank"])) {$rank=$_POST["rank"];}
elseif (isset($_GET["rank"])) {$rank=$_GET["rank"];}
if (isset($_POST["owner"])) {$owner=$_POST["owner"];}
elseif (isset($_GET["owner"])) {$owner=$_GET["owner"];}
if (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
elseif (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
if (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
elseif (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
if (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
elseif (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
if (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
elseif (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
if (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
elseif (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
if (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
elseif (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
if (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
elseif (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
if (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
elseif (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
if (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
elseif (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
if (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
elseif (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
if (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
elseif (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
if (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
elseif (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
if (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
elseif (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
if (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
elseif (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
if (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
elseif (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
if (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
elseif (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
if (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
elseif (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
if (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
elseif (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
if (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
elseif (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
if (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
elseif (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
if (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
elseif (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
if (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
elseif (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
if (isset($_POST["DB"])) {$DB=$_POST["DB"];}
elseif (isset($_GET["DB"])) {$DB=$_GET["DB"];}
if (isset($_POST["process"])) {$process=$_POST["process"];}
elseif (isset($_GET["process"])) {$process=$_GET["process"];}
if (isset($_POST["vicidial_id"])) {$vicidial_id=$_POST["vicidial_id"];}
elseif (isset($_GET["vicidial_id"])) {$vicidial_id=$_GET["vicidial_id"];}
if (isset($_POST["call_date"])) {$call_date=$_POST["call_date"];}
elseif (isset($_GET["call_date"])) {$call_date=$_GET["call_date"];}
if (isset($_POST["order_id"])) {$order_id=$_POST["order_id"];}
elseif (isset($_GET["order_id"])) {$order_id=$_GET["order_id"];}
if (isset($_POST["appointment_date"])) {$appointment_date=$_POST["appointment_date"];}
elseif (isset($_GET["appointment_date"])) {$appointment_date=$_GET["appointment_date"];}
if (isset($_POST["appointment_time"])) {$appointment_time=$_POST["appointment_time"];}
elseif (isset($_GET["appointment_time"])) {$appointment_time=$_GET["appointment_time"];}
if (isset($_POST["call_notes"])) {$call_notes=$_POST["call_notes"];}
elseif (isset($_GET["call_notes"])) {$call_notes=$_GET["call_notes"];}
if (isset($_POST["notesid"])) {$notesid=$_POST["notesid"];}
elseif (isset($_GET["notesid"])) {$notesid=$_GET["notesid"];}
if ($notesid < 100)
{$notesid=0;}
if (strlen($vicidial_id) < 1)
{$vicidial_id = $uniqueid;}
if (strlen($appointment_time) < 1)
{$appointment_time = '12:00:00';}
$appointment_timeARRAY = explode(":",$appointment_time);
$appointment_hour = $appointment_timeARRAY[0];
$appointment_min = $appointment_timeARRAY[1];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
if (strlen($call_date) < 1)
{$call_date = $NOW_TIME;}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^-_0-9a-zA-Z]/","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass = preg_replace("/\'|\"|\\\\|;/","",$pass);
}
if ($DB > 0)
{
echo "<BR>$lead_id|$entry_date|$modify_date|$status|$user|$vendor_lead_code|$source_id|$list_id|$gmt_offset_now|$called_since_last_reset|$phone_code|$phone_number|$title|$first_name|$middle_initial|$last_name|$address1|$address2|$address3|$city|$state|$province|$postal_code|$country_code|$gender|$date_of_birth|$alt_phone|$email|$security_phrase|$comments|$called_count|$last_local_call_time|$rank|$owner|\n<BR>";
}
### BEGIN find any custom field labels ###
$label_title = 'Title';
$label_first_name = 'Første';
$label_middle_initial = 'MI';
$label_last_name = 'Last';
$label_address1 = 'Adresse1';
$label_address2 = 'Adresse2';
$label_address3 = 'Adresse3';
$label_city = 'By';
$label_state = 'State';
$label_province = 'Provins';
$label_postal_code = 'Postnummer';
$label_vendor_lead_code = 'Vendor ID';
$label_gender = 'Gender';
$label_phone_number = 'Telefon';
$label_phone_code = 'Landsnummer';
$label_alt_phone = 'Alt. telefon';
$label_security_phrase = 'Vis';
$label_email = 'Email';
$label_comments = 'Comments';
$stmt="SELECT label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments from system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if (strlen($row[0])>0) {$label_title = $row[0];}
if (strlen($row[1])>0) {$label_first_name = $row[1];}
if (strlen($row[2])>0) {$label_middle_initial = $row[2];}
if (strlen($row[3])>0) {$label_last_name = $row[3];}
if (strlen($row[4])>0) {$label_address1 = $row[4];}
if (strlen($row[5])>0) {$label_address2 = $row[5];}
if (strlen($row[6])>0) {$label_address3 = $row[6];}
if (strlen($row[7])>0) {$label_city = $row[7];}
if (strlen($row[8])>0) {$label_state = $row[8];}
if (strlen($row[9])>0) {$label_province = $row[9];}
if (strlen($row[10])>0) {$label_postal_code = $row[10];}
if (strlen($row[11])>0) {$label_vendor_lead_code = $row[11];}
if (strlen($row[12])>0) {$label_gender = $row[12];}
if (strlen($row[13])>0) {$label_phone_number = $row[13];}
if (strlen($row[14])>0) {$label_phone_code = $row[14];}
if (strlen($row[15])>0) {$label_alt_phone = $row[15];}
if (strlen($row[16])>0) {$label_security_phrase = $row[16];}
if (strlen($row[17])>0) {$label_email = $row[17];}
if (strlen($row[18])>0) {$label_comments = $row[18];}
### END find any custom field labels ###
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
echo "<HTML>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Agent Notes";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo "<link rel=\"stylesheet\" href=\"calendar.css\">\n";
?>
<?php
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
if ($process > 0)
{
#Update vicidial_list record
$stmt="UPDATE vicidial_list SET vendor_lead_code='$vendor_lead_code',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',phone_code='$phone_code',phone_number='$phone_number',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',rank='$rank',owner='$owner' where lead_id='$lead_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
#Update the agent screen with new data
$stmt="UPDATE vicidial_live_agents set external_update_fields='1',external_update_fields_data='vendor_lead_code,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,phone_code,phone_number,gender,date_of_birth,alt_phone,email,security_phrase,comments,rank,owner' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
if ($notesid < 100)
{
# Insert into vicidial_call_notes
$stmt="INSERT INTO vicidial_call_notes set lead_id='$lead_id',vicidial_id='$vicidial_id',call_date='$call_date',order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$notesid = mysqli_insert_id($link);
}
else
{
# update vicidial_call_notes record
$stmt="UPDATE vicidial_call_notes set order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes' where notesid='$notesid';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
echo "<BR><b>Data Changes Accepted</b><BR><BR>";
}
$URLarray = explode("?", $PHP_SELF);
$URLsubmit = $URLarray[0];
?>
<TABLE Border=0 CELLPADDING=0 CELLSPACING=2 WIDTH=450>
<TR><TD COLSPAN=2 ALIGN=CENTER>
<FORM METHOD=POST NAME=vsn ID=vsn ACTION="<?php echo $URLsubmit ?>">
<input type=hidden name=DB id=DB value=<?php echo $DB ?>>
<input type=hidden name=process id=process value=1>
<input type=hidden name=lead_id id=lead_id value="<?php echo $lead_id ?>">
<input type=hidden name=user id=user value="<?php echo $user ?>">
<input type=hidden name=pass id=user value="<?php echo $pass ?>">
<input type=hidden name=notesid id=notesid value="<?php echo $notesid ?>">
<input type=hidden name=vendor_id id=vendor_id value="<?php echo $vendor_id ?>">
<input type=hidden name=title id=title value="<?php echo $title ?>">
<input type=hidden name=middle_initial id=middle_initial value="<?php echo $middle_initial ?>">
<input type=hidden name=province id=province value="<?php echo $middle_initial ?>">
<input type=hidden name=phone_code id=phone_code value="<?php echo $phone_code ?>">
<input type=hidden name=gender id=gender value="<?php echo $gender ?>">
<input type=hidden name=date_of_birth id=date_of_birth value="<?php echo $date_of_birth ?>">
<input type=hidden name=alt_phone id=alt_phone value="<?php echo $alt_phone ?>">
<input type=hidden name=email id=email value="<?php echo $email ?>">
<input type=hidden name=security_phrase id=security_phrase value="<?php echo $security_phrase ?>">
<input type=hidden name=comments id=comments value="<?php echo $comments ?>">
<input type=hidden name=rank id=rank value="<?php echo $rank ?>">
<input type=hidden name=owner id=owner value="<?php echo $owner ?>">
</TD></TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Vendor ID: </TD><TD ALIGN=LEFT><input type=text name=vendor_id id=vendor_id size=20 maxlength=20 value="<?php echo $vendor_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Source ID: </TD><TD ALIGN=LEFT>$source_id<input type=hidden name=source_id id=source_id value="<?php echo $source_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Title: </TD><TD ALIGN=LEFT><input type=text name=title id=title size=5 maxlength=4 value="<?php echo $title ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_first_name ?>: </TD><TD ALIGN=LEFT><input type=text name=first_name id=first_name size=30 maxlength=30 value="<?php echo $first_name ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Middle Initial: </TD><TD ALIGN=LEFT><input type=text name=middle_initial id=middle_initial size=2 maxlength=1 value="<?php echo $middle_initial ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_last_name ?>: </TD><TD ALIGN=LEFT><input type=text name=last_name id=last_name size=30 maxlength=30 value="<?php echo $last_name ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address1 ?>: </TD><TD ALIGN=LEFT><input type=text name=address1 id=address1 size=30 maxlength=100 value="<?php echo $address1 ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address2 ?>: </TD><TD ALIGN=LEFT><input type=text name=address2 id=address2 size=30 maxlength=100 value="<?php echo $address2 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address3 ?>: </TD><TD ALIGN=LEFT><input type=text name=address3 id=address3 size=30 maxlength=100 value="<?php echo $address3 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_city ?>: </TD><TD ALIGN=LEFT><input type=text name=city id=city size=30 maxlength=50 value="<?php echo $city ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_state ?>: </TD><TD ALIGN=LEFT>
<SELECT name="state" id=state>
<OPTION value="<?php echo $state ?>" selected><?php echo $state ?></OPTION>
<OPTGROUP label="United Stats">
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AK">Alaska</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="CA">California</OPTION>
<OPTION value="CO">Colorado</OPTION>
<OPTION value="CT">Connecticut</OPTION>
<OPTION value="DE">Delaware</OPTION>
<OPTION value="FL">Florida</OPTION>
<OPTION value="GA">Georgia</OPTION>
<OPTION value="HI">Hawaii</OPTION>
<OPTION value="ID">Idaho</OPTION>
<OPTION value="IL">Illinois</OPTION>
<OPTION value="IN">Indiana</OPTION>
<OPTION value="IA">Iowa</OPTION>
<OPTION value="KS">Kansas</OPTION>
<OPTION value="KY">Kentucky</OPTION>
<OPTION value="LA">Louisiana</OPTION>
<OPTION value="ME">Maine</OPTION>
<OPTION value="MD">Maryland</OPTION>
<OPTION value="MA">Massachusetts</OPTION>
<OPTION value="MI">Michigan</OPTION>
<OPTION value="MN">Minnesota</OPTION>
<OPTION value="MS">Mississippi</OPTION>
<OPTION value="MO">Missouri</OPTION>
<OPTION value="MT">Montana</OPTION>
<OPTION value="NE">Nebraska</OPTION>
<OPTION value="NV">Nevada</OPTION>
<OPTION value="NH">New Hampshire</OPTION>
<OPTION value="NJ">New Jersey</OPTION>
<OPTION value="NM">New Mexico</OPTION>
<OPTION value="NY">New York</OPTION>
<OPTION value="NC">North Carolina</OPTION>
<OPTION value="ND">North Dakota</OPTION>
<OPTION value="OH">Ohio</OPTION>
<OPTION value="OK">Oklahoma</OPTION>
<OPTION value="OR">Oregon</OPTION>
<OPTION value="PA">Pennsylvania</OPTION>
<OPTION value="RI">Rhode Island</OPTION>
<OPTION value="SC">South Carolina</OPTION>
<OPTION value="SD">South Dakota</OPTION>
<OPTION value="TN">Tennessee</OPTION>
<OPTION value="TX">Texas</OPTION>
<OPTION value="UT">Utah</OPTION>
<OPTION value="VT">Vermont</OPTION>
<OPTION value="VA">Virginia</OPTION>
<OPTION value="WA">Washington</OPTION>
<OPTION value="DC">Washington, DC</OPTION>
<OPTION value="WV">West Virginia</OPTION>
<OPTION value="WI">Wisconsin</OPTION>
<OPTION value="WY">Wyoming</OPTION>
</OPTGROUP>
<!--
<OPTGROUP label="Canada">
<OPTION value="AB">ALBERTA</OPTION>
<OPTION value="NT">NORTHWEST TERRITORY</OPTION>
<OPTION value="BC">BRITISH COLUMBIA</OPTION>
<OPTION value="ON">ONTARIO</OPTION>
<OPTION value="LB">LABRADOR</OPTION>
<OPTION value="PE">PRINCE EDWARDISLAND</OPTION>
<OPTION value="MB">MANITOBA</OPTION>
<OPTION value="PQ">QUEBEC</OPTION>
<OPTION value="NB">NEW BRUNSWICK</OPTION>
<OPTION value="SK">SASKATCHEWAN</OPTION>
<OPTION value="NF">NEWFOUNDLAND</OPTION>
<OPTION value="YT">YUKON TERRITORY</OPTION>
<OPTION value="NS">NOVA SCOTIA</OPTION>
</OPTGROUP>
-->
</SELECT> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Provins: </TD><TD ALIGN=LEFT><input type=text name=province id=province size=20 maxlength=50 value="<?php echo $province ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_postal_code ?>: </TD><TD ALIGN=LEFT><input type=text name=postal_code id=postal_code size=6 maxlength=5 value="<?php echo $postal_code ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Telefon Code: </TD><TD ALIGN=LEFT><input type=text name=phone_code id=phone_code size=10 maxlength=10 value="<?php echo $phone_code ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_phone_number ?>: </TD><TD ALIGN=LEFT><input type=text name=phone_number id=phone_number size=18 maxlength=18 value="<?php echo $phone_number ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Køn:</TD><TD ALIGN=LEFT><input type=text name=gender id=gender size=2 maxlength=1 value="<?php echo $gender ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Fødselsdato:</TD><TD ALIGN=LEFT><input type=text name=date_if_birth id=date_if_birth size=12 maxlength=12 value="<?php echo $date_of_birth ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Alt. telefon: </TD><TD ALIGN=LEFT><input type=text name=alt_phone id=alt_phone size=12 maxlength=12 value="<?php echo $alt_phone ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Email: </TD><TD ALIGN=LEFT><input type=text name=email id=email size=30 maxlength=70 value="<?php echo $email ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Vis: </TD><TD ALIGN=LEFT><input type=text name=security_phrase id=security_phrase size=30 maxlength=100 value="<?php echo $security_phrase ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Kommentar:</TD><TD ALIGN=LEFT><input type=text name=comments id=comments size=40 maxlength=255 value="<?php echo $comments ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Rank: </TD><TD ALIGN=LEFT><input type=text name=rank id=rank size=5 maxlength=5 value="<?php echo $rank ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Owner: </TD><TD ALIGN=LEFT><input type=text name=owner id=owner size=20 maxlength=20 value="<?php echo $owner ?>"> *</TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Order ID: </TD><TD ALIGN=LEFT><input type=text name=order_id id=order_id size=20 maxlength=20 value="<?php echo $order_id ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Appointment Date/Time: </TD><TD ALIGN=LEFT><input type=text name=appointment_date id=appointment_date size=10 maxlength=10 value="<?php echo $appointment_date ?>">
<script language="JavaScript">
var o_cal = new tcal ({
// form name
'formname': 'vsn',
// input name
'controlname': 'appointment_date'
});
o_cal.a_tpl.yearscroll = false;
// o_cal.a_tpl.weekstart = 1; // Monday week start
</script>
<input type=hidden name=appointment_time id=appointment_time value="<?php echo $appointment_time ?>">
<SELECT name=appointment_hour id=appointment_hour>
<option>00</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<OPTION value="<?php echo $appointment_hour ?>" selected><?php echo $appointment_hour ?></OPTION>
</SELECT>
<SELECT name=appointment_min id=appointment_min>
<option>00</option>
<option>05</option>
<option>10</option>
<option>15</option>
<option>20</option>
<option>25</option>
<option>30</option>
<option>35</option>
<option>40</option>
<option>45</option>
<option>50</option>
<option>55</option>
<OPTION value="<?php echo $appointment_min ?>" selected><?php echo $appointment_min ?></OPTION>
</SELECT>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=2>Appointment Notat:<BR><TEXTAREA NAME=call_notes ID=call_notes ROWS=5 COLS=50><?php echo $call_notes ?></TEXTAREA></font><br>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=1>Please click INDSEND to commit the changes, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * denotes required fields</font><br>
</TD>
</TR>
<TR BGCOLOR=white>
<TD ALIGN=CENTER COLSPAN=2>
<SCRIPT LANGUAGE="JavaScript">
function submit_form()
{
var appointment_hourFORM = document.getElementById('appointment_hour');
var appointment_hourVALUE = appointment_hourFORM[appointment_hourFORM.selectedIndex].text;
var appointment_minFORM = document.getElementById('appointment_min');
var appointment_minVALUE = appointment_minFORM[appointment_minFORM.selectedIndex].text;
document.vsn.appointment_time.value = appointment_hourVALUE + ":" + appointment_minVALUE + ":00";
document.vsn.submit();
}
</SCRIPT>
<input type=button value="INDSEND" name=smt id=smt onClick="submit_form()">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</B></FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,145 @@
<?php
# voicemail_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to check whether the voicemail box on the server defined has new and old messages
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
#
#
# changes
# 50422-1147 - First build of script
# 50503-1241 - added session_name checking for extra security
# 50711-1201 - removed HTTP authentication in favor of user/pass vars
# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1204 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2202 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1038 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ikke gyldigt Brugernavn/Password: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ikke gyldigt server_ip: |$server_ip| or Ikke gyldigt session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ikke gyldigt session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build VMBOX: $vmail_box server_ip: $server_ip-->\n";
echo "<title>Voicemail check";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$MT[0]='';
$row=''; $rowx='';
if (strlen($vmail_box)<1)
{
$channel_live=0;
echo "voicemail box $vmail_box er ikke valid\n";
exit;
}
else
{
$stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$vmails_list = mysqli_num_rows($rslt);
$loop_count=0;
while ($vmails_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0]|$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- skriptets tidsforbrug: $RUNtime sekunder -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,480 @@
<?php
# active_list_refresh.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to serve updates of the live data to the display scripts
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $ADD - ('1','2','3','4','5')
# - $order - ('asc','desc')
# - $format - ('text','table','menu','selectlist','textarea')
# - $bgcolor - ('#123456','white','black','etc...')
# - $txtcolor - ('#654321','black','white','etc...')
# - $txtsize - ('1','2','3','etc...')
# - $selectsize - ('2','3','4','etc...')
# - $selectfontsize - ('8','10','12','etc...')
# - $selectedext - ('cc100')
# - $selectedtrunk - ('Zap/25-1')
# - $selectedlocal - ('SIP/cc100')
# - $textareaheight - ('8','10','12','etc...')
# - $textareawidth - ('8','10','12','etc...')
# - $field_name - ('extension','busyext','extension_xfer','etc...')
#
#
# changes
# 50323-1147 - First build of script
# 50401-1132 - small formatting changes
# 50502-1402 - added field_name as modifiable variable
# 50503-1213 - added session_name checking for extra security
# 50503-1311 - added conferences list
# 50610-1155 - Added NULL check on MySQL results to reduced errors
# 50711-1209 - removed HTTP authentication in favor of user/pass vars
# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1118 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0029 - Converted ereg to preg functions
# 130603-2222 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-0957 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];}
elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];}
if (isset($_GET["order"])) {$order=$_GET["order"];}
elseif (isset($_POST["order"])) {$order=$_POST["order"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];}
elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];}
if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];}
elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];}
if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];}
elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];}
if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];}
elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];}
if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];}
elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];}
if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];}
elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];}
if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];}
elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];}
if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];}
elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];}
if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];}
elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];}
if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];}
elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];}
### security strip all non-alphanumeric characters out of the variables ###
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$ADD=preg_replace("/[^0-9]/","",$ADD);
$order=preg_replace("/[^0-9a-zA-Z]/","",$order);
$format=preg_replace("/[^0-9a-zA-Z]/","",$format);
$bgcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$bgcolor);
$txtcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$txtcolor);
$txtsize=preg_replace("/[^0-9a-zA-Z]/","",$txtsize);
$selectsize=preg_replace("/[^0-9a-zA-Z]/","",$selectsize);
$selectfontsize=preg_replace("/[^0-9a-zA-Z]/","",$selectfontsize);
$selectedext=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedext);
$selectedtrunk=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedtrunk);
$selectedlocal=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedlocal);
$textareaheight=preg_replace("/[^0-9a-zA-Z]/","",$textareaheight);
$textareawidth=preg_replace("/[^0-9a-zA-Z]/","",$textareawidth);
$field_name=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$field_name);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($ADD)) {$ADD="1";}
if (!isset($order)) {$order='desc';}
if (!isset($format)) {$format="text";}
if (!isset($bgcolor)) {$bgcolor='white';}
if (!isset($txtcolor)) {$txtcolor='black';}
if (!isset($txtsize)) {$txtsize='2';}
if (!isset($selectsize)) {$selectsize='4';}
if (!isset($selectfontsize)) {$selectfontsize='10';}
if (!isset($textareaheight)) {$textareaheight='10';}
if (!isset($textareawidth)) {$textareawidth='20';}
$version = '0.0.10';
$build = '130328-0029';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='table')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build ADD: $ADD server_ip: $server_ip-->\n";
echo "<title>Κατάλογος Οθόνης: ";
if ($ADD==1) {echo "Ενεργές τηλ. συνδέσεις";}
if ($ADD==2) {echo "Απασχολημένες τηλ. συνδέσεις";}
if ($ADD==3) {echo "Εξωτερικές γραμμές";}
if ($ADD==4) {echo "Τοπικές τηλ. συνδέσεις";}
if ($ADD==5) {echo "Διασκέψεις";}
if ($ADD==99999) {echo "HELP";}
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
######################
# ADD=1 display all live extensions on a server
######################
if ($ADD==1)
{
$pt='pt';
if (!$field_name) {$field_name = 'extension';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension,fullname FROM phones where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=2 display all busy extensions on a server
######################
if ($ADD==2)
{
if (!$field_name) {$field_name = 'busyext';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension FROM live_channels where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=3 display all busy outside lines(trunks) on a server
######################
if ($ADD==3)
{
if (!$field_name) {$field_name = 'trunk';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedtrunk") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=4 display all busy Local lines on a server
######################
if ($ADD==4)
{
if (!$field_name) {$field_name = 'local';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_sip_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedlocal") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=5 display all agc-usable conferences on a server
######################
if ($ADD==5)
{
$pt='pt';
if (!$field_name) {$field_name = 'conferences';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT conf_exten,extension FROM conferences where server_ip = '$server_ip' order by conf_exten $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
if ($format=='table') {echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";}
if ($format=='table') {echo "\n</body>\n</html>\n";}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,102 @@
<?php
# audit_comments.php
#
# Copyright (C) 2014 poundteam.com,vicidial.org LICENSE: AGPLv2
#
# This script is designed to display QC audit comments, contributed by poundteam.com
#
# changes:
# 121116-1322 - First build, added to vicidial codebase
# 130802-0957 - Changed to PHP mysqli functions
# 140304-2154 - Enabled special characters in comments
#
require_once("functions.php");
function audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign) {
$audit_comments_active=audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log);
if ($audit_comments_active) {
//Get comment from list
$stmt="select comments from vicidial_list where lead_id='$lead_id' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments2',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if (strlen($row[0]) > 0) {
$comment=$row[0];
//Put comment in comment table
$stmt="INSERT INTO vicidial_comments (lead_id,user_id,list_id,campaign_id,comment) VALUES ('$lead_id','$user','$list_id','$campaign','".mysqli_real_escape_string($link, $comment)."');";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments3',$user,$server_ip,$session_name,$one_mysql_log);
}
$affected=mysqli_affected_rows($link);
if($affected>0) {
$stmt="UPDATE vicidial_list set comments='' where lead_id='$lead_id';";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments4',$user,$server_ip,$session_name,$one_mysql_log);
}
} else {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditCommentsERROR-Comment not moved',$user,$server_ip,$session_name,$one_mysql_log);
echo "\n<!-- 00142-AuditCommentsERROR-Comment not moved -->";
}
}
}
}
function audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log){
$stmt="select count(audit_comments) from vicidial_lists_custom where list_id='$list_id' and audit_comments='1' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments5',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if ($row[0] == '1') {
return true;
} else {
return false;
}
}
function get_audited_comments($lead_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log) {
global $ACcount;
global $ACcomments;
$stmt="select user_id,comment from vicidial_comments where lead_id='$lead_id';";
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"00142-65-AuditComments:$stmt LeadID: $lead_id,$format,$user,$mel,$NOW_TIME,\$link,$server_ip,$session_name,$one_mysql_log",$user,$server_ip,$session_name,$one_mysql_log);
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-69-AuditComments',$user,$server_ip,$session_name,$one_mysql_log);
}
$ACcount=mysqli_num_rows($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-72-AuditComments $ACcount='.$ACcount,$user,$server_ip,$session_name,$one_mysql_log);
if($ACcount>0) {
$i=0;
while ($i < $ACcount) {
$row=mysqli_fetch_row($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-77-AuditComments UserID='.$row[0],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= "UserID: $row[0]\n";
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-79-AuditComments Comment='.$row[1],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= $row[1];
$ACcomments .= "\n----------------------------------\n";
$i++;
}
return true;
} else {
return false;
}
}
?>
@@ -0,0 +1,95 @@
/* calendar icon */
img.tcalIcon {
cursor: pointer;
margin-left: 1px;
vertical-align: middle;
}
/* calendar container element */
div#tcal {
position: absolute;
visibility: hidden;
z-index: 100;
width: 158px;
padding: 2px 0 0 0;
}
/* all tables in calendar */
div#tcal table {
width: 100%;
border: 1px solid silver;
border-collapse: collapse;
background-color: white;
}
/* navigation table */
div#tcal table.ctrl {
border-bottom: 0;
}
/* navigation buttons */
div#tcal table.ctrl td {
width: 15px;
height: 20px;
}
/* month year header */
div#tcal table.ctrl th {
background-color: white;
color: black;
border: 0;
}
/* week days header */
div#tcal th {
border: 1px solid silver;
border-collapse: collapse;
text-align: center;
padding: 3px 0;
font-family: tahoma, verdana, arial;
font-size: 10px;
background-color: gray;
color: white;
}
/* date cells */
div#tcal td {
border: 0;
border-collapse: collapse;
text-align: center;
padding: 2px 0;
font-family: tahoma, verdana, arial;
font-size: 11px;
width: 22px;
cursor: pointer;
}
/* date highlight
in case of conflicting settings order here determines the priority from least to most important */
div#tcal td.othermonth {
color: silver;
}
div#tcal td.weekend {
background-color: #ACD6F5;
}
div#tcal td.today {
border: 1px solid red;
}
div#tcal td.selected {
background-color: #FFB3BE;
}
/* iframe element used to suppress windowed controls in IE5/6 */
iframe#tcalIF {
position: absolute;
visibility: hidden;
z-index: 98;
border: 0;
}
/* transparent shadow */
div#tcalShade {
position: absolute;
visibility: hidden;
z-index: 99;
}
div#tcalShade table {
border: 0;
border-collapse: collapse;
width: 100%;
}
div#tcalShade table td {
border: 0;
border-collapse: collapse;
padding: 0;
}
@@ -0,0 +1,335 @@
// Tigra Calendar v4.0.2 (2009-01-12) Database (yyyy-mm-dd)
// http://www.softcomplex.com/products/tigra_calendar/
// Public Domain Software... You're welcome.
// default settins
var A_TCALDEF = {
'months' : ['Φεβρουάριος', 'February', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
'imgpath' : '../agc/images/' // directory with calendar images
}
// date parsing function
function f_tcalParseDate (s_date) {
var re_date = /^\s*(\d{2,4})\-(\d{1,2})\-(\d{1,2})\s*$/;
if (!re_date.exec(s_date))
return alert ("Ακυρο date: '" + s_date + "'.\nAccepted format is yyyy-mm-dd.")
var n_day = Number(RegExp.$3),
n_month = Number(RegExp.$2),
n_year = Number(RegExp.$1);
if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Ακυρο month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays = new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Ακυρο day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);
}
// date generating function
function f_tcalGenerDate (d_date) {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
);
}
// implementation
function tcal (a_cfg, a_tpl) {
// apply default template if not specified
if (!a_tpl)
a_tpl = A_TCALDEF;
// register in global collections
if (!window.A_TCALS)
window.A_TCALS = [];
if (!window.A_TCALSIDX)
window.A_TCALSIDX = [];
this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
window.A_TCALS[this.s_id] = this;
window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
// assign methods
this.f_show = f_tcal_show;
this.f_hide = f_tcal_hide;
this.f_toggle = f_tcalToggle;
this.f_update = f_tcalUpdate;
this.f_relDate = f_tcalRelDate;
this.f_parseDate = f_tcalParseDate;
this.f_generDate = f_tcalGenerDate;
// create calendar icon
this.s_iconId = 'tcalico_' + this.s_id;
this.e_icon = f_getElement(this.s_iconId);
if (!this.e_icon) {
document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
this.e_icon = f_getElement(this.s_iconId);
}
// save received parameters
this.a_cfg = a_cfg;
this.a_tpl = a_tpl;
}
function f_tcal_show (d_date) {
// find input field
if (!this.a_cfg.controlname)
throw("TC: control name is not specified");
if (this.a_cfg.formname) {
var e_form = document.forms[this.a_cfg.formname];
if (!e_form)
throw("TC: form '" + this.a_cfg.formname + "' can not be found");
this.e_input = e_form.elements[this.a_cfg.controlname];
}
else
this.e_input = f_getElement(this.a_cfg.controlname);
if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
// dynamically create HTML elements if needed
this.e_div = f_getElement('tcal');
if (!this.e_div) {
this.e_div = document.createElement("DIV");
this.e_div.id = 'tcal';
document.body.appendChild(this.e_div);
}
this.e_shade = f_getElement('tcalShade');
if (!this.e_shade) {
this.e_shade = document.createElement("DIV");
this.e_shade.id = 'tcalShade';
document.body.appendChild(this.e_shade);
}
this.e_iframe = f_getElement('tcalIF')
if (b_ieFix && !this.e_iframe) {
this.e_iframe = document.createElement("IFRAME");
this.e_iframe.style.filter = 'alpha(opacity=0)';
this.e_iframe.id = 'tcalIF';
this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
document.body.appendChild(this.e_iframe);
}
// hide all calendars
f_tcal_hideAll();
// generate HTML and show calendar
this.e_icon = f_getElement(this.s_iconId);
if (!this.f_update())
return;
this.e_div.style.visibility = 'visible';
this.e_shade.style.visibility = 'visible';
if (this.e_iframe)
this.e_iframe.style.visibility = 'visible';
// change icon and status
this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
this.e_icon.title = 'Close Calendar';
this.b_visible = true;
}
function f_tcal_hide (n_date) {
if (n_date)
this.e_input.value = this.f_generDate(new Date(n_date));
// no action if not visible
if (!this.b_visible)
return;
// hide elements
if (this.e_iframe)
this.e_iframe.style.visibility = 'hidden';
if (this.e_shade)
this.e_shade.style.visibility = 'hidden';
this.e_div.style.visibility = 'hidden';
// change icon and status
this.e_icon = f_getElement(this.s_iconId);
this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
this.e_icon.title = 'Open Calendar';
this.b_visible = false;
}
function f_tcalToggle () {
return this.b_visible ? this.f_hide() : this.f_show();
}
function f_tcalUpdate (d_date) {
var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
var d_selected = this.e_input.value == ''
? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
: this.f_parseDate(this.e_input.value);
// figure out date to display
if (!d_date)
// selected by default
d_date = d_selected;
else if (typeof(d_date) == 'number')
// get from number
d_date = f_tcalResetTime(new Date(d_date));
else if (typeof(d_date) == 'string')
// parse from string
this.f_parseDate(d_date);
if (!d_date) return false;
// first date to display
var d_firstday = new Date(d_date);
d_firstday.setDate(1);
d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
var a_class, s_html = '<table class="ctrl"><tbody><tr>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
+ '</tr></tbody></table><table><tbody><tr class="wd">';
// print weekdays titles
for (var i = 0; i < 7; i++)
s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
s_html += '</tr>' ;
// print calendar table
var n_date, n_month, d_current = new Date(d_firstday);
while (d_current.getMonth() == d_date.getMonth() ||
d_current.getMonth() == d_firstday.getMonth()) {
// print row heder
s_html +='<tr>';
for (var n_wday = 0; n_wday < 7; n_wday++) {
a_class = [];
n_date = d_current.getDate();
n_month = d_current.getMonth();
// other month
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length] = 'othermonth';
// weekend
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length] = 'weekend';
// today
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length] = 'today';
// selected
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length] = 'selected';
s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
d_current.setDate(++n_date);
while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
d_current.setHours(d_current.getHours + 1);
d_current = f_tcalResetTime(d_current);
}
}
// print row footer
s_html +='</tr>';
}
s_html +='</tbody></table>';
// update HTML, positions and sizes
this.e_div.innerHTML = s_html;
var n_width = this.e_div.offsetWidth;
var n_height = this.e_div.offsetHeight;
var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
if (n_left < 0) n_left = 0;
this.e_div.style.left = n_left + 'px';
this.e_div.style.top = n_top + 'px';
this.e_shade.style.width = (n_width + 8) + 'px';
this.e_shade.style.left = (n_left - 1) + 'px';
this.e_shade.style.top = (n_top - 1) + 'px';
this.e_shade.innerHTML = b_ieFix
? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
if (this.e_iframe) {
this.e_iframe.style.left = n_left + 'px';
this.e_iframe.style.top = n_top + 'px';
this.e_iframe.style.width = (n_width + 6) + 'px';
this.e_iframe.style.height = (n_height + 6) +'px';
}
return true;
}
function f_getPosition (e_elemRef, s_coord) {
var n_pos = 0, n_offset,
e_elem = e_elemRef;
while (e_elem) {
n_offset = e_elem["offset" + s_coord];
n_pos += n_offset;
e_elem = e_elem.offsetParent;
}
// margin correction in some browsers
if (b_ieMac)
n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
else if (b_safari)
n_pos -= n_offset;
e_elem = e_elemRef;
while (e_elem != document.body) {
n_offset = e_elem["scroll" + s_coord];
if (n_offset && e_elem.style.overflow == 'scroll')
n_pos -= n_offset;
e_elem = e_elem.parentNode;
}
return n_pos;
}
function f_tcalRelDate (d_date, d_diff, s_units) {
var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
var d_result = new Date(d_date);
d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
if (d_result.getDate() != d_date.getDate())
d_result.setDate(0);
return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
}
function f_tcal_hideAll () {
for (var i = 0; i < window.A_TCALSIDX.length; i++)
window.A_TCALSIDX[i].f_hide();
}
function f_tcalResetTime (d_date) {
d_date.setHours(0);
d_date.setMinutes(0);
d_date.setSeconds(0);
d_date.setMilliseconds(0);
return d_date;
}
f_getElement = document.all ?
function (s_id) { return document.all[s_id] } :
function (s_id) { return document.getElementById(s_id) };
if (document.addEventListener)
window.addEventListener('scroll', f_tcal_hideAll, false);
if (window.attachEvent)
window.attachEvent('onscroll', f_tcal_hideAll);
// global variables
var s_userAgent = navigator.userAgent.toLowerCase(),
re_webkit = /WebKit\/(\d+)/i;
var b_mac = s_userAgent.indexOf('mac') != -1,
b_ie5 = s_userAgent.indexOf('msie 5') != -1,
b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
var b_ieFix = b_ie5 || b_ie6,
b_ieMac = b_mac && b_ie5,
b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
@@ -0,0 +1,201 @@
<?php
# call_log_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the inbound and outbound calls for a specific phone
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
# - $in_limit - ('10','20','50','100',...)
# - $out_limit - ('10','20','50','100',...)
#
#
# changes
# 50406-1013 - First build of script
# 50407-1452 - Added definable limits
# 50503-1236 - added session_name checking for extra security
# 50610-1158 - Added NULL check on MySQL results to reduced errors
# 50711-1202 - removed HTTP authentication in favor of user/pass vars
# 60323-1550 - added option for showing different number dialed in log
# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1202 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0028 - Converted ereg to preg functions
# 130603-2219 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1005 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($in_limit)) {$in_limit="100";}
if (!isset($out_limit)) {$out_limit="100";}
$number_dialed = 'number_dialed';
#$number_dialed = 'extension';
$version = '0.0.10';
$build = '130328-0028';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Έμφάνιση Καταγραμμένων Κλήσεων";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten δεν ισχύει ή πρωτόκολλο $protocol δεν ισχύει\n";
exit;
}
else
{
##### print outbound calls from the call_log table
$stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$out_calls_count = mysqli_num_rows($rslt);}
echo "$out_calls_count|";
$loop_count=0;
while ($out_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[3] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);}
echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|";
}
echo "\n";
##### print inbound calls from the live_inbound_log table
$stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$in_calls_count = mysqli_num_rows($rslt);}
echo "$in_calls_count|";
$loop_count=0;
while ($in_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[4] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
$callerIDnum = $row[3]; $callerIDname = $row[3];
$callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum);
$callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname);
echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,782 @@
<?php
# conf_exten_check.php version 2.8
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the meetme conference has live channels connected and which they are
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $ACTION - ('refresh','register')
# - $client - ('agc','vdc')
# - $conf_exten - ('8600011',...)
# - $exten - ('123test',...)
# - $auto_dial_level - ('0','1','1.2',...)
# - $campagentstdisp - ('YES',...)
#
# changes
# 50509-1054 - First build of script
# 50511-1112 - Added ability to register a conference room
# 50610-1159 - Added NULL check on MySQL results to reduced errors
# 50706-1429 - script changed to not use HTTP login vars, user/pass instead
# 50706-1525 - Added date-time display for vicidial client display
# 50816-1500 - Added random update to vicidial_live_agents table for vdc users
# 51121-1353 - Altered echo statements for several small PHP speed optimizations
# 60410-1424 - Added ability to grab calls-being-placed and agent status
# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1201 - Added variable filters to close security holes for login form
# 61128-2255 - Added update for manual dial vicidial_live_agents
# 70319-1542 - Added agent disabled display function
# 71122-0205 - Added vicidial_live_agent status output
# 80424-0442 - Added non_latin lookup from system_settings
# 80519-1425 - Added calls-in-queue tally
# 80703-1106 - Added API functionality for Hangup and Dispo
# 81104-0229 - Added mysql error logging capability
# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries
# 90102-1402 - Added check for system and database time synchronization
# 90120-1720 - Added compatibility for API pause/resume and dial a number
# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours
# 90408-0020 - Added API vtiger specific callback activity record ability
# 90508-0727 - Changed to PHP long tags
# 90706-1430 - Fixed AGENTDIRECT calls in queue display count
# 90908-1037 - Added DEAD call logging
# 91130-2022 - Added code for manager override of in-group selection
# 91228-1341 - Added API fields update functions
# 100109-1337 - Fixed Manual dial live call detection
# 100527-0957 - Added send_dtmf, transfer_conference and park_call API functions
# 100727-2209 - Added timer actions for hangup, extension, callmenu and ingroup as well as destination
# 101123-1105 - Added api manual dial queue feature to external_dial function
# 101208-0308 - Moved the Calls in Queue count and other counts outside of the autodial section (issue 406)
# 110610-0059 - Small fix for manual dial calls lasting more than 100 minutes in real-time report
# 120809-2353 - Added external_recording function
# 121028-2305 - Added extra check on session_name to validate agent screen requests
# 130328-0011 - Converted ereg to preg functions
# 130603-2218 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1015 - Changed to use PHP mysqli functions
# 140126-0659 - Added external_pause_code function
#
$version = '2.8-37';
$build = '140126-0659';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=39;
$one_mysql_log=0;
$DB=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
### If you have globals turned off uncomment these lines
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];}
elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];}
if (isset($_GET["client"])) {$client=$_GET["client"];}
elseif (isset($_POST["client"])) {$client=$_POST["client"];}
if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];}
elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];}
elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];}
if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];}
elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^\-_0-9a-zA-Z]/i","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($client)) {$client="agc";}
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_TIME = date("Ymd_His");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$random = (rand(1000000, 9999999) + 10000000);
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build MEETME: $conf_exten server_ip: $server_ip-->\n";
echo "<title>Ελεγχος τηλ.σύνδεσης διάσκεψης";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if ($ACTION == 'refresh')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($conf_exten)<1)
{
$channel_live=0;
echo "Conf Exten $conf_exten δεν ισχύει\n";
exit;
}
else
{
if ($client == 'vdc')
{
$Acount=0;
$Scount=0;
$AexternalDEAD=0;
$Aagent_log_id='';
$Acallerid='';
$DEADcustomer=0;
$Astatus='';
$Acampaign_id='';
### see if the agent has a record in the vicidial_live_agents table
$stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Acount=$row[0];
### see if the agent has a record in the vicidial_session_data table
$stmt="SELECT count(*) from vicidial_session_data where user='$user' and server_ip='$server_ip' and session_name='$session_name';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03039',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Scount=$row[0];
if ($Acount > 0)
{
$stmt="SELECT status,callerid,agent_log_id,campaign_id,lead_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Astatus = $row[0];
$Acallerid = $row[1];
$Aagent_log_id = $row[2];
$Acampaign_id = $row[3];
$Alead_id = $row[4];
$api_manual_dial='STANDARD';
$stmt = "SELECT api_manual_dial FROM vicidial_campaigns where campaign_id='$Acampaign_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$vcc_conf_ct = mysqli_num_rows($rslt);
if ($vcc_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$api_manual_dial = $row[0];
}
}
# ### find out if external table shows agent should be disabled
# $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_to_mysqli($stmt, $link);
# $row=mysqli_fetch_row($rslt);
# $AexternalDEAD=$row[0];
##### BEGIN check στο calls in queue, number of active calls in the campaign
if ($campagentstdisp == 'YES')
{
$ADsql='';
### grab the status of this agent to display
$stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Alogin=$row[0];
$Acampaign=$row[1];
$AccampSQL=$row[2];
$AccampSQL = preg_replace('/\s\-/','', $AccampSQL);
$AccampSQL = preg_replace('/\s/',"','", $AccampSQL);
if (preg_match('/AGENTDIRECT/i', $AccampSQL))
{
$AccampSQL = preg_replace('/AGENTDIRECT/i','', $AccampSQL);
$ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )";
}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$RingCalls=$row[0];
if ($RingCalls > 0) {$RingCalls = "<font class=\"queue_text_red\">Κλήσεις στη ουρά: $RingCalls</font>";}
else {$RingCalls = "<font class=\"queue_text\">Κλήσεις στη ουρά: $RingCalls</font>";}
### grab the number of calls being placed from this server and campaign
$stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$DiaLCalls=$row[0];
}
else
{
$Alogin='N';
$RingCalls='N';
$DiaLCalls='N';
}
##### END check στο calls in queue, number of active calls in the campaign
if ($auto_dial_level > 0)
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent is στο is hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03018',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) and (preg_match("/^M/",$Acallerid)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03038',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03019',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03020',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03021',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
else
{
### update the vicidial_live_agents every second with a new random number so it is shown to be alive
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_to_mysqli($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
##### BEGIN DEAD logging section #####
### find whether the call the agent is στο is hung up
$stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$AcalleridCOUNT=$row[0];
if ( ($AcalleridCOUNT > 0) and (preg_match("/INCALL/i",$Astatus)) )
{
$updateNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_auto_calls set last_update_time='$updateNOW_TIME' where callerid='$Acallerid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03037',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ( ($AcalleridCOUNT < 1) and (preg_match("/INCALL/i",$Astatus)) and (strlen($Aagent_log_id) > 0) )
{
$DEADcustomer++;
### find whether the agent log record has already logged DEAD
$stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03030',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$Aagent_log_idCOUNT=$row[0];
if ($Aagent_log_idCOUNT < 1)
{
$NEWdead_epoch = date("U");
$deadNOW_TIME = date("Y-m-d H:i:s");
$stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03031',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03032',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
##### END DEAD logging section #####
}
### grab the API hangup and API dispo fields in vicidial_live_agents
$stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds,external_dtmf,external_transferconf,external_park,external_timer_action_destination,external_recording,external_pause_code from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$external_hangup = $row[0];
$external_status = $row[1];
$external_pause = $row[2];
$external_dial = $row[3];
$external_update_fields = $row[4];
$external_update_fields_data = $row[5];
$timer_action = $row[6];
$timer_action_message = $row[7];
$timer_action_seconds = $row[8];
$external_dtmf = $row[9];
$external_transferconf = $row[10];
$external_park = $row[11];
$timer_action_destination = $row[12];
$external_recording = $row[13];
$external_pause_code = $row[14];
$MDQ_count=0;
if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') )
{
$stmt="SELECT count(*) FROM vicidial_manual_dial_queue where user='$user' and status='READY';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03033',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_count_record_ct = mysqli_num_rows($rslt);
if ($mdq_count_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_count = $row[0];
}
if ( ($MDQ_count > 0) and (strlen($external_dial) < 16) and ($Astatus=='PAUSED') and ($Alead_id < 1) )
{
$stmt="SELECT mdq_id,external_dial FROM vicidial_manual_dial_queue where user='$user' and status='READY' order by entry_time limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03034',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mdq_record_ct = mysqli_num_rows($rslt);
if ($mdq_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$MDQ_mdq_id = $row[0];
$MDQ_external_dial = $row[1];
$external_dial = $MDQ_external_dial;
$stmt="UPDATE vicidial_manual_dial_queue SET status='QUEUE' where mdq_id='$MDQ_mdq_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$UMDQaffected_rows_update = mysqli_affected_rows($link);
if ($UMDQaffected_rows_update > 0)
{
$stmt="UPDATE vicidial_live_agents SET external_dial='$MDQ_external_dial' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03036',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMDQaffected_rows_update = mysqli_affected_rows($link);
}
}
}
}
if (strlen($external_status)<1) {$external_status = '::::::::::';}
$web_epoch = date("U");
$stmt="SELECT UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$server_epoch = $row[0];
$db_epoch = $row[1];
$time_diff = ($server_epoch - $db_epoch);
$web_diff = ($db_epoch - $web_epoch);
##### check for in-group change details
$InGroupChangeDetails = '0|||';
$manager_ingroup_set=0;
$stmt="SELECT count(*) FROM vicidial_live_agents where user='$user' and manager_ingroup_set='SET';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03022',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mis_record_ct = mysqli_num_rows($rslt);
if ($mis_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$manager_ingroup_set = $row[0];
}
if ($manager_ingroup_set > 0)
{
$stmt="UPDATE vicidial_live_agents SET closer_campaigns=external_ingroups, manager_ingroup_set='Y' where user='$user' and manager_ingroup_set='SET';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMISaffected_rows_update = mysqli_affected_rows($link);
if ($VLAMISaffected_rows_update > 0)
{
$stmt="SELECT external_ingroups,external_blended,external_igb_set_user,outbound_autodial,dial_method FROM vicidial_live_agents vla, vicidial_campaigns vc where user='$user' and manager_ingroup_set='Y' and vla.campaign_id=vc.campaign_id;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03024',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$migs_record_ct = mysqli_num_rows($rslt);
if ($migs_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_ingroups = $row[0];
$external_blended = $row[1];
$external_igb_set_user = $row[2];
$outbound_autodial = $row[3];
$dial_method = $row[4];
$stmt="SELECT full_name FROM vicidial_users where user='$external_igb_set_user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03025',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$mign_record_ct = mysqli_num_rows($rslt);
if ($mign_record_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$external_igb_set_name = $row[0];
}
$NEWoutbound_autodial='N';
if ( ($external_blended > 0) and ($dial_method != "INBOUND_MAN") and ($dial_method != "MANUAL") )
{$NEWoutbound_autodial='Y';}
$stmt="UPDATE vicidial_live_agents SET outbound_autodial='$NEWoutbound_autodial' 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,'03026',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAMIBaffected_rows_update = mysqli_affected_rows($link);
$InGroupChangeDetails = "1|$external_blended|$external_igb_set_user|$external_igb_set_name";
$stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$Acampaign_id',event_date='$NOW_TIME',blended='$external_blended',closer_campaigns='$external_ingroups',manager_change='$external_igb_set_user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03027',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
}
##### grab the shift information the agent
$stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group = $row[0];
$VU_agent_shift_enforcement_override = $row[1];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$shift_enforcement = $row[0];
$LOGgroup_shiftsSQL = preg_replace('/\s\s/','',$row[1]);
$LOGgroup_shiftsSQL = preg_replace('/\s/',"','",$LOGgroup_shiftsSQL);
$LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')";
### CHECK TO SEE IF πράκτορας IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR
$Ashift_logout=0;
if ( ( (preg_match("/ALL/",$shift_enforcement)) and (!preg_match("/OFF|START/",$VU_agent_shift_enforcement_override)) ) or (preg_match("/ALL/",$VU_agent_shift_enforcement_override)) )
{
$shift_ok=0;
if (strlen($LOGgroup_shiftsSQL) < 3)
{$Ashift_logout++;}
else
{
$HHMM = date("Hi");
$wday = date("w");
$stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);}
$shifts_to_print = mysqli_num_rows($rslt);
$o=0;
while ( ($shifts_to_print > $o) and ($shift_ok < 1) )
{
$rowx=mysqli_fetch_row($rslt);
$shift_id = $rowx[0];
$shift_start_time = $rowx[1];
$shift_length = $rowx[2];
$shift_weekdays = $rowx[3];
if (preg_match("/$wday/i",$shift_weekdays))
{
$HHshift_length = substr($shift_length,0,2);
$MMshift_length = substr($shift_length,3,2);
$HHshift_start_time = substr($shift_start_time,0,2);
$MMshift_start_time = substr($shift_start_time,2,2);
$HHshift_end_time = ($HHshift_length + $HHshift_start_time);
$MMshift_end_time = ($MMshift_length + $MMshift_start_time);
if ($MMshift_end_time > 59)
{
$MMshift_end_time = ($MMshift_end_time - 60);
$HHshift_end_time++;
}
if ($HHshift_end_time > 23)
{$HHshift_end_time = ($HHshift_end_time - 24);}
$HHshift_end_time = sprintf("%02s", $HHshift_end_time);
$MMshift_end_time = sprintf("%02s", $MMshift_end_time);
$shift_end_time = "$HHshift_end_time$MMshift_end_time";
if (
( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or
( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or
( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) )
)
{$shift_ok++;}
}
$o++;
}
if ($shift_ok < 1)
{$Ashift_logout++;}
}
}
if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (preg_match("/0\$/i",$StarTtime)) )
{$Alogin='TIME_SYNC';}
if ( ($Acount < 1) or ($Scount < 1) )
{$Alogin='DEAD_VLA';}
if ($AexternalDEAD > 0)
{$Alogin='DEAD_EXTERNAL';}
if ($Ashift_logout > 0)
{$Alogin='SHIFT_LOGOUT';}
if ($external_pause == 'LOGOUT')
{
$Alogin='API_LOGOUT';
$external_pause='';
}
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . "\n";
if (strlen($timer_action) > 3)
{
$stmt="UPDATE vicidial_live_agents SET external_timer_action='' 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,'03028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAETAaffected_rows_update = mysqli_affected_rows($link);
}
}
$total_conf=0;
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$sip_list = mysqli_num_rows($rslt);}
# echo "$sip_list|";
$loop_count=0;
while ($sip_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
# echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++; $total_conf++;
$row=mysqli_fetch_row($rslt);
$ChannelA[$total_conf] = "$row[0]";
if ($format=='debug') {echo "\n<!-- $row[0] -->";}
}
}
$channels_list = ($channels_list + $sip_list);
echo "$channels_list|";
$counter=0;
$countecho='';
while($total_conf > $counter)
{
$counter++;
$countecho = "$countecho$ChannelA[$counter] ~";
# echo "$ChannelA[$counter] ~";
}
echo "$countecho\n";
}
if ($ACTION == 'register')
{
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($conf_exten)<1) || (strlen($exten)<1) )
{
$channel_live=0;
echo "Conf Exten $conf_exten δεν ισχύει or Exten $exten δεν ισχύει\n";
exit;
}
else
{
$stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);}
}
echo "Διάσκεψη $conf_exten έχει καταχωρηθεί $exten\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect.php version 2.6
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass");
if (!$link)
{
die('MySQL connect ERROR: ' . mysql_error());
}
mysql_select_db("$VARDB_database");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
@@ -0,0 +1,65 @@
<?php
#
# dbconnect_mysqli.php version 2.8
#
# database connection settings and some global web settings
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES:
# 130328-0022 - Converted ereg to preg functions
# 130802-0957 - Changed to PHP mysqli functions
#
if ( file_exists("/etc/astguiclient.conf") )
{
$DBCagc = file("/etc/astguiclient.conf");
foreach ($DBCagc as $DBCline)
{
$DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline);
if (preg_match("/^PATHlogs/", $DBCline))
{$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);}
if (preg_match("/^PATHweb/", $DBCline))
{$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);}
if (preg_match("/^VARserver_ip/", $DBCline))
{$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);}
if (preg_match("/^VARDB_server/", $DBCline))
{$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);}
if (preg_match("/^VARDB_database/", $DBCline))
{$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);}
if (preg_match("/^VARDB_user/", $DBCline))
{$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);}
if (preg_match("/^VARDB_pass/", $DBCline))
{$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);}
if (preg_match("/^VARDB_port/", $DBCline))
{$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);}
}
}
else
{
#defaults for DB connection
$VARDB_server = 'localhost';
$VARDB_port = '3306';
$VARDB_user = 'cron';
$VARDB_pass = '1234';
$VARDB_database = '1234';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
}
$link=mysqli_connect("$VARDB_server", "$VARDB_user", "$VARDB_pass", "$VARDB_database", $VARDB_port);
if (!$link)
{
die('MySQL connect ERROR: ' . mysqli_error($link));
}
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBRooTWritablE = '1';
$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings
$flag_channels=0;
$flag_string = 'VICIast20';
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,353 @@
<?php
# inbound_popup.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed to open up when a live_inbound call comes in giving the user
# options of what to do with the call or options to lookup the callerID on various web sites
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $uniqueid - ('1234567890.123456',...)
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $ext_context - ('default','demo',...)
# - $ext_priority - ('1','2',...)
# - $voicemail_dump_exten - ('85026666666666')
# - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL)
#
#
# changes
# 50428-1500 - First build of script display only
# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links
# 50503-1244 - added session_name checking for extra security
# 50711-1203 - removed HTTP authentication in favor of user/pass vars
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2215 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1008 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];}
elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];}
if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];}
elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];}
if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];}
elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];}
elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];}
if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);}
else {$local_web_callerID_URL = '';}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$DO = '-1';
if ( (preg_match("/^Zap/i",$channel)) and (!preg_match("/-/i",$channel)) ) {$channel = "$channel$DO";}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
$forever_stop=0;
$user_abb = "$user$user$user$user";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build UNIQUEID: $uniqueid server_ip: $server_ip-->\n";
?>
<script language="Javascript">
var server_ip = '<?php echo $server_ip ?>';
var epoch_sec = '<?php echo $StarTtime ?>';
var user_abb = '<?php echo $user_abb ?>';
var vmail_box = '<?php echo $vmail_box ?>';
var ext_context = '<?php echo $ext_context ?>';
var ext_priority = '<?php echo $ext_priority ?>';
var voicemail_dump_exten = '<?php echo $voicemail_dump_exten ?>';
var session_name = '<?php echo $session_name ?>';
var user = '<?php echo $user ?>';
var pass = '<?php echo $pass ?>';
// ################################################################################
// Send Hangup command for Live call connected to phone now to Manager
function livehangup_send_hangup(taskvar)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "HLagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
livehangup_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Hangup&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(livehangup_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// Send Redirect command for ringing call to go directly to your voicemail
function liveredirect_send_vmail(taskvar,taskbox)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
var queryCID = "RVagcP" + epoch_sec + user_abb;
var hangupvalue = taskvar;
var mailboxvalue = taskbox;
liveredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Redirect&format=text&channel=" + hangupvalue + "&queryCID=" + queryCID + "&exten=" + voicemail_dump_exten + "" + mailboxvalue + "&ext_context=" + ext_context + "&ext_priority=" + ext_priority;
xmlhttp.open('POST', 'manager_send.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(liveredirect_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
Nactiveext = null;
Nactiveext = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
delete xmlhttp;
}
call_action_link_clear();
}
// ################################################################################
// timeout to deactivate the call action links after 30 δευτερόλεπτα
function link_timeout()
{
window.focus();
setTimeout("call_action_link_clear()", 30000);
}
// ################################################################################
// deactivates the call action links
function call_action_link_clear()
{
document.getElementById("callactions").innerHTML = "";
}
</script>
<?php
echo "<title>ΕΝΕΡΓΗ ΕΙΣΕΡΧΟΜΕΝΗ ΚΛΗΣΗ";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#CCC2E0\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"link_timeout();\">\n";
echo "<CENTER><H2>ΕΝΕΡΓΗ ΕΙΣΕΡΧΟΜΕΝΗ ΚΛΗΣΗ</H2>\n";
echo "<B>$NOW_TIME</B><BR><BR>\n";
}
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if (strlen($uniqueid)<9)
{
$channel_live=0;
echo "Uniqueid $uniqueid δεν ισχύει\n";
exit;
}
else
{
$stmt="SELECT uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,acknowledged,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$channels_list = mysqli_num_rows($rslt);
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt|||||
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
echo "<table width=95% cellpadding=1 cellspacing=3>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Channel: </td><td align=left>$row[1]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>CallerID: </td><td align=left>$row[3]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n";
$phone = preg_replace("/.*\</i","",$row[3]);
$phone = preg_replace("/\>.*/i","",$phone);
$NPA = substr($phone, 0, 3);
$NXX = substr($phone, 3, 3);
$XXXX = substr($phone, 6, 4);
$D='-';
echo "<a href=\"http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&q=$NPA+$NXX+$XXXX&btnG=Search\" target=\"_blank\">GOOGLE</a> - \n";
echo "<a href=\"http://www.anywho.com/qry/wp_rl?npa=$NPA&telephone=$NXX$XXXX\" target=\"_blank\">ANYWHO</a> - \n";
echo "<a href=\"http://www.switchboard.com/bin/cgirlookup.dll?SR=&MEM=1&LNK=32%3A36&type=BOTH&at=$NPA&e=$NXX&n=$XXXX&search.x=55&search.y=20\" target=\"_blank\">SWITCHBOARD</a> - \n";
echo "<a href=\"http://yellowpages.superpages.com/listings.jsp?SRC=&STYPE=&PG=L&CB=&C=&N=&E=&T=&S=&Z=&A=727&X=533&P=8730&AXP=$NPA$NXX$XXXX&R=N&PS=15&search=Find+It\" target=\"_blank\">VERIZON</a> - \n";
echo "<a href=\"http://www.whitepages.com/1014/log_click/search/Reverse_Τηλ?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">WHITEPAGES</a> - \n";
echo "<a href=\"http://www.411.com/10742/search/Reverse_Τηλ?phone=%28$NPA%29+$NXX$D$XXXX\" target=\"_blank\">411.COM</a> - \n";
echo "<a href=\"http://www.phonenumber.com/10006/search/Reverse_Τηλ?npa=$NPA&phone=$NXX$XXXX\" target=\"_blank\">411.COM</a> - \n";
$local_web_callerID_QUERY_STRING ='';
$local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA";
$local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX";
$local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX";
$local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]";
$local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]";
$local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]";
$local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]";
$local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]";
$local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]";
$local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]";
$local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]";
echo "<a href=\"$local_web_callerID_URL$local_web_callerID_QUERY_STRING\" target=\"_blank\">CUSTOM</a> - \n";
echo "</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Αριθμός που καλέσατε: </td><td align=left>$row[8]</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td>Σημειώσεις:</td><td align=left>$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|</td></tr>\n";
echo "<tr bgcolor=\"#DDDDFF\"><td colspan=2 align=center>\n<span id=\"callactions\">";
echo "<a href=\"#\" onclick=\"livehangup_send_hangup('$row[1]');return false;\">ΚΛΕΙΣΙΜΟ</a> - \n";
echo "<a href=\"#\" onclick=\"liveredirect_send_vmail('$row[1]','$vmail_box');return false;\">ΣΤΕΙΛΕ ΣΤΟ ΦΩΝΗΤΙΚΟ ΤΑΧΥΔΡΟΜΕΙΟ ΜΟΥ</a>\n";
echo "</span></td></tr>\n";
echo "</table>\n";
$stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,284 @@
<?php
# live_exten_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the client channel is live and to what channel it is connected
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50404-1249 - First build of script
# 50406-1402 - added connected trunk lookup
# 50428-1452 - added live_inbound check for exten on 2nd line of output
# 50503-1233 - added session_name checking for extra security
# 50524-1429 - added parked calls count
# 50610-1204 - Added NULL check on MySQL results to reduced errors
# 50711-1204 - removed HTTP authentication in favor of user/pass vars
# 60103-1541 - added favorite extens status display
# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1203 - Added variable filters to close security holes for login form
# 60825-1029 - Fixed translation variable issue ChannelA
# 90508-0727 - Changed to PHP long tags
# 130328-0027 - Converted ereg to preg functions
# 130603-2214 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1522 - Added optional encrypted passwords compatibility
# 130802-1009 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];}
elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];}
if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];}
elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '2.6-13';
$build = '130328-0027';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Ελεγχος ενεργής τηλ.σύνδεσης";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
echo "DateTime: $NOW_TIME|";
echo "UnixTime: $StarTtime|";
$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
echo "$row[0]|";
$MT[0]='';
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten δεν ισχύει ή πρωτόκολλο $protocol δεν ισχύει\n";
exit;
}
else
{
$stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
echo "$channels_list|";
$loop_count=0;
while ($channels_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$ChanneLA[$loop_count] = "$row[0]";
$ChanneLB[$loop_count] = "$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
$counter=0;
while($loop_count > $counter)
{
$counter++;
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$trunk_count = mysqli_num_rows($rslt);}
if ($trunk_count>0)
{
$row=mysqli_fetch_row($rslt);
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $row[0]|";
}
else
{
echo "Conversation: $counter ~";
echo "ChannelA: $ChanneLA[$counter] ~";
echo "ChannelB: $ChanneLB[$counter] ~";
echo "ChannelBtrunk: $ChanneLA[$counter]|";
}
}
}
}
}
echo "\n";
### check for live_inbound entry
$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$channels_list = mysqli_num_rows($rslt);}
if ($channels_list>0)
{
$row=mysqli_fetch_row($rslt);
$LIuniqueid = "$row[0]";
$LIchannel = "$row[1]";
$LIcallerid = "$row[3]";
$LIdatetime = "$row[6]";
echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|";
if ($format=='debug') {echo "\n<!-- $row[0]|$row[1]|$row[2]|$row[3]|$row[4]|$row[5]|$row[6]|$row[7]|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]| -->";}
}
echo "\n";
### if favorites are present do a lookup to see if any are active
if ($favorites_count > 0)
{
$favorites = explode(',',$favorites_list);
$h=0;
$favs_print='';
while ($favorites_count > $h)
{
$fav_extension = explode('/',$favorites[$h]);
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$favs_print .= "$fav_extension[1]: $row[0] ~";
$h++;
}
echo "$favs_print\n";
}
if ($format=='debug') {echo "\n<!-- |$favorites_count|$favorites_list| -->";}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,152 @@
<?php
# park_calls_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the details on the parked calls on the server
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
#
#
# changes
# 50524-1515 - First build of script
# 50711-1208 - removed HTTP authentication in favor of user/pass vars
# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1205 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0024 - Converted ereg to preg functions
# 130603-2213 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1024 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($park_limit)) {$park_limit="1000";}
$version = '0.0.4';
$build = '60619-1205';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Εμφάνιση Σταθμευμένων Κλήσεων";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten δεν ισχύει ή πρωτόκολλο $protocol δεν ισχύει\n";
exit;
}
else
{
##### print parked calls from the parked_channels table
$stmt="SELECT channel,server_ip,channel_group,extension,parked_by,parked_time from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$park_calls_count = mysqli_num_rows($rslt);
echo "$park_calls_count\n";
$loop_count=0;
while ($park_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,919 @@
<?php
# phone_only.php - the web-based web-phone-only client application
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 110511-1336 - First Build
# 110526-1757 - Added webphone_auto_answer option
# 120223-2124 - Removed logging of good login passwords if webroot writable is enabled
# 130123-1923 - Added ability to use user-login-first options.php option
# 130328-0005 - Converted ereg to preg functions
# 130603-2212 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130718-0946 - Fixed login bug
# 130802-1139 - Changed to PHP mysqli functions
#
$version = '2.8-8p';
$build = '130802-1139';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=73;
$one_mysql_log=0;
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];}
elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
if (!isset($flag_channels))
{
$flag_channels=0;
$flag_string='';
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("[^0-9a-z]","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_pass);
$forever_stop=0;
if ($force_logout)
{
echo "Έχετε αποσυνδεθεί. Σας ευχαριστούμε\n";
exit;
}
$isdst = date("I");
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$tsNOW_TIME = date("YmdHis");
$FILE_TIME = date("Ymd-His");
$loginDATE = date("Ymd");
$CIDdate = date("ymdHis");
$month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y"));
$past_month_date = date("Y-m-d H:i:s",$month_old);
$minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y"));
$past_minutes_date = date("Y-m-d H:i:s",$minutes_old);
$webphone_width = 460;
$webphone_height = 500;
$PHP_SELF=$_SERVER['PHP_SELF'];
$random = (rand(1000000, 9999999) + 10000000);
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09001',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$vdc_header_date_format = $row[1];
$vdc_customer_date_format = $row[2];
$vdc_header_phone_format = $row[3];
$WeBRooTWritablE = $row[4];
$timeclock_end_of_day = $row[5];
$vtiger_url = $row[6];
$enable_vtiger_integration = $row[7];
$outbound_autodial_active = $row[8];
$enable_second_webform = $row[9];
$user_territories_active = $row[10];
$static_agent_url = $row[11];
$custom_fields_enabled = $row[12];
}
##### END SETTINGS LOOKUP #####
###########################################
##### DEFINABLE SETTINGS AND OPTIONS
###########################################
# set defaults for hard-coded variables
$user_login_first = '0'; # set to 1 to have the vicidial_user login before the Σύνδεση τηλεφώνου
$clientDST = '1'; # set to 1 to check for DST στο server for agent time
$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login
$hide_timeclock_link = '0'; # set to 1 to hide the timeclock link στο the agent login screen
$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window
$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500
$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770
$webphone_width = 460; # set the webphone frame width
$webphone_height = 500; # set the webphone frame height
$webphone_pad = 0; # set the table cellpadding for the webphone
$webphone_location = 'right'; # set the location στο the agent screen 'right' or 'bar'
$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6
$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0
$FORM_COLOR = '#EFEFEF';
$SIDEBAR_COLOR = '#F6F6F6';
# if options file exists, use the override values for the above variables
# see the options-example.php file for more information
if (file_exists('options.php'))
{
require_once('options.php');
}
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/phone_only\.php/i','',$agcPAGE);
if (strlen($static_agent_url) > 5)
{$agcPAGE = $static_agent_url;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../agc/css/style.css" />
<link rel="stylesheet" type="text/css" href="../agc/css/custom.css" />
';
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build -->\n";
echo "<!-- BROWSER: $BROWSER_WIDTH x $BROWSER_HEIGHT $JS_browser_width x $JS_browser_height -->\n";
$stmt="SELECT user_group from vicidial_users where user='$VD_login';";
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09002',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$VU_user_group=$row[0];
if ($relogin == 'YES')
{
echo "<title>Τηλ web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Timeclock</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_el/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Ελληνικά <img src=\"../agc/images/el.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Τηλ-Only Σύνδεση </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"$phone_pass\" /></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση χρήστη: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης χρήστη: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ΥΠΟΒΑΛΕΤΕ\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($user_login_first == 1)
{
if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) )
{
echo "<title>Τηλ web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Timeclock</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_el/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Ελληνικά <img src=\"../agc/images/el.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" id=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Τηλ-Only Σύνδεση </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση χρήστη: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης χρήστη: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ΥΠΟΒΑΛΕΤΕ\" value=\"Submit\" /> &nbsp; \n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) )
{
$stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09073',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$phone_login=$row[0];
$phone_pass=$row[1];
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Τηλ web client: Σύνδεση Τηλεφώνου</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Timeclock</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_el/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Ελληνικά <img src=\"../agc/images/el.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Τηλ-Only Σύνδεση </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ΥΠΟΒΑΛΕΤΕ\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
}
}
if ( (strlen($phone_login) < 1) or (strlen($phone_pass) < 1) )
{
echo "<title>Τηλ web client: Σύνδεση Τηλεφώνου</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Timeclock</a><br />\n";}
echo "<table width=100%><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_el/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Ελληνικά <img src=\"../agc/images/el.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Τηλ-Only Σύνδεση </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=\"10\" maxlength=\"20\" value=\"\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ΥΠΟΒΑΛΕΤΕ\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./vicidial_auth_entries.txt", "a");}
$VDloginDISPLAY=0;
if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) )
{
$VDloginDISPLAY=1;
}
else
{
$auth=0;
$auth_message = user_authorization($VD_login,$VD_pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if($auth>0)
{
##### grab the full name of the agent
$stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,agent_call_log_view_override,agent_choose_blended,agent_lead_search_override from vicidial_users where user='$VD_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09004',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$LOGfullname = $row[0];
$user_level = $row[1];
$VU_user_group = $row[10];
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts,agent_status_viewable_groups,agent_status_view_time,agent_call_log_view,agent_xfer_consultative,agent_xfer_dial_override,agent_xfer_vm_transfer,agent_xfer_blind_transfer,agent_xfer_dial_with_customer,agent_xfer_park_customer_dial,agent_fullscreen,webphone_url_override,webphone_dialpad_override,webphone_systemkey_override from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09005',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$agent_fullscreen = $row[12];
$webphone_url = $row[13];
$webphone_dialpad_override = $row[14];
$system_key = $row[15];
if ( ($webphone_dialpad_override != 'DISABLED') and (strlen($webphone_dialpad_override) > 0) )
{$webphone_dialpad = $webphone_dialpad_override;}
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|GOOD|$date|$VD_login|XXXX|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
$user_abb = "$VD_login$VD_login$VD_login$VD_login";
while ( (strlen($user_abb) > 4) and ($forever_stop < 200) )
{$user_abb = preg_replace("/^./i","",$user_abb); $forever_stop++;}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "vdweb|FAIL|$date|$VD_login|XXXX|$ip|$browser|\n");
fclose($fp);
}
$VDloginDISPLAY=1;
$VDdisplayMESSAGE = "Η σύνδεση δεν είναι σωστή, παρακαλώ προσπαθήστε πάλι<br />";
if ($auth_message == 'LOCK')
{$VDdisplayMESSAGE = "Too many login attempts, try again in 15 minutes<br />";}
}
}
if ($VDloginDISPLAY)
{
echo "<title>Τηλ web client: Login</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Timeclock</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_el/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Ελληνικά <img src=\"../agc/images/el.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\" />\n";
echo "<input type=\"hidden\" name=\"phone_login\" value=\"$phone_login\" />\n";
echo "<input type=\"hidden\" name=\"phone_pass\" value=\"$phone_pass\" />\n";
echo "<center><br /><b>$VDdisplayMESSAGE</b><br /><br />";
echo "<table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Τηλ-Only Σύνδεση </td>";
echo "</tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"> &nbsp; </font></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση χρήστη: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"VD_login\" size=\"10\" maxlength=\"20\" value=\"$VD_login\" /></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης χρήστη: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"VD_pass\" size=\"10\" maxlength=\"20\" value=\"$VD_pass\" /></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ΥΠΟΒΑΛΕΤΕ\" value=\"Submit\" /> &nbsp; \n";
echo "<span id=\"LogiNReseT\"></span></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</font></td></tr>\n";
echo "</table>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
$original_phone_login = $phone_login;
# code for parsing load-balanced agent phone allocation where agent interface
# will send multiple phones-table logins so that the script can determine the
# server that has the fewest agents logged into it.
# login: ca101,cb101,cc101
$alias_found=0;
$stmt="select count(*) from phones_alias where alias_id = '$phone_login';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09006',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_found = "$row[0]";
}
if ($alias_found > 0)
{
$stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09007',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysqli_num_rows($rslt);
if ($alias_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$alias_name = "$row[0]";
$phone_login = "$row[1]";
}
}
$pa=0;
if ( (preg_match('/,/',$phone_login)) and (strlen($phone_login) > 2) )
{
$phoneSQL = "(";
$phones_auto = explode(',',$phone_login);
$phones_auto_ct = count($phones_auto);
while($pa < $phones_auto_ct)
{
if ($pa > 0)
{$phoneSQL .= " or ";}
$desc = ($phones_auto_ct - $pa); # traverse in reverse order
$phoneSQL .= "(login='$phones_auto[$desc]' and pass='$phone_pass')";
$pa++;
}
$phoneSQL .= ")";
}
else {$phoneSQL = "login='$phone_login' and pass='$phone_pass'";}
$authphone=0;
#$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';";
$stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and active_asterisk_server='Y' and phones.server_ip=servers.server_ip;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09008',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$authphone=$row[0];
if (!$authphone)
{
echo "<title>Τηλ web client: Σύνδεση Τηλεφώνου Error</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
if ($hide_timeclock_link < 1)
{echo "<a href=\"./timeclock.php?referrer=agent&amp;pl=$phone_login&amp;pp=$phone_pass&amp;VD_login=$VD_login&amp;VD_pass=$VD_pass\"> Timeclock</a><br />\n";}
echo "<table width=\"100%\"><tr><td></td>\n";
echo "<!-- ILPV -->\n";
echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP NOWRAP><a href=\"../agc_en/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">English <img src=\"../agc/images/en.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n";echo "<TD WIDTH=100 ALIGN=RIGHT VALIGN=TOP BGCOLOR=\"#CCFFCC\" NOWRAP><a href=\"../agc_el/phone_only.php?relogin=YES&VD_login=$VD_login&VD_campaign=$VD_campaign&phone_login=$phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Ελληνικά <img src=\"../agc/images/el.gif\" BORDER=0 HEIGHT=14 WIDTH=20></a></TD>\n"; echo "</tr></table>\n";
echo "<form name=\"vicidial_form\" id=\"vicidial_form\" action=\"$agcPAGE\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"DB\" value=\"$DB\">\n";
echo "<input type=\"hidden\" name=\"VD_login\" value=\"$VD_login\" />\n";
echo "<input type=\"hidden\" name=\"VD_pass\" value=\"$VD_pass\" />\n";
echo "<br /><br /><br /><center><table width=\"460px\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$MAIN_COLOR\"><tr bgcolor=\"white\">";
echo "<td align=\"left\" valign=\"bottom\"><img src=\"../agc/images/vdc_tab_vicidial.gif\" border=\"0\" alt=\"VICIdial\" /></td>";
echo "<td align=\"center\" valign=\"middle\"> Τηλ-Only Σύνδεση Error</td>";
echo "</tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><font size=\"1\"> &nbsp; <br /><font size=\"3\">Συγγνώμη, αλλά η τηλεφωνική σύνδεση και ο κωδικός πρόσβασής σας δεν είναι ενεργά σε αυτό το σύστημα, παρακαλώ προσπαθήστε πάλι: <br /> &nbsp;</font></td></tr>\n";
echo "<tr><td align=\"right\">Σύνδεση Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"text\" name=\"phone_login\" size=\"10\" maxlength=\"20\" value=\"$phone_login\"></td></tr>\n";
echo "<tr><td align=\"right\">Κωδικός πρόσβασης Τηλεφώνου: </td>";
echo "<td align=\"left\"><input type=\"password\" name=\"phone_pass\" size=10 maxlength=20 value=\"$phone_pass\"></td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"ΥΠΟΒΑΛΕΤΕ\" value=\"Submit\" /></td></tr>\n";
echo "<tr><td align=\"left\" colspan=\"2\"><font size=\"1\"><br />ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</font></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### go through the entered phones to figure out which server has fewest agents
### logged in and use that Σύνδεση τηλεφώνου account
if ($pa > 0)
{
$pb=0;
$pb_login='';
$pb_server_ip='';
$pb_count=0;
$pb_log='';
while($pb < $phones_auto_ct)
{
### find the server_ip of each phone_login
$stmtx="SELECT server_ip from phones where login = '$phones_auto[$pb]';";
if ($DB) {echo "|$stmtx|\n";}
if ($non_latin > 0) {$rslt=mysql_to_mysqli($link, "SET NAMES 'UTF8'");}
$rslt=mysql_to_mysqli($stmtx, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09009',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysqli_fetch_row($rslt);
### get number of agents logged in to each server
$stmt="SELECT count(*) from web_client_sessions where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09010',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
### find out whether the server is set to active
$stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' and active_asterisk_server='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09011',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysqli_fetch_row($rslt);
### find out if this server has a twin
$twin_not_live=0;
$stmt="SELECT active_twin_server_ip from servers where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09012',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyy=mysqli_fetch_row($rslt);
if (strlen($rowyy[0]) > 4)
{
### find out whether the twin server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowyy[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09013',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowyz=mysqli_fetch_row($rslt);
if ($rowyz[0] < 1) {$twin_not_live=1;}
}
### find out whether the server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09014',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowz=mysqli_fetch_row($rslt);
$pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]|$twin_not_live| ";
if ( ($rowy[0] > 0) and ($rowz[0] > 0) and ($twin_not_live < 1) )
{
if ( ($pb_count >= $row[0]) or (strlen($pb_server_ip) < 4) )
{
$pb_count=$row[0];
$pb_server_ip=$rowx[0];
$phone_login=$phones_auto[$pb];
}
}
$pb++;
}
echo "<!-- Τηλs balance selection: $phone_login|$pb_server_ip|$past_minutes_date| |$pb_log -->\n";
}
echo "<title>Τηλ web client</title>\n";
$stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,phone_ring_timeout,on_hook_agent,webphone_auto_answer from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$extension=$row[0];
$dialplan_number=$row[1];
$voicemail_id=$row[2];
$phone_ip=$row[3];
$computer_ip=$row[4];
$server_ip=$row[5];
$login=$row[6];
$pass=$row[7];
$status=$row[8];
$active=$row[9];
$phone_type=$row[10];
$fullname=$row[11];
$company=$row[12];
$picture=$row[13];
$messages=$row[14];
$old_messages=$row[15];
$protocol=$row[16];
$local_gmt=$row[17];
$ASTmgrUSERNAME=$row[18];
$ASTmgrSECRET=$row[19];
$login_user=$row[20];
$login_pass=$row[21];
$login_campaign=$row[22];
$park_on_extension=$row[23];
$conf_on_extension=$row[24];
$VICIDiaL_park_on_extension=$row[25];
$VICIDiaL_park_on_filename=$row[26];
$monitor_prefix=$row[27];
$recording_exten=$row[28];
$voicemail_exten=$row[29];
$voicemail_dump_exten=$row[30];
$ext_context=$row[31];
$dtmf_send_extension=$row[32];
$call_out_number_group=$row[33];
$client_browser=$row[34];
$install_directory=$row[35];
$local_web_callerID_URL=$row[36];
$VICIDiaL_web_URL=$row[37];
$AGI_call_logging_enabled=$row[38];
$user_switching_enabled=$row[39];
$conferencing_enabled=$row[40];
$admin_hangup_enabled=$row[41];
$admin_hijack_enabled=$row[42];
$admin_monitor_enabled=$row[43];
$call_parking_enabled=$row[44];
$updater_check_enabled=$row[45];
$AFLogging_enabled=$row[46];
$QUEUE_ACTION_enabled=$row[47];
$CallerID_popup_enabled=$row[48];
$voicemail_button_enabled=$row[49];
$enable_fast_refresh=$row[50];
$fast_refresh_rate=$row[51];
$enable_persistant_mysql=$row[52];
$auto_dial_next_number=$row[53];
$VDstop_rec_after_each_call=$row[54];
$DBX_server=$row[55];
$DBX_database=$row[56];
$DBX_user=$row[57];
$DBX_pass=$row[58];
$DBX_port=$row[59];
$outbound_cid=$row[65];
$enable_sipsak_messages=$row[66];
$conf_secret=$row[72];
$is_webphone=$row[73];
$use_external_server_ip=$row[74];
$codecs_list=$row[75];
$webphone_dialpad=$row[76];
$phone_ring_timeout=$row[77];
$on_hook_agent=$row[78];
$webphone_auto_answer=$row[79];
$no_empty_session_warnings=0;
if ( ($phone_login == 'nophone') or ($on_hook_agent == 'Y') )
{
$no_empty_session_warnings=1;
}
if ($PhonESComPIP == '1')
{
if (strlen($computer_ip) < 4)
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
}
if ($PhonESComPIP == '2')
{
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09017',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
if ($clientDST)
{
$local_gmt = ($local_gmt + $isdst);
}
if ($protocol == 'EXTERNAL')
{
$protocol = 'Local';
$extension = "$dialplan_number$AT$ext_context";
}
$SIP_user = "$protocol/$extension";
$SIP_user_DiaL = "$protocol/$extension";
if ( (preg_match('/8300/',$dialplan_number)) and (strlen($dialplan_number)<5) and ($protocol == 'Local') )
{
$SIP_user = "$protocol/$extension$VD_login";
}
$session_ext = preg_replace("/[^a-z0-9]/i", "", $extension);
if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);}
$session_rand = (rand(1,9999999) + 10000000);
$session_name = "$StarTtimE$US$session_ext$session_rand";
if ($webform_sessionname)
{$webform_sessionname = "&session_name=$session_name";}
else
{$webform_sessionname = '';}
$stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'phone';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09018',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','phone','$NOW_TIME','$session_name');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09019',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VICIDiaL_is_logged_in=1;
$webphone_content='';
### build Iframe variable content for webphone here
$codecs_list = preg_replace("/ /",'',$codecs_list);
$codecs_list = preg_replace("/-/",'',$codecs_list);
$codecs_list = preg_replace("/&/",'',$codecs_list);
$webphone_server_ip = $server_ip;
if ($use_external_server_ip=='Y')
{
##### find external_server_ip if enabled for this phone account
$stmt="SELECT external_server_ip FROM servers where server_ip='$server_ip' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09020',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$exip_ct = mysqli_num_rows($rslt);
if ($exip_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_server_ip =$row[0];
}
}
if (strlen($webphone_url) < 6)
{
##### find webphone_url in system_settings and generate IFRAME code for it #####
$stmt="SELECT webphone_url FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09021',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wu_ct = mysqli_num_rows($rslt);
if ($wu_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$webphone_url =$row[0];
}
}
if (strlen($system_key) < 1)
{
##### find system_key in system_settings if populated #####
$stmt="SELECT webphone_systemkey FROM system_settings LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'09022',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$wsk_ct = mysqli_num_rows($rslt);
if ($wsk_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$system_key =$row[0];
}
}
$webphone_options='INITIAL_LOAD';
if ($webphone_dialpad == 'Y') {$webphone_options .= "--DIALPAD_Y";}
if ($webphone_dialpad == 'N') {$webphone_options .= "--DIALPAD_N";}
if ($webphone_dialpad == 'TOGGLE') {$webphone_options .= "--DIALPAD_TOGGLE";}
if ($webphone_dialpad == 'TOGGLE_OFF') {$webphone_options .= "--DIALPAD_OFF_TOGGLE";}
if ($webphone_auto_answer == 'Y') {$webphone_options .= "--AUTOANSWER_Y";}
if ($webphone_auto_answer == 'N') {$webphone_options .= "--AUTOANSWER_N";}
### base64 encode variables
$b64_phone_login = base64_encode($extension);
$b64_phone_pass = base64_encode($conf_secret);
$b64_session_name = base64_encode($session_name);
$b64_server_ip = base64_encode($webphone_server_ip);
$b64_callerid = base64_encode($outbound_cid);
$b64_protocol = base64_encode($protocol);
$b64_codecs = base64_encode($codecs_list);
$b64_options = base64_encode($webphone_options);
$b64_system_key = base64_encode($system_key);
$WebPhonEurl = "$webphone_url?phone_login=$b64_phone_login&phone_login=$b64_phone_login&phone_pass=$b64_phone_pass&server_ip=$b64_server_ip&callerid=$b64_callerid&protocol=$b64_protocol&codecs=$b64_codecs&options=$b64_options&system_key=$b64_system_key";
if ($webphone_location == 'bar')
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
else
{
$webphone_content = "<iframe src=\"$WebPhonEurl\" style=\"width:1100px;height:500px;background-color:transparent;z-index:17;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"webphone\" name=\"webphone\" width=\"" . $webphone_width . "px\" height=\"" . $webphone_height . "px\"> </iframe>";
}
if (preg_match('/MSIE/',$browser))
{
$useIE=1;
echo "<!-- client web browser used: MSIE |$browser|$useIE| -->\n";
}
else
{
$useIE=0;
echo "<!-- client web browser used: W3C-Compliant |$browser|$useIE| -->\n";
}
}
}
### SCREEN WIDTH AND HEIGHT CALCULATIONS ###
### DO NOT EDIT! ###
if ($stretch_dimensions > 0)
{
if ($agent_status_view < 1)
{
if ($JS_browser_width >= 510)
{$BROWSER_WIDTH = ($JS_browser_width - 80);}
}
else
{
if ($JS_browser_width >= 730)
{$BROWSER_WIDTH = ($JS_browser_width - 300);}
}
if ($JS_browser_height >= 340)
{$BROWSER_HEIGHT = ($JS_browser_height - 40);}
}
if ($agent_fullscreen=='Y')
{
$BROWSER_WIDTH = ($JS_browser_width - 10);
$BROWSER_HEIGHT = $JS_browser_height;
}
$MASTERwidth=($BROWSER_WIDTH - 340);
$MASTERheight=($BROWSER_HEIGHT - 200);
if ($MASTERwidth < 430) {$MASTERwidth = '430';}
if ($MASTERheight < 300) {$MASTERheight = '300';}
if ($webphone_location == 'bar') {$MASTERwidth = ($MASTERwidth + $webphone_height);}
$CAwidth = ($MASTERwidth + 340); # 770 - cover all (none-in-session, customer hunngup, etc...)
$SBwidth = ($MASTERwidth + 331); # 761 - SideBar starting point
$MNwidth = ($MASTERwidth + 330); # 760 - main frame
$XFwidth = ($MASTERwidth + 320); # 750 - transfer/conference
$HCwidth = ($MASTERwidth + 310); # 740 - hotkeys and callbacks
$CQwidth = ($MASTERwidth + 300); # 730 - calls in queue listings
$AMwidth = ($MASTERwidth + 270); # 700 - refresh links
$SCwidth = ($MASTERwidth + 230); # 670 - live call δευτερόλεπτα counter, sidebar link
$PDwidth = ($MASTERwidth + 210); # 650 - preset-dial links
$MUwidth = ($MASTERwidth + 180); # 610 - agent mute
$SSwidth = ($MASTERwidth + 176); # 606 - scroll script
$SDwidth = ($MASTERwidth + 170); # 600 - scroll script, customer data and calls-in-session
$HKwidth = ($MASTERwidth + 20); # 450 - Hotkeys button
$HSwidth = ($MASTERwidth + 1); # 431 - Header spacer
$PBwidth = ($MASTERwidth + 0); # 430 - Presets list
$CLwidth = ($MASTERwidth - 120); # 310 - Calls in queue link
$GHheight = ($MASTERheight + 1260);# 1560 - Gender Hide span
$DBheight = ($MASTERheight + 260); # 560 - Debug span
$WRheight = ($MASTERheight + 160); # 460 - Warning boxes
$CQheight = ($MASTERheight + 140); # 440 - Calls in queue section
$SLheight = ($MASTERheight + 122); # 422 - SideBar link, Agents view link
$QLheight = ($MASTERheight + 112); # 412 - Calls in queue link
$HKheight = ($MASTERheight + 105); # 405 - HotKey active Button
$AMheight = ($MASTERheight + 100); # 400 - Agent mute buttons
$PBheight = ($MASTERheight + 90); # 390 - preset dial links
$MBheight = ($MASTERheight + 65); # 365 - Manual Dial Buttons
$CBheight = ($MASTERheight + 50); # 350 - Agent Callback, pause code, volume control Buttons and agent status
$SSheight = ($MASTERheight + 31); # 331 - script content
$HTheight = ($MASTERheight + 10); # 310 - transfer frame, callback comments and hotkey
$BPheight = ($MASTERheight - 250); # 50 - bottom buffer, Agent Xfer Span
$SCheight = 49; # 49 - δευτερόλεπτα στο call display
$SFheight = 65; # 65 - height of the script and form contents
$SRheight = 69; # 69 - height of the script and form refrech links
if ($webphone_location == 'bar')
{
$SCheight = ($SCheight + $webphone_height);
# $SFheight = ($SFheight + $webphone_height);
$SRheight = ($SRheight + $webphone_height);
}
$AVTheight = '0';
if ($is_webphone) {$AVTheight = '20';}
echo "</head>\n";
$zi=2;
echo "<body bgcolor=\"white\">\n";
echo " Τηλ: $original_phone_login - $server_ip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"$PHP_SELF?relogin=YES&session_epoch=1234567890&session_id=&session_name=$session_name&VD_login=$VD_login&phone_login=$original_phone_login&phone_pass=$phone_pass&VD_pass=$VD_pass\">Logout</a><BR>\n";
if ($webphone_location == 'bar')
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;width=".$webphone_width."px;overflow:hidden;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanBAR\"><span id=\"webphonecontent\" style=\"overflow:hidden;\">$webphone_content</span></span>\n";
}
else
{
echo "<span style=\"position:absolute;left:0px;top:30px;height:500px;overflow:scroll;z-index:$zi;background-color:$SIDEBAR_COLOR;\" id=\"webphoneSpanDEFAULT\"><table cellpadding=\"$webphone_pad\" cellspacing=\"0\" border=\"0\"><tr><td width=\"5px\" rowspan=\"2\">&nbsp;</td><td align=\"center\"><font class=\"body_text\">
Web Τηλ: &nbsp; </font></td></tr><tr><td align=\"center\"><span id=\"webphonecontent\">$webphone_content</span></td></tr></table></span>\n";
}
?>
</body>
</html>
<?php
exit;
?>
@@ -0,0 +1,464 @@
<?php
# timeclock.php - VICIDIAL system user timeclock
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 80523-0134 - First Build
# 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field
# 80525-2351 - Added an audit log that is not to be editable
# 80602-0641 - Fixed status update bug
# 90508-0727 - Changed to PHP long tags
# 100621-1023 - Added admin_web_directory variable
# 130328-0021 - Converted ereg to preg functions
# 130603-2211 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-2010 - Added optional encrypted passwords compatibility
# 130802-1031 - Changed to PHP mysqli functions
# 131208-2155 - Added user log TIMEOUTLOGOUT event status
#
$version = '2.8-10';
$build = '131208-2155';
$StarTtimE = date("U");
$NOW_TIME = date("Y-m-d H:i:s");
$last_action_date = $NOW_TIME;
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (preg_match("/443/i",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = preg_replace('/timeclock\.php/i','',$agcPAGE);
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];}
elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];}
if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];}
elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];}
if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];}
elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["commit"])) {$commit=$_GET["commit"];}
elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];}
if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];}
elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (!isset($phone_login))
{
if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];}
elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];}
}
if (!isset($phone_pass))
{
if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];}
elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];}
}
### security strip all non-alphanumeric characters out of the variables ###
$DB=preg_replace("/[^0-9a-z]/","",$DB);
$phone_login=preg_replace("/[^\,0-9a-zA-Z]/","",$phone_login);
$phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass);
$VD_login=preg_replace("/[^0-9a-zA-Z]/","",$VD_login);
$VD_pass=preg_replace("/[^0-9a-zA-Z]/","",$VD_pass);
$VD_campaign=preg_replace("/[^0-9a-zA-Z_]/","",$VD_campaign);
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$stage=preg_replace("/[^0-9a-zA-Z]/","",$stage);
$commit=preg_replace("/[^0-9a-zA-Z]/","",$commit);
$referrer=preg_replace("/[^0-9a-zA-Z]/","",$referrer);
require_once("dbconnect_mysqli.php");
require_once("functions.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,admin_home_url,admin_web_directory FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
$i=0;
while ($i < $qm_conf_ct)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$welcomeURL = $row[1];
$admin_web_directory = $row[2];
$i++;
}
##### END SETTINGS LOOKUP #####
###########################################
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ( ($stage == 'login') or ($stage == 'logout') )
{
### see if user/pass exist for this user in vicidial_users table
$valid_user=0;
$auth_message = user_authorization($user,$pass,'',1,0,0);
if ($auth_message == 'GOOD')
{$valid_user=1;}
print "<!-- vicidial_users active count for $user: |$valid_user| -->\n";
if ($valid_user < 1)
{
### NOT A VALID USER/PASS
$VDdisplayMESSAGE = "Ο χρήστης και ο κωδικός πρόσβασης που πληκτρολογήσατε δεν είναι ενεργός στο σύστημα<BR>Παρακαλώ δοκιμάστε ξανά:";
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Timeclock</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Timeclock </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Σύνδεση χρήστη: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Κωδικός πρόσβασης χρήστη: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ΥΠΟΒΑΛΕΤΕ VALUE=ΥΠΟΒΑΛΕΤΕ> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
else
{
### VALID USER/PASS, CONTINUE
### get name and group for this user
$stmt="SELECT full_name,user_group from vicidial_users where user='$user' and active='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$full_name = $row[0];
$user_group = $row[1];
print "<!-- vicidial_users name and group for $user: |$full_name|$user_group| -->\n";
### get vicidial_timeclock_status record count for this user
$stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$vts_count = $row[0];
$last_action_sec=99;
if ($vts_count > 0)
{
### vicidial_timeclock_status record found, grab status and date of last activity
$stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$status = $row[0];
$event_epoch = $row[1];
$last_action_date = date("Y-m-d H:i:s", $event_epoch);
$last_action_sec = ($StarTtimE - $event_epoch);
if ($last_action_sec > 0)
{
$totTIME_H = ($last_action_sec / 3600);
$totTIME_H_int = round($totTIME_H, 2);
$totTIME_H_int = intval("$totTIME_H");
$totTIME_M = ($totTIME_H - $totTIME_H_int);
$totTIME_M = ($totTIME_M * 60);
$totTIME_M_int = round($totTIME_M, 2);
$totTIME_M_int = intval("$totTIME_M");
$totTIME_S = ($totTIME_M - $totTIME_M_int);
$totTIME_S = ($totTIME_S * 60);
$totTIME_S = round($totTIME_S, 0);
if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";}
if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";}
if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
$totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S";
}
else
{
$totTIME_HMS='0:00:00';
}
print "<!-- vicidial_timeclock_status previous status for $user: |$status|$event_epoch|$last_action_sec| -->\n";
}
else
{
### No vicidial_timeclock_status record found, insert one
$stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$status='START';
$totTIME_HMS='0:00:00';
$affected_rows = mysqli_affected_rows($link);
print "<!-- ΝΕΟ vicidial_timeclock_status record inserted for $user: |$affected_rows| -->\n";
}
if ( ($last_action_sec < 30) and ($status != 'START') )
{
### You cannot log in or out within 30 δευτερόλεπτα of your last login/logout
$VDdisplayMESSAGE = "Δεν μπορείτε να συνδεθείτε για διάστημα 30 δευτερολέπτων από την τελευταία σας σύνδεση ή αποσύνδεση";
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Timeclock</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Timeclock </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Σύνδεση χρήστη: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Κωδικός πρόσβασης χρήστη: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ΥΠΟΒΑΛΕΤΕ VALUE=ΥΠΟΒΑΛΕΤΕ> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ($commit == 'YES')
{
if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='login') )
{
$VDdisplayMESSAGE = "Τώρα έχετε συνδεδεμένων";
$LOGtimeMESSAGE = "Μπορείτε συνδεδεμένος στο $NOW_TIME";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- ΝΕΟ vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- ΝΕΟ vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
}
if ( ($status=='LOGIN') and ($stage=='logout') )
{
$VDdisplayMESSAGE = "Έχετε αποσυνδεθεί";
$LOGtimeMESSAGE = "Έχετε αποσυνδεθεί από την$NOW_TIME<BR>Ποσό χρόνο ήταν συνδεδεμένος:$totTIME_HMS";
### Add a record to the timeclock log
$stmt="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$timeclock_id = mysqli_insert_id($link);
print "<!-- ΝΕΟ vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n";
### Update last login record in the timeclock log
$stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_log record updated for $user: |$affected_rows| -->\n";
### Update the user's timeclock status record
$stmt="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n";
### Add a record to the timeclock audit log
$stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- ΝΕΟ vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n";
### Update last login record in the timeclock audit log
$stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
print "<!-- vicidial_timeclock_audit_log record updated for $user: |$affected_rows| -->\n";
}
if ( ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) )
{echo "ERROR: η καταχώρηση του timeclock στο αρχείο καταγραφής έχει ήδη πραγματοποιηθεί:$status|$stage"; exit;}
if ($referrer=='agent')
{$BACKlink = "<A HREF=\"./vicidial.php?pl=$phone_login&pp=$phone_pass&VD_login=$user\"><font color=\"#003333\">ΕΠΙΣΤΡΟΦΗ στην οθόνη Συνδεσης του Χειριστή</font></A>";}
if ($referrer=='admin')
{$BACKlink = "<A HREF=\"/$admin_web_directory/admin.php\"><font color=\"#003333\">ΕΠΙΣΤΡΟΦΗ στην Διαχείριση</font></A>";}
if ($referrer=='welcome')
{$BACKlink = "<A HREF=\"$welcomeURL\"><font color=\"#003333\">ΕΠΙΣΤΡΟΦΗ στην οθόνη υποδοχής</font></A>";}
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Timeclock</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Timeclock </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><B> $BACKlink <BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
if ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') or ($status=='TIMEOUTLOGOUT') )
{
$VDdisplayMESSAGE = "Ο χρόνος από την τελευταία φορά σύνδεσης:$totTIME_HMS";
$log_action = 'login';
$button_name = 'LOGIN';
$LOGtimeMESSAGE = "Τελευταάι αποσύνδεση:$last_action_date<BR><BR>Κάντε κλικ παρακάτω για να συνδεθείτε";
}
if ($status=='LOGIN')
{
$VDdisplayMESSAGE = "Χρονικό διάστημα που είσαστε συνδεμένος:$totTIME_HMS";
$log_action = 'logout';
$button_name = 'LOGOUT';
$LOGtimeMESSAGE = "Συνδεθήκατε: $last_action_date<BR>Χρονικό διάστημα που είσαστε συνδεμένος:$totTIME_HMS<BR><BR>Κάντε κλικ στην ΑΠΣΥΝΔΕΣΗ για να αποσυνδεθείτε";
}
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Timeclock</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"$log_action\">\n";
echo "<INPUT TYPE=HIDDEN NAME=commit VALUE=\"YES\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=user VALUE=\"$user\">\n";
echo "<INPUT TYPE=HIDDEN NAME=pass VALUE=\"$pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Timeclock </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><font size=3><B> $LOGtimeMESSAGE<BR>&nbsp; </B></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=$button_name VALUE=$button_name> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
exit;
}
}
else
{
echo"<HTML><HEAD>\n";
echo"<TITLE>Agent Timeclock</TITLE>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"</HEAD>\n";
echo "<BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0>\n";
echo "<FORM NAME=vicidial_form ID=vicidial_form ACTION=\"$agcPAGE\" METHOD=POST>\n";
echo "<INPUT TYPE=HIDDEN NAME=stage VALUE=\"login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=referrer VALUE=\"$referrer\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_login VALUE=\"$phone_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=phone_pass VALUE=\"$phone_pass\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_login VALUE=\"$VD_login\">\n";
echo "<INPUT TYPE=HIDDEN NAME=VD_pass VALUE=\"$VD_pass\">\n";
echo "<CENTER><BR><B>$VDdisplayMESSAGE</B><BR><BR>";
echo "<TABLE WIDTH=460 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#CCFFCC\"><TR BGCOLOR=WHITE>";
echo "<TD ALIGN=LEFT VALIGN=BOTTOM><IMG SRC=\"../agc/images/vtc_tab_vicidial.gif\" Border=0></TD>";
echo "<TD ALIGN=CENTER VALIGN=MIDDLE><B> Timeclock </B></TD>";
echo "</TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Σύνδεση χρήστη: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=user SIZE=10 maxlength=20 VALUE=\"$VD_login\"></TD></TR>\n";
echo "<TR><TD ALIGN=RIGHT>Κωδικός πρόσβασης χρήστη: </TD>";
echo "<TD ALIGN=LEFT><INPUT TYPE=PASSWORD NAME=pass SIZE=10 maxlength=20 VALUE=''></TD></TR>\n";
echo "<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=Submit NAME=ΥΠΟΒΑΛΕΤΕ VALUE=ΥΠΟΒΑΛΕΤΕ> &nbsp; </TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2><font size=1><BR>ΕΚΔΟΣΗ: $version &nbsp; &nbsp; &nbsp; ΔΗΜΙΟΥΡΓΙΑ: $build</TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n\n";
echo "</body>\n\n";
echo "</html>\n\n";
}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,375 @@
<?php
# vdc_email_display.php - VICIDIAL administration page
#
# Copyright (C) 2013 Matt Florell, Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# This page displays any incoming emails in the Vicidial user interface. It
# also allows the user to download and view any attachments sent in the email,
# and also gives the user the ability to respond to the email and even
# attach files to it. The page also logs all email messages that are sent
# through it to the vicidial_email_log table
#
# changes:
# 121214-2300 - First Build
# 130127-0027 - Better non-latin characters support
# 130328-0007 - Converted ereg to preg functions
# 130603-2210 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1515 - Added optional encrypted passwords compatibility
# 130802-1032 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["attachment_id"])) {$attachment_id=$_GET["attachment_id"];}
elseif (isset($_POST["attachment_id"])) {$attachment_id=$_POST["attachment_id"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];}
elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["sender_email"])) {$sender_email=$_GET["sender_email"];}
elseif (isset($_POST["sender_email"])) {$sender_email=$_POST["sender_email"];}
if (isset($_GET["reply_subject"])) {$reply_subject=$_GET["reply_subject"];}
elseif (isset($_POST["reply_subject"])) {$reply_subject=$_POST["reply_subject"];}
if (isset($_GET["reply_to_address"])) {$reply_to_address=$_GET["reply_to_address"];}
elseif (isset($_POST["reply_to_address"])) {$reply_to_address=$_POST["reply_to_address"];}
if (isset($_GET["reply_from_address"])) {$reply_from_address=$_GET["reply_from_address"];}
elseif (isset($_POST["reply_from_address"])) {$reply_from_address=$_POST["reply_from_address"];}
if (isset($_GET["reply_message"])) {$reply_message=$_GET["reply_message"];}
elseif (isset($_POST["reply_message"])) {$reply_message=$_POST["reply_message"];}
if (isset($_GET["REPLY"])) {$REPLY=$_GET["REPLY"];}
elseif (isset($_POST["REPLY"])) {$REPLY=$_POST["REPLY"];}
$attachment1=$_FILES["attachment1"];
$A1_orig = $_FILES['attachment1']['name'];
$A1_path = $_FILES['attachment1']['tmp_name'];
$A1_type = $_FILES['attachment1']['type'];
$attachment2=$_FILES["attachment2"];
$A2_orig = $_FILES['attachment2']['name'];
$A2_path = $_FILES['attachment2']['tmp_name'];
$A2_type = $_FILES['attachment2']['type'];
$attachment3=$_FILES["attachment3"];
$A3_orig = $_FILES['attachment3']['name'];
$A3_path = $_FILES['attachment3']['tmp_name'];
$A3_type = $_FILES['attachment3']['type'];
$attachment4=$_FILES["attachment4"];
$A4_orig = $_FILES['attachment4']['name'];
$A4_path = $_FILES['attachment4']['tmp_name'];
$A4_type = $_FILES['attachment4']['type'];
$attachment5=$_FILES["attachment5"];
$A5_orig = $_FILES['attachment5']['name'];
$A5_path = $_FILES['attachment5']['tmp_name'];
$A5_type = $_FILES['attachment5']['type'];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "EMAIL"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled,allow_emails FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
$allow_emails = $row[4];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($allow_emails<1)
{
echo "Your system does not have the email setting enabled\n";
exit;
}
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and modify_leads='1';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
$LVAactive=9;
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) ) )
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_email_display.php method=POST name=email_display_form id=email_display_form>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
if ($REPLY)
{
$to = "$reply_to_address";
$from = "$reply_from_address";
$subject ="$reply_subject";
$message = "$reply_message";
$headers = "From: $from";
$attachment_str="";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
for ($i=1; $i<=5; $i++)
{
$attachment_orig_name="A".$i."_orig";
$attachment_path="A".$i."_path";
$LF_orig=$$attachment_orig_name;
$LF_path=$$attachment_path;
#echo "<p>".$$attachment_name."<BR/>".$$attachment_orig_name."<BR/>".$$attachment_path."<BR/><p>";
if ($LF_orig)
{
if (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig))
{
echo "ERROR: Ακυρο File Name: $LF_orig\n";
exit;
}
else
{
copy($LF_path, "/tmp/$LF_orig");
$file = fopen("/tmp/$LF_orig","rb");
$data = fread($file,filesize("/tmp/$LF_orig"));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$LF_orig\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$LF_orig\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
$attachment_str.="$LF_orig|";
}
}
}
$sendmail = @mail($to, $subject, $message, $headers);
if ($sendmail)
{
$reply_message=preg_replace('/(\"|\||\'|\;)/', '\\\$1', $reply_message);
$log_stmt="INSERT INTO vicidial_email_log(email_row_id, lead_id, email_date, user, email_to, message, campaign_id, attachments) VALUES('$email_row_id', '$lead_id', now(), '$user', '$reply_to_address', '$reply_message', '$campaign', '$attachment_str')";
$log_rslt=mysql_to_mysqli($log_stmt, $link);
echo "<p>mail sent to $to!</p>";
# Hangup the "call" στο the agent screen
$stmt="UPDATE vicidial_live_agents set external_hangup='1' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
else
{
echo "<p>mail could not be sent!</p>";
}
exit;
}
if ($lead_id) {
$stmt="select * from vicidial_email_list where lead_id='$lead_id' and direction='INBOUND' and status IN('NEW','INCALL') order by email_date asc";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$email_row_id=$row["email_row_id"];
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_from"], $matches);
if (strlen($matches[0])>0) {
$email_from = substr($matches[0],1,-1);
} else {
$email_from = $row["email_from"];
}
preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_to"], $matches);
if (strlen($matches[0])>0) {
$row["email_from"]=preg_replace('/\>/', '&gt;', $row["email_from"]);
$row["email_from"]=preg_replace('/\</', '&lt;', $row["email_from"]);
$email_to = substr($matches[0],1,-1);
} else {
$row["email_to"]=preg_replace('/\>/', '\>', $row["email_to"]);
$email_to = $row["email_to"];
}
$EMAIL_form="<center><TABLE cellspacing=2 cellpadding=2 bgcolor='#CCCCCC' width='500'>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Date received:</td><td align='left' valign='top' width='*'>$row[email_date]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>From:</td><td align='left' valign='top' width='*'>$row[email_from]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Subject:</td><td align='left' valign='top' width='*'>$row[subject]</td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Message:</td><td align='left' valign='top' width='*'><pre>$row[message]</pre></td></tr>\n";
$att_stmt="select * from inbound_email_attachments where email_row_id='$email_row_id'";
$att_rslt=mysql_to_mysqli($att_stmt, $link);
if (mysqli_num_rows($att_rslt)>0) {
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>συνημμένα:</td><td align='left' valign='top' width='*'><pre>";
while($att_row=mysqli_fetch_array($att_rslt)) {
$EMAIL_form.="<LI><a href='$_SERVER[PHP_SELF]?attachment_id=$att_row[attachment_id]&lead_id=$lead_id'>$att_row[filename]</a>\n";
}
$EMAIL_form.="</pre></td></tr>";
}
$EMAIL_form.="<tr><td colspan='2'><HR></td></tr>";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Response:</td><td align='left' valign='top' width='*'>RE: $row[subject]<input type='hidden' name='reply_subject' value='RE: $row[subject]'></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>Reply:<BR><BR><input type='button' name='copy' value='COPY MESSAGE >>>' onClick='CopyMessage($row[email_row_id])'></td><td align='left' valign='top' width='*'><textarea rows='8' cols='50' name='reply_message' id='reply_message'>$reply_message</textarea></td></tr>\n";
$EMAIL_form.="<tr bgcolor=white><td align='right' valign='top' width='150'>συνημμένα:</td><td align='left' valign='top' width='*'>";
$EMAIL_form.="<span id='attachment_span1'><input type=file name='attachment1' value='$attachment1'></span><BR/>";
$EMAIL_form.="<span id='attachment_span2'><input type=file name='attachment2'></span><BR/>";
$EMAIL_form.="<span id='attachment_span3'><input type=file name='attachment3'></span><BR/>";
$EMAIL_form.="<span id='attachment_span4'><input type=file name='attachment4'></span><BR/>";
$EMAIL_form.="<span id='attachment_span5'><input type=file name='attachment5'></span>";
$EMAIL_form.="</td></tr>\n";
$EMAIL_form.="<tr><td colspan='2' align='center'><input type='submit' name='REPLY' value='REPLY'></td></tr>";
$EMAIL_form.="</table></center>\n";
$EMAIL_form.="<input type='hidden' name='reply_to_address' value='$email_from'>\n";
$EMAIL_form.="<input type='hidden' name='reply_from_address' value='$email_to'>\n";
$EMAIL_form.="<input type='hidden' name='campaign' value='$campaign'>\n";
$EMAIL_form.="<input type='hidden' name='lead_id' value='$lead_id'>\n";
$EMAIL_form.="<input type='hidden' name='email_row_id' value='$email_row_id'>\n";
$EMAIL_form.="<input type='hidden' name='user' value='$user'>\n";
$EMAIL_form.="<input type='hidden' name='pass' value='$pass'>\n";
}
if ($attachment_id) {
$stmt="select * from inbound_email_attachments where attachment_id='$attachment_id'";
$rslt=mysql_to_mysqli($stmt, $link);
if (mysqli_num_rows($rslt)>0) {
$row=mysqli_fetch_array($rslt);
$filename=$row["filename"];
$encoding=$row["file_encoding"];
$file_size=$row["file_size"];
$file_type=$row["file_type"];
$file_contents=$row["file_contents"];
if ($encoding=="base64") {
$file_contents=base64_decode($file_contents);
$file_size=strlen($file_contents);
}
header("Content-length: ".$file_size."");
header("Content-type: ".$file_type."");
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $file_contents;
}
} else {
?>
<html>
<head>
<title>AGENT email frame</title>
</head>
<script language="Javascript">
function ParseFileName()
{
for (var i=1; i<=5; i++)
{
var attachment_field=eval("document.forms[0].attachment"+i);
var endstr=attachment_field.value.lastIndexOf('\\');
if (endstr>-1)
{
endstr++;
var filename=attachment_field.value.substring(endstr);
attachment_field.value=filename;
}
}
}
function CopyMessage()
{
<?php
$row["message"]=preg_replace('/\r|\n/', ' ', $row["message"]);
echo "var message=\"".preg_replace('/\"/', '\\\"', $row["message"])."\";\n";
?>
var msg_array=message.split(" ");
var full_msg="";
var msg_line="> ";
for (var i=0; i<msg_array.length; i++)
{
if (msg_array[i].length>=48)
{
msg_line+=msg_array[i]+" ";
}
if (msg_line.length+msg_array[i].length<50)
{
msg_line+=msg_array[i]+" ";
}
else
{
full_msg+=msg_line+"\n";
msg_line="> "+msg_array[i]+" ";
}
}
full_msg+=msg_line+"\n";
var email_field_value=document.getElementById("reply_message").value+"\n";
email_field_value+=full_msg;
document.getElementById("reply_message").value=email_field_value;
}
</script>
<style type="text/css">
pre { white-space: pre-wrap; }
</style>
<body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get' name="email_display_form" id="email_display_form" onSubmit="if (this.submitted) return false; this.submitted=true" enctype="multipart/form-data">
<?php echo $EMAIL_form; ?>
</form>
</body>
</html>
<?php
}
} else {
echo "ERROR - ID variable missing";
}
?>
@@ -0,0 +1,486 @@
<?php
# vdc_form_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the FORM tab in the agent
# interface, as well as take submission of the form submission when the agent
# dispositions the call
#
# CHANGELOG:
# 100630-1119 - First build of script
# 100703-1124 - Added submit_button,admin_submit fields, which will log to admin log
# 100712-2322 - Added code to log vicidial_list.entry_list_id field if data altered
# 100916-1749 - Added non-lead variable parsing
# 110719-0856 - Added HIDEBLOB type
# 110730-2335 - Added call_id variable
# 111025-1433 - Fixed case sensitivity on list fields
# 120315-1729 - Filtere out single quotes and backslashes from custom fields
# 130328-0012 - Converted ereg to preg functions
# 130402-2256 - Added user_group variable
# 130603-2204 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130615-2155 - Allow qc_enabled user access to this page even if not logged in as an agent
# 130705-1512 - Added optional encrypted passwords compatibility
# 130802-1033 - Changed to PHP mysqli functions
# 140101-2139 - Small fix for admin modify lead page on encrypted password systems
# 140429-2042 - Added TABLEper_call_notes display script variable for form display
#
$version = '2.8-15';
$build = '140429-2042';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
$bcrypt=1;
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["submit_button"])) {$submit_button=$_GET["submit_button"];}
elseif (isset($_POST["submit_button"])) {$submit_button=$_POST["submit_button"];}
if (isset($_GET["admin_submit"])) {$admin_submit=$_GET["admin_submit"];}
elseif (isset($_POST["admin_submit"])) {$admin_submit=$_POST["admin_submit"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["bcrypt"])) {$bcrypt=$_GET["bcrypt"];}
elseif (isset($_POST["bcrypt"])) {$bcrypt=$_POST["bcrypt"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
if ($bcrypt == 'OFF')
{$bcrypt=0;}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if ($stage=='WELCOME')
{echo "FORM"; exit;}
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';}
$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|';
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
$custom_fields_enabled = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;| /","",$user);
$pass = preg_replace("/\'|\"|\\\\|;| /","",$pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,$bcrypt,0);
if ($auth_message == 'GOOD')
{$auth=1;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and ( (modify_leads='1') or (qc_enabled='1') );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$VUmodify=$row[0];
$stmt="SELECT count(*) from vicidial_live_agents where user='$user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LVAactive=$row[0];
if ($custom_fields_enabled < 1)
{
echo "Custom Fields Disabled: |$custom_fields_enabled|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) and ($VUmodify < 1) ) )
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
exit;
}
else
{
# do nothing for now
}
### BEGIN parse submission of the custom fields form ###
if ($stage=='SUBMIT')
{
$update_sent=0;
$CFoutput='';
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06001',$user,$server_ip,$session_name,$one_mysql_log);}
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{
$update_SQL='';
$VL_update_SQL='';
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06003',$user,$server_ip,$session_name,$one_mysql_log);}
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$new_field_value='';
$form_field_value='';
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$A_field_name[$o] = $rowx[2];
$A_field_type[$o] = $rowx[6];
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_required[$o] = $rowx[12];
$A_field_value[$o] = '';
$field_name_id = $A_field_label[$o];
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$form_field_value = preg_replace("/\'/","",$form_field_value); // remove single-quote
$form_field_value = preg_replace("/\\b/","",$form_field_value); // remove backslashes
if ( ($A_field_type[$o]=='MULTI') or ($A_field_type[$o]=='CHECKBOX') or ($A_field_type[$o]=='RADIO') )
{
$k=0;
$multi_count = count($form_field_value);
$multi_array = $form_field_value;
while ($k < $multi_count)
{
$new_field_value .= "$multi_array[$k],";
$k++;
}
$form_field_value = preg_replace("/,$/","",$new_field_value);
}
if ($A_field_type[$o]=='TIME')
{
if (isset($_GET["MINUTE_$field_name_id"])) {$form_field_valueM=$_GET["MINUTE_$field_name_id"];}
elseif (isset($_POST["MINUTE_$field_name_id"])) {$form_field_valueM=$_POST["MINUTE_$field_name_id"];}
if (isset($_GET["HOUR_$field_name_id"])) {$form_field_valueH=$_GET["HOUR_$field_name_id"];}
elseif (isset($_POST["HOUR_$field_name_id"])) {$form_field_valueH=$_POST["HOUR_$field_name_id"];}
$form_field_value = "$form_field_valueH:$form_field_valueM:00";
}
$A_field_value[$o] = $form_field_value;
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') or ($A_field_type[$o]=='HIDDEN') or ($A_field_type[$o]=='HIDEBLOB') or ($A_field_type[$o]=='READONLY') )
{
$A_field_value[$o]='----IGNORE----';
}
else
{
if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
{
$VL_update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
else
{
$update_SQL .= "$A_field_label[$o]='$A_field_value[$o]',";
}
$SUBMIT_output .= "<b>$A_field_name[$o]:</b> $A_field_value[$o]<BR>";
}
$o++;
}
$custom_update_count=0;
if (strlen($update_SQL)>3)
{
$custom_record_lead_count=0;
$stmt="SELECT count(*) from custom_$list_id where lead_id='$lead_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06004',$user,$server_ip,$session_name,$one_mysql_log);}
$fieldleadcount_to_print = mysqli_num_rows($rslt);
if ($fieldleadcount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$custom_record_lead_count = $rowx[0];
}
$update_SQL = preg_replace("/,$/","",$update_SQL);
$custom_table_update_SQL = "INSERT INTO custom_$list_id SET lead_id='$lead_id',$update_SQL;";
if ($custom_record_lead_count > 0)
{$custom_table_update_SQL = "UPDATE custom_$list_id SET $update_SQL where lead_id='$lead_id';";}
$rslt=mysql_to_mysqli($custom_table_update_SQL, $link);
$custom_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$custom_update_count|$custom_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
if (strlen($VL_update_SQL)>3)
{
$custom_update_vl_SQL='';
if ($custom_update_count > 0)
{$custom_update_vl_SQL = "entry_list_id='$list_id',";}
$VL_update_SQL = preg_replace("/,$/","",$VL_update_SQL);
$list_table_update_SQL = "UPDATE vicidial_list SET $custom_update_vl_SQL $VL_update_SQL where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
$update_sent++;
}
else
{
if ($custom_update_count > 0)
{
$list_table_update_SQL = "UPDATE vicidial_list SET entry_list_id='$list_id' where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($list_table_update_SQL, $link);
$list_update_count = mysqli_affected_rows($link);
if ($DB) {echo "$list_update_count|$list_table_update_SQL\n";}
if (!$rslt) {die('Could not execute: ' . mysqli_error($link));}
}
}
if ( ($admin_submit=='YES') and ($update_sent > 0) )
{
### LOG INSERTION Admin Log Table ###
$ip = getenv("REMOTE_ADDR");
$SQL_log = "$list_table_update_SQL|$custom_table_update_SQL|";
$SQL_log = preg_replace('/;/','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY CUSTOM LEAD', event_sql=\"$SQL_log\", event_notes='$custom_update_count|$list_update_count';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
}
}
else
{$CFoutput .= "ERROR: no custom list fields table\n";}
echo "Custom Form Output:\n<BR>\n";
echo "$SUBMIT_output";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "</form>\n";
}
### END parse submission of the custom fields form ###
else
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Agent Form Display Script";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo " <link rel=\"stylesheet\" href=\"calendar.css\">\n";
echo " <script language=\"Javascript\">\n";
echo " function open_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:close_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help-</a><BR> &nbsp; \";\n";
echo " document.getElementById(taskspan).innerHTML = \"<B>\" + taskhelp + \"</B>\";\n";
echo " document.getElementById(taskspan).style.background = \"#FFFF99\";\n";
echo " }\n";
echo " function close_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \"\";\n";
echo " document.getElementById(taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:open_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help+</a>\";\n";
echo " document.getElementById(taskspan).style.background = \"white\";\n";
echo " }\n";
echo " </script>\n";
echo " <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "</head>\n";
echo "<BODY BGCOLOR=\"#" . $bgcolor . "\" marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onload=\"parent.document.getElementById('FORM_LOADED').value='1';\">";
echo "\n";
echo "<form action=./vdc_form_display.php method=POST name=form_custom_fields id=form_custom_fields>\n";
echo "<input type=hidden name=lead_id id=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=list_id id=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=user id=user value=\"$user\">\n";
echo "<input type=hidden name=pass id=pass value=\"$pass\">\n";
echo "\n";
require_once("functions.php");
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user);
echo "$CFoutput";
if ($submit_button=='YES')
{
if ($bcrypt=='0')
{echo "<input type=hidden name=bcrypt id=bcrypt value=\"OFF\">\n";}
echo "<input type=hidden name=admin_submit id=admin_submit value=\"YES\">\n";
echo "<BR><BR><input type=submit name=VCformSubmit id=VCformSubmit value=submit>\n";
}
echo "</form></center><BR><BR>\n";
echo "</BODY></HTML>\n";
}
exit;
?>
@@ -0,0 +1,705 @@
<?php
# vdc_script_display.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed display the contents of the SCRIPT tab in the agent interface
#
# CHANGELOG:
# 90824-1435 - First build of script
# 90827-1548 - Added list override script option
# 91204-1913 - Added recording_filename and recording_id variables
# 91211-1103 - Added user_custom_... variables
# 100116-0702 - Added preset variables
# 100127-1611 - Added ignore_list_script_override option
# 100823-1644 - Added DID variables
# 100902-1344 - Added closecallid, xfercallid, agent_log_id variables
# 110420-1201 - Added web_vars variable
# 110730-2339 - Added call_id variable
# 120227-2017 - Added parsing of IGNORENOSCROLL option in script to force scroll
# 130328-0013 - Converted ereg to preg functions
# 130402-2255 - Added user_group variable
# 130603-2206 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1513 - Added optional encrypted passwords compatibility
# 130802-1035 - Changed to PHP mysqli functions
# 140429-2034 - Added TABLEper_call_notes display script variable
#
$version = '2.8-17';
$build = '140429-2034';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["title"])) {$title=$_GET["title"];}
elseif (isset($_POST["title"])) {$title=$_POST["title"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
if (isset($_GET["gender"])) {$gender=$_GET["gender"];}
elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];}
if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
if (isset($_GET["closer"])) {$closer=$_GET["closer"];}
elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
if (isset($_GET["rank"])) {$rank=$_GET["rank"];}
elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];}
if (isset($_GET["owner"])) {$owner=$_GET["owner"];}
elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];}
if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];}
elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];}
if (isset($_GET["did_extension"])) {$did_extension=$_GET["did_extension"];}
elseif (isset($_POST["did_extension"])) {$did_extension=$_POST["did_extension"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["closecallid"])) {$closecallid=$_GET["closecallid"];}
elseif (isset($_POST["closecallid"])) {$closecallid=$_POST["closecallid"];}
if (isset($_GET["xfercallid"])) {$xfercallid=$_GET["xfercallid"];}
elseif (isset($_POST["xfercallid"])) {$xfercallid=$_POST["xfercallid"];}
if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];}
elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];}
if (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
elseif (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
if (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
elseif (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
if (isset($_GET["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_GET["CF_uses_custom_fields"];}
elseif (isset($_POST["CF_uses_custom_fields"])) {$CF_uses_custom_fields=$_POST["CF_uses_custom_fields"];}
if (isset($_GET["entry_list_id"])) {$entry_list_id=$_GET["entry_list_id"];}
elseif (isset($_POST["entry_list_id"])) {$entry_list_id=$_POST["entry_list_id"];}
if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];}
elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["web_vars"])) {$web_vars=$_GET["web_vars"];}
elseif (isset($_POST["web_vars"])) {$web_vars=$_POST["web_vars"];}
if (isset($_GET["orig_pass"])) {$orig_pass=$_GET["orig_pass"];}
elseif (isset($_POST["orig_pass"])) {$orig_pass=$_POST["orig_pass"];}
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
$script_height = ($script_height - 20);
$IFRAME=0;
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$orig_pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);
$orig_pass = preg_replace("/\'|\"|\\\\|;/","",$orig_pass);
}
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,1,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Invalid Username/Password: |$user|$pass|$auth_message|\n";
exit;
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>VICIDiaL Script Display Script";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
if (strlen($in_script) < 1)
{$call_script = $camp_script;}
else
{$call_script = $in_script;}
$ignore_list_script_override='N';
$stmt = "SELECT ignore_list_script_override FROM vicidial_inbound_groups where group_id='$group';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$ilso_ct = mysqli_num_rows($rslt);
if ($ilso_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$ignore_list_script_override = $row[0];
}
if ($ignore_list_script_override=='Y')
{$ignore_list_script=1;}
if ($ignore_list_script < 1)
{
$stmt="SELECT agent_script_override from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_script_override = $row[0];
if (strlen($agent_script_override) > 0)
{$call_script = $agent_script_override;}
}
$stmt="SELECT list_name,list_description from vicidial_lists where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_name = $row[0];
$list_description = $row[1];
$stmt="SELECT script_name,script_text from vicidial_scripts where script_id='$call_script';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$script_name = $row[0];
$script_text = stripslashes($row[1]);
if (preg_match("/iframe\ssrc/i",$script_text))
{
$IFRAME=1;
$lead_id = preg_replace('/\s/i','+',$lead_id);
$vendor_id = preg_replace('/\s/i','+',$vendor_id);
$vendor_lead_code = preg_replace('/\s/i','+',$vendor_lead_code);
$list_id = preg_replace('/\s/i','+',$list_id);
$list_name = preg_replace('/\s/i','+',$list_name);
$list_description = preg_replace('/\s/i','+',$list_description);
$gmt_offset_now = preg_replace('/\s/i','+',$gmt_offset_now);
$phone_code = preg_replace('/\s/i','+',$phone_code);
$phone_number = preg_replace('/\s/i','+',$phone_number);
$title = preg_replace('/\s/i','+',$title);
$first_name = preg_replace('/\s/i','+',$first_name);
$middle_initial = preg_replace('/\s/i','+',$middle_initial);
$last_name = preg_replace('/\s/i','+',$last_name);
$address1 = preg_replace('/\s/i','+',$address1);
$address2 = preg_replace('/\s/i','+',$address2);
$address3 = preg_replace('/\s/i','+',$address3);
$city = preg_replace('/\s/i','+',$city);
$state = preg_replace('/\s/i','+',$state);
$province = preg_replace('/\s/i','+',$province);
$postal_code = preg_replace('/\s/i','+',$postal_code);
$country_code = preg_replace('/\s/i','+',$country_code);
$gender = preg_replace('/\s/i','+',$gender);
$date_of_birth = preg_replace('/\s/i','+',$date_of_birth);
$alt_phone = preg_replace('/\s/i','+',$alt_phone);
$email = preg_replace('/\s/i','+',$email);
$security_phrase = preg_replace('/\s/i','+',$security_phrase);
$comments = preg_replace('/\s/i','+',$comments);
$user = preg_replace('/\s/i','+',$user);
$pass = preg_replace('/\s/i','+',$orig_pass);
$campaign = preg_replace('/\s/i','+',$campaign);
$phone_login = preg_replace('/\s/i','+',$phone_login);
$original_phone_login = preg_replace('/\s/i','+',$original_phone_login);
$phone_pass = preg_replace('/\s/i','+',$phone_pass);
$fronter = preg_replace('/\s/i','+',$fronter);
$closer = preg_replace('/\s/i','+',$closer);
$group = preg_replace('/\s/i','+',$group);
$channel_group = preg_replace('/\s/i','+',$channel_group);
$SQLdate = preg_replace('/\s/i','+',$SQLdate);
$epoch = preg_replace('/\s/i','+',$epoch);
$uniqueid = preg_replace('/\s/i','+',$uniqueid);
$customer_zap_channel = preg_replace('/\s/i','+',$customer_zap_channel);
$customer_server_ip = preg_replace('/\s/i','+',$customer_server_ip);
$server_ip = preg_replace('/\s/i','+',$server_ip);
$SIPexten = preg_replace('/\s/i','+',$SIPexten);
$session_id = preg_replace('/\s/i','+',$session_id);
$phone = preg_replace('/\s/i','+',$phone);
$parked_by = preg_replace('/\s/i','+',$parked_by);
$dispo = preg_replace('/\s/i','+',$dispo);
$dialed_number = preg_replace('/\s/i','+',$dialed_number);
$dialed_label = preg_replace('/\s/i','+',$dialed_label);
$source_id = preg_replace('/\s/i','+',$source_id);
$rank = preg_replace('/\s/i','+',$rank);
$owner = preg_replace('/\s/i','+',$owner);
$camp_script = preg_replace('/\s/i','+',$camp_script);
$in_script = preg_replace('/\s/i','+',$in_script);
$script_width = preg_replace('/\s/i','+',$script_width);
$script_height = preg_replace('/\s/i','+',$script_height);
$fullname = preg_replace('/\s/i','+',$fullname);
$recording_filename = preg_replace('/\s/i','+',$recording_filename);
$recording_id = preg_replace('/\s/i','+',$recording_id);
$user_custom_one = preg_replace('/\s/i','+',$user_custom_one);
$user_custom_two = preg_replace('/\s/i','+',$user_custom_two);
$user_custom_three = preg_replace('/\s/i','+',$user_custom_three);
$user_custom_four = preg_replace('/\s/i','+',$user_custom_four);
$user_custom_five = preg_replace('/\s/i','+',$user_custom_five);
$preset_number_a = preg_replace('/\s/i','+',$preset_number_a);
$preset_number_b = preg_replace('/\s/i','+',$preset_number_b);
$preset_number_c = preg_replace('/\s/i','+',$preset_number_c);
$preset_number_d = preg_replace('/\s/i','+',$preset_number_d);
$preset_number_e = preg_replace('/\s/i','+',$preset_number_e);
$preset_number_f = preg_replace('/\s/i','+',$preset_number_f);
$preset_dtmf_a = preg_replace('/\s/i','+',$preset_dtmf_a);
$preset_dtmf_b = preg_replace('/\s/i','+',$preset_dtmf_b);
$did_id = preg_replace('/\s/i','+',$did_id);
$did_extension = preg_replace('/\s/i','+',$did_extension);
$did_pattern = preg_replace('/\s/i','+',$did_pattern);
$did_description = preg_replace('/\s/i','+',$did_description);
$called_count = preg_replace('/\s/i','+',$called_count);
$web_vars = preg_replace('/\s/i','+',$web_vars);
}
$script_text = preg_replace('/--A--lead_id--B--/i',"$lead_id",$script_text);
$script_text = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$script_text);
$script_text = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$script_text);
$script_text = preg_replace('/--A--list_id--B--/i',"$list_id",$script_text);
$script_text = preg_replace('/--A--list_name--B--/i',"$list_name",$script_text);
$script_text = preg_replace('/--A--list_description--B--/i',"$list_description",$script_text);
$script_text = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$script_text);
$script_text = preg_replace('/--A--phone_code--B--/i',"$phone_code",$script_text);
$script_text = preg_replace('/--A--phone_number--B--/i',"$phone_number",$script_text);
$script_text = preg_replace('/--A--title--B--/i',"$title",$script_text);
$script_text = preg_replace('/--A--first_name--B--/i',"$first_name",$script_text);
$script_text = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$script_text);
$script_text = preg_replace('/--A--last_name--B--/i',"$last_name",$script_text);
$script_text = preg_replace('/--A--address1--B--/i',"$address1",$script_text);
$script_text = preg_replace('/--A--address2--B--/i',"$address2",$script_text);
$script_text = preg_replace('/--A--address3--B--/i',"$address3",$script_text);
$script_text = preg_replace('/--A--city--B--/i',"$city",$script_text);
$script_text = preg_replace('/--A--state--B--/i',"$state",$script_text);
$script_text = preg_replace('/--A--province--B--/i',"$province",$script_text);
$script_text = preg_replace('/--A--postal_code--B--/i',"$postal_code",$script_text);
$script_text = preg_replace('/--A--country_code--B--/i',"$country_code",$script_text);
$script_text = preg_replace('/--A--gender--B--/i',"$gender",$script_text);
$script_text = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$script_text);
$script_text = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$script_text);
$script_text = preg_replace('/--A--email--B--/i',"$email",$script_text);
$script_text = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$script_text);
$script_text = preg_replace('/--A--comments--B--/i',"$comments",$script_text);
$script_text = preg_replace('/--A--user--B--/i',"$user",$script_text);
$script_text = preg_replace('/--A--pass--B--/i',"$pass",$script_text);
$script_text = preg_replace('/--A--campaign--B--/i',"$campaign",$script_text);
$script_text = preg_replace('/--A--phone_login--B--/i',"$phone_login",$script_text);
$script_text = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$script_text);
$script_text = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$script_text);
$script_text = preg_replace('/--A--fronter--B--/i',"$fronter",$script_text);
$script_text = preg_replace('/--A--closer--B--/i',"$closer",$script_text);
$script_text = preg_replace('/--A--group--B--/i',"$group",$script_text);
$script_text = preg_replace('/--A--channel_group--B--/i',"$channel_group",$script_text);
$script_text = preg_replace('/--A--SQLdate--B--/i',"$SQLdate",$script_text);
$script_text = preg_replace('/--A--epoch--B--/i',"$epoch",$script_text);
$script_text = preg_replace('/--A--uniqueid--B--/i',"$uniqueid",$script_text);
$script_text = preg_replace('/--A--customer_zap_channel--B--/i',"$customer_zap_channel",$script_text);
$script_text = preg_replace('/--A--customer_server_ip--B--/i',"$customer_server_ip",$script_text);
$script_text = preg_replace('/--A--server_ip--B--/i',"$server_ip",$script_text);
$script_text = preg_replace('/--A--SIPexten--B--/i',"$SIPexten",$script_text);
$script_text = preg_replace('/--A--session_id--B--/i',"$session_id",$script_text);
$script_text = preg_replace('/--A--phone--B--/i',"$phone",$script_text);
$script_text = preg_replace('/--A--parked_by--B--/i',"$parked_by",$script_text);
$script_text = preg_replace('/--A--dispo--B--/i',"$dispo",$script_text);
$script_text = preg_replace('/--A--dialed_number--B--/i',"$dialed_number",$script_text);
$script_text = preg_replace('/--A--dialed_label--B--/i',"$dialed_label",$script_text);
$script_text = preg_replace('/--A--source_id--B--/i',"$source_id",$script_text);
$script_text = preg_replace('/--A--rank--B--/i',"$rank",$script_text);
$script_text = preg_replace('/--A--owner--B--/i',"$owner",$script_text);
$script_text = preg_replace('/--A--camp_script--B--/i',"$camp_script",$script_text);
$script_text = preg_replace('/--A--in_script--B--/i',"$in_script",$script_text);
$script_text = preg_replace('/--A--script_width--B--/i',"$script_width",$script_text);
$script_text = preg_replace('/--A--script_height--B--/i',"$script_height",$script_text);
$script_text = preg_replace('/--A--fullname--B--/i',"$fullname",$script_text);
$script_text = preg_replace('/--A--recording_filename--B--/i',"$recording_filename",$script_text);
$script_text = preg_replace('/--A--recording_id--B--/i',"$recording_id",$script_text);
$script_text = preg_replace('/--A--user_custom_one--B--/i',"$user_custom_one",$script_text);
$script_text = preg_replace('/--A--user_custom_two--B--/i',"$user_custom_two",$script_text);
$script_text = preg_replace('/--A--user_custom_three--B--/i',"$user_custom_three",$script_text);
$script_text = preg_replace('/--A--user_custom_four--B--/i',"$user_custom_four",$script_text);
$script_text = preg_replace('/--A--user_custom_five--B--/i',"$user_custom_five",$script_text);
$script_text = preg_replace('/--A--preset_number_a--B--/i',"$preset_number_a",$script_text);
$script_text = preg_replace('/--A--preset_number_b--B--/i',"$preset_number_b",$script_text);
$script_text = preg_replace('/--A--preset_number_c--B--/i',"$preset_number_c",$script_text);
$script_text = preg_replace('/--A--preset_number_d--B--/i',"$preset_number_d",$script_text);
$script_text = preg_replace('/--A--preset_number_e--B--/i',"$preset_number_e",$script_text);
$script_text = preg_replace('/--A--preset_number_f--B--/i',"$preset_number_f",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_a--B--/i',"$preset_dtmf_a",$script_text);
$script_text = preg_replace('/--A--preset_dtmf_b--B--/i',"$preset_dtmf_b",$script_text);
$script_text = preg_replace('/--A--did_id--B--/i',"$did_id",$script_text);
$script_text = preg_replace('/--A--did_extension--B--/i',"$did_extension",$script_text);
$script_text = preg_replace('/--A--did_pattern--B--/i',"$did_pattern",$script_text);
$script_text = preg_replace('/--A--did_description--B--/i',"$did_description",$script_text);
$script_text = preg_replace('/--A--closecallid--B--/i',"$closecallid",$script_text);
$script_text = preg_replace('/--A--xfercallid--B--/i',"$xfercallid",$script_text);
$script_text = preg_replace('/--A--agent_log_id--B--/i',"$agent_log_id",$script_text);
$script_text = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$script_text);
$script_text = preg_replace('/--A--call_id--B--/i',"$call_id",$script_text);
$script_text = preg_replace('/--A--user_group--B--/i',"$user_group",$script_text);
$script_text = preg_replace('/--A--called_count--B--/i',"$called_count",$script_text);
$script_text = preg_replace('/--A--web_vars--B--/i',"$web_vars",$script_text);
if ($CF_uses_custom_fields=='Y')
{
### find the names of all custom fields, if any
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('vendor_lead_code','source_id','list_id','gmt_offset_now','called_since_last_reset','phone_code','phone_number','title','first_name','middle_initial','last_name','address1','address2','address3','city','state','province','postal_code','country_code','gender','date_of_birth','alt_phone','email','security_phrase','comments','called_count','last_local_call_time','rank','owner');";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$cffn_ct = mysqli_num_rows($rslt);
$d=0;
while ($cffn_ct > $d)
{
$row=mysqli_fetch_row($rslt);
$field_name_id = $row[0];
$field_name_tag = "--A--" . $field_name_id . "--B--";
if (isset($_GET["$field_name_id"])) {$form_field_value=$_GET["$field_name_id"];}
elseif (isset($_POST["$field_name_id"])) {$form_field_value=$_POST["$field_name_id"];}
$script_text = preg_replace("/$field_name_tag/i","$form_field_value",$script_text);
if ($DB) {echo "$d|$field_name_id|$field_name_tag|$form_field_value|<br>\n";}
$d++;
}
}
$NOTESout='';
if (preg_match('/--A--TABLEper_call_notes--B--/i',$script_text))
{
### BEGIN Gather Call Log and notes ###
if ($hide_call_log_info!='Y')
{
if ($search != 'logfirst')
{$NOTESout .= "CALL LOG FOR THIS LEAD:<br>\n";}
$NOTESout .= "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>";
$NOTESout .= "<TR>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:10px;font-family:sans-serif;\"><B> &nbsp; # &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; DATE/TIME &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; AGENT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; LENGTH &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; STATUS &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; PHONE &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; CAMPAIGN &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; IN/OUT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; ALT &nbsp; </font></TD>";
$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; HANGUP &nbsp; </font></TD>";
# $NOTESout .= "</TR><TR>";
# $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\" COLSPAN=9><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; FULL NAME &nbsp; </font></TD>";
$NOTESout .= "</TR>";
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$out_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$out_logs_to_print|$stmt|";}
$g=0;
$u=0;
while ($out_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = $row[3];
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLalt_dial[$g] = $row[9];
$ALLuniqueid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLin_out[$g] = "OUT-AUTO";
if ($row[10] == 'MANUAL') {$ALLin_out[$g] = "OUT-MANUAL";}
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLuniqueid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$out_notes_to_print = mysqli_num_rows($rslt);
if ($out_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
$stmt="SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='$lead_id' order by call_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$in_logs_to_print = mysqli_num_rows($rslt);
if ($format=='debug') {$NOTESout .= "|$in_logs_to_print|$stmt|";}
$u=0;
while ($in_logs_to_print > $u)
{
$row=mysqli_fetch_row($rslt);
$ALLsort[$g] = "$row[0]-----$g";
$ALLstart_epoch[$g] = $row[0];
$ALLcall_date[$g] = $row[1];
$ALLcampaign_id[$g] = $row[2];
$ALLlength_in_sec[$g] = ($row[3] - $row[9]);
if ($ALLlength_in_sec[$g] < 0) {$ALLlength_in_sec[$g]=0;}
$ALLstatus[$g] = $row[4];
$ALLphone_code[$g] = $row[5];
$ALLphone_number[$g] = $row[6];
$ALLlead_id[$g] = $row[7];
$ALLhangup_reason[$g] = $row[8];
$ALLuniqueid[$g] = $row[10];
$ALLclosecallid[$g] = $row[11];
$ALLuser[$g] = $row[12];
$ALLalt_dial[$g] = "MAIN";
$ALLin_out[$g] = "IN";
$stmtA="SELECT call_notes FROM vicidial_call_notes WHERE lead_id='$ALLlead_id[$g]' and vicidial_id='$ALLclosecallid[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$in_notes_to_print = mysqli_num_rows($rslt);
if ($in_notes_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$Allcall_notes[$g] = $rowA[0];
if (strlen($Allcall_notes[$g]) > 0)
{$Allcall_notes[$g] = "<b>NOTES: </b> $Allcall_notes[$g]";}
}
$stmtA="SELECT full_name FROM vicidial_users WHERE user='$ALLuser[$g]';";
$rsltA=mysql_to_mysqli($stmtA, $link);
$users_to_print = mysqli_num_rows($rslt);
if ($users_to_print > 0)
{
$rowA=mysqli_fetch_row($rsltA);
$ALLuser[$g] .= " - $rowA[0]";
}
$Allcounter[$g] = $g;
$g++;
$u++;
}
if ($g > 0)
{sort($ALLsort, SORT_NUMERIC);}
else
{$NOTESout .= "<tr bgcolor=white><td colspan=11 align=center>No calls found</td></tr>";}
$u=0;
while ($g > $u)
{
$sort_split = explode("-----",$ALLsort[$u]);
$i = $sort_split[1];
if (preg_match("/1$|3$|5$|7$|9$/i", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$phone_number_display = $ALLphone_number[$i];
if ($disable_alter_custphone == 'HIDE')
{$phone_number_display = 'XXXXXXXXXX';}
$u++;
$NOTESout .= "<tr $bgcolor>";
$NOTESout .= "<td><font size=1>$u</td>";
$NOTESout .= "<td align=right><font size=2>$ALLcall_date[$i]</td>";
$NOTESout .= "<td align=right><font size=2> $ALLuser[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLlength_in_sec[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLstatus[$i]</td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLphone_code[$i] $phone_number_display </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLcampaign_id[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLin_out[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLalt_dial[$i] </td>\n";
$NOTESout .= "<td align=right><font size=2> $ALLhangup_reason[$i] </td>\n";
$NOTESout .= "</TR><TR>";
$NOTESout .= "<td></td>";
$NOTESout .= "<TD $bgcolor COLSPAN=9 align=left><font style=\"font-size:11px;font-family:sans-serif;\"> $Allcall_notes[$i] </font></TD>";
$NOTESout .= "</tr>\n";
}
$NOTESout .= "</TABLE>";
$NOTESout .= "<BR>";
}
### END Gather Call Log and notes ###
}
$script_text = preg_replace("/\n/i","<BR>",$script_text);
$script_text = preg_replace('/--A--TABLEper_call_notes--B--/i',"$NOTESout",$script_text);
$script_text = stripslashes($script_text);
echo "<!-- IFRAME$IFRAME -->\n";
echo "<!-- $script_id -->\n";
echo "<TABLE WIDTH=$script_width><TR><TD>\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "<div class=\"scroll_script\" id=\"NewScriptContents\">";}
echo "<center><B>$script_name</B><BR></center>\n";
echo "$script_text\n";
if ( ( ($IFRAME < 1) and ($ScrollDIV > 0) ) or (preg_match("/IGNORENOSCROLL/i",$script_text)) )
{echo "</div>";}
echo "</TD></TR></TABLE>\n";
exit;
?>
@@ -0,0 +1,646 @@
<?php
# vdc_script_notes.php
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed open in the SCRIPT tab in the agent interface through
# an IFRAME. It will create a new record for every SUBMIT
#
# Example of a ViciDial agent SCRIPT using this script:
# <iframe src="./vdc_script_notes.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&pass=--A--pass--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&rank=--A--rank--B--&owner=--A--owner--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="--A--script_width--B--" height="--A--script_height--B--" STYLE="z-index:17"> </iframe>
#
# CHANGELOG:
# 100215-0744 - First build of script
# 100622-2230 - Added field labels
# 130328-0020 - Converted ereg to preg functions
# 130603-2203 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1037 - Changed to PHP mysqli functions
#
$version = '2.8-5';
$build = '130802-1037';
require_once("dbconnect_mysqli.php");
require_once("functions.php");
if (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
elseif (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
if (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
elseif (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
$vendor_lead_code = $vendor_id;
if (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
elseif (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
if (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];}
elseif (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];}
if (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
elseif (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
if (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
elseif (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
if (isset($_POST["title"])) {$title=$_POST["title"];}
elseif (isset($_GET["title"])) {$title=$_GET["title"];}
if (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
elseif (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
if (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];}
elseif (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];}
if (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
elseif (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
if (isset($_POST["address1"])) {$address1=$_POST["address1"];}
elseif (isset($_GET["address1"])) {$address1=$_GET["address1"];}
if (isset($_POST["address2"])) {$address2=$_POST["address2"];}
elseif (isset($_GET["address2"])) {$address2=$_GET["address2"];}
if (isset($_POST["address3"])) {$address3=$_POST["address3"];}
elseif (isset($_GET["address3"])) {$address3=$_GET["address3"];}
if (isset($_POST["city"])) {$city=$_POST["city"];}
elseif (isset($_GET["city"])) {$city=$_GET["city"];}
if (isset($_POST["state"])) {$state=$_POST["state"];}
elseif (isset($_GET["state"])) {$state=$_GET["state"];}
if (isset($_POST["province"])) {$province=$_POST["province"];}
elseif (isset($_GET["province"])) {$province=$_GET["province"];}
if (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
elseif (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
if (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
elseif (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
if (isset($_POST["gender"])) {$gender=$_POST["gender"];}
elseif (isset($_GET["gender"])) {$gender=$_GET["gender"];}
if (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];}
elseif (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];}
if (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
elseif (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
if (isset($_POST["email"])) {$email=$_POST["email"];}
elseif (isset($_GET["email"])) {$email=$_GET["email"];}
if (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];}
elseif (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];}
if (isset($_POST["comments"])) {$comments=$_POST["comments"];}
elseif (isset($_GET["comments"])) {$comments=$_GET["comments"];}
if (isset($_POST["user"])) {$user=$_POST["user"];}
elseif (isset($_GET["user"])) {$user=$_GET["user"];}
if (isset($_POST["pass"])) {$pass=$_POST["pass"];}
elseif (isset($_GET["pass"])) {$pass=$_GET["pass"];}
if (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
elseif (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
if (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];}
elseif (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];}
if (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];}
elseif (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];}
if (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];}
elseif (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];}
if (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];}
elseif (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];}
if (isset($_POST["closer"])) {$closer=$_POST["closer"];}
elseif (isset($_GET["closer"])) {$closer=$_GET["closer"];}
if (isset($_POST["group"])) {$group=$_POST["group"];}
elseif (isset($_GET["group"])) {$group=$_GET["group"];}
if (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
elseif (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
if (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];}
elseif (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];}
if (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];}
elseif (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];}
if (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
elseif (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
if (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];}
elseif (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];}
if (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];}
elseif (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];}
if (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
elseif (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
if (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];}
elseif (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];}
if (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
elseif (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
if (isset($_POST["phone"])) {$phone=$_POST["phone"];}
elseif (isset($_GET["phone"])) {$phone=$_GET["phone"];}
if (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
elseif (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
if (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
elseif (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
if (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];}
elseif (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];}
if (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];}
elseif (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];}
if (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];}
elseif (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];}
if (isset($_POST["rank"])) {$rank=$_POST["rank"];}
elseif (isset($_GET["rank"])) {$rank=$_GET["rank"];}
if (isset($_POST["owner"])) {$owner=$_POST["owner"];}
elseif (isset($_GET["owner"])) {$owner=$_GET["owner"];}
if (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];}
elseif (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];}
if (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];}
elseif (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];}
if (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];}
elseif (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];}
if (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];}
elseif (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];}
if (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];}
elseif (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];}
if (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];}
elseif (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];}
if (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];}
elseif (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];}
if (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];}
elseif (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];}
if (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];}
elseif (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];}
if (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];}
elseif (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];}
if (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];}
elseif (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];}
if (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];}
elseif (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];}
if (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];}
elseif (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];}
if (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];}
elseif (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];}
if (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];}
elseif (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];}
if (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];}
elseif (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];}
if (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];}
elseif (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];}
if (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];}
elseif (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];}
if (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];}
elseif (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];}
if (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];}
elseif (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];}
if (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];}
elseif (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];}
if (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];}
elseif (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];}
if (isset($_POST["DB"])) {$DB=$_POST["DB"];}
elseif (isset($_GET["DB"])) {$DB=$_GET["DB"];}
if (isset($_POST["process"])) {$process=$_POST["process"];}
elseif (isset($_GET["process"])) {$process=$_GET["process"];}
if (isset($_POST["vicidial_id"])) {$vicidial_id=$_POST["vicidial_id"];}
elseif (isset($_GET["vicidial_id"])) {$vicidial_id=$_GET["vicidial_id"];}
if (isset($_POST["call_date"])) {$call_date=$_POST["call_date"];}
elseif (isset($_GET["call_date"])) {$call_date=$_GET["call_date"];}
if (isset($_POST["order_id"])) {$order_id=$_POST["order_id"];}
elseif (isset($_GET["order_id"])) {$order_id=$_GET["order_id"];}
if (isset($_POST["appointment_date"])) {$appointment_date=$_POST["appointment_date"];}
elseif (isset($_GET["appointment_date"])) {$appointment_date=$_GET["appointment_date"];}
if (isset($_POST["appointment_time"])) {$appointment_time=$_POST["appointment_time"];}
elseif (isset($_GET["appointment_time"])) {$appointment_time=$_GET["appointment_time"];}
if (isset($_POST["call_notes"])) {$call_notes=$_POST["call_notes"];}
elseif (isset($_GET["call_notes"])) {$call_notes=$_GET["call_notes"];}
if (isset($_POST["notesid"])) {$notesid=$_POST["notesid"];}
elseif (isset($_GET["notesid"])) {$notesid=$_GET["notesid"];}
if ($notesid < 100)
{$notesid=0;}
if (strlen($vicidial_id) < 1)
{$vicidial_id = $uniqueid;}
if (strlen($appointment_time) < 1)
{$appointment_time = '12:00:00';}
$appointment_timeARRAY = explode(":",$appointment_time);
$appointment_hour = $appointment_timeARRAY[0];
$appointment_min = $appointment_timeARRAY[1];
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$txt = '.txt';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$CIDdate = date("mdHis");
$ENTRYdate = date("YmdHis");
$MT[0]='';
$agents='@agents';
if (strlen($call_date) < 1)
{$call_date = $NOW_TIME;}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$timeclock_end_of_day = $row[1];
$agentonly_callback_campaign_lock = $row[2];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^-_0-9a-zA-Z]/","",$pass);
$length_in_sec = preg_replace("/[^0-9]/","",$length_in_sec);
$phone_code = preg_replace("/[^0-9]/","",$phone_code);
$phone_number = preg_replace("/[^0-9]/","",$phone_number);
}
else
{
$user = preg_replace("/\'|\"|\\\\|;/","",$user);
$pass = preg_replace("/\'|\"|\\\\|;/","",$pass);
}
if ($DB > 0)
{
echo "<BR>$lead_id|$entry_date|$modify_date|$status|$user|$vendor_lead_code|$source_id|$list_id|$gmt_offset_now|$called_since_last_reset|$phone_code|$phone_number|$title|$first_name|$middle_initial|$last_name|$address1|$address2|$address3|$city|$state|$province|$postal_code|$country_code|$gender|$date_of_birth|$alt_phone|$email|$security_phrase|$comments|$called_count|$last_local_call_time|$rank|$owner|\n<BR>";
}
### BEGIN find any custom field labels ###
$label_title = 'Title';
$label_first_name = 'Πρώτο';
$label_middle_initial = 'MI';
$label_last_name = 'Last';
$label_address1 = 'Διεύθυνση1';
$label_address2 = 'Διεύθυνση2';
$label_address3 = 'Διεύθυνση3';
$label_city = 'Πόλη';
$label_state = 'State';
$label_province = 'Επαρχία';
$label_postal_code = 'Ταχ.Κωδ.';
$label_vendor_lead_code = 'ID προμηθευτού';
$label_gender = 'Gender';
$label_phone_number = 'Τηλ';
$label_phone_code = 'Κωδικός Κλήσης';
$label_alt_phone = 'Εναλ/κό Τηλ';
$label_security_phrase = 'Παρουσίαση';
$label_email = 'Email';
$label_comments = 'Comments';
$stmt="SELECT label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments from system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if (strlen($row[0])>0) {$label_title = $row[0];}
if (strlen($row[1])>0) {$label_first_name = $row[1];}
if (strlen($row[2])>0) {$label_middle_initial = $row[2];}
if (strlen($row[3])>0) {$label_last_name = $row[3];}
if (strlen($row[4])>0) {$label_address1 = $row[4];}
if (strlen($row[5])>0) {$label_address2 = $row[5];}
if (strlen($row[6])>0) {$label_address3 = $row[6];}
if (strlen($row[7])>0) {$label_city = $row[7];}
if (strlen($row[8])>0) {$label_state = $row[8];}
if (strlen($row[9])>0) {$label_province = $row[9];}
if (strlen($row[10])>0) {$label_postal_code = $row[10];}
if (strlen($row[11])>0) {$label_vendor_lead_code = $row[11];}
if (strlen($row[12])>0) {$label_gender = $row[12];}
if (strlen($row[13])>0) {$label_phone_number = $row[13];}
if (strlen($row[14])>0) {$label_phone_code = $row[14];}
if (strlen($row[15])>0) {$label_alt_phone = $row[15];}
if (strlen($row[16])>0) {$label_security_phrase = $row[16];}
if (strlen($row[17])>0) {$label_email = $row[17];}
if (strlen($row[18])>0) {$label_comments = $row[18];}
### END find any custom field labels ###
# default optional vars if not set
if (!isset($format)) {$format="text";}
if ($format == 'debug') {$DB=1;}
if (!isset($ACTION)) {$ACTION="refresh";}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
echo "<HTML>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build USER: $user server_ip: $server_ip-->\n";
echo "<title>Πράκτορας Σημειώσεις";
echo "</title>\n";
echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
echo "<link rel=\"stylesheet\" href=\"calendar.css\">\n";
?>
<?php
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
if ($process > 0)
{
#Update vicidial_list record
$stmt="UPDATE vicidial_list SET vendor_lead_code='$vendor_lead_code',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',phone_code='$phone_code',phone_number='$phone_number',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',rank='$rank',owner='$owner' where lead_id='$lead_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
#Update the agent screen with new data
$stmt="UPDATE vicidial_live_agents set external_update_fields='1',external_update_fields_data='vendor_lead_code,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,phone_code,phone_number,gender,date_of_birth,alt_phone,email,security_phrase,comments,rank,owner' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
if ($notesid < 100)
{
# Insert into vicidial_call_notes
$stmt="INSERT INTO vicidial_call_notes set lead_id='$lead_id',vicidial_id='$vicidial_id',call_date='$call_date',order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$notesid = mysqli_insert_id($link);
}
else
{
# update vicidial_call_notes record
$stmt="UPDATE vicidial_call_notes set order_id='$order_id',appointment_date='$appointment_date',appointment_time='$appointment_time',call_notes='$call_notes' where notesid='$notesid';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
echo "<BR><b>Data Changes Accepted</b><BR><BR>";
}
$URLarray = explode("?", $PHP_SELF);
$URLsubmit = $URLarray[0];
?>
<TABLE Border=0 CELLPADDING=0 CELLSPACING=2 WIDTH=450>
<TR><TD COLSPAN=2 ALIGN=CENTER>
<FORM METHOD=POST NAME=vsn ID=vsn ACTION="<?php echo $URLsubmit ?>">
<input type=hidden name=DB id=DB value=<?php echo $DB ?>>
<input type=hidden name=process id=process value=1>
<input type=hidden name=lead_id id=lead_id value="<?php echo $lead_id ?>">
<input type=hidden name=user id=user value="<?php echo $user ?>">
<input type=hidden name=pass id=user value="<?php echo $pass ?>">
<input type=hidden name=notesid id=notesid value="<?php echo $notesid ?>">
<input type=hidden name=vendor_id id=vendor_id value="<?php echo $vendor_id ?>">
<input type=hidden name=title id=title value="<?php echo $title ?>">
<input type=hidden name=middle_initial id=middle_initial value="<?php echo $middle_initial ?>">
<input type=hidden name=province id=province value="<?php echo $middle_initial ?>">
<input type=hidden name=phone_code id=phone_code value="<?php echo $phone_code ?>">
<input type=hidden name=gender id=gender value="<?php echo $gender ?>">
<input type=hidden name=date_of_birth id=date_of_birth value="<?php echo $date_of_birth ?>">
<input type=hidden name=alt_phone id=alt_phone value="<?php echo $alt_phone ?>">
<input type=hidden name=email id=email value="<?php echo $email ?>">
<input type=hidden name=security_phrase id=security_phrase value="<?php echo $security_phrase ?>">
<input type=hidden name=comments id=comments value="<?php echo $comments ?>">
<input type=hidden name=rank id=rank value="<?php echo $rank ?>">
<input type=hidden name=owner id=owner value="<?php echo $owner ?>">
</TD></TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">ID προμηθευτού: </TD><TD ALIGN=LEFT><input type=text name=vendor_id id=vendor_id size=20 maxlength=20 value="<?php echo $vendor_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Source ID: </TD><TD ALIGN=LEFT>$source_id<input type=hidden name=source_id id=source_id value="<?php echo $source_id ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Title: </TD><TD ALIGN=LEFT><input type=text name=title id=title size=5 maxlength=4 value="<?php echo $title ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_first_name ?>: </TD><TD ALIGN=LEFT><input type=text name=first_name id=first_name size=30 maxlength=30 value="<?php echo $first_name ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Middle Initial: </TD><TD ALIGN=LEFT><input type=text name=middle_initial id=middle_initial size=2 maxlength=1 value="<?php echo $middle_initial ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_last_name ?>: </TD><TD ALIGN=LEFT><input type=text name=last_name id=last_name size=30 maxlength=30 value="<?php echo $last_name ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address1 ?>: </TD><TD ALIGN=LEFT><input type=text name=address1 id=address1 size=30 maxlength=100 value="<?php echo $address1 ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address2 ?>: </TD><TD ALIGN=LEFT><input type=text name=address2 id=address2 size=30 maxlength=100 value="<?php echo $address2 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_address3 ?>: </TD><TD ALIGN=LEFT><input type=text name=address3 id=address3 size=30 maxlength=100 value="<?php echo $address3 ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_city ?>: </TD><TD ALIGN=LEFT><input type=text name=city id=city size=30 maxlength=50 value="<?php echo $city ?>"> *</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_state ?>: </TD><TD ALIGN=LEFT>
<SELECT name="state" id=state>
<OPTION value="<?php echo $state ?>" selected><?php echo $state ?></OPTION>
<OPTGROUP label="United Κράτοςs">
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AK">Alaska</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="CA">California</OPTION>
<OPTION value="CO">Colorado</OPTION>
<OPTION value="CT">Connecticut</OPTION>
<OPTION value="DE">Delaware</OPTION>
<OPTION value="FL">Florida</OPTION>
<OPTION value="GA">Georgia</OPTION>
<OPTION value="HI">Hawaii</OPTION>
<OPTION value="ID">Idaho</OPTION>
<OPTION value="IL">Illinois</OPTION>
<OPTION value="IN">Indiana</OPTION>
<OPTION value="IA">Iowa</OPTION>
<OPTION value="KS">Kansas</OPTION>
<OPTION value="KY">Kentucky</OPTION>
<OPTION value="LA">Louisiana</OPTION>
<OPTION value="ME">Maine</OPTION>
<OPTION value="MD">Maryland</OPTION>
<OPTION value="MA">Massachusetts</OPTION>
<OPTION value="MI">Michigan</OPTION>
<OPTION value="MN">Minnesota</OPTION>
<OPTION value="MS">Mississippi</OPTION>
<OPTION value="MO">Missouri</OPTION>
<OPTION value="MT">Montana</OPTION>
<OPTION value="NE">Nebraska</OPTION>
<OPTION value="NV">Nevada</OPTION>
<OPTION value="NH">New Hampshire</OPTION>
<OPTION value="NJ">New Jersey</OPTION>
<OPTION value="NM">New Mexico</OPTION>
<OPTION value="NY">New York</OPTION>
<OPTION value="NC">North Carolina</OPTION>
<OPTION value="ND">North Dakota</OPTION>
<OPTION value="OH">Ohio</OPTION>
<OPTION value="OK">Oklahoma</OPTION>
<OPTION value="OR">Oregon</OPTION>
<OPTION value="PA">Pennsylvania</OPTION>
<OPTION value="RI">Rhode Island</OPTION>
<OPTION value="SC">South Carolina</OPTION>
<OPTION value="SD">South Dakota</OPTION>
<OPTION value="TN">Tennessee</OPTION>
<OPTION value="TX">Texas</OPTION>
<OPTION value="UT">Utah</OPTION>
<OPTION value="VT">Vermont</OPTION>
<OPTION value="VA">Virginia</OPTION>
<OPTION value="WA">Washington</OPTION>
<OPTION value="DC">Washington, DC</OPTION>
<OPTION value="WV">West Virginia</OPTION>
<OPTION value="WI">Wisconsin</OPTION>
<OPTION value="WY">Wyoming</OPTION>
</OPTGROUP>
<!--
<OPTGROUP label="Canada">
<OPTION value="AB">ALBERTA</OPTION>
<OPTION value="NT">NORTHWEST TERRITORY</OPTION>
<OPTION value="BC">BRITISH COLUMBIA</OPTION>
<OPTION value="ON">ONTARIO</OPTION>
<OPTION value="LB">LABRADOR</OPTION>
<OPTION value="PE">PRINCE EDWARDISLAND</OPTION>
<OPTION value="MB">MANITOBA</OPTION>
<OPTION value="PQ">QUEBEC</OPTION>
<OPTION value="NB">NEW BRUNSWICK</OPTION>
<OPTION value="SK">SASKATCHEWAN</OPTION>
<OPTION value="NF">NEWFOUNDLAND</OPTION>
<OPTION value="YT">YUKON TERRITORY</OPTION>
<OPTION value="NS">NOVA SCOTIA</OPTION>
</OPTGROUP>
-->
</SELECT> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Επαρχία: </TD><TD ALIGN=LEFT><input type=text name=province id=province size=20 maxlength=50 value="<?php echo $province ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_postal_code ?>: </TD><TD ALIGN=LEFT><input type=text name=postal_code id=postal_code size=6 maxlength=5 value="<?php echo $postal_code ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Τηλ Code: </TD><TD ALIGN=LEFT><input type=text name=phone_code id=phone_code size=10 maxlength=10 value="<?php echo $phone_code ?>"></TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA"><?php echo $label_phone_number ?>: </TD><TD ALIGN=LEFT><input type=text name=phone_number id=phone_number size=18 maxlength=18 value="<?php echo $phone_number ?>"> *</TD>
</TR>
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Φύλο:</TD><TD ALIGN=LEFT><input type=text name=gender id=gender size=2 maxlength=1 value="<?php echo $gender ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Ημερομηνία Γέννησης:</TD><TD ALIGN=LEFT><input type=text name=date_if_birth id=date_if_birth size=12 maxlength=12 value="<?php echo $date_of_birth ?>"></TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Εναλ/κό Τηλ: </TD><TD ALIGN=LEFT><input type=text name=alt_phone id=alt_phone size=12 maxlength=12 value="<?php echo $alt_phone ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Email: </TD><TD ALIGN=LEFT><input type=text name=email id=email size=30 maxlength=70 value="<?php echo $email ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Παρουσίαση: </TD><TD ALIGN=LEFT><input type=text name=security_phrase id=security_phrase size=30 maxlength=100 value="<?php echo $security_phrase ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Σχολιασμός: </TD><TD ALIGN=LEFT><input type=text name=comments id=comments size=40 maxlength=255 value="<?php echo $comments ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Rank: </TD><TD ALIGN=LEFT><input type=text name=rank id=rank size=5 maxlength=5 value="<?php echo $rank ?>"> *</TD>
</TR> -->
<!-- <TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Owner: </TD><TD ALIGN=LEFT><input type=text name=owner id=owner size=20 maxlength=20 value="<?php echo $owner ?>"> *</TD>
</TR> -->
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Order ID: </TD><TD ALIGN=LEFT><input type=text name=order_id id=order_id size=20 maxlength=20 value="<?php echo $order_id ?>"></TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA">Appointment Date/Time: </TD><TD ALIGN=LEFT><input type=text name=appointment_date id=appointment_date size=10 maxlength=10 value="<?php echo $appointment_date ?>">
<script language="JavaScript">
var o_cal = new tcal ({
// form name
'formname': 'vsn',
// input name
'controlname': 'appointment_date'
});
o_cal.a_tpl.yearscroll = false;
// o_cal.a_tpl.weekstart = 1; // Monday week start
</script>
<input type=hidden name=appointment_time id=appointment_time value="<?php echo $appointment_time ?>">
<SELECT name=appointment_hour id=appointment_hour>
<option>00</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<OPTION value="<?php echo $appointment_hour ?>" selected><?php echo $appointment_hour ?></OPTION>
</SELECT>
<SELECT name=appointment_min id=appointment_min>
<option>00</option>
<option>05</option>
<option>10</option>
<option>15</option>
<option>20</option>
<option>25</option>
<option>30</option>
<option>35</option>
<option>40</option>
<option>45</option>
<option>50</option>
<option>55</option>
<OPTION value="<?php echo $appointment_min ?>" selected><?php echo $appointment_min ?></OPTION>
</SELECT>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=2>Appointment Σημειώσεις:<BR><TEXTAREA NAME=call_notes ID=call_notes ROWS=5 COLS=50><?php echo $call_notes ?></TEXTAREA></font><br>
</TD>
</TR>
<TR BGCOLOR="#E6E6E6">
<TD ALIGN=CENTER COLSPAN=2><FONT FACE="ARIAL,HELVETICA" size=1>Please click ΥΠΟΒΑΛΕΤΕ to commit the changes, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * denotes required fields</font><br>
</TD>
</TR>
<TR BGCOLOR=white>
<TD ALIGN=CENTER COLSPAN=2>
<SCRIPT LANGUAGE="JavaScript">
function submit_form()
{
var appointment_hourFORM = document.getElementById('appointment_hour');
var appointment_hourVALUE = appointment_hourFORM[appointment_hourFORM.selectedIndex].text;
var appointment_minFORM = document.getElementById('appointment_min');
var appointment_minVALUE = appointment_minFORM[appointment_minFORM.selectedIndex].text;
document.vsn.appointment_time.value = appointment_hourVALUE + ":" + appointment_minVALUE + ":00";
document.vsn.submit();
}
</SCRIPT>
<input type=button value="ΥΠΟΒΑΛΕΤΕ" name=smt id=smt onClick="submit_form()">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</B></FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,145 @@
<?php
# voicemail_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to check whether the voicemail box on the server defined has new and old messages
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $vmail_box - ('101','1234',...)
#
#
# changes
# 50422-1147 - First build of script
# 50503-1241 - added session_name checking for extra security
# 50711-1201 - removed HTTP authentication in favor of user/pass vars
# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1204 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0025 - Converted ereg to preg functions
# 130603-2202 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-1038 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];}
elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
$version = '0.0.7';
$build = '130328-0025';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Ακυρο session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- ΕΚΔΟΣΗ: $version ΔΗΜΙΟΥΡΓΙΑ: $build VMBOX: $vmail_box server_ip: $server_ip-->\n";
echo "<title>Έλεγχος φωνητικού ταχυδρομείου";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$MT[0]='';
$row=''; $rowx='';
if (strlen($vmail_box)<1)
{
$channel_live=0;
echo "Κουτί φωνητικού ταχυδρομείου $vmail_box δεν ισχύει\n";
exit;
}
else
{
$stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$vmails_list = mysqli_num_rows($rslt);
$loop_count=0;
while ($vmails_list>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
echo "$row[0]|$row[1]";
if ($format=='debug') {echo "\n<!-- $row[0] $row[1] -->";}
}
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
}
exit;
?>
@@ -0,0 +1,29 @@
<?
$US='_';
$CL=':';
$AT='@';
$DS='-';
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
if (($server_port == '80') or ($server_port == '443') ) {$server_port='';}
else {$server_port = "$CL$server_port";}
$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name";
$agcDIR = eregi_replace('agc_en/vicidial.php','agc',$agcPAGE);
header("Location: $agcDIR/vicidial.php");
echo"<HTML><HEAD>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$agcDIR/vicidial.php\">\n";
echo"</HEAD>\n";
echo"<BODY BGCOLOR=#FFFFFF marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
echo"<a href=\"$agcDIR/vicidial.php\">click here to continue. . .</a>\n";
echo"</BODY></HTML>\n";
exit;
?>
@@ -0,0 +1,480 @@
<?php
# active_list_refresh.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to serve updates of the live data to the display scripts
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $ADD - ('1','2','3','4','5')
# - $order - ('asc','desc')
# - $format - ('text','table','menu','selectlist','textarea')
# - $bgcolor - ('#123456','white','black','etc...')
# - $txtcolor - ('#654321','black','white','etc...')
# - $txtsize - ('1','2','3','etc...')
# - $selectsize - ('2','3','4','etc...')
# - $selectfontsize - ('8','10','12','etc...')
# - $selectedext - ('cc100')
# - $selectedtrunk - ('Zap/25-1')
# - $selectedlocal - ('SIP/cc100')
# - $textareaheight - ('8','10','12','etc...')
# - $textareawidth - ('8','10','12','etc...')
# - $field_name - ('extension','busyext','extension_xfer','etc...')
#
#
# changes
# 50323-1147 - First build of script
# 50401-1132 - small formatting changes
# 50502-1402 - added field_name as modifiable variable
# 50503-1213 - added session_name checking for extra security
# 50503-1311 - added conferences list
# 50610-1155 - Added NULL check on MySQL results to reduced errors
# 50711-1209 - removed HTTP authentication in favor of user/pass vars
# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1118 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0029 - Converted ereg to preg functions
# 130603-2222 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130802-0957 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];}
elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];}
if (isset($_GET["order"])) {$order=$_GET["order"];}
elseif (isset($_POST["order"])) {$order=$_POST["order"];}
if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];}
elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];}
if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];}
elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];}
if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];}
elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];}
if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];}
elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];}
if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];}
elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];}
if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];}
elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];}
if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];}
elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];}
if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];}
elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];}
if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];}
elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];}
if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];}
elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];}
if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];}
elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];}
### security strip all non-alphanumeric characters out of the variables ###
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$ADD=preg_replace("/[^0-9]/","",$ADD);
$order=preg_replace("/[^0-9a-zA-Z]/","",$order);
$format=preg_replace("/[^0-9a-zA-Z]/","",$format);
$bgcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$bgcolor);
$txtcolor=preg_replace("/[^\#0-9a-zA-Z]/","",$txtcolor);
$txtsize=preg_replace("/[^0-9a-zA-Z]/","",$txtsize);
$selectsize=preg_replace("/[^0-9a-zA-Z]/","",$selectsize);
$selectfontsize=preg_replace("/[^0-9a-zA-Z]/","",$selectfontsize);
$selectedext=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedext);
$selectedtrunk=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedtrunk);
$selectedlocal=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$selectedlocal);
$textareaheight=preg_replace("/[^0-9a-zA-Z]/","",$textareaheight);
$textareawidth=preg_replace("/[^0-9a-zA-Z]/","",$textareawidth);
$field_name=preg_replace("/[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]/","",$field_name);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($ADD)) {$ADD="1";}
if (!isset($order)) {$order='desc';}
if (!isset($format)) {$format="text";}
if (!isset($bgcolor)) {$bgcolor='white';}
if (!isset($txtcolor)) {$txtcolor='black';}
if (!isset($txtsize)) {$txtsize='2';}
if (!isset($selectsize)) {$selectsize='4';}
if (!isset($selectfontsize)) {$selectfontsize='10';}
if (!isset($textareaheight)) {$textareaheight='10';}
if (!isset($textareawidth)) {$textareawidth='20';}
$version = '0.0.10';
$build = '130328-0029';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='table')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSIÓN: $version CONSTRUCCIÓN: $build ADD: $ADD server_ip: $server_ip-->\n";
echo "<title>Despliegue de listas: ";
if ($ADD==1) {echo "Extensiones activas";}
if ($ADD==2) {echo "Extensiones ocupadas";}
if ($ADD==3) {echo "Líneas de salida";}
if ($ADD==4) {echo "Extensiones Locales";}
if ($ADD==5) {echo "Conferencias";}
if ($ADD==99999) {echo "HELP";}
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
######################
# ADD=1 display all live extensions on a server
######################
if ($ADD==1)
{
$pt='pt';
if (!$field_name) {$field_name = 'extension';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension,fullname FROM phones where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=2 display all busy extensions on a server
######################
if ($ADD==2)
{
if (!$field_name) {$field_name = 'busyext';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT extension FROM live_channels where server_ip = '$server_ip' order by extension $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=3 display all busy outside lines(trunks) on a server
######################
if ($ADD==3)
{
if (!$field_name) {$field_name = 'trunk';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedtrunk") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=4 display all busy Local lines on a server
######################
if ($ADD==4)
{
if (!$field_name) {$field_name = 'local';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT channel, extension FROM live_sip_channels where server_ip = '$server_ip' order by channel $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$busys_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($busys_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedlocal") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
######################
# ADD=5 display all agc-usable conferences on a server
######################
if ($ADD==5)
{
$pt='pt';
if (!$field_name) {$field_name = 'conferences';}
if ($format=='table') {echo "<TABLE WIDTH=120 BGCOLOR=$bgcolor cellpadding=0 cellspacing=0>\n";}
if ($format=='menu') {echo "<SELECT SIZE=1 name=\"$field_name\">\n";}
if ($format=='selectlist')
{
echo "<SELECT SIZE=$selectsize name=\"$field_name\" STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">\n";
}
if ($format=='textarea')
{
echo "<TEXTAREA ROWS=$textareaheight COLS=$textareawidth NAME=extension WRAP=off STYLE=\"font-family : sans-serif; font-size : $selectfontsize$pt\">";
}
$stmt="SELECT conf_exten,extension FROM conferences where server_ip = '$server_ip' order by conf_exten $order";
if ($format=='table') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$phones_to_print = mysqli_num_rows($rslt);}
$o=0;
while ($phones_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if ($format=='table')
{
echo "<TR><TD ALIGN=LEFT NOWRAP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=$txtcolor SIZE=$txtsize>";
echo "$row[0] - $row[1]";
echo "</TD></TR>\n";
}
if ( ($format=='text') or ($format=='textarea') )
{
echo "$row[0] - $row[1]\n";
}
if ( ($format=='menu') or ($format=='selectlist') )
{
echo "<OPTION ";
if ($row[0]=="$selectedext") {echo "SELECTED ";}
echo "VALUE=\"$row[0]\">";
echo "$row[0] - $row[1]";
echo "</OPTION>\n";
}
$o++;
}
if ($format=='table') {echo "</TABLE>\n";}
if ($format=='menu') {echo "</SELECT>\n";}
if ($format=='selectlist') {echo "</SELECT>\n";}
if ($format=='textarea') {echo "</TEXTAREA>\n";}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
if ($format=='table') {echo "\n<!-- tiempo de ejecución del script: $RUNtime segundos -->";}
if ($format=='table') {echo "\n</body>\n</html>\n";}
exit;
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,102 @@
<?php
# audit_comments.php
#
# Copyright (C) 2014 poundteam.com,vicidial.org LICENSE: AGPLv2
#
# This script is designed to display QC audit comments, contributed by poundteam.com
#
# changes:
# 121116-1322 - First build, added to vicidial codebase
# 130802-0957 - Changed to PHP mysqli functions
# 140304-2154 - Enabled special characters in comments
#
require_once("functions.php");
function audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign) {
$audit_comments_active=audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log);
if ($audit_comments_active) {
//Get comment from list
$stmt="select comments from vicidial_list where lead_id='$lead_id' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments2',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if (strlen($row[0]) > 0) {
$comment=$row[0];
//Put comment in comment table
$stmt="INSERT INTO vicidial_comments (lead_id,user_id,list_id,campaign_id,comment) VALUES ('$lead_id','$user','$list_id','$campaign','".mysqli_real_escape_string($link, $comment)."');";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments3',$user,$server_ip,$session_name,$one_mysql_log);
}
$affected=mysqli_affected_rows($link);
if($affected>0) {
$stmt="UPDATE vicidial_list set comments='' where lead_id='$lead_id';";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments4',$user,$server_ip,$session_name,$one_mysql_log);
}
} else {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditCommentsERROR-Comment not moved',$user,$server_ip,$session_name,$one_mysql_log);
echo "\n<!-- 00142-AuditCommentsERROR-Comment not moved -->";
}
}
}
}
function audit_comments_active($list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log){
$stmt="select count(audit_comments) from vicidial_lists_custom where list_id='$list_id' and audit_comments='1' limit 1;";
if ($format=='debug') {
echo "\n<!-- $stmt -->";
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-AuditComments5',$user,$server_ip,$session_name,$one_mysql_log);
}
$row=mysqli_fetch_row($rslt);
if ($row[0] == '1') {
return true;
} else {
return false;
}
}
function get_audited_comments($lead_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log) {
global $ACcount;
global $ACcomments;
$stmt="select user_id,comment from vicidial_comments where lead_id='$lead_id';";
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"00142-65-AuditComments:$stmt LeadID: $lead_id,$format,$user,$mel,$NOW_TIME,\$link,$server_ip,$session_name,$one_mysql_log",$user,$server_ip,$session_name,$one_mysql_log);
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-69-AuditComments',$user,$server_ip,$session_name,$one_mysql_log);
}
$ACcount=mysqli_num_rows($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-72-AuditComments $ACcount='.$ACcount,$user,$server_ip,$session_name,$one_mysql_log);
if($ACcount>0) {
$i=0;
while ($i < $ACcount) {
$row=mysqli_fetch_row($rslt);
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-77-AuditComments UserID='.$row[0],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= "UserID: $row[0]\n";
mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142-79-AuditComments Comment='.$row[1],$user,$server_ip,$session_name,$one_mysql_log);
$ACcomments .= $row[1];
$ACcomments .= "\n----------------------------------\n";
$i++;
}
return true;
} else {
return false;
}
}
?>
@@ -0,0 +1,95 @@
/* calendar icon */
img.tcalIcon {
cursor: pointer;
margin-left: 1px;
vertical-align: middle;
}
/* calendar container element */
div#tcal {
position: absolute;
visibility: hidden;
z-index: 100;
width: 158px;
padding: 2px 0 0 0;
}
/* all tables in calendar */
div#tcal table {
width: 100%;
border: 1px solid silver;
border-collapse: collapse;
background-color: white;
}
/* navigation table */
div#tcal table.ctrl {
border-bottom: 0;
}
/* navigation buttons */
div#tcal table.ctrl td {
width: 15px;
height: 20px;
}
/* month year header */
div#tcal table.ctrl th {
background-color: white;
color: black;
border: 0;
}
/* week days header */
div#tcal th {
border: 1px solid silver;
border-collapse: collapse;
text-align: center;
padding: 3px 0;
font-family: tahoma, verdana, arial;
font-size: 10px;
background-color: gray;
color: white;
}
/* date cells */
div#tcal td {
border: 0;
border-collapse: collapse;
text-align: center;
padding: 2px 0;
font-family: tahoma, verdana, arial;
font-size: 11px;
width: 22px;
cursor: pointer;
}
/* date highlight
in case of conflicting settings order here determines the priority from least to most important */
div#tcal td.othermonth {
color: silver;
}
div#tcal td.weekend {
background-color: #ACD6F5;
}
div#tcal td.today {
border: 1px solid red;
}
div#tcal td.selected {
background-color: #FFB3BE;
}
/* iframe element used to suppress windowed controls in IE5/6 */
iframe#tcalIF {
position: absolute;
visibility: hidden;
z-index: 98;
border: 0;
}
/* transparent shadow */
div#tcalShade {
position: absolute;
visibility: hidden;
z-index: 99;
}
div#tcalShade table {
border: 0;
border-collapse: collapse;
width: 100%;
}
div#tcalShade table td {
border: 0;
border-collapse: collapse;
padding: 0;
}
@@ -0,0 +1,335 @@
// Tigra Calendar v4.0.2 (2009-01-12) Database (yyyy-mm-dd)
// http://www.softcomplex.com/products/tigra_calendar/
// Public Domain Software... You're welcome.
// default settins
var A_TCALDEF = {
'months' : ['Enero', 'February', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
'imgpath' : '../agc/images/' // directory with calendar images
}
// date parsing function
function f_tcalParseDate (s_date) {
var re_date = /^\s*(\d{2,4})\-(\d{1,2})\-(\d{1,2})\s*$/;
if (!re_date.exec(s_date))
return alert ("Inválido date: '" + s_date + "'.\nAccepted format is yyyy-mm-dd.")
var n_day = Number(RegExp.$3),
n_month = Number(RegExp.$2),
n_year = Number(RegExp.$1);
if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Inválido month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays = new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Inválido day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);
}
// date generating function
function f_tcalGenerDate (d_date) {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
);
}
// implementation
function tcal (a_cfg, a_tpl) {
// apply default template if not specified
if (!a_tpl)
a_tpl = A_TCALDEF;
// register in global collections
if (!window.A_TCALS)
window.A_TCALS = [];
if (!window.A_TCALSIDX)
window.A_TCALSIDX = [];
this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
window.A_TCALS[this.s_id] = this;
window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
// assign methods
this.f_show = f_tcal_show;
this.f_hide = f_tcal_hide;
this.f_toggle = f_tcalToggle;
this.f_update = f_tcalUpdate;
this.f_relDate = f_tcalRelDate;
this.f_parseDate = f_tcalParseDate;
this.f_generDate = f_tcalGenerDate;
// create calendar icon
this.s_iconId = 'tcalico_' + this.s_id;
this.e_icon = f_getElement(this.s_iconId);
if (!this.e_icon) {
document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
this.e_icon = f_getElement(this.s_iconId);
}
// save received parameters
this.a_cfg = a_cfg;
this.a_tpl = a_tpl;
}
function f_tcal_show (d_date) {
// find input field
if (!this.a_cfg.controlname)
throw("TC: control name is not specified");
if (this.a_cfg.formname) {
var e_form = document.forms[this.a_cfg.formname];
if (!e_form)
throw("TC: form '" + this.a_cfg.formname + "' can not be found");
this.e_input = e_form.elements[this.a_cfg.controlname];
}
else
this.e_input = f_getElement(this.a_cfg.controlname);
if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
// dynamically create HTML elements if needed
this.e_div = f_getElement('tcal');
if (!this.e_div) {
this.e_div = document.createElement("DIV");
this.e_div.id = 'tcal';
document.body.appendChild(this.e_div);
}
this.e_shade = f_getElement('tcalShade');
if (!this.e_shade) {
this.e_shade = document.createElement("DIV");
this.e_shade.id = 'tcalShade';
document.body.appendChild(this.e_shade);
}
this.e_iframe = f_getElement('tcalIF')
if (b_ieFix && !this.e_iframe) {
this.e_iframe = document.createElement("IFRAME");
this.e_iframe.style.filter = 'alpha(opacity=0)';
this.e_iframe.id = 'tcalIF';
this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
document.body.appendChild(this.e_iframe);
}
// hide all calendars
f_tcal_hideAll();
// generate HTML and show calendar
this.e_icon = f_getElement(this.s_iconId);
if (!this.f_update())
return;
this.e_div.style.visibility = 'visible';
this.e_shade.style.visibility = 'visible';
if (this.e_iframe)
this.e_iframe.style.visibility = 'visible';
// change icon and status
this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
this.e_icon.title = 'Close Calendar';
this.b_visible = true;
}
function f_tcal_hide (n_date) {
if (n_date)
this.e_input.value = this.f_generDate(new Date(n_date));
// no action if not visible
if (!this.b_visible)
return;
// hide elements
if (this.e_iframe)
this.e_iframe.style.visibility = 'hidden';
if (this.e_shade)
this.e_shade.style.visibility = 'hidden';
this.e_div.style.visibility = 'hidden';
// change icon and status
this.e_icon = f_getElement(this.s_iconId);
this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
this.e_icon.title = 'Open Calendar';
this.b_visible = false;
}
function f_tcalToggle () {
return this.b_visible ? this.f_hide() : this.f_show();
}
function f_tcalUpdate (d_date) {
var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
var d_selected = this.e_input.value == ''
? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
: this.f_parseDate(this.e_input.value);
// figure out date to display
if (!d_date)
// selected by default
d_date = d_selected;
else if (typeof(d_date) == 'number')
// get from number
d_date = f_tcalResetTime(new Date(d_date));
else if (typeof(d_date) == 'string')
// parse from string
this.f_parseDate(d_date);
if (!d_date) return false;
// first date to display
var d_firstday = new Date(d_date);
d_firstday.setDate(1);
d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
var a_class, s_html = '<table class="ctrl"><tbody><tr>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
+ '</tr></tbody></table><table><tbody><tr class="wd">';
// print weekdays titles
for (var i = 0; i < 7; i++)
s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
s_html += '</tr>' ;
// print calendar table
var n_date, n_month, d_current = new Date(d_firstday);
while (d_current.getMonth() == d_date.getMonth() ||
d_current.getMonth() == d_firstday.getMonth()) {
// print row heder
s_html +='<tr>';
for (var n_wday = 0; n_wday < 7; n_wday++) {
a_class = [];
n_date = d_current.getDate();
n_month = d_current.getMonth();
// other month
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length] = 'othermonth';
// weekend
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length] = 'weekend';
// today
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length] = 'today';
// selected
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length] = 'selected';
s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
d_current.setDate(++n_date);
while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
d_current.setHours(d_current.getHours + 1);
d_current = f_tcalResetTime(d_current);
}
}
// print row footer
s_html +='</tr>';
}
s_html +='</tbody></table>';
// update HTML, positions and sizes
this.e_div.innerHTML = s_html;
var n_width = this.e_div.offsetWidth;
var n_height = this.e_div.offsetHeight;
var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
if (n_left < 0) n_left = 0;
this.e_div.style.left = n_left + 'px';
this.e_div.style.top = n_top + 'px';
this.e_shade.style.width = (n_width + 8) + 'px';
this.e_shade.style.left = (n_left - 1) + 'px';
this.e_shade.style.top = (n_top - 1) + 'px';
this.e_shade.innerHTML = b_ieFix
? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
if (this.e_iframe) {
this.e_iframe.style.left = n_left + 'px';
this.e_iframe.style.top = n_top + 'px';
this.e_iframe.style.width = (n_width + 6) + 'px';
this.e_iframe.style.height = (n_height + 6) +'px';
}
return true;
}
function f_getPosition (e_elemRef, s_coord) {
var n_pos = 0, n_offset,
e_elem = e_elemRef;
while (e_elem) {
n_offset = e_elem["offset" + s_coord];
n_pos += n_offset;
e_elem = e_elem.offsetParent;
}
// margin correction in some browsers
if (b_ieMac)
n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
else if (b_safari)
n_pos -= n_offset;
e_elem = e_elemRef;
while (e_elem != document.body) {
n_offset = e_elem["scroll" + s_coord];
if (n_offset && e_elem.style.overflow == 'scroll')
n_pos -= n_offset;
e_elem = e_elem.parentNode;
}
return n_pos;
}
function f_tcalRelDate (d_date, d_diff, s_units) {
var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
var d_result = new Date(d_date);
d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
if (d_result.getDate() != d_date.getDate())
d_result.setDate(0);
return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
}
function f_tcal_hideAll () {
for (var i = 0; i < window.A_TCALSIDX.length; i++)
window.A_TCALSIDX[i].f_hide();
}
function f_tcalResetTime (d_date) {
d_date.setHours(0);
d_date.setMinutes(0);
d_date.setSeconds(0);
d_date.setMilliseconds(0);
return d_date;
}
f_getElement = document.all ?
function (s_id) { return document.all[s_id] } :
function (s_id) { return document.getElementById(s_id) };
if (document.addEventListener)
window.addEventListener('scroll', f_tcal_hideAll, false);
if (window.attachEvent)
window.attachEvent('onscroll', f_tcal_hideAll);
// global variables
var s_userAgent = navigator.userAgent.toLowerCase(),
re_webkit = /WebKit\/(\d+)/i;
var b_mac = s_userAgent.indexOf('mac') != -1,
b_ie5 = s_userAgent.indexOf('msie 5') != -1,
b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
var b_ieFix = b_ie5 || b_ie6,
b_ieMac = b_mac && b_ie5,
b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
@@ -0,0 +1,201 @@
<?php
# call_log_display.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send the inbound and outbound calls for a specific phone
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
#
# required variables:
# - $server_ip
# - $session_name
# - $user
# - $pass
# optional variables:
# - $format - ('text','debug')
# - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
# - $protocol - ('SIP','Zap','IAX2',...)
# - $in_limit - ('10','20','50','100',...)
# - $out_limit - ('10','20','50','100',...)
#
#
# changes
# 50406-1013 - First build of script
# 50407-1452 - Added definable limits
# 50503-1236 - added session_name checking for extra security
# 50610-1158 - Added NULL check on MySQL results to reduced errors
# 50711-1202 - removed HTTP authentication in favor of user/pass vars
# 60323-1550 - added option for showing different number dialed in log
# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1202 - Added variable filters to close security holes for login form
# 90508-0727 - Changed to PHP long tags
# 130328-0028 - Converted ereg to preg functions
# 130603-2219 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1005 - Changed to PHP mysqli functions
#
require_once("dbconnect_mysqli.php");
require_once("functions.php");
### If you have globals turned off uncomment these lines
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];}
elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];}
if (isset($_GET["format"])) {$format=$_GET["format"];}
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
if (isset($_GET["exten"])) {$exten=$_GET["exten"];}
elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];}
if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];}
elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];}
$user=preg_replace("/[^0-9a-zA-Z]/","",$user);
$pass=preg_replace("/[^0-9a-zA-Z]/","",$pass);
$session_name = preg_replace("/\'|\"|\\\\|;/","",$session_name);
$server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
# default optional vars if not set
if (!isset($format)) {$format="text";}
if (!isset($in_limit)) {$in_limit="100";}
if (!isset($out_limit)) {$out_limit="100";}
$number_dialed = 'number_dialed';
#$number_dialed = 'extension';
$version = '0.0.10';
$build = '130328-0028';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0);
if ($auth_message == 'GOOD')
{$auth=1;}
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
{
echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|$auth_message|\n";
exit;
}
else
{
if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) )
{
echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n";
exit;
}
else
{
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
{
echo "Inválido session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSIÓN: $version CONSTRUCCIÓN: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Desplegar registro de llamadas";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten No es válido o protocolo $protocol No es válido\n";
exit;
}
else
{
##### print outbound calls from the call_log table
$stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$out_calls_count = mysqli_num_rows($rslt);}
echo "$out_calls_count|";
$loop_count=0;
while ($out_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[3] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);}
echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|";
}
echo "\n";
##### print inbound calls from the live_inbound_log table
$stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($rslt) {$in_calls_count = mysqli_num_rows($rslt);}
echo "$in_calls_count|";
$loop_count=0;
while ($in_calls_count>$loop_count)
{
$loop_count++;
$row=mysqli_fetch_row($rslt);
$call_time_M = ($row[4] / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
$callerIDnum = $row[3]; $callerIDname = $row[3];
$callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum);
$callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname);
echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- tiempo de ejecución del script: $RUNtime segundos -->";
echo "\n</body>\n</html>\n";
}
exit;
?>

Some files were not shown because too many files have changed in this diff Show More