cleanup of extras

git-svn-id: svn://192.168.202.10@17 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-07-07 15:44:57 +00:00
parent 3716a7fea9
commit 93b5fa1e52
558 changed files with 224656 additions and 307 deletions
@@ -0,0 +1,400 @@
<?
# AST_inboundEXTstats.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$inbound_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $inbound_to_print)
{
$row=mysql_fetch_row($rslt);
$inbound[$i] =$row[0];
$fullnum[$i] =$row[1];
$inbname[$i] =$row[2];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>ASTERISK: Inbound Calls Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($inbound_to_print > $o)
{
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "ASTERISK: Inbound Calls Stats $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
if (eregi("\*",$group))
{$extenSQL = "and extension LIKE \"%$group\"";}
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total Calls That came into this number: $TOTALcalls\n";
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
if ($row[0])
{
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
}
else {$DROPpercent=0; $average_hold_seconds=0;}
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
##############################
######### CALLS STATS
echo "\n";
echo "---------- CALL LISTINGS\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$CID = sprintf("%-20s", $row[0]);
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$datetime = sprintf("%-19s", $row[3]);
$USERavgTALK = $row[2];
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
$i++;
}
echo "+----------------------+----------------------+--------+---------------------+\n";
##############################
######### TIME STATS
if ($output == 'FULL')
{
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
<?
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

@@ -0,0 +1,228 @@
<?
### inbound_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
#
# changes:
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK REMOTE INBOUND: Popup</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Redirect command sent for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
$Suser = 'username=';
$Spass = '&passwd=';
$Sphone = '&phone=';
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
if ( ($phone == 'unknown') or (strlen($phone)<9) )
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
echo "<a href=\"$newurl\">Look up this customer in Customer Service System</a>\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
else
{
echo "Redirect command FAILED for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,244 @@
<?
# phone_stats.php.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
#
# changes:
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$admin_page = './admin.php';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $row[0];
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ADMIN: Phone Stats</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; ASTERISK ADMIN: Administration</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>LIST ALL PHONES</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A NEW PHONE</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SEARCH FOR A PHONE</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A SERVER</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>LIST ALL SERVERS</a></TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SHOW ALL CONFERENCES</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A NEW CONFERENCE</a></TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> &nbsp; \n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> &nbsp;\n";
echo "<input type=submit name=submit value=submit>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
echo "<br><center>\n";
echo "<B>CALL TIME AND CHANNELS:</B>\n";
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>CHANNEL GROUP </td><td align=right><font size=2>COUNT</td><td align=right><font size=2> HOURS:MINUTES</td></tr>\n";
$total_calls=0;
$o=0;
while ($statuses_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_seconds = $row[2];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
echo "<td align=right><font size=2> $row[0]</td>\n";
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
$rslt=mysql_query($stmt, $link);
$counts_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$call_seconds = $row[0];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
# echo "|$stmt|\n";
echo "<tr><td><font size=2>TOTAL CALLS </td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>LAST 1000 CALLS FOR DATE RANGE:</B>\n";
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>NUMBER </td><td><font size=2>CHANNEL GROUP </td><td align=right><font size=2> DATE</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[1]</td>\n";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
$call_seconds=0;
$o++;
}
echo "</TABLE></center>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,162 @@
<?
### remote_inbound.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo"<HTML><HEAD>\n";
echo"<TITLE>ASTERISK REMOTE INBOUND: Main</TITLE></HEAD>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
echo"</HEAD>\n";
?>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
echo "$NOW_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $PHP_AUTH_USER - $fullname - CALLS SENT TO: $dialplan_number<BR><BR>\n";
echo "Click on the channel below that you would like to have directed to your phone<BR><BR>\n";
echo "<PRE>\n";
echo "CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
echo "----------------------------------------------------------------------------------------------\n";
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-11s", $row[0]);
$server = sprintf("%-14s", $row[1]);
$channel_group = sprintf("%-16s", $row[2]);
$extension = sprintf("%-13s", $row[3]);
$parked_by = sprintf("%-21s", $row[4]);
$parked_time = sprintf("%-19s", $row[5]);
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
$i++;
}
}
else
{
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
echo "*************************************** NO PARKED CALLS **************************************\n";
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "</PRE>\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,30 @@
<?
### test.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
$STARTtime = date("U");
$STARTdate = date("Y-m-d H:i:s");
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$stmt="SELECT * from phones;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
print "|$auth|\n";
exit;
?>
@@ -0,0 +1,400 @@
<?
# AST_inboundEXTstats.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$inbound_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $inbound_to_print)
{
$row=mysql_fetch_row($rslt);
$inbound[$i] =$row[0];
$fullnum[$i] =$row[1];
$inbname[$i] =$row[2];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>ASTERISK: Inbound Anruf-Notfall</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($inbound_to_print > $o)
{
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "WÄHLEN Sie BITTE Eine ZAHL Vor UND DATUM OBEN UND KLICKEN REICHT Ein\n";
}
else
{
echo "ASTERISK: Inbound Anruf-Notfall $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
if (eregi("\*",$group))
{$extenSQL = "and extension LIKE \"%$group\"";}
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Gesamtanrufe, die in diese Zahl kamen: $TOTALcalls\n";
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
if ($row[0])
{
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
}
else {$DROPpercent=0; $average_hold_seconds=0;}
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
##############################
######### CALLS STATS
echo "\n";
echo "---------- CALL LISTINGS\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$CID = sprintf("%-20s", $row[0]);
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$datetime = sprintf("%-19s", $row[3]);
$USERavgTALK = $row[2];
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
$i++;
}
echo "+----------------------+----------------------+--------+---------------------+\n";
##############################
######### TIME STATS
if ($output == 'FULL')
{
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN VON GESAMTANRUFEN\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
<?
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

@@ -0,0 +1,228 @@
<?
### inbound_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
#
# changes:
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ENTFERNTINBOUND: Popup</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Adressieren Sie den Befehl um, der für Führung gesendet wird $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
$Suser = 'username=';
$Spass = '&passwd=';
$Sphone = '&phone=';
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
if ( ($phone == 'unknown') or (strlen($phone)<9) )
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
echo "<a href=\"$newurl\">Schauen Sie oben diesen Kunden im Kundendienst-System</a>\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Schließen Sie dieses Fenster</a>\n<BR><BR>\n";
}
else
{
echo "Adressieren Sie den Befehl um, der für Führung VERLASSEN wird $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Schließen Sie dieses Fenster</a>\n<BR><BR>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,244 @@
<?
# phone_stats.php.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
#
# changes:
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$admin_page = './admin.php';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $row[0];
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ADMIN: Telefon-Notfall</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; STERNCHEN ADMIN: Leitung</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>VERZEICHNEN SIE ALLE TELEFONE</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADDIEREN Sie Ein NEUES TELEFON</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SUCHE NACH Einem TELEFON</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADDIEREN Sie Einen BEDIENER</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>VERZEICHNEN SIE ALLE BEDIENER</a></TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ZEIGEN SIE ALLE KONFERENZEN</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADDIEREN Sie Eine NEUE KONFERENZ</a></TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> &nbsp; \n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> &nbsp;\n";
echo "<input type=submit name=submit value=submit>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
echo "<br><center>\n";
echo "<B>ANRUF-ZEIT UND FÜHRUNGEN:</B>\n";
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>KANALGRUPPE </td><td align=right><font size=2>ZÄHLIMPULS</td><td align=right><font size=2> HOURS:MINUTES</td></tr>\n";
$total_calls=0;
$o=0;
while ($statuses_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_seconds = $row[2];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
echo "<td align=right><font size=2> $row[0]</td>\n";
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
$rslt=mysql_query($stmt, $link);
$counts_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$call_seconds = $row[0];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
# echo "|$stmt|\n";
echo "<tr><td><font size=2>GESAMTANRUFE</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>ANRUFE DES LETZT-1000 FÜR DATUM-STRECKE:</B>\n";
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>ZAHL </td><td><font size=2>KANALGRUPPE </td><td align=right><font size=2>DATUM</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[1]</td>\n";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
$call_seconds=0;
$o++;
}
echo "</TABLE></center>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,162 @@
<?
### remote_inbound.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo"<HTML><HEAD>\n";
echo"<TITLE>ASTERISK ENTFERNTINBOUND: Hauptsächlich</TITLE></HEAD>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
echo"</HEAD>\n";
?>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
echo "$NOW_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $PHP_AUTH_USER - $fullname - ANRUFE GESCHICKT ZU: $dialplan_number<BR><BR>\n";
echo "Klicken Sie an die Führung unter der, die Sie auf Ihr Telefonverwiesen haben möchten<BR><BR>\n";
echo "<PRE>\n";
echo "CHANNEL BEDIENER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
echo "----------------------------------------------------------------------------------------------\n";
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-11s", $row[0]);
$server = sprintf("%-14s", $row[1]);
$channel_group = sprintf("%-16s", $row[2]);
$extension = sprintf("%-13s", $row[3]);
$parked_by = sprintf("%-21s", $row[4]);
$parked_time = sprintf("%-19s", $row[5]);
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
$i++;
}
}
else
{
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
echo "*************************************** NO PARKED CALLS **************************************\n";
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "</PRE>\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,400 @@
<?
# AST_inboundEXTstats.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$inbound_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $inbound_to_print)
{
$row=mysql_fetch_row($rslt);
$inbound[$i] =$row[0];
$fullnum[$i] =$row[1];
$inbname[$i] =$row[2];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>ASTERISK: Στατιστικά Εισερχομένων Κλησεων</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($inbound_to_print > $o)
{
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=ΕΠΙΒΕΒΑΙΩΣΗ VALUE=ΥΠΟΒΑΛΛΩ>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΕΝΑΝ ΑΡΙΘΜΟ ΚΑΙ ΗΜΕΡΟΜΗΝΙΑ ΑΝΩΤΕΡΩ, ΚΑΙ ΠΑΤΗΣΤΕ ΕΠΙΒΕΒΑΙΩΣΗ\n";
}
else
{
echo "ASTERISK: Στατιστικά Εισερχομένων Κλησεων $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
if (eregi("\*",$group))
{$extenSQL = "and extension LIKE \"%$group\"";}
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Συνολικές κλήσεις που ήρθαν σε αυτό τον αριθμό: $TOTALcalls\n";
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
echo "\n";
echo "---------- ΕΓΚΑΤΑΛ\n";
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
if ($row[0])
{
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
}
else {$DROPpercent=0; $average_hold_seconds=0;}
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
##############################
######### CALLS STATS
echo "\n";
echo "---------- CALL LISTINGS\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$CID = sprintf("%-20s", $row[0]);
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$datetime = sprintf("%-19s", $row[3]);
$USERavgTALK = $row[2];
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
$i++;
}
echo "+----------------------+----------------------+--------+---------------------+\n";
##############################
######### TIME STATS
if ($output == 'FULL')
{
echo "\n";
echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΟΝΟΥ\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "ΓΡΑΦΙΚΗ ΠΑΡΑΣΤΑΣΗ ΜΕ 15ΛΕΠΤΕΣ ΑΥΞΗΣΕΙΣ ΤΩΝ ΣΥΝΟΛΙΚΩΝ ΚΛΗΣΕΩΝ\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
<?
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

@@ -0,0 +1,228 @@
<?
### inbound_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
#
# changes:
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΕΙΣΕΡΧΟΜΕΝΟ: Υπερεμφανιζόμενο Παραθύρο</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Η εντολή ανακατεύθυνσης στάλθηκε για το κανάλι $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
$Suser = 'username=';
$Spass = '&passwd=';
$Sphone = '&phone=';
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
if ( ($phone == 'unknown') or (strlen($phone)<9) )
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
echo "<a href=\"$newurl\">Αναζήτηση του Πελάτη στο Σύστημα Εξυπηρέτησης Πελατών</a>\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Κλείσε αυτό το παράθυρο</a>\n<BR><BR>\n";
}
else
{
echo "Η εντολή ανακατεύθυνσης ΑΠΕΤΥΧΕ για το κανάλι $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Κλείσε αυτό το παράθυρο</a>\n<BR><BR>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,244 @@
<?
# phone_stats.php.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
#
# changes:
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$admin_page = './admin.php';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $row[0];
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ADMIN: Στατιστικά Τηλεφώνου</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; ΣΥΣΤΗΜΑ ΚΛΗΣΕΩΝ: Διαχείριση</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΛΙΣΤΑ ΤΗΛΕΦΩΝΩΝ</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΠΡΟΣΘΗΚΗ ΤΗΛΕΦΩΝΟΥ</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΑΝΑΖΗΤΗΣΗ ΤΗΛΕΦΩΝΟΥ</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΠΡΟΣΘΗΚΗ ΔΙΑΚΟΜΙΣΤΗ</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΛΙΣΤΑ ΔΙΑΚΟΜΙΣΤΩΝ</a></TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΕΜΦΑΝΙΣΗ ΣΥΝΔΙΑΛΕΞΕΩΝ</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΠΡΟΣΘΗΚΗ ΣΥΝΔΙΑΛΕΞΗΣ</a></TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> &nbsp; \n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> &nbsp;\n";
echo "<input type=submit name=submit value=submit>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
echo "<br><center>\n";
echo "<B>ΧΡΟΝΟΣ ΟΜΙΛΙΑΣ ΚΑΙ ΚΑΝΑΛΙΑ:</B>\n";
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>ΚΑΝΑΛΙ ΟΜΑΔΑΣ </td><td align=right><font size=2>ΚΑΤΑΜΕΤΡΗΣΗ</td><td align=right><font size=2> ΩΡΕΣ:ΛΕΠΤΑ</td></tr>\n";
$total_calls=0;
$o=0;
while ($statuses_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_seconds = $row[2];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
echo "<td align=right><font size=2> $row[0]</td>\n";
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
$rslt=mysql_query($stmt, $link);
$counts_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$call_seconds = $row[0];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
# echo "|$stmt|\n";
echo "<tr><td><font size=2>ΣΥΝΟΛΙΚΕΣ ΚΛΗΣΕΙΣ</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>ΤΕΛΕΥΤΑΙΕΣ 1000 ΚΛΗΣΕΙΣ ΓΙΑ ΤΟ ΔΙΑΣΤΗΜΑ ΗΜΕΡΟΜΗΝΙΑΣ:</B>\n";
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>ΑΡΙΘΜΟΣ </td><td><font size=2>ΚΑΝΑΛΙ ΟΜΑΔΑΣ </td><td align=right><font size=2> ΗΜΕΡΑ</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[1]</td>\n";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
$call_seconds=0;
$o++;
}
echo "</TABLE></center>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,162 @@
<?
### remote_inbound.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]; if (!$ΕΠΙΒΕΒΑΙΩΣΗ) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo"<HTML><HEAD>\n";
echo"<TITLE>ASTERISK ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΕΙΣΕΡΧΟΜΕΝΟ: Κύριο</TITLE></HEAD>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
echo"</HEAD>\n";
?>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
echo "$NOW_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $PHP_AUTH_USER - $fullname - ΚΛΗΣΕΙΣ ΣΤΑΛΘΗΚΑΝ ΠΡΟΣ: $dialplan_number<BR><BR>\n";
echo "Πατήστε στο κανάλι παρακάτω, που θα επιθυμούσατε να έχετε κατευθύνει στο τηλέφωνό σας<BR><BR>\n";
echo "<PRE>\n";
echo "CHANNEL ΔΙΑΚΟΜΙΣΤΗΣ CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
echo "----------------------------------------------------------------------------------------------\n";
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-11s", $row[0]);
$server = sprintf("%-14s", $row[1]);
$channel_group = sprintf("%-16s", $row[2]);
$extension = sprintf("%-13s", $row[3]);
$parked_by = sprintf("%-21s", $row[4]);
$parked_time = sprintf("%-19s", $row[5]);
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
$i++;
}
}
else
{
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
echo "*************************************** NO PARKED CALLS **************************************\n";
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "</PRE>\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,400 @@
<?
# AST_inboundEXTstats.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$inbound_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $inbound_to_print)
{
$row=mysql_fetch_row($rslt);
$inbound[$i] =$row[0];
$fullnum[$i] =$row[1];
$inbname[$i] =$row[2];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>ASTERISK: Inbound Calls Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($inbound_to_print > $o)
{
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "ASTERISK: Inbound Calls Stats $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
if (eregi("\*",$group))
{$extenSQL = "and extension LIKE \"%$group\"";}
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total Calls That came into this number: $TOTALcalls\n";
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
if ($row[0])
{
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
}
else {$DROPpercent=0; $average_hold_seconds=0;}
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
##############################
######### CALLS STATS
echo "\n";
echo "---------- CALL LISTINGS\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$CID = sprintf("%-20s", $row[0]);
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$datetime = sprintf("%-19s", $row[3]);
$USERavgTALK = $row[2];
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
$i++;
}
echo "+----------------------+----------------------+--------+---------------------+\n";
##############################
######### TIME STATS
if ($output == 'FULL')
{
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,16 @@
<?
$link=mysql_connect("10.10.11.10", "astcron", "astcron");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/home/www/htdocs';
#$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

@@ -0,0 +1,228 @@
<?
### inbound_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
#
# changes:
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK REMOTE INBOUND: Popup</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Redirect command sent for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
$Suser = 'username=';
$Spass = '&passwd=';
$Sphone = '&phone=';
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
if ( ($phone == 'unknown') or (strlen($phone)<9) )
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
echo "<a href=\"$newurl\">Look up this customer in Customer Service System</a>\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
else
{
echo "Redirect command FAILED for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,244 @@
<?
# phone_stats.php.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
#
# changes:
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$admin_page = './admin.php';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $row[0];
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ADMIN: Phone Stats</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; ASTERISK ADMIN: Administration</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>LIST ALL PHONES</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A NEW PHONE</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SEARCH FOR A PHONE</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A SERVER</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>LIST ALL SERVERS</a></TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SHOW ALL CONFERENCES</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A NEW CONFERENCE</a></TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> &nbsp; \n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> &nbsp;\n";
echo "<input type=submit name=submit value=submit>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
echo "<br><center>\n";
echo "<B>CALL TIME AND CHANNELS:</B>\n";
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>CHANNEL GROUP </td><td align=right><font size=2>COUNT</td><td align=right><font size=2> HOURS:MINUTES</td></tr>\n";
$total_calls=0;
$o=0;
while ($statuses_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_seconds = $row[2];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
echo "<td align=right><font size=2> $row[0]</td>\n";
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
$rslt=mysql_query($stmt, $link);
$counts_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$call_seconds = $row[0];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
# echo "|$stmt|\n";
echo "<tr><td><font size=2>TOTAL CALLS </td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>LAST 1000 CALLS FOR DATE RANGE:</B>\n";
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>NUMBER </td><td><font size=2>CHANNEL GROUP </td><td align=right><font size=2> DATE</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[1]</td>\n";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
$call_seconds=0;
$o++;
}
echo "</TABLE></center>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,162 @@
<?
### remote_inbound.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo"<HTML><HEAD>\n";
echo"<TITLE>ASTERISK REMOTE INBOUND: Main</TITLE></HEAD>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
echo"</HEAD>\n";
?>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
echo "$NOW_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $PHP_AUTH_USER - $fullname - CALLS SENT TO: $dialplan_number<BR><BR>\n";
echo "Click on the channel below that you would like to have directed to your phone<BR><BR>\n";
echo "<PRE>\n";
echo "CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
echo "----------------------------------------------------------------------------------------------\n";
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-11s", $row[0]);
$server = sprintf("%-14s", $row[1]);
$channel_group = sprintf("%-16s", $row[2]);
$extension = sprintf("%-13s", $row[3]);
$parked_by = sprintf("%-21s", $row[4]);
$parked_time = sprintf("%-19s", $row[5]);
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
$i++;
}
}
else
{
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
echo "*************************************** NO PARKED CALLS **************************************\n";
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "</PRE>\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,400 @@
<?
# AST_inboundEXTstats.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];}
elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$inbound_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $inbound_to_print)
{
$row=mysql_fetch_row($rslt);
$inbound[$i] =$row[0];
$fullnum[$i] =$row[1];
$inbname[$i] =$row[2];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>ASTERISK: Estadística de Llamadas Entrantes</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($inbound_to_print > $o)
{
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=ENVIAR VALUE=ENVIAR>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "SELECCIONE POR FAVOR Un NÚMERO Y La FECHA ARRIBA Y El TECLEO SOMETEN\n";
}
else
{
echo "ASTERISK: Estadística de Llamadas Entrantes $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
if (eregi("\*",$group))
{$extenSQL = "and extension LIKE \"%$group\"";}
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Llamadas totales que vinieron en este número: $TOTALcalls\n";
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
if ($row[0])
{
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
}
else {$DROPpercent=0; $average_hold_seconds=0;}
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
##############################
######### CALLS STATS
echo "\n";
echo "---------- CALL LISTINGS\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
echo "+----------------------+----------------------+--------+---------------------+\n";
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$CID = sprintf("%-20s", $row[0]);
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$datetime = sprintf("%-19s", $row[3]);
$USERavgTALK = $row[2];
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
$i++;
}
echo "+----------------------+----------------------+--------+---------------------+\n";
##############################
######### TIME STATS
if ($output == 'FULL')
{
echo "\n";
echo "---------- ESTADÍSTICAS DEL TIEMPO\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "GRÁFICO EN 15 INCREMENTOS MINUCIOSOS DE LLAMADAS TOTALES\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
<?
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

@@ -0,0 +1,228 @@
<?
### inbound_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
#
# changes:
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];}
elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK SALIENTES REMOTOS: Popup</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Vuelva a dirigir el comando enviado para el canal $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
$Suser = 'username=';
$Spass = '&passwd=';
$Sphone = '&phone=';
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
if ( ($phone == 'unknown') or (strlen($phone)<9) )
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
echo "<a href=\"$newurl\">Mire para arriba a este cliente en sistema del servicio de cliente</a>\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Cierre esta ventana</a>\n<BR><BR>\n";
}
else
{
echo "Vuelva a dirigir el comando FALLADO para el canal $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Cierre esta ventana</a>\n<BR><BR>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,244 @@
<?
# phone_stats.php.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
#
# changes:
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];}
elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$admin_page = './admin.php';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $row[0];
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>ASTERISK ADMIN: Estadísticas Del Teléfono</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; ASTERISK ADMIN: Administración</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ENUMERE TODOS LOS TELÉFONOS</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>AGREGUE Un TELÉFONO NUEVO</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>BÚSQUEDA PARA Un TELÉFONO</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>AGREGUE Un SERVIDOR</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ENUMERE TODOS LOS SERVIDORES</a></TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> &nbsp; <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>DEMUESTRE TODAS LAS CONFERENCIAS</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>AGREGUE Una NUEVA CONFERENCIA</a></TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> &nbsp; \n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> &nbsp;\n";
echo "<input type=submit name=submit value=submit>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
echo "<br><center>\n";
echo "<B>TIEMPO DE LLAMADA Y CANALES:</B>\n";
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>GRUPO DE CANALES </td><td align=right><font size=2>CUENTA</td><td align=right><font size=2> HORAS:MINUTOS</td></tr>\n";
$total_calls=0;
$o=0;
while ($statuses_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_seconds = $row[2];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
echo "<td align=right><font size=2> $row[0]</td>\n";
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
$rslt=mysql_query($stmt, $link);
$counts_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$call_seconds = $row[0];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
# echo "|$stmt|\n";
echo "<tr><td><font size=2>LLAMADAS TOTALES </td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>LLAMADAS DEL ÚLTIMO 1000 PARA LA GAMA DE LA FECHA:</B>\n";
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>NÚMERO </td><td><font size=2>GRUPO DE CANALES </td><td align=right><font size=2> FECHA</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
# echo "|$stmt|\n";
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[1]</td>\n";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
$call_seconds=0;
$o++;
}
echo "</TABLE></center>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,162 @@
<?
### remote_inbound.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$ENVIAR=$_GET["ENVIAR"]; if (!$ENVIAR) {$ENVIAR=$_POST["ENVIAR"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './inbound_popup.php';
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
##### get server listing for dynamic pulldown
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
$fullname = $rowx[0];
$dialplan_number = $rowx[1];
$user_server_ip = $rowx[2];
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
}
else
{
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo"<HTML><HEAD>\n";
echo"<TITLE>ASTERISK ENTRANTES REMOTOS: Principal</TITLE></HEAD>\n";
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
echo"</HEAD>\n";
?>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
echo "$NOW_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $PHP_AUTH_USER - $fullname - LLAMADAS REALIZADAS A: $dialplan_number<BR><BR>\n";
echo "Chasque encendido el canal debajo de ése que usted quisiera haber dirigido a su teléfono<BR><BR>\n";
echo "<PRE>\n";
echo "CHANNEL SERVIDOR CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
echo "----------------------------------------------------------------------------------------------\n";
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-11s", $row[0]);
$server = sprintf("%-14s", $row[1]);
$channel_group = sprintf("%-16s", $row[2]);
$extension = sprintf("%-13s", $row[3]);
$parked_by = sprintf("%-21s", $row[4]);
$parked_time = sprintf("%-19s", $row[5]);
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
$i++;
}
}
else
{
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
echo "*************************************** NO PARKED CALLS **************************************\n";
echo "**********************************************************************************************\n";
echo "**********************************************************************************************\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "</PRE>\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,396 @@
<?
### AST_CLOSERstats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select group_id from vicidial_inbound_groups;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: VDAD Closer Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=3111&group_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "VICIDIAL: Auto-dial Closer Stats $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total Calls placed from this Campaign: $TOTALcalls\n";
echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total DROP Calls: $DROPcalls $DROPpercent%\n";
echo "Average Length for DROP Calls in seconds: $average_hold_seconds\n";
##############################
######### USER STATS
echo "\n";
echo "---------- USER STATS\n";
echo "+--------------------------+------------+--------+--------+\n";
echo "| USER | CALLS | TIME M | AVRG M |\n";
echo "+--------------------------+------------+--------+--------+\n";
$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$user = sprintf("%-6s", $row[0]);
$full_name = sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$USERcalls = sprintf("%10s", $row[2]);
$USERtotTALK = $row[3];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$USERtotTALK_MS = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
$i++;
}
echo "+--------------------------+------------+--------+--------+\n";
##############################
######### TIME STATS
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,417 @@
<?
### AST_VDADstats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: VDAD Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "VICIDIAL: Auto-dial Stats $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total Calls placed from this Campaign: $TOTALcalls\n";
echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total DROP Calls: $DROPcalls $DROPpercent%\n";
echo "Average Length for DROP Calls in seconds: $average_hold_seconds\n";
echo "\n";
echo "---------- AUTO-DIAL NO ANSWERS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$NAcalls = sprintf("%10s", $row[0]);
$NApercent = (($NAcalls / $TOTALcalls) * 100);
$NApercent = round($NApercent, 0);
$average_na_seconds = ($row[1] / $row[0]);
$average_na_seconds = round($average_na_seconds, 0);
$average_na_seconds = sprintf("%10s", $average_na_seconds);
echo "Total NA calls -Busy,Disconnect,BTvoicemail: $NAcalls $NApercent%\n";
echo "Average Call Length for NA Calls in seconds: $average_na_seconds\n";
##############################
######### USER STATS
echo "\n";
echo "---------- USER STATS\n";
echo "+--------------------------+------------+--------+--------+\n";
echo "| USER | CALLS | TIME M | AVRG M |\n";
echo "+--------------------------+------------+--------+--------+\n";
$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$user = sprintf("%-6s", $row[0]);
$full_name = sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$USERcalls = sprintf("%10s", $row[2]);
$USERtotTALK = $row[3];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$USERtotTALK_MS = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
$i++;
}
echo "+--------------------------+------------+--------+--------+\n";
##############################
######### TIME STATS
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,161 @@
<?
### AST_VICIDIAL_hopperlist.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.10.15';}
$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$campaign_id[$i] =$row[0];
$campaign_name[$i] =$row[1];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Hopper List</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
#echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
#echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($campaigns_to_print > $o)
{
if ($campaign_id[$o] == $group) {echo "<option selected value=\"$campaign_id[$o]\">$campaign_id[$o] - $campaign_name[$o]</option>\n";}
else {echo "<option value=\"$campaign_id[$o]\">$campaign_id[$o] - $campaign_name[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> \n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "PLEASE SELECT A CAMPAIGN ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "VICIDIAL: Live Current Hopper List $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
echo "Total leads in hopper right now: $TOTALcalls\n";
##############################
######### LEAD STATS
echo "\n";
echo "---------- LEADS IN HOPPER\n";
echo "+------+-----------+------------+-------+--------+-------+--------+\n";
echo "| | LEAD_ID | PHONE NUM | STATE | STATUS | COUNT | GMT |\n";
echo "+------+-----------+------------+-------+--------+-------+--------+\n";
$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$FMT_i = sprintf("%-4s", $i);
$lead_id = sprintf("%-9s", $row[0]);
$phone_number = sprintf("%-10s", $row[1]);
$state = sprintf("%-5s", $row[2]);
$status = sprintf("%-6s", $row[3]);
$count = sprintf("%-5s", $row[4]);
$gmt = sprintf("%-6s", $row[5]);
echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
$i++;
}
echo "+------+-----------+------------+-------+--------+-------+--------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,118 @@
<?
### AST_admin_log_display.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date);
# AST GUI database administration
# AST_admin_log_display.php
#
# CHANGES
# 50325-0932 - First build
# 51123-1443 - removed globals=on requirement
# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat
#
$version = '0.0.4';
$build = '60620-1044';
$STARTtime = date("U");
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo "<html>\n";
echo "<head>\n";
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<!-- VERSION: $version BUILD: $build ADD: $ADD-->\n";
echo "<title>VICIDIAL ADMIN LOG DISPLAY</title>";
echo "</head>\n";
# Fri, 25 Mar 2005
$DAY_DATE = date("j");
if ($DAY_DATE < 10)
# {$GREP_DATE = date("D, j M Y");}
{$GREP_DATE = date("D, 0j M Y");}
else
{$GREP_DATE = date("D, j M Y");}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!$query_date) {$query_date = $GREP_DATE;}
$Gquery_date = eregi_replace(" ",'\ ',$query_date);
echo "<!-- |$query_date|$Gquery_date| -->\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=20 MAXLENGTH=20 VALUE=\"$query_date\">\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
echo "VICIDIAL ADMIN CHANGE LOG $NOW_TIME\n";
#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,232 @@
<?
### AST_agent_performance.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Performance</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($campaigns_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n";
if (!$group)
{
echo "\n";
echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from 6 hour shift specified\n";
}
else
{
if ($shift == 'AM')
{
$query_date_BEGIN = "$query_date 08:45:00";
$query_date_END = "$query_date 15:33:00";
$time_BEGIN = "08:45:00";
$time_END = "15:33:00";
}
if ($shift == 'PM')
{
$query_date_BEGIN = "$query_date 15:33:00";
$query_date_END = "$query_date 23:15:00";
$time_BEGIN = "15:33:00";
$time_END = "23:15:00";
}
echo "VICIDIAL: Agent Performance $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENTS Details -------------\n\n";
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
echo "| USER NAME | ID | CALLS | TALK | TALKAVG| A | B | DC | DNC | N | NI | SALE |\n";
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
$TOTcalls=($TOTcalls + $row[0]);
$TOTtotTALK=($TOTtotTALK + $row[1]);
$calls[$i] = sprintf("%-6s", $row[0]);
$full_name[$i]= sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
$user[$i] = sprintf("%-6s", $row[3]);
$USERtotTALK = $row[1];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$pfUSERtotTALK_MS[$i] = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$pfUSERavgTALK_MS[$i] = sprintf("%6s", $USERavgTALK_MS);
$i++;
}
$k=0;
while($k < $i)
{
$ctA[$k]="0 "; $ctB[$k]="0 "; $ctDC[$k]="0 "; $ctDNC[$k]="0 "; $ctN[$k]="0 "; $ctNI[$k]="0 "; $ctSALE[$k]="0 ";
$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$m=0;
while ($m < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]); $TOT_A = ($TOT_A + $row[0]);}
if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]); $TOT_B = ($TOT_B + $row[0]);}
if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]); $TOT_DC = ($TOT_DC + $row[0]);}
if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]); $TOT_DNC = ($TOT_DNC + $row[0]);}
if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]); $TOT_N = ($TOT_N + $row[0]);}
if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]); $TOT_NI = ($TOT_NI + $row[0]);}
if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]); $TOT_SALE = ($TOT_SALE + $row[0]);}
$m++;
}
echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
$k++;
}
$TOTcalls = sprintf("%-7s", $TOTcalls);
$TOTtotTALK_M = ($TOTtotTALK / 60);
$TOTtotTALK_M = round($TOTtotTALK_M, 2);
$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
$TOTtotTALK_S = ($TOTtotTALK_S * 60);
$TOTtotTALK_S = round($TOTtotTALK_S, 0);
if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
$TOTtotTALK_MS = sprintf("%7s", $TOTtotTALK_MS);
while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
$TOT_A = sprintf("%-5s", $TOT_A);
$TOT_B = sprintf("%-5s", $TOT_B);
$TOT_DC = sprintf("%-5s", $TOT_DC);
$TOT_DNC = sprintf("%-5s", $TOT_DNC);
$TOT_N = sprintf("%-5s", $TOT_N);
$TOT_NI = sprintf("%-5s", $TOT_NI);
$TOT_SALE = sprintf("%-5s", $TOT_SALE);
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
echo "| TOTALS | $TOTcalls| $TOTtotTALK_MS| | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
echo "\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,406 @@
<?
### AST_agent_performance_detail.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Performance</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($campaigns_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n";
if (!$group)
{
echo "\n";
echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from 6 hour shift specified\n";
}
else
{
if ($shift == 'AM')
{
$query_date_BEGIN = "$query_date 03:45:00";
$query_date_END = "$query_date 15:15:00";
$time_BEGIN = "03:45:00";
$time_END = "15:15:00";
}
if ($shift == 'PM')
{
$query_date_BEGIN = "$query_date 15:15:00";
$query_date_END = "$query_date 23:15:00";
$time_BEGIN = "15:15:00";
$time_END = "23:15:00";
}
echo "VICIDIAL: Agent Performance Detail $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENTS Details -------------\n\n";
echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
echo "| USER NAME | ID | CALLS | TIME | PAUSE | PAUSAVG| WAIT | WAITAVG| TALK | TALKAVG| DISPO | DISPAVG| A | B | DC | DNC | N | NI | CB | SALE |\n";
echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
$TOTcalls=($TOTcalls + $row[0]);
$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
$TOTtotTALK=($TOTtotTALK + $row[1]);
$TOTtotWAIT=($TOTtotWAIT + $row[7]);
$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
$TOTtotDISPO=($TOTtotDISPO + $row[9]);
$calls[$i] = sprintf("%-6s", $row[0]);
$full_name[$i]= sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
$user[$i] = sprintf("%-6s", $row[3]);
$USERtime = ($row[1] + $row[5] + $row[7] + $row[9]);
$USERtotTALK = $row[1];
$USERavgTALK = $row[4];
$USERtotPAUSE = $row[5];
$USERavgPAUSE = $row[6];
$USERtotWAIT = $row[7];
$USERavgWAIT = $row[8];
$USERtotDISPO = $row[9];
$USERavgDISPO = $row[10];
$USERtime_M = ($USERtime / 60);
$USERtime_M = round($USERtime_M, 2);
$USERtime_M_int = intval("$USERtime_M");
$USERtime_S = ($USERtime_M - $USERtime_M_int);
$USERtime_S = ($USERtime_S * 60);
$USERtime_S = round($USERtime_S, 0);
if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
$USERtime_MS = "$USERtime_M_int:$USERtime_S";
$pfUSERtime_MS[$i] = sprintf("%7s", $USERtime_MS);
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$pfUSERtotTALK_MS[$i] = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$pfUSERavgTALK_MS[$i] = sprintf("%6s", $USERavgTALK_MS);
$USERtotPAUSE_M = ($USERtotPAUSE / 60);
$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
$pfUSERtotPAUSE_MS[$i] = sprintf("%6s", $USERtotPAUSE_MS);
$USERavgPAUSE_M = ($USERavgPAUSE / 60);
$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
$pfUSERavgPAUSE_MS[$i] = sprintf("%6s", $USERavgPAUSE_MS);
$USERtotWAIT_M = ($USERtotWAIT / 60);
$USERtotWAIT_M = round($USERtotWAIT_M, 2);
$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
$USERtotWAIT_S = ($USERtotWAIT_S * 60);
$USERtotWAIT_S = round($USERtotWAIT_S, 0);
if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
$pfUSERtotWAIT_MS[$i] = sprintf("%6s", $USERtotWAIT_MS);
$USERavgWAIT_M = ($USERavgWAIT / 60);
$USERavgWAIT_M = round($USERavgWAIT_M, 2);
$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
$USERavgWAIT_S = ($USERavgWAIT_S * 60);
$USERavgWAIT_S = round($USERavgWAIT_S, 0);
if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
$pfUSERavgWAIT_MS[$i] = sprintf("%6s", $USERavgWAIT_MS);
$USERtotDISPO_M = ($USERtotDISPO / 60);
$USERtotDISPO_M = round($USERtotDISPO_M, 2);
$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
$USERtotDISPO_S = ($USERtotDISPO_S * 60);
$USERtotDISPO_S = round($USERtotDISPO_S, 0);
if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
$pfUSERtotDISPO_MS[$i] = sprintf("%6s", $USERtotDISPO_MS);
$USERavgDISPO_M = ($USERavgDISPO / 60);
$USERavgDISPO_M = round($USERavgDISPO_M, 2);
$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
$USERavgDISPO_S = ($USERavgDISPO_S * 60);
$USERavgDISPO_S = round($USERavgDISPO_S, 0);
if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
$pfUSERavgDISPO_MS[$i] = sprintf("%6s", $USERavgDISPO_MS);
$i++;
}
$k=0;
while($k < $i)
{
$ctA[$k]="0 "; $ctB[$k]="0 "; $ctDC[$k]="0 "; $ctDNC[$k]="0 "; $ctN[$k]="0 "; $ctNI[$k]="0 "; $ctSALE[$k]="0 "; $ctCB[$k]="0 ";
$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$m=0;
while ($m < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]); $TOT_A = ($TOT_A + $row[0]);}
if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]); $TOT_B = ($TOT_B + $row[0]);}
if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]); $TOT_DC = ($TOT_DC + $row[0]);}
if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]); $TOT_DNC = ($TOT_DNC + $row[0]);}
if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]); $TOT_N = ($TOT_N + $row[0]);}
if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]); $TOT_NI = ($TOT_NI + $row[0]);}
if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]); $TOT_SALE = ($TOT_SALE + $row[0]);}
if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]); $TOT_CB = ($TOT_CB + $row[0]);}
$m++;
}
echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
$k++;
}
$TOTcalls = sprintf("%-7s", $TOTcalls);
$TOTtime_M = ($TOTtime / 60);
$TOTtime_M = 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 ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
$TOTtime_MS = sprintf("%7s", $TOTtime_MS);
while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
$TOTtotTALK_M = ($TOTtotTALK / 60);
$TOTtotTALK_M = round($TOTtotTALK_M, 2);
$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
$TOTtotTALK_S = ($TOTtotTALK_S * 60);
$TOTtotTALK_S = round($TOTtotTALK_S, 0);
if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
$TOTtotTALK_MS = sprintf("%7s", $TOTtotTALK_MS);
while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
$TOTtotDISPO_M = ($TOTtotDISPO / 60);
$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
$TOTtotDISPO_MS = sprintf("%7s", $TOTtotDISPO_MS);
while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
$TOTtotPAUSE_MS = sprintf("%7s", $TOTtotPAUSE_MS);
while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
$TOTtotWAIT_M = ($TOTtotWAIT / 60);
$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
$TOTtotWAIT_MS = sprintf("%7s", $TOTtotWAIT_MS);
while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
$TOTavgTALK_M = round($TOTavgTALK_M, 2);
$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
$TOTavgTALK_S = ($TOTavgTALK_S * 60);
$TOTavgTALK_S = round($TOTavgTALK_S, 0);
if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
$TOTavgTALK_MS = sprintf("%6s", $TOTavgTALK_MS);
while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
$TOTavgDISPO_MS = sprintf("%6s", $TOTavgDISPO_MS);
while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
$TOTavgPAUSE_MS = sprintf("%6s", $TOTavgPAUSE_MS);
while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
$TOTavgWAIT_MS = sprintf("%6s", $TOTavgWAIT_MS);
while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
$TOT_A = sprintf("%-5s", $TOT_A);
$TOT_B = sprintf("%-5s", $TOT_B);
$TOT_DC = sprintf("%-5s", $TOT_DC);
$TOT_DNC = sprintf("%-5s", $TOT_DNC);
$TOT_N = sprintf("%-5s", $TOT_N);
$TOT_NI = sprintf("%-5s", $TOT_NI);
$TOT_CB = sprintf("%-5s", $TOT_CB);
$TOT_SALE = sprintf("%-5s", $TOT_SALE);
echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
echo "| TOTALS | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
echo "\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,281 @@
<?
### AST_agent_time_sheet.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["agent"])) {$agent=$_GET["agent"];}
elseif (isset($_POST["agent"])) {$agent=$_POST["agent"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["calls_summary"])) {$calls_summary=$_GET["calls_summary"];}
elseif (isset($_POST["calls_summary"])) {$calls_summary=$_POST["calls_summary"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Time Sheet</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<INPUT TYPE=TEXT NAME=agent SIZE=10 MAXLENGTH=20 VALUE=\"$agent\">\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=3>\n";
if (!$agent)
{
echo "\n";
echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from available agent log data\n";
}
else
{
$query_date_BEGIN = "$query_date 00:00:00";
$query_date_END = "$query_date 23:59:59";
$time_BEGIN = "00:00:00";
$time_END = "23:59:59";
$stmt="select full_name from vicidial_users where user='$agent';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
echo "VICIDIAL: Agent Time Sheet $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
if ($calls_summary)
{
$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
$pfTOTAL_TIME_HMS = sprintf("%8s", $TOTAL_TIME_HMS);
$TALK_TIME_H = ($row[1] / 3600);
$TALK_TIME_H = round($TALK_TIME_H, 2);
$TALK_TIME_H_int = intval("$TALK_TIME_H");
$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
$TALK_TIME_M = ($TALK_TIME_M * 60);
$TALK_TIME_M = round($TALK_TIME_M, 2);
$TALK_TIME_M_int = intval("$TALK_TIME_M");
$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
$TALK_TIME_S = ($TALK_TIME_S * 60);
$TALK_TIME_S = round($TALK_TIME_S, 0);
if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
$pfTALK_TIME_HMS = sprintf("%8s", $TALK_TIME_HMS);
$PAUSE_TIME_H = ($row[3] / 3600);
$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
$pfPAUSE_TIME_HMS = sprintf("%8s", $PAUSE_TIME_HMS);
$WAIT_TIME_H = ($row[5] / 3600);
$WAIT_TIME_H = round($WAIT_TIME_H, 2);
$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
$WAIT_TIME_M = ($WAIT_TIME_M * 60);
$WAIT_TIME_M = round($WAIT_TIME_M, 2);
$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
$WAIT_TIME_S = ($WAIT_TIME_S * 60);
$WAIT_TIME_S = round($WAIT_TIME_S, 0);
if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
$pfWAIT_TIME_HMS = sprintf("%8s", $WAIT_TIME_HMS);
$WRAPUP_TIME_H = ($row[7] / 3600);
$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
$pfWRAPUP_TIME_HMS = sprintf("%8s", $WRAPUP_TIME_HMS);
$TALK_AVG_M = ($row[2] / 60);
$TALK_AVG_M = round($TALK_AVG_M, 2);
$TALK_AVG_M_int = intval("$TALK_AVG_M");
$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
$TALK_AVG_S = ($TALK_AVG_S * 60);
$TALK_AVG_S = round($TALK_AVG_S, 0);
if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
$pfTALK_AVG_MS = sprintf("%6s", $TALK_AVG_MS);
$PAUSE_AVG_M = ($row[4] / 60);
$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
$pfPAUSE_AVG_MS = sprintf("%6s", $PAUSE_AVG_MS);
$WAIT_AVG_M = ($row[6] / 60);
$WAIT_AVG_M = round($WAIT_AVG_M, 2);
$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
$WAIT_AVG_S = ($WAIT_AVG_S * 60);
$WAIT_AVG_S = round($WAIT_AVG_S, 0);
if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
$pfWAIT_AVG_MS = sprintf("%6s", $WAIT_AVG_MS);
$WRAPUP_AVG_M = ($row[8] / 60);
$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
$pfWRAPUP_AVG_MS = sprintf("%6s", $WRAPUP_AVG_MS);
echo "TOTAL CALLS TAKEN: $row[0]\n";
echo "TALK TIME: $pfTALK_TIME_HMS AVERAGE: $pfTALK_AVG_MS\n";
echo "PAUSE TIME: $pfPAUSE_TIME_HMS AVERAGE: $pfPAUSE_AVG_MS\n";
echo "WAIT TIME: $pfWAIT_TIME_HMS AVERAGE: $pfWAIT_AVG_MS\n";
echo "WRAPUP TIME: $pfWRAPUP_TIME_HMS AVERAGE: $pfWRAPUP_AVG_MS\n";
echo "----------------------------------------------------------------\n";
echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
echo "\n";
}
else
{
echo "<a href=\"$PHP_SELF?calls_summary=1&agent=$agent&query_date=$query_date\">Call Activity Summary</a>\n\n";
}
$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
echo "FIRST LOGIN: $row[0]\n";
$start = $row[1];
$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
echo "LAST LOG ACTIVITY: $row[0]\n";
$end = $row[1];
$login_time = ($end - $start);
$LOGIN_TIME_H = ($login_time / 3600);
$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
$pfLOGIN_TIME_HMS = sprintf("%8s", $LOGIN_TIME_HMS);
echo "-----------------------------------------\n";
echo "TOTAL LOGGED-IN TIME: $pfLOGIN_TIME_HMS\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,281 @@
<?
### AST_agent_time_sheet_archive.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1721 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["agent"])) {$agent=$_GET["agent"];}
elseif (isset($_POST["agent"])) {$agent=$_POST["agent"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["calls_summary"])) {$calls_summary=$_GET["calls_summary"];}
elseif (isset($_POST["calls_summary"])) {$calls_summary=$_POST["calls_summary"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Time Sheet</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<INPUT TYPE=TEXT NAME=agent SIZE=10 MAXLENGTH=20 VALUE=\"$agent\">\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=3>\n";
if (!$agent)
{
echo "\n";
echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from available agent log data\n";
}
else
{
$query_date_BEGIN = "$query_date 00:00:00";
$query_date_END = "$query_date 23:59:59";
$time_BEGIN = "00:00:00";
$time_END = "23:59:59";
$stmt="select full_name from vicidial_users where user='$agent';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
echo "VICIDIAL: Agent Time Sheet $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
if ($calls_summary)
{
$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
$pfTOTAL_TIME_HMS = sprintf("%8s", $TOTAL_TIME_HMS);
$TALK_TIME_H = ($row[1] / 3600);
$TALK_TIME_H = round($TALK_TIME_H, 2);
$TALK_TIME_H_int = intval("$TALK_TIME_H");
$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
$TALK_TIME_M = ($TALK_TIME_M * 60);
$TALK_TIME_M = round($TALK_TIME_M, 2);
$TALK_TIME_M_int = intval("$TALK_TIME_M");
$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
$TALK_TIME_S = ($TALK_TIME_S * 60);
$TALK_TIME_S = round($TALK_TIME_S, 0);
if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
$pfTALK_TIME_HMS = sprintf("%8s", $TALK_TIME_HMS);
$PAUSE_TIME_H = ($row[3] / 3600);
$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
$pfPAUSE_TIME_HMS = sprintf("%8s", $PAUSE_TIME_HMS);
$WAIT_TIME_H = ($row[5] / 3600);
$WAIT_TIME_H = round($WAIT_TIME_H, 2);
$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
$WAIT_TIME_M = ($WAIT_TIME_M * 60);
$WAIT_TIME_M = round($WAIT_TIME_M, 2);
$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
$WAIT_TIME_S = ($WAIT_TIME_S * 60);
$WAIT_TIME_S = round($WAIT_TIME_S, 0);
if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
$pfWAIT_TIME_HMS = sprintf("%8s", $WAIT_TIME_HMS);
$WRAPUP_TIME_H = ($row[7] / 3600);
$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
$pfWRAPUP_TIME_HMS = sprintf("%8s", $WRAPUP_TIME_HMS);
$TALK_AVG_M = ($row[2] / 60);
$TALK_AVG_M = round($TALK_AVG_M, 2);
$TALK_AVG_M_int = intval("$TALK_AVG_M");
$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
$TALK_AVG_S = ($TALK_AVG_S * 60);
$TALK_AVG_S = round($TALK_AVG_S, 0);
if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
$pfTALK_AVG_MS = sprintf("%6s", $TALK_AVG_MS);
$PAUSE_AVG_M = ($row[4] / 60);
$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
$pfPAUSE_AVG_MS = sprintf("%6s", $PAUSE_AVG_MS);
$WAIT_AVG_M = ($row[6] / 60);
$WAIT_AVG_M = round($WAIT_AVG_M, 2);
$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
$WAIT_AVG_S = ($WAIT_AVG_S * 60);
$WAIT_AVG_S = round($WAIT_AVG_S, 0);
if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
$pfWAIT_AVG_MS = sprintf("%6s", $WAIT_AVG_MS);
$WRAPUP_AVG_M = ($row[8] / 60);
$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
$pfWRAPUP_AVG_MS = sprintf("%6s", $WRAPUP_AVG_MS);
echo "TOTAL CALLS TAKEN: $row[0]\n";
echo "TALK TIME: $pfTALK_TIME_HMS AVERAGE: $pfTALK_AVG_MS\n";
echo "PAUSE TIME: $pfPAUSE_TIME_HMS AVERAGE: $pfPAUSE_AVG_MS\n";
echo "WAIT TIME: $pfWAIT_TIME_HMS AVERAGE: $pfWAIT_AVG_MS\n";
echo "WRAPUP TIME: $pfWRAPUP_TIME_HMS AVERAGE: $pfWRAPUP_AVG_MS\n";
echo "----------------------------------------------------------------\n";
echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
echo "\n";
}
else
{
echo "<a href=\"$PHP_SELF?calls_summary=1&agent=$agent&query_date=$query_date\">Call Activity Summary</a>\n\n";
}
$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
echo "FIRST LOGIN: $row[0]\n";
$start = $row[1];
$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
echo "LAST LOG ACTIVITY: $row[0]\n";
$end = $row[1];
$login_time = ($end - $start);
$LOGIN_TIME_H = ($login_time / 3600);
$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
$pfLOGIN_TIME_HMS = sprintf("%8s", $LOGIN_TIME_HMS);
echo "-----------------------------------------\n";
echo "TOTAL LOGGED-IN TIME: $pfLOGIN_TIME_HMS\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,396 @@
<?
### AST_parkstats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1717 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select distinct channel_group from park_log;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Park Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "PLEASE SELECT A GROUP AND DATE ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "VICIDIAL: Park Stats $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*),sum(parked_sec) from park_log where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total Calls taken in this Group: $TOTALcalls\n";
echo "Average Hold Time(seconds) for all Calls: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(parked_sec) from park_log where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Total Dropped Calls: $DROPcalls $DROPpercent%\n";
echo "Average Hold Time(seconds) for Dropped Calls: $average_hold_seconds\n";
##############################
######### USER STATS
echo "\n";
echo "---------- USER STATS\n";
echo "+--------------------------+------------+--------+--------+\n";
echo "| USER | CALLS | TIME M | AVRG M |\n";
echo "+--------------------------+------------+--------+--------+\n";
$stmt="select park_log.user,full_name,count(*),sum(talked_sec),avg(talked_sec) from park_log,vicidial_users where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and park_log.user is not null and talked_sec is not null and talked_sec > 4 and park_log.user=vicidial_users.user group by park_log.user;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$user = sprintf("%-6s", $row[0]);
$full_name = sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$USERcalls = sprintf("%10s", $row[2]);
$USERtotTALK = $row[3];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$USERtotTALK_MS = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
$i++;
}
echo "+--------------------------+------------+--------+--------+\n";
##############################
######### TIME STATS
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:00:00' and parked_time <= '$query_date $h:14:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:00:00' and parked_time <= '$query_date $h:14:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:15:00' and parked_time <= '$query_date $h:29:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:15:00' and parked_time <= '$query_date $h:29:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:30:00' and parked_time <= '$query_date $h:44:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:30:00' and parked_time <= '$query_date $h:44:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:45:00' and parked_time <= '$query_date $h:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from park_log where parked_time >= '$query_date $h:45:00' and parked_time <= '$query_date $h:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,310 @@
<?
# AST_server_performance.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
#
# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
# path from root to where ploticus files will be stored
$DOCroot = "$WeBServeRRooT/vicidial/ploticus/";
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($group)) {$group = '';}
$stmt="select server_ip from servers;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$servers_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $servers_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Server Performance</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($servers_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "</SELECT>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n";
if (!$group)
{
echo "\n";
echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from 6 hour shift specified\n";
}
else
{
if ($shift == 'AM')
{
$query_date_BEGIN = "$query_date 08:45:00";
$query_date_END = "$query_date 15:32:00";
$time_BEGIN = "08:45:00";
$time_END = "15:15:00";
}
if ($shift == 'PM')
{
$query_date_BEGIN = "$query_date 15:32:00";
$query_date_END = "$query_date 23:15:00";
$time_BEGIN = "15:15:00";
$time_END = "23:15:00";
}
echo "VICIDIAL: Server Performance $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- TOTALS, PEAKS and AVERAGES\n";
$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$HIGHload = sprintf("%10s", $row[0]);
$HIGHmulti = intval($HIGHload / 100);
#$HIGHmulti = ($HIGHload / 100);
$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$AVGload = sprintf("%10s", $row[0]);
$AVGchannels = sprintf("%10s", $row[1]);
$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$AVGcpuUSER = sprintf("%10s", $row[0]);
$AVGcpuSYSTEM = sprintf("%10s", $row[1]);
$AVGcpuIDLE = sprintf("%10s", $row[2]);
$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$USEDram = sprintf("%10s", $row[0]);
$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$OFFHOOKtime = sprintf("%10s", $row[1]);
echo "Total Calls in/out on this server: $TOTALcalls\n";
echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
echo "Average channels in use for server: $AVGchannels\n";
echo "Average load for server: $AVGload\n";
echo "Peak load for server: $HIGHload\n";
#echo "Peak used memory for server (in MB): $USEDram\n";
echo "Average USER process cpu percentage: $AVGcpuUSER %\n";
echo "Average SYSTEM process cpu percentage: $AVGcpuSYSTEM %\n";
echo "Average IDLE process cpu percentage: $AVGcpuIDLE %\n";
echo "\n";
echo "---------- LINE GRAPH:\n";
##############################
######### Graph stats
$DAT = '.dat';
$HTM = '.htm';
$PNG = '.png';
$filedate = date("Y-m-d_His");
$DATfile = "$group$query_date$shift$filedate$DAT";
$HTMfile = "$group$query_date$shift$filedate$HTM";
$PNGfile = "$group$query_date$shift$filedate$PNG";
$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
$DATfp = fopen ("$DOCroot/$DATfile", "a");
$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
$row[6] = intval($row[6] * $HIGHmulti);
fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
$i++;
}
fclose($DATfp);
$rows_to_max = ($rows_to_print + 100);
$HTMcontent = '';
$HTMcontent .= "#proc page\n";
$HTMcontent .= "#if @DEVICE in png,gif\n";
$HTMcontent .= " scale: 0.6\n";
$HTMcontent .= "\n";
$HTMcontent .= "#endif\n";
$HTMcontent .= "#proc getdata\n";
$HTMcontent .= "file: $DOCroot/$DATfile\n";
$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc areadef\n";
$HTMcontent .= "title: Server $group $query_date_BEGIN to $query_date_END\n";
$HTMcontent .= "titledetails: size=14 align=C\n";
$HTMcontent .= "rectangle: 1 1 14 7\n";
$HTMcontent .= "xscaletype: time hh:mm:ss\n";
$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
$HTMcontent .= "yrange: 0 $HIGHload\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc xaxis\n";
$HTMcontent .= "stubs: inc 30 minutes\n";
$HTMcontent .= "minorticinc: 5 minutes\n";
$HTMcontent .= "stubformat: hh:mm:ssa\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc yaxis\n";
$HTMcontent .= "stubs: inc 50\n";
$HTMcontent .= "grid: color=yellow\n";
$HTMcontent .= "gridskip: min\n";
$HTMcontent .= "ticincrement: 100 1000\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc lineplot\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: userproc\n";
$HTMcontent .= "linedetails: color=purple width=.5\n";
$HTMcontent .= "fill: lavender\n";
$HTMcontent .= "legendlabel: user proc%\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc lineplot\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: sysproc\n";
$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
$HTMcontent .= "fill: dullyellow\n";
$HTMcontent .= "legendlabel: system proc%\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc curvefit\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: load\n";
$HTMcontent .= "linedetails: color=blue width=.5\n";
$HTMcontent .= "legendlabel: load\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc curvefit\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: processes\n";
$HTMcontent .= "linedetails: color=red width=.5\n";
$HTMcontent .= "legendlabel: processes\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc curvefit\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: channels\n";
$HTMcontent .= "linedetails: color=green width=.5\n";
$HTMcontent .= "legendlabel: channels\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc legend\n";
$HTMcontent .= "location: max-2 max\n";
$HTMcontent .= "seglen: 0.2\n";
$HTMcontent .= "\n";
fwrite ($HTMfp, "$HTMcontent");
fclose($HTMfp);
passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
sleep(1);
echo "</PRE>\n";
echo "\n";
echo "<IMG SRC=\"./ploticus/$PNGfile\">\n";
echo "<!-- /usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile -->";
}
?>
</BODY></HTML>
@@ -0,0 +1,255 @@
<?
### AST_timeonVDAD.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# live real-time stats for the VICIDIAL Auto-Dialer
#
# changes:
# 50406-0920 - Added Paused agents < 1 min (Chris Doyle)
# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
$stmt="update park_log set status='HUNGUP' where hangup_time is not null;";
# $rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
if ($DB)
{
$stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');";
# $rslt=mysql_query($stmt, $link);
echo "$stmt\n";
}
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB&reset_counter=$reset_counter\">\n";
echo "<TITLE>VICIDIAL: Time On VDAD</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE><FONT SIZE=3>";
###################################################################################
###### TIME ON SYSTEM
###################################################################################
echo "VICIDIAL: Agents Time On Calls $NOW_TIME <a href=\"./server_stats.php\">REPORTS</a>\n\n";
echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
echo "| STATION | USER | SESSIONID | CHANNEL | STATUS | START TIME | MINUTES |\n";
echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[3]='';
$row[5]=' - WAITING - ';
$row[6]=$row[7];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$sessionid = sprintf("%-9s", $row[2]);
$channel = sprintf("%-10s", $row[3]);
$cc=0;
while ( (strlen($channel) > 10) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 10) {$cc=101;}
}
$status = sprintf("%-6s", $row[4]);
$start_time = sprintf("%-19s", $row[5]);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
if (eregi("PAUSED",$row[4]))
{
if ($call_time_M_int >= 1)
{$i++; continue;}
else
{$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>';}
}
$agentcount++;
echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
echo " $agentcount agents logged in on server $server_ip\n\n";
echo " <SPAN class=\"yellow\"><B> </SPAN> - Paused agents</B>\n";
echo " <SPAN class=\"blue\"><B> </SPAN> - 5 minutes or more on call</B>\n";
echo " <SPAN class=\"purple\"><B> </SPAN> - Over 10 minutes on call</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
echo "********************************* NO AGENTS ON CALLS *********************************\n";
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Time On VDAD $NOW_TIME\n\n";
echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
echo "| CHANNEL | STATUS | CAMPAIGN | PHONE NUMBER | START TIME | MINUTES |\n";
echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");
$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-10s", $row[0]);
$cc=0;
while ( (strlen($channel) > 10) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 10) {$cc=101;}
}
$status = sprintf("%-6s", $row[1]);
$campaign = sprintf("%-8s", $row[2]);
$all_phone = "$row[3]$row[4]";
$number_dialed = sprintf("%-18s", $all_phone);
$start_time = sprintf("%-19s", $row[5]);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if (eregi("LIVE",$status)) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 6) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
echo " $i calls being placed on server $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - LIVE CALL WAITING</B>\n";
# echo " <SPAN class=\"red\"><B> </SPAN> - Over 5 minutes on hold</B>\n";
}
else
{
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
echo "******************************* NO LIVE CALLS WAITING *********************************\n";
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,316 @@
<?
### AST_timeonVDAD_closer.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# live real-time stats for the VICIDIAL Auto-Dialer
#
# CHANGES
#
# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
$stmt="update park_log set status='HUNGUP' where hangup_time is not null;";
# $rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
if ($DB)
{
$stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');";
# $rslt=mysql_query($stmt, $link);
echo "$stmt\n";
}
}
?>
<HTML>
<HEAD>
<?
echo "<STYLE type=\"text/css\">\n";
echo "<!--\n";
$stmt="select group_id,group_color from vicidial_inbound_groups;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
if ($groups_to_print > 0)
{
$g=0;
while ($g < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$group_id[$g] = $row[0];
$group_color[$g] = $row[1];
echo " .$group_id[$g] {color: black; background-color: $group_color[$g]}\n";
$g++;
}
}
?>
.DEAD {color: white; background-color: black}
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB&reset_counter=$reset_counter\">\n";
echo "<TITLE>VICIDIAL: Time On VDAD</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE><FONT SIZE=3>";
###################################################################################
###### TIME ON SYSTEM
###################################################################################
echo "VICIDIAL: Agents Time On Calls $NOW_TIME <a href=\"./server_stats.php\">REPORTS</a>\n\n";
echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
echo "| STATION | USER | SESSIONID | CHANNEL | STATUS | CALLTIME | MINUTES | CAMPAIGN | FRONT |\n";
echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED|CLOSER",$row[4]))
{
$row[3]='';
$row[5]='- WAIT -';
$row[6]=$row[7];
}
$extension[$i] = sprintf("%-10s", $row[0]);
$user[$i] = sprintf("%-6s", $row[1]);
$sessionid[$i] = sprintf("%-9s", $row[2]);
$channel[$i] = sprintf("%-19s", $row[3]);
$cc[$i]=0;
while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
{
$channel[$i] = eregi_replace(".$","",$channel[$i]);
$cc[$i]++;
if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
}
$status[$i] = sprintf("%-6s", $row[4]);
$start_time[$i] = sprintf("%-8s", $row[5]);
$cd[$i]=0;
while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
{
$start_time[$i] = eregi_replace("^.","",$start_time[$i]);
$cd[$i]++;
if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
}
$uniqueid[$i] = $row[8];
$lead_id[$i] = $row[9];
$closer[$i] = $row[1];
$call_time_S[$i] = ($STARTtime - $row[6]);
$call_time_M[$i] = ($call_time_S[$i] / 60);
$call_time_M[$i] = round($call_time_M[$i], 2);
$call_time_M_int[$i] = intval("$call_time_M[$i]");
$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
$call_time_MS[$i] = sprintf("%7s", $call_time_MS[$i]);
$i++;
}
$ext_count = $i;
$i=0;
while ($i < $ext_count)
{
$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$camp_to_print = mysql_num_rows($rslt);
if ($camp_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$campaign = sprintf("%-12s", $row[0]);
$camp_color = $row[0];
}
else
{$campaign = 'DEAD '; $camp_color = 'DEAD';}
if (eregi("READY|PAUSED|CLOSER",$status[$i]))
{$campaign = ' '; $camp_color = '';}
$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$xfer_to_print = mysql_num_rows($rslt);
if ($xfer_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$fronter = sprintf("%-6s", $row[0]);
}
else
{$fronter = ' ';}
$G = ''; $EG = '';
$G="<SPAN class=\"$camp_color\"><B>"; $EG='</B></SPAN>';
# if ($call_time_M_int[$i] >= 5) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int[$i] >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
$i++;
}
echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
echo " $i agents logged in on server $server_ip\n\n";
# echo " <SPAN class=\"blue\"><B> </SPAN> - 5 minutes or more on call</B>\n";
# echo " <SPAN class=\"purple\"><B> </SPAN> - Over 10 minutes on call</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
echo "********************************* NO AGENTS ON CALLS *********************************\n";
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
#echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Time On VDAD $NOW_TIME\n\n";
echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
echo "| CHANNEL | STATUS | CAMPAIGN | PHONE NUMBER | CALLTIME | MINUTES |\n";
echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");
$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-19s", $row[0]);
$cc=0;
while ( (strlen($channel) > 19) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 19) {$cc=101;}
}
$start_time = sprintf("%-8s", $row[5]);
$cd=0;
while ( (strlen($start_time) > 8) and ($cd < 100) )
{
$start_time = eregi_replace("^.","",$start_time);
$cd++;
if (strlen($start_time) <= 8) {$cd=101;}
}
$status = sprintf("%-6s", $row[1]);
$campaign = sprintf("%-12s", $row[2]);
$all_phone = "$row[3]$row[4]";
$number_dialed = sprintf("%-18s", $all_phone);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if (eregi("LIVE",$status)) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 6) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
echo " $i calls being placed on server $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - LIVE CALL WAITING</B>\n";
# echo " <SPAN class=\"red\"><B> </SPAN> - Over 5 minutes on hold</B>\n";
}
else
{
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
echo "******************************* NO LIVE CALLS WAITING *********************************\n";
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,349 @@
<?
# AST_timeonVDADall.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# live real-time stats for the VICIDIAL Auto-Dialer all servers
#
# changes:
# 50406-0920 - Added Paused agents < 1 min (Chris Doyle)
# 51130-1218 - Modified layout and info to show all servers in a vicidial system
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60511-1343 - Added leads and drop info at the top of the screen
# 60608-1539 - Fixed CLOSER tallies for active calls
# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["RR"])) {$RR=$_GET["RR"];}
elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (!isset($group)) {$group='';}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$NOW_DAY = date("Y-m-d");
$NOW_HOUR = date("H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$stmt="select campaign_id from vicidial_campaigns where active='Y';";
$rslt=mysql_query($stmt, $link);
if (!isset($DB)) {$DB=0;}
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
if (!isset($RR)) {$RR=40;}
$NFB = '<b><font size=6 face="courier">';
$NFE = '</font></b>';
$F=''; $FG=''; $B=''; $BG='';
$reset_counter++;
if (!isset($reset_counter)) {$reset_counter=0;}
if ($reset_counter > 7)
{
$reset_counter=0;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
.orange {color: black; background-color: orange}
.r1 {color: black; background-color: #FFCCCC}
.r2 {color: black; background-color: #FF9999}
.r3 {color: black; background-color: #FF6666}
.r4 {color: white; background-color: #FF0000}
.b1 {color: black; background-color: #CCCCFF}
.b2 {color: black; background-color: #9999FF}
.b3 {color: black; background-color: #6666FF}
.b4 {color: white; background-color: #0000FF}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"$RR; URL=$PHP_SELF?RR=$RR&DB=$DB&group=$group\">\n";
echo "<TITLE>VICIDIAL: Time On VDAD Campaign: $group</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "VICIDIAL: Realtime Campaign: \n";
echo "<INPUT TYPE=HIDDEN NAME=RR VALUE=4>\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "<a href=\"$PHP_SELF?group=$group&RR=40&DB=$DB\">STOP</a> | <a href=\"$PHP_SELF?group=$group&RR=4&DB=$DB\">GO</a>";
echo " &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "\n\n";
if (!$group) {echo "<BR><BR>please select a campaign from the pulldown above</FORM>\n"; exit;}
else
{
$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$HOPlev = $row[8];
echo "<BR><table cellpadding=0 cellspacing=0><TR>";
echo "<TD ALIGN=RIGHT><font size=2><B>DIAL LEVEL:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[0]&nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>STATUSES:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[1], $row[2], $row[3], $row[4], $row[5] &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>ORDER:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[6] &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>FILTER:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[7] &nbsp; &nbsp; </TD>";
echo "</TR>";
$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDhop = $row[0];
$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$DAleads = $row[0];
$callsTODAY = $row[1];
$dropsTODAY = $row[2];
$drpctTODAY = $row[3];
echo "<TR>";
echo "<TD ALIGN=RIGHT><font size=2><B>HOPPER LEVEL:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $HOPlev &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>LEADS IN HOPPER:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $VDhop &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>DIALABLE LEADS:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $DAleads &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=CENTER COLSPAN=2><font size=2> &nbsp; <B> TIME:</B> </TD>";
echo "</TR>";
echo "<TR>";
echo "<TD ALIGN=RIGHT><font size=2><B>CALLS TODAY:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $callsTODAY &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>CALLS DROPPED:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $dropsTODAY &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>DROPPED PERCENT:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $drpctTODAY% &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=CENTER COLSPAN=2><font size=2> &nbsp; $NOW_TIME </TD>";
echo "</TR></TABLE>";
echo "</FORM>\n\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
if (eregi("CLOSER",$group))
{
$stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$closer_campaigns = preg_replace("/^ | -$/","",$row[0]);
$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
$closer_campaigns = "'$closer_campaigns'";
$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );";
}
else
{$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";}
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
$out_total=0;
$out_ring=0;
$out_live=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("LIVE",$row[0]))
{$out_live++;}
else
{
if (eregi("CLOSER",$row[0]))
{$nothing=1;}
else
{$out_ring++;}
}
$out_total++;
$i++;
}
if ($out_live > 0) {$F='<FONT class="r1">'; $FG='</FONT>';}
if ($out_live > 4) {$F='<FONT class="r2">'; $FG='</FONT>';}
if ($out_live > 9) {$F='<FONT class="r3">'; $FG='</FONT>';}
if ($out_live > 14) {$F='<FONT class="r4">'; $FG='</FONT>';}
if (eregi("CLOSER",$group))
{echo "$NFB$out_total$NFE current active calls&nbsp; &nbsp; &nbsp; \n";}
else
{echo "$NFB$out_total$NFE calls being placed &nbsp; &nbsp; &nbsp; \n";}
echo "$NFB$out_ring$NFE calls ringing &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$F &nbsp;$out_live $FG$NFE calls waiting for agents &nbsp; &nbsp; &nbsp; \n";
}
else
{
echo " NO LIVE CALLS WAITING \n";
}
###################################################################################
###### TIME ON SYSTEM
###################################################################################
$agent_incall=0;
$agent_ready=0;
$agent_paused=0;
$agent_total=0;
$Aecho = '';
$Aecho .= "VICIDIAL: Agents Time On Calls Campaign: $group $NOW_TIME\n\n";
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n";
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[5]=$row[6];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$sessionid = sprintf("%-9s", $row[2]);
$status = sprintf("%-6s", $row[3]);
$server_ip = sprintf("%-15s", $row[4]);
$call_server_ip = sprintf("%-15s", $row[7]);
$campaign_id = sprintf("%-10s", $row[8]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
if (eregi("PAUSED",$row[3]))
{
if ($call_time_M_int >= 1)
{$i++; continue;}
else
{$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>'; $agent_paused++; $agent_total++;}
}
# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") )
# {$G='<SPAN class="orange"><B>'; $EG='</B></SPAN>';}
if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
$agentcount++;
$Aecho .= "| $G$extension$EG | <a href=\"./user_status.php?user=$user\" target=\"_blank\">$G$user$EG</a> | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n";
$i++;
}
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= " $agentcount agents logged in on all servers\n\n";
$Aecho .= " <SPAN class=\"yellow\"><B> </SPAN> - Paused agents</B>\n";
# $Aecho .= " <SPAN class=\"orange\"><B> </SPAN> - Balanced call</B>\n";
$Aecho .= " <SPAN class=\"blue\"><B> </SPAN> - Agent waiting for call</B>\n";
$Aecho .= " <SPAN class=\"purple\"><B> </SPAN> - Over 5 minutes on call</B>\n";
if ($agent_ready > 0) {$B='<FONT class="b1">'; $BG='</FONT>';}
if ($agent_ready > 4) {$B='<FONT class="b2">'; $BG='</FONT>';}
if ($agent_ready > 9) {$B='<FONT class="b3">'; $BG='</FONT>';}
if ($agent_ready > 14) {$B='<FONT class="b4">'; $BG='</FONT>';}
echo "\n<BR>\n";
echo "$NFB$agent_total$NFE agents logged in &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_incall$NFE agents in calls &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$B &nbsp;$agent_ready $BG$NFE agents waiting &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_paused$NFE paused agents &nbsp; &nbsp; &nbsp; \n";
echo "<PRE><FONT SIZE=2>";
echo "";
echo "$Aecho";
}
else
{
echo " NO AGENTS ON CALLS \n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,301 @@
<?
### AST_timeonVDADall.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# live real-time stats for the VICIDIAL Auto-Dialer all servers
#
# changes:
# 50406-0920 - Added Paused agents < 1 min (Chris Doyle)
# 51130-1218 - Modified layout and info to show all servers in a vicidial system
# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala
# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];}
$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];}
$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];}
$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];}
$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];}
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
if (!$RR) {$RR=40;}
$NFB = '<b><font size=6 face="courier">';
$NFE = '</font></b>';
$F=''; $FG=''; $B=''; $BG='';
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
.orange {color: black; background-color: orange}
.r1 {color: black; background-color: #FFCCCC}
.r2 {color: black; background-color: #FF9999}
.r3 {color: black; background-color: #FF6666}
.r4 {color: white; background-color: #FF0000}
.b1 {color: black; background-color: #CCCCFF}
.b2 {color: black; background-color: #9999FF}
.b3 {color: black; background-color: #6666FF}
.b4 {color: white; background-color: #0000FF}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"$RR; URL=$PHP_SELF?RR=$RR&DB=$DB&group=$group\">\n";
echo "<TITLE>VF DIALER: Time On VDAD Campaign: $group</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "VF DIALER: Realtime Campaign: \n";
echo "<INPUT TYPE=HIDDEN NAME=RR VALUE=4>\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "<a href=\"$PHP_SELF?group=$group&RR=40&DB=$DB\">STOP</a> | <a href=\"$PHP_SELF?group=$group&RR=4&DB=$DB\">GO</a>";
echo " &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "\n\n";
if (!$group) {echo "<BR><BR>please select a campaign from the pulldown above</FORM>\n"; exit;}
else
{
$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
echo "<BR><font size=2>";
echo "<B>DIAL LEVEL:</B> $row[0] &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<B>STATUSES:</B> $row[1], $row[2], $row[3], $row[4], $row[5] &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<B>ORDER:</B> $row[6]</font>";
echo "</FORM>\n\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
if (eregi("CLOSER",$group))
{$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";}
else
{$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";}
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
$out_total=0;
$out_ring=0;
$out_live=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("LIVE",$row[0]))
{$out_live++;}
else
{
if (eregi("CLOSER",$row[0]))
{$nothing=1;}
else
{$out_ring++;}
}
$out_total++;
$i++;
}
if ($out_live > 0) {$F='<FONT class="r1">'; $FG='</FONT>';}
if ($out_live > 4) {$F='<FONT class="r2">'; $FG='</FONT>';}
if ($out_live > 9) {$F='<FONT class="r3">'; $FG='</FONT>';}
if ($out_live > 14) {$F='<FONT class="r4">'; $FG='</FONT>';}
if (eregi("CLOSER",$group))
{echo "$NFB$out_total$NFE current active calls&nbsp; &nbsp; &nbsp; \n";}
else
{echo "$NFB$out_total$NFE calls being placed &nbsp; &nbsp; &nbsp; \n";}
echo "$NFB$out_ring$NFE calls ringing &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$F &nbsp;$out_live $FG$NFE calls waiting for agents &nbsp; &nbsp; &nbsp; \n";
}
else
{
echo " NO LIVE CALLS WAITING \n";
}
###################################################################################
###### TIME ON SYSTEM
###################################################################################
$agent_incall=0;
$agent_ready=0;
$agent_paused=0;
$agent_total=0;
$Aecho = '';
$Aecho .= "VF DIALER: Agents Time On Calls Campaign: $group $NOW_TIME\n\n";
$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n";
$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n";
$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[5]=$row[6];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$sessionid = sprintf("%-9s", $row[2]);
$status = sprintf("%-6s", $row[3]);
$server_ip = sprintf("%-15s", $row[4]);
$call_server_ip = sprintf("%-15s", $row[7]);
$campaign_id = sprintf("%-10s", $row[8]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
if (eregi("PAUSED",$row[3]))
{
if ($call_time_M_int >= 1)
{$i++; continue;}
else
{$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>'; $agent_paused++; $agent_total++;}
}
# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") )
# {$G='<SPAN class="orange"><B>'; $EG='</B></SPAN>';}
if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
$sessionid = trim($sessionid);
$agentcount++;
$Aecho .= "| $G$extension$EG | <a href=\"./user_status.php?user=$user\" target=\"_blank\">$G$user$EG</a> | $G$sessionid$EG <a href=\"sip:6$sessionid@$server_ip\">LISTEN</a> | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n";
$i++;
}
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= " $agentcount agents logged in on all servers\n";
$Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n";
$Aecho .= " <SPAN class=\"yellow\"><B> </SPAN> - Paused agents</B>\n";
# $Aecho .= " <SPAN class=\"orange\"><B> </SPAN> - Balanced call</B>\n";
$Aecho .= " <SPAN class=\"blue\"><B> </SPAN> - Agent waiting for call</B>\n";
$Aecho .= " <SPAN class=\"purple\"><B> </SPAN> - Over 5 minutes on call</B>\n";
if ($agent_ready > 0) {$B='<FONT class="b1">'; $BG='</FONT>';}
if ($agent_ready > 4) {$B='<FONT class="b2">'; $BG='</FONT>';}
if ($agent_ready > 9) {$B='<FONT class="b3">'; $BG='</FONT>';}
if ($agent_ready > 14) {$B='<FONT class="b4">'; $BG='</FONT>';}
echo "\n<BR>\n";
echo "$NFB$agent_total$NFE agents logged in &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_incall$NFE agents in calls &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$B &nbsp;$agent_ready $BG$NFE agents waiting &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_paused$NFE paused agents &nbsp; &nbsp; &nbsp; \n";
echo "<PRE><FONT SIZE=2>";
echo "";
echo "$Aecho";
}
else
{
echo " NO AGENTS ON CALLS \n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,180 @@
<?
### AST_timeoncall.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"15; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>VICIDIAL: Time On Call</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE>\n\n";
echo "VICIDIAL: Time On Call $NOW_TIME\n\n";
echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
echo "| STATION | SESSIONID | CHANNEL | NUMBER DIALED | START TIME | MINUTES |\n";
echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="select extension from live_channels where server_ip='$server_ip';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$ext_to_print = mysql_num_rows($rslt);
$i=0;
$live_zap_counter=0;
$sessions = '';
while ($i < $ext_to_print)
{
$row=mysql_fetch_row($rslt);
if (preg_match("/^8600/i",$row[0]))
{
$sessions .= "$row[0]|";
}
$i++;
}
$sessions = preg_replace("/\|$/",'',$sessions);
if ($DB) {echo "SESSIONS: -$sessions-\n";}
$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
$live_calls_counter=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
{
if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
$session_id = '';
}
else
{
if (preg_match("/$row[3]/i",$sessions))
{
if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
$session_id = $row[3];
$station = preg_replace("/SIP\//",'',$row[0]);
$station = preg_replace("/-.*/",'',$station);
$LIVE_sessions[$live_calls_counter] = "$session_id";
$LIVE_sessions_FORMAT[$live_calls_counter] = sprintf("%-9s", $session_id);
$LIVE_stations[$live_calls_counter] = "$station";
$LIVE_stations_FORMAT[$live_calls_counter] = sprintf("%-10s", $station);
# echo "| $station | $session_id | \n";
$live_calls_counter++;
}
else
{
if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
$session_id = '';
}
}
$i++;
}
if ($live_calls_counter > 0)
{
$i=0;
$LC_counter = $live_calls_counter;
while ($i < $live_calls_counter)
{
$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-9s", $row[0]);
$number_dialed = sprintf("%-16s", $row[2]);
$start_time = sprintf("%-19s", $row[3]);
$call_time_S = ($STARTtime - $row[4]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 12) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 31) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
echo " $i stations on live calls on server $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - 12 minutes or more on live call\n";
echo " <SPAN class=\"red\"><B> </SPAN> - Over 30 minutes on live call\n";
}
else
{
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
echo "*************************************** NO LIVE STATIONS ********************************\n";
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
}
}
else
{
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
echo "*************************************** NO LIVE STATIONS ********************************\n";
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,197 @@
<?
### AST_timeonpark.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$timeONEhoursAGO = ($STARTtime - 3600);
$epochHALFhoursAGO = ($STARTtime - 1860);
$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO);
$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO);
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
$stmt="update park_log set status='HUNGUP' where hangup_time is not null;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
if ($DB)
{
$stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');";
$rslt=mysql_query($stmt, $link);
echo "$stmt\n";
$stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');";
$rslt=mysql_query($stmt, $link);
echo "$stmt\n";
}
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB&reset_counter=$reset_counter\">\n";
echo "<TITLE>VICIDIAL: Time On Park</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE><FONT SIZE=3>\n\n";
echo "VICIDIAL: Time On Park $NOW_TIME\n\n";
echo "+------------+-----------------+---------------------+---------+\n";
echo "| CHANNEL | GROUP | START TIME | MINUTES |\n";
echo "+------------+-----------------+---------------------+---------+\n";
#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");
$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-10s", $row[2]);
$number_dialed = sprintf("%-15s", $row[3]);
$start_time = sprintf("%-19s", $row[4]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 1) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 6) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------+-----------------+---------------------+---------+\n";
echo " $i callers waiting on server $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - 1 minute or more on hold</B>\n";
echo " <SPAN class=\"red\"><B> </SPAN> - Over 5 minutes on hold</B>\n";
}
else
{
echo "****************************************************************\n";
echo "****************************************************************\n";
echo "******************** NO LIVE CALLS WAITING *********************\n";
echo "****************************************************************\n";
echo "****************************************************************\n";
}
###################################################################################
###### TIME ON INBOUND CALLS
###################################################################################
echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Agents Time On Inbound Calls $NOW_TIME\n\n";
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
echo "| STATION | USER | CHANNEL | GROUP | START TIME | MINUTES |\n";
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$channel = sprintf("%-10s", $row[2]);
$number_dialed = sprintf("%-15s", $row[3]);
$start_time = sprintf("%-19s", $row[4]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 12) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 31) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
echo " $i agents on calls on server $server_ip\n\n";
echo " <SPAN class=\"blue\"><B> </SPAN> - 12 minutes or more on call</B>\n";
echo " <SPAN class=\"purple\"><B> </SPAN> - Over 30 minutes on call</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
echo "********************************* NO AGENTS ON CALLS *********************************\n";
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,476 @@
<?
# admin_modify_lead.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];}
elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];}
if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];}
elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];}
if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];}
elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];}
if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];}
elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];}
if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];}
elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
### AST GUI database administration modify lead in vicidial_list
### admin_modify_lead.php
# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead
# CHANGES
#
# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user
# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60609-1112 - Added DNC list addition if status changed to DNC
# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat
#
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./project_auth_entries.txt", "a");}
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname =$row[0];
$LOGmodify_leads =$row[1];
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
}
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>VICIDIAL ADMIN: Lead record modification</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
if ($end_call > 0)
{
$call_length = ($STARTtime - $call_began);
### insert a NEW record to the vicidial_closer_log table
$stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
### update the lead record in the vicidial_list table
$stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "information modified<BR><BR>\n";
echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
if ( ($dispo != $status) and ($dispo == 'CBHOLD') )
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record inactivated: $lead_id<BR>\n";
}
if ( ($dispo != $status) and ($dispo == 'CALLBK') )
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record inactivated: $lead_id<BR>\n";
}
if ( ($dispo != $status) and ($status == 'DNC') )
{
### add lead to the internal DNC list
$stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>Lead added to DNC List: $lead_id - $phone_number<BR>\n";
}
}
else
{
if ($CBchangeUSERtoANY == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record changed to ANYONE<BR>\n";
}
if ($CBchangeUSERtoUSER == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record user changed to $CBuser<BR>\n";
}
if ($CBchangeANYtoUSER == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record changed to USERONLY, user: $CBuser<BR>\n";
}
$stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_count = $row[0];
if ($lead_count > 0)
{
$stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_id = "$row[0]";
$dispo = "$row[3]";
$tsr = "$row[4]";
$vendor_id = "$row[5]";
$list_id = "$row[7]";
$campaign_id = "$row[8]";
$phone_code = "$row[10]";
$phone_number = "$row[11]";
$title = "$row[12]";
$first_name = "$row[13]"; #
$middle_initial = "$row[14]";
$last_name = "$row[15]"; #
$address1 = "$row[16]"; #
$address2 = "$row[17]"; #
$address3 = "$row[18]"; #
$city = "$row[19]"; #
$state = "$row[20]"; #
$province = "$row[21]"; #
$postal_code = "$row[22]"; #
$country_code = "$row[23]"; #
$gender = "$row[24]";
$date_of_birth = "$row[25]";
$alt_phone = "$row[26]"; #
$email = "$row[27]"; #
$security = "$row[28]"; #
$comments = "$row[29]"; #
echo "<br>Call information: $first_name $last_name - $phone_number<br><br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=end_call value=1>\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=dispo value=\"$dispo\">\n";
echo "<input type=hidden name=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
echo "<input type=hidden name=phone_code value=\"$phone_code\">\n";
echo "<input type=hidden name=phone_number value=\"$phone_number\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=channel value=\"$channel\">\n";
echo "<input type=hidden name=call_began value=\"$call_began\">\n";
echo "<input type=hidden name=parked_time value=\"$parked_time\">\n";
echo "<table cellpadding=1 cellspacing=0>\n";
echo "<tr><td colspan=2>Vendor ID: $vendor_id &nbsp; &nbsp; Lead ID: $lead_id</td></tr>\n";
echo "<tr><td colspan=2>Fronter: <A HREF=\"user_stats.php?user=$tsr\">$tsr</A> &nbsp; &nbsp; List ID: $list_id</td></tr>\n";
echo "<tr><td align=right>First Name: </td><td align=left><input type=text name=first_name size=15 maxlength=30 value=\"$first_name\"> &nbsp; \n";
echo " Last Name: <input type=text name=last_name size=15 maxlength=30 value=\"$last_name\"> </td></tr>\n";
echo "<tr><td align=right>Address 1 : </td><td align=left><input type=text name=address1 size=30 maxlength=30 value=\"$address1\"></td></tr>\n";
echo "<tr><td align=right>Address 2 : </td><td align=left><input type=text name=address2 size=30 maxlength=30 value=\"$address2\"></td></tr>\n";
echo "<tr><td align=right>Address 3 : </td><td align=left><input type=text name=address3 size=30 maxlength=30 value=\"$address3\"></td></tr>\n";
echo "<tr><td align=right>City : </td><td align=left><input type=text name=city size=30 maxlength=30 value=\"$city\"></td></tr>\n";
echo "<tr><td align=right>State: </td><td align=left><input type=text name=state size=2 maxlength=2 value=\"$state\"> &nbsp; \n";
echo " Postal Code: <input type=text name=postal_code size=10 maxlength=10 value=\"$postal_code\"> </td></tr>\n";
echo "<tr><td align=right>Province : </td><td align=left><input type=text name=province size=30 maxlength=30 value=\"$province\"></td></tr>\n";
echo "<tr><td align=right>Country : </td><td align=left><input type=text name=country_code size=3 maxlength=3 value=\"$country_code\"></td></tr>\n";
echo "<tr><td align=right>Alt Phone : </td><td align=left><input type=text name=alt_phone size=10 maxlength=10 value=\"$alt_phone\"></td></tr>\n";
echo "<tr><td align=right>Email : </td><td align=left><input type=text name=email size=30 maxlength=50 value=\"$email\"></td></tr>\n";
echo "<tr><td align=right>Security : </td><td align=left><input type=text name=security size=30 maxlength=100 value=\"$security\"></td></tr>\n";
echo "<tr><td align=right>Comments : </td><td align=left><input type=text name=comments size=30 maxlength=255 value=\"$comments\"></td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Disposition: </td><td align=left><select size=1 name=status>\n";
$stmt="SELECT * from vicidial_statuses where selectable='Y' order by status";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
$statuses_list='';
$o=0;
$DS=0;
while ($statuses_to_print > $o)
{
$rowx=mysql_fetch_row($rslt);
if ($dispo == "$rowx[0]")
{$statuses_list .= "<option SELECTED value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; $DS++;}
else
{$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
$o++;
}
if ($DS < 1) {$statuses_list .= "<option SELECTED value=\"$dispo\">$dispo</option>\n";}
echo "$statuses_list";
echo "</select></td></tr>\n";
echo "<tr><td colspan=2><input type=submit name=submit value=\"SUBMIT\"></td></tr>\n";
echo "</table></form>\n";
echo "<BR><BR><BR>\n";
if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') )
{
### find any vicidial_callback records for this lead
$stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$CB_to_print = mysql_num_rows($rslt);
$rowx=mysql_fetch_row($rslt);
if ($CB_to_print>0)
{
if ($rowx[9] == 'USERONLY')
{
echo "<br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=CBchangeUSERtoANY value=\"YES\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=callback_id value=\"$rowx[0]\">\n";
echo "<input type=submit name=submit value=\"CHANGE TO ANYONE CALLBACK\"></form><BR>\n";
echo "<br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=CBchangeUSERtoUSER value=\"YES\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=callback_id value=\"$rowx[0]\">\n";
echo "New Callback Owner UserID: <input type=text name=CBuser size=8 maxlength=10 value=\"$rowx[8]\"> \n";
echo "<input type=submit name=submit value=\"CHANGE USERONLY CALLBACK USER\"></form><BR>\n";
}
else
{
echo "<br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=CBchangeANYtoUSER value=\"YES\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=callback_id value=\"$rowx[0]\">\n";
echo "New Callback Owner UserID: <input type=text name=CBuser size=8 maxlength=10 value=\"$rowx[8]\"> \n";
echo "<input type=submit name=submit value=\"CHANGE TO USERONLY CALLBACK\"></form><BR>\n";
}
}
else
{
echo "<BR>No Callback records found<BR>\n";
}
}
}
else
{
echo "lead lookup FAILED for lead_id $lead_id &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
# echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
echo "<br><br>\n";
echo "<center>\n";
echo "<B>CALLS TO THIS LEAD:</B>\n";
echo "<TABLE width=550 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>DATE/TIME </td><td align=left><font size=2>LENGTH</td><td align=left><font size=2> STATUS</td><td align=left><font size=2> TSR</td><td align=right><font size=2> CAMPAIGN</td><td align=right><font size=2> LIST</td><td align=right><font size=2> LEAD</td></tr>\n";
$stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[4]</td>";
echo "<td align=left><font size=2> $row[7]</td>\n";
echo "<td align=left><font size=2> $row[8]</td>\n";
echo "<td align=left><font size=2> <A HREF=\"user_stats.php?user=$row[11]\" target=\"_blank\">$row[11]</A> </td>\n";
echo "<td align=right><font size=2> $row[3] </td>\n";
echo "<td align=right><font size=2> $row[2] </td>\n";
echo "<td align=right><font size=2> $row[1] </td></tr>\n";
$u++;
}
echo "</TABLE></center>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,224 @@
<?
### admin_search_lead.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
### AST GUI database administration search for lead info
### admin_modify_lead.php
#
# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead
#
# changes:
# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
# - Changed results to multi-record
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./project_auth_entries.txt", "a");}
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname =$row[0];
$LOGmodify_leads =$row[1];
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
}
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>VICIDIAL ADMIN: Lead Search</title>
</head>
<title>Lead Lookup</title>
</head>
<body bgcolor=white>
<?
if ( (!$vendor_id) and (!$phone) and (!$lead_id) )
{
echo date("l F j, Y G:i:s A");
echo "\n<br><br><center>\n";
echo "<form method=post name=search action=\"$PHP_SELF\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<b>Please enter a:<br> Vendor ID(vendor lead code): <input type=text name=vendor_id size=10 maxlength=10> or \n";
echo "<br><b>a Home Phone Number: <input type=text name=phone size=10 maxlength=10> or\n";
echo "<br><b>a lead ID: <input type=text name=lead_id size=10 maxlength=10> <br><br>\n";
echo "<input type=submit name=submit value=SUBMIT></b>\n";
echo "</form>\n</center>\n";
echo "</body></html>\n";
exit;
}
else
{
if ($vendor_id)
{
$stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000";
}
else
{
if ($phone)
{
$stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000";
}
else
{
if ($lead_id)
{
$stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000";
}
else
{
print "ERROR: you must search for something! Go back and search for something";
exit;
}
}
}
if ($DB)
{
echo "\n\n$stmt\n\n";
}
$rslt=mysql_query($stmt, $link);
$results_to_print = mysql_num_rows($rslt);
if ($results_to_print < 1)
{
echo date("l F j, Y G:i:s A");
echo "\n<br><br><center>\n";
echo "<b>The search variables you entered are not active in the system</b><br><br>\n";
echo "<b>Please go back and double check the information you entered and submit again</b>\n";
echo "</center>\n";
echo "</body></html>\n";
exit;
}
else
{
echo "<b>RESULTS: $results_to_print</b><BR><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LEAD ID</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>STATUS</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>VENDOR ID</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LAST AGENT</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LIST ID</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>PHONE</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>NAME</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CITY</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>SECURITY</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LAST CALL</B></FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
{
$row=mysql_fetch_row($rslt);
$o++;
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><a href=\"admin_modify_lead.php?lead_id=$row[0]\">$row[0]</a></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[11]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[13] $row[15]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[19]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[28]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n<a href=\"$PHP_SELF\">NEW SEARCH</a>";
echo "\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds";
?>
</body>
</html>
@@ -0,0 +1,508 @@
<?
### closer-fronter_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the closer popup of a specific call that starts recording the call and allows you to go and fetch info on that caller in the local CRM system.
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
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["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
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["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
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["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["security"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["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["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
#$DB = '1'; # DEBUG override
$US = '_';
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$REC_TIME = date("Ymd-His");
$FILE_datetime = $STARTtime;
$parked_time = $STARTtime;
# $ext_context = 'default'; defined in dbconnect file
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$user|$pass|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($user);
$password=strtoupper($pass);
$stmt="SELECT full_name from vicidial_users where user='$user' and pass='$pass'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$fullname = $row[0];
fwrite ($fp, "VD_CLOSER|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n");
fclose($fp);
if ( (strlen($customer_zap_channel)>2) and (eregi('zap',$customer_zap_channel)) )
{
echo "\n<!-- zap channel: $customer_zap_channel -->\n";
echo "\n<!-- session_id: $session_id -->\n";
}
else
{
echo "Bad channel: $customer_zap_channel\n";
echo "Make sure the Zap channel is live and try again\n";
exit;
}
}
else
{
fwrite ($fp, "VD_CLOSER|FAIL|$date|$user|$pass|$ip|$browser|\n");
fclose($fp);
}
}
echo "<html>\n";
echo "<head>\n";
echo "<title>VICIDIAL FRONTER-CLOSER: Popup</title>\n";
if (eregi('CL_UNIV',$channel_group))
{
?>
<script language="Javascript1.2">
var btn_name="search";
if (document.layers) {
document.captureEvents(Event.KEYPRESS);
document.onkeypress = function (evt) {
if (evt.target.constructor == Input) {
if (evt.target.name == 'lead_id' || evt.target.name == 'phone' || evt.target.name == 'confirmation_id') {
return ((evt.which >= '0'.charCodeAt() && evt.which <= '9'.charCodeAt()));
}
}
}
}
function CheckForm() {
if (btn_name=="update") {
if (document.forms[0].phone.value.length!=10) {
alert("The phone number you entered does not have 10 digits.\n\nIt has "+document.forms[0].phone.value.length+" - please correct it and try again.");
return false;
} else if (document.forms[0].confirmation_id.value.length<=5) {
alert("The confirmation ID is either missing or not enough characters in length.\n\nPlease correct it and try again.");
return false;
} else {
return true;
}
}
}
</script>
<?
}
else
{
echo "<script language=\"Javascript1.2\">\n";
echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n";
echo "</script>\n";
}
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad="document.forms[0].search_phone.focus(); setTimeout('document.forms[0].search_phone.focus()', 1000); self.focus()">
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from live_channels where server_ip='$server_ip' and channel='$customer_zap_channel'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
# $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_query($stmt, $link);
$DTqueryCID = "RZ$FILE_datetime$user";
### insert a NEW record to the vicidial_manager table to be processed
$channel = $customer_zap_channel;
$channel = eregi_replace('Zap/', "", $channel);
$SIPexten = eregi_replace('SIP/', "", $SIPexten);
$filename = "$REC_TIME$US$SIPexten";
# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: Zap/$channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_query($stmt, $link);
# Local/78600098@demo-6617,2
$stmt = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Originate','$DTqueryCID','Channel: $local_DEF$conf_silent_prefix$session_id$local_AMP$ext_context','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: $filename','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('Zap/$channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$stmt="SELECT recording_id FROM recording_log where filename='$filename'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$recording_id = $row[0];
echo "Recording command sent for channel $channel - $filename - $recording_id &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$stmt="SELECT full_name from vicidial_users where user='$user'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
echo "Call Referred by: $user - $full_name\n<BR><BR>\n";
$url = "http://10.10.99.2/vicidial/closer_dispo.php?lead_id=$lead_id&channel=$channel&server_ip=$server_ip&extension=$SIPexten&call_began=$STARTtime&parked_time=$parked_time&DB=$DB";
echo "<a href=\"$url\">View Customer Info and Disposition Call</a>\n<BR><BR>\n";
# $stmt="UPDATE park_log set grab_time='$NOW_TIME',status='TALKING',extension='$extension',user='$user' where parked_time='$parked_time' and server_ip='$server_ip' and channel='$channel'";
# if ($DB) {echo "|$stmt|\n";}
# $fp = fopen ("./closer_SQL_updates.txt", "a");
# fwrite ($fp, "$date|$user|$stmt|\n");
# fclose($fp);
# $rslt=mysql_query($stmt, $link);
###########################################################################################
####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX
###########################################################################################
if (eregi('CL_TEST',$channel_group))
{
echo "GALLERIA TEST CLOSER GROUP: $channel_group\n";
$stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$fronter=$row[0];
$search_phone=$row[1];
?>
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$fronter ?>">
<input type=hidden name="closer" value="<?=$user ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor='#99FF99'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$search_phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<?
}
if ( (eregi('CL_MWCOF',$channel_group)) or (eregi('MWCOF',$group)) or (eregi('TESTCAMP',$group)))
{
echo "BUYERS EDGE INTERNAL CLOSER GROUP: $channel_group\n";
$stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$fronter=$row[0];
$search_phone=$row[1];
?>
<form action="http://10.10.99.2/vicidial/closer_lookup4.php" method="post">
<input type=hidden name="fronter" value="<?=$fronter ?>">
<input type=hidden name="closer" value="<?=$user ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor='#99FF99'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$search_phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<?
}
if (eregi('CL_GAL',$channel_group))
{
echo "GALLERIA CLOSER GROUP: $channel_group\n";
$group_color='#CCCCCC';
if (eregi('CL_GALLERIA',$channel_group))
{
echo "<br><font color=green size=3><b>-- INTERNAL CALL GALLERIA FRONT --</b></font><br>\n";
$group_color='#99FF99';
}
if (eregi('CL_GALLER2',$channel_group))
{
echo "<br><font color=red size=3><b>-- TouchAsia CALL Simple Escapes FRONT --</b></font><br>\n";
$group_color='#FF9999';
}
if (eregi('CL_GALLER3',$channel_group))
{
echo "<br><font color=red size=3><b>-- DebitSupplies CALL Simple Escapes FRONT --</b></font><br>\n";
$group_color='#FF9999';
}
if (eregi('CL_GALLER4',$channel_group))
{
echo "<br><font color=red size=3><b>-- Vishnu CALL Simple Escapes FRONT --</b></font><br>\n";
$group_color='#FF9999';
}
?>
<form action="http://10.10.99.2/vicidial/closer_lookup4.php" method="post">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$user ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor="<?=$group_color ?>">
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<!----
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$user ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>NEW COF BlueGreen Customer Search</font></th>
</tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
---->
<?
}
if (eregi('CL_UNIV',$channel_group))
{
echo "UNIVERSAL CLOSER GROUP: $channel_group\n";
?>
<form action="uk_mail_lookup.php" method="post" onSubmit="return CheckForm()">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$user ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 width=80% cellpadding=5 cellspacing=0 align=center>
<tr>
<th colspan=2 bgcolor='#CCCCCC'><font class='standard_bold'>New Search</font></th>
</tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Reservation Number:</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10
name="reservation_no" value="" ONKEYPRESS="var keyCode = event.which ? event.which : event.keyCode; if (keyCode!=8 && keyCode!=9 && keyCode!=37 && keyCode!=39) return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()))"></td>
</tr>
<tr bgcolor='#CCCCCC'><td align=right width='50%' nowrap><font class='standard_bold'>Confirmation #:</font></td>
<td align=left width='50%' nowrap><input type=text name='confirmation_no' size=10 maxlength=20 value=''></td></tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone #:</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10
name="phone" value="" ONKEYPRESS="var keyCode = event.which ? event.which : event.keyCode; if (keyCode!=8 && keyCode!=9 && keyCode!=37 && keyCode!=39) return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()))"></td>
</tr><tr>
<th colspan=2 bgcolor='#CCCCCC'><input type=submit name="submit_COF" value="SEARCH" onClick="javascript:btn_name='search'"><br><br></th>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold'><a href='closer_popup.php'>Back</a></font></th>
</tr>
</table>
</form>
<?
}
###########################################################################################
####### END CUSTOM CONTENTS
###########################################################################################
# echo "<a href=\"#\">Close this window</a>\n<BR><BR>\n";
}
else
{
echo "Record command FAILED for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "Please go back and try again\n<BR><BR>\n";
# echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,423 @@
<?
### closer-fronter_popup2.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the closer popup of a specific call that starts recording the call and allows you to go and fetch info on that caller in the local CRM system.
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
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["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
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["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
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["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["security"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["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["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
#$DB = '1'; # DEBUG override
$US = '_';
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$REC_TIME = date("Ymd-His");
$FILE_datetime = $STARTtime;
$parked_time = $STARTtime;
# $ext_context = 'default'; defined in dbconnect file
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if (!$auth)
{
if ( (strlen($PHP_AUTH_USER)>1) and ( (eregi("tsr",$PHP_AUTH_PW)) or (eregi("sales",$PHP_AUTH_PW)) ) )
{
$auth=1;
$user = $PHP_AUTH_USER;
$pass = $PHP_AUTH_PW;
}
}
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER - $user - $PHP_AUTH_USER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$user|$pass|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($user);
$password=strtoupper($pass);
$stmt="SELECT full_name from vicidial_users where user='$user' and pass='$pass'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$fullname = $row[0];
fwrite ($fp, "VD_CLOSER|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n");
fclose($fp);
if ( (strlen($customer_zap_channel)>2) and ( (eregi('zap',$customer_zap_channel)) or (eregi('iax',$customer_zap_channel)) ) )
{
echo "\n<!-- zap channel: $customer_zap_channel -->\n";
echo "<!-- session_id: $session_id -->\n";
echo "<!-- fronter: $fronter -->\n";
echo "<!-- user: $user -->\n";
}
else
{
echo "Bad channel: $customer_zap_channel\n";
echo "Make sure the Zap channel is live and try again\n";
exit;
}
}
else
{
fwrite ($fp, "VD_CLOSER|FAIL|$date|$user|$pass|$ip|$browser|\n");
fclose($fp);
}
}
echo "<html>\n";
echo "<head>\n";
echo "<title>VICIDIAL FRONTER-CLOSER: Popup</title>\n";
if (eregi('CL_UNIV',$channel_group))
{
?>
<script language="Javascript1.2">
var btn_name="search";
if (document.layers) {
document.captureEvents(Event.KEYPRESS);
document.onkeypress = function (evt) {
if (evt.target.constructor == Input) {
if (evt.target.name == 'lead_id' || evt.target.name == 'phone' || evt.target.name == 'confirmation_id') {
return ((evt.which >= '0'.charCodeAt() && evt.which <= '9'.charCodeAt()));
}
}
}
}
function CheckForm() {
if (btn_name=="update") {
if (document.forms[0].phone.value.length!=10) {
alert("The phone number you entered does not have 10 digits.\n\nIt has "+document.forms[0].phone.value.length+" - please correct it and try again.");
return false;
} else if (document.forms[0].confirmation_id.value.length<=5) {
alert("The confirmation ID is either missing or not enough characters in length.\n\nPlease correct it and try again.");
return false;
} else {
return true;
}
}
}
</script>
<?
}
else
{
echo "<script language=\"Javascript1.2\">\n";
echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n";
echo "</script>\n";
}
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad="document.forms[0].search_phone.focus(); setTimeout('document.forms[0].search_phone.focus()', 1000); self.focus()">
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from live_channels where server_ip='$server_ip' and channel='$customer_zap_channel'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
# $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_query($stmt, $link);
$DTqueryCID = "RZ$FILE_datetime$user";
### insert a NEW record to the vicidial_manager table to be processed
$channel = $customer_zap_channel;
# $channel = eregi_replace('Zap/', "", $channel);
$SIPexten = eregi_replace('SIP/', "", $SIPexten);
$filename = "$REC_TIME$US$SIPexten";
# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: Zap/$channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_query($stmt, $link);
# Local/78600098@demo-6617,2
$stmt = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Originate','$DTqueryCID','Channel: $local_DEF$conf_silent_prefix$session_id$local_AMP$ext_context','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: $filename','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$stmt="SELECT recording_id FROM recording_log where filename='$filename'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$recording_id = $row[0];
echo "Recording command sent for channel $channel - $filename - $recording_id &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$stmt="SELECT full_name from vicidial_users where user='$fronter'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
echo "Call Referred by: $fronter - $full_name\n<BR><BR>\n";
$url = "http://10.10.10.196/vicidial/closer_dispo.php?lead_id=$lead_id&channel=$channel&server_ip=$server_ip&extension=$SIPexten&call_began=$STARTtime&parked_time=$parked_time&DB=$DB";
echo "<a href=\"$url\">View Customer Info and Disposition Call</a>\n<BR><BR>\n";
$stmt="SELECT group_name,group_color from vicidial_inbound_groups where group_id='$channel_group'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$group_name = $row[0];
$group_color = $row[1];
echo "<br>\n";
echo "<table border=0 cellspacing=5 cellpadding=3 align=center width=90% bgcolor=\"$group_color\"><tr><td><b> $channel_group - $group_name </b></td></tr></table><br>\n\n";
###########################################################################################
####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX
###########################################################################################
if (eregi('CL',$channel_group))
{
if (strlen($phone) > 9) {$search_phone = $phone;}
if ( (strlen($search_phone) < 10) or (strlen($fronter) < 1) )
{
echo "<!-- looking for fronter and search_phone: |$fronter|$search_phone| -->\n";
$stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if (strlen($fronter) < 1) {$fronter=$row[0];}
if (strlen($search_phone) < 10) {$search_phone=$row[1];}
}
?>
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$fronter ?>">
<input type=hidden name="closer" value="<?=$closer ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor="<?=$group_color ?>">
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$search_phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<?
}
if (eregi('UNIV',$channel_group))
{
echo "UNIVERSAL CLOSER GROUP: $channel_group\n";
?>
<form action="uk_mail_lookup.php" method="post" onSubmit="return CheckForm()">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$user ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 width=80% cellpadding=5 cellspacing=0 align=center>
<tr>
<th colspan=2 bgcolor='#CCCCCC'><font class='standard_bold'>New Search</font></th>
</tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Reservation Number:</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10
name="reservation_no" value="" ONKEYPRESS="var keyCode = event.which ? event.which : event.keyCode; if (keyCode!=8 && keyCode!=9 && keyCode!=37 && keyCode!=39) return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()))"></td>
</tr>
<tr bgcolor='#CCCCCC'><td align=right width='50%' nowrap><font class='standard_bold'>Confirmation #:</font></td>
<td align=left width='50%' nowrap><input type=text name='confirmation_no' size=10 maxlength=20 value=''></td></tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone #:</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10
name="phone" value="" ONKEYPRESS="var keyCode = event.which ? event.which : event.keyCode; if (keyCode!=8 && keyCode!=9 && keyCode!=37 && keyCode!=39) return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()))"></td>
</tr><tr>
<th colspan=2 bgcolor='#CCCCCC'><input type=submit name="submit_COF" value="SEARCH" onClick="javascript:btn_name='search'"><br><br></th>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold'><a href='closer_popup.php'>Back</a></font></th>
</tr>
</table>
</form>
<?
}
###########################################################################################
####### END CUSTOM CONTENTS
###########################################################################################
# echo "<a href=\"#\">Close this window</a>\n<BR><BR>\n";
}
else
{
echo "Record command FAILED for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "Please go back and try again\n<BR><BR>\n";
# echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,345 @@
<?
### closer.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["group_selected"])) {$group_selected=$_GET["group_selected"];}
elseif (isset($_POST["group_selected"])) {$group_selected=$_POST["group_selected"];}
if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];}
elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["groupselect"])) {$groupselect=$_GET["groupselect"];}
elseif (isset($_POST["groupselect"])) {$groupselect=$_POST["groupselect"];}
if (isset($_GET["PHONE_LOGIN"])) {$PHONE_LOGIN=$_GET["PHONE_LOGIN"];}
elseif (isset($_POST["PHONE_LOGIN"])) {$PHONE_LOGIN=$_POST["PHONE_LOGIN"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
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["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["debugvars"])) {$debugvars=$_GET["debugvars"];}
elseif (isset($_POST["debugvars"])) {$debugvars=$_POST["debugvars"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$popup_page = './closer_popup.php';
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$fullname = $row[0];
fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
$color_class[0] = 'green';
$color_class[1] = 'red';
$color_class[2] = 'blue';
$color_class[3] = 'purple';
$color_class[4] = 'orange';
$color_class[5] = 'green';
$color_class[6] = 'red';
$color_class[7] = 'blue';
$color_class[8] = 'purple';
$color_class[9] = 'orange';
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
A:link {color: yellow}
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.orange {color: white; background-color: orange}
-->
</STYLE>
<TITLE>VICIDIAL CLOSER: Main</TITLE></HEAD>
</HEAD>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$group_selected = count($groupselect);
if (!$dialplan_number)
{
if ($extension)
{
$stmt="SELECT count(*) from phones where extension='$extension';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$ext_found=$row[0];
if ($ext_found > 0)
{
$stmt="SELECT dialplan_number,server_ip from phones where extension='$extension';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$dialplan_number=$row[0];
$server_ip=$row[1];
if (!$group_selected)
{
$stmt="select distinct channel_group from park_log;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
echo "<br>Please select the groups you want to pick calls up from: <form action=$PHP_SELF method=GET>\n";
echo "<table border=0><tr><td align=left>\n";
echo "<input type=hidden name=PHONE_LOGIN value=1>\n";
echo "<input type=hidden name=dialplan_number value=\"$dialplan_number\">\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "Inbound Call Groups: <br>\n";
$o=0;
while ($groups_to_print > $o)
{
$group_form_print = sprintf("%-20s", $groups[$o]);
echo "<input name=\"groupselect[]\" type=checkbox value=\"$groups[$o]\">$group_form_print <BR>\n";
$o++;
}
echo "</td></tr></table>\n";
echo "<input type=submit name=submit value=submit>\n";
echo "<BR><BR><BR>\n";
}
else
{
$o=0;
while($o < $group_selected)
{
$form_groups = "$form_groups&groupselect[$o]=$groupselect[$o]";
$o++;
}
$stmt="INSERT INTO vicidial_user_log values('','$user','LOGIN','CLOSER','$NOW_TIME','$STARTtime');";
$rslt=mysql_query($stmt, $link);
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"3; URL=$PHP_SELF?dialplan_number=$dialplan_number&server_ip=$server_ip&extension=$extension&DB=$DB$form_groups\">\n";
echo "<font=green><b>extension found, forwarding you to closer page, please wait 3 seconds...</b></font>\n";
}
}
else
{
echo "<font=red><b>The extension you entered does not exist, please try again</b></font>\n";
echo "<br>Please enter your phone_ID: <form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=PHONE_LOGIN value=1>\n";
echo "phone station ID: <input type=text name=extension size=10 maxlength=10 value=\"$extension\"> &nbsp; \n";
echo "<input type=submit name=submit value=submit>\n";
echo "<BR><BR><BR>\n";
}
}
else
{
echo "<br>Please enter your phone_ID: <form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=PHONE_LOGIN value=1>\n";
echo "phone station ID: <input type=text name=extension size=10 maxlength=10> &nbsp; \n";
echo "<input type=submit name=submit value=submit>\n";
echo "<BR><BR><BR>\n";
}
exit;
}
$o=0;
while($o < $group_selected)
{
$listen_groups = "$listen_groups &nbsp; &nbsp; $groupselect[$o]";
$form_groups = "$form_groups&groupselect[$o]=$groupselect[$o]";
$o++;
}
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF?dialplan_number=$dialplan_number&server_ip=$server_ip&extension=$extension&DB=$DB$form_groups\">\n";
#CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME
#----------------------------------------------------------------------------------------------
#Zap/73-1 10.10.11.11 IN_800_TPP_CS TPPpark 7275338730 2004-04-22 12:41:00
echo "$NOW_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $PHP_AUTH_USER - $fullname - CALLS SENT TO: $dialplan_number<BR><BR>\n";
echo "Click on the channel below that you would like to have directed to your phone<BR>\n";
echo "<PRE>\n";
echo "CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
echo "---------------------------------------------------------------------------------------------- \n";
$stmt="SELECT count(*) from parked_channels where server_ip='$server_ip'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="SELECT * from parked_channels where server_ip='$server_ip' and channel_group LIKE \"CL_%\" order by channel_group,parked_time";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-11s", $row[0]);
$server = sprintf("%-14s", $row[1]);
$channel_group = sprintf("%-16s", $row[2]);
$park_extension = sprintf("%-13s", $row[3]);
$parked_by = sprintf("%-21s", $row[4]);
$parked_time = sprintf("%-19s", $row[5]);
$G=''; $EG='';
$o=0;
$with_color=0;
while($o < $group_selected)
{
if (eregi("$groupselect[$o]",$channel_group))
{
$G="<SPAN class=\"$color_class[$o]\"><B>"; $EG='</B></SPAN>';
$with_color++;
}
$o++;
}
if ($with_color)
{
if (eregi('CL_GAL',$row[2]))
{
echo "$G<A HREF=\"$popup_page?channel=$row[0]&server_ip=$server_ip&parked_time=$row[5]&dialplan_number=$dialplan_number&extension=$extension&channel_group=$row[2]&DB=$DB&debugvars=asdfuiywer786sdg786sfg7sdsgjhg352j3452hg45f2j3h4g5f2j3h4g5f2jhg4f5j3fg45jh23f5j4h23gf&parked_by=$row[4]&debugvars=asdfuiywer786sdg786sfg7sdsgjhg352j3452hg45f2j3h4g5f2j3h4g5f2jhg4f5j3fg45jh23f5j4h23gf\" target=\"_blank\">$channel</A>$server$channel_group$park_extension $parked_time $EG\n";
}
else
{
echo "$G<A HREF=\"$popup_page?channel=$row[0]&server_ip=$server_ip&parked_time=$row[5]&dialplan_number=$dialplan_number&extension=$extension&channel_group=$row[2]&DB=$DB&debugvars=asdfuiywer786sdg786sfg7sdsgjhg352j3452hg45f2j3h4g5f2j3h4g5f2jhg4f5j3fg45jh23f5j4h23gf&parked_by=$row[4]\" target=\"_blank\">$channel</A>$server$channel_group$park_extension$parked_by$parked_time $EG\n";
}
}
#
$i++;
}
}
else
{
echo "********************************************************************************************** \n";
echo "********************************************************************************************** \n";
echo "*************************************** NO PARKED CALLS ************************************** \n";
echo "********************************************************************************************** \n";
echo "********************************************************************************************** \n";
}
echo " \n\n";
echo "looking for calls on these groups:\n";
$o=0;
while($o < $group_selected)
{
$group_print = sprintf("%-20s", $groupselect[$o]);
echo " <SPAN class=\"$color_class[$o]\"><B> </SPAN> - $group_print</B>\n";
$o++;
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "</PRE>\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,329 @@
<?
### closer_dispo.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the closer disposition screen of a call that has been grabbed. This allows the closer to modify customer information and disposition the call
# CHANGES
#
# 60619-1641 - Added variable filtering to eliminate SQL injection attack threat
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$fullname = $row[0];
fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>VICIDIAL CLOSER: Call Disposition</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
if ($end_call > 0)
{
$call_length = ($STARTtime - $call_began);
### insert a NEW record to the vicidial_closer_log table
$stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
### update the lead record in the vicidial_list table
$stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$stmt="SELECT count(*) from live_channels where server_ip='$server_ip' and channel='" . mysql_real_escape_string($channel) . "' and extension like \"%" . mysql_real_escape_string($extension) . "%\"";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Hangup','$DTqueryCID','Channel: " . mysql_real_escape_string($channel) . "','','','','','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Hangup command sent for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
}
else
{
echo "Hangup command FAILED for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
}
}
else
{
$stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_count = $row[0];
if ($lead_count > 0)
{
$stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_id = "$row[0]";
$tsr = "$row[4]";
$vendor_id = "$row[5]";
$list_id = "$row[7]";
$campaign_id = "$row[8]";
$phone_code = "$row[10]";
$phone_number = "$row[11]";
$title = "$row[12]";
$first_name = "$row[13]"; #
$middle_initial = "$row[14]";
$last_name = "$row[15]"; #
$address1 = "$row[16]"; #
$address2 = "$row[17]"; #
$address3 = "$row[18]"; #
$city = "$row[19]"; #
$state = "$row[20]"; #
$province = "$row[21]"; #
$postal_code = "$row[22]"; #
$country_code = "$row[23]"; #
$gender = "$row[24]";
$date_of_birth = "$row[25]";
$alt_phone = "$row[26]"; #
$email = "$row[27]"; #
$security = "$row[28]"; #
$comments = "$row[29]"; #
echo "<br>Call information: $first_name $last_name - $phone_number<br><br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=end_call value=1>\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
echo "<input type=hidden name=phone_code value=\"$phone_code\">\n";
echo "<input type=hidden name=phone_number value=\"$phone_number\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=channel value=\"$channel\">\n";
echo "<input type=hidden name=call_began value=\"$call_began\">\n";
echo "<input type=hidden name=parked_time value=\"$parked_time\">\n";
echo "<table cellpadding=1 cellspacing=0>\n";
echo "<tr><td colspan=2>Vendor ID: $vendor_id &nbsp; &nbsp; Campaign ID: $campaign_id</td></tr>\n";
echo "<tr><td colspan=2>Fronter: $tsr &nbsp; &nbsp; List ID: $list_id</td></tr>\n";
echo "<tr><td align=right>First Name: </td><td align=left><input type=text name=first_name size=15 maxlength=30 value=\"$first_name\"> &nbsp; \n";
echo " Last Name: <input type=text name=last_name size=15 maxlength=30 value=\"$last_name\"> </td></tr>\n";
echo "<tr><td align=right>Address 1 : </td><td align=left><input type=text name=address1 size=30 maxlength=30 value=\"$address1\"></td></tr>\n";
echo "<tr><td align=right>Address 2 : </td><td align=left><input type=text name=address2 size=30 maxlength=30 value=\"$address2\"></td></tr>\n";
echo "<tr><td align=right>Address 3 : </td><td align=left><input type=text name=address3 size=30 maxlength=30 value=\"$address3\"></td></tr>\n";
echo "<tr><td align=right>City : </td><td align=left><input type=text name=city size=30 maxlength=30 value=\"$city\"></td></tr>\n";
echo "<tr><td align=right>State: </td><td align=left><input type=text name=state size=2 maxlength=2 value=\"$state\"> &nbsp; \n";
echo " Postal Code: <input type=text name=postal_code size=10 maxlength=10 value=\"$postal_code\"> </td></tr>\n";
echo "<tr><td align=right>Province : </td><td align=left><input type=text name=province size=30 maxlength=30 value=\"$province\"></td></tr>\n";
echo "<tr><td align=right>Country : </td><td align=left><input type=text name=country_code size=3 maxlength=3 value=\"$country_code\"></td></tr>\n";
echo "<tr><td align=right>Alt Phone : </td><td align=left><input type=text name=alt_phone size=10 maxlength=10 value=\"$alt_phone\"></td></tr>\n";
echo "<tr><td align=right>Email : </td><td align=left><input type=text name=email size=30 maxlength=50 value=\"$email\"></td></tr>\n";
echo "<tr><td align=right>Security : </td><td align=left><input type=text name=security size=30 maxlength=100 value=\"$security\"></td></tr>\n";
echo "<tr><td align=right>Comments : </td><td align=left><input type=text name=comments size=30 maxlength=255 value=\"$comments\"></td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Disposition: </td><td align=left><select size=1 name=status>\n";
$stmt="SELECT * from vicidial_statuses where selectable='Y' order by status";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
$statuses_list='';
$o=0;
while ($statuses_to_print > $o) {
$rowx=mysql_fetch_row($rslt);
$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
$o++;
}
echo "$statuses_list";
echo "</select></td></tr>\n";
echo "<tr><td colspan=2><input type=submit name=submit value=\"END CALL\"></td></tr>\n";
echo "</table></form>\n";
echo "<BR><BR><BR>\n";
}
else
{
echo "lead lookup FAILED for lead_id $lead_id &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
# echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,445 @@
<?
### closer_popup.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the closer popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["group_selected"])) {$group_selected=$_GET["group_selected"];}
elseif (isset($_POST["group_selected"])) {$group_selected=$_POST["group_selected"];}
if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];}
elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["groupselect"])) {$groupselect=$_GET["groupselect"];}
elseif (isset($_POST["groupselect"])) {$groupselect=$_POST["groupselect"];}
if (isset($_GET["PHONE_LOGIN"])) {$PHONE_LOGIN=$_GET["PHONE_LOGIN"];}
elseif (isset($_POST["PHONE_LOGIN"])) {$PHONE_LOGIN=$_POST["PHONE_LOGIN"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
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["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["debugvars"])) {$debugvars=$_GET["debugvars"];}
elseif (isset($_POST["debugvars"])) {$debugvars=$_POST["debugvars"];}
if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];}
elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
#$DB=1;
$US = '_';
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$REC_TIME = date("Ymd-His");
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$fullname = $row[0];
fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo "<html>\n";
echo "<head>\n";
echo "<title>VICIDIAL CLOSER: Popup</title>\n";
if (eregi('CL_UNIV',$channel_group))
{
?>
<script language="Javascript1.2">
var btn_name="search";
if (document.layers) {
document.captureEvents(Event.KEYPRESS);
document.onkeypress = function (evt) {
if (evt.target.constructor == Input) {
if (evt.target.name == 'lead_id' || evt.target.name == 'phone' || evt.target.name == 'confirmation_id') {
return ((evt.which >= '0'.charCodeAt() && evt.which <= '9'.charCodeAt()));
}
}
}
}
function CheckForm() {
if (btn_name=="update") {
if (document.forms[0].phone.value.length!=10) {
alert("The phone number you entered does not have 10 digits.\n\nIt has "+document.forms[0].phone.value.length+" - please correct it and try again.");
return false;
} else if (document.forms[0].confirmation_id.value.length<=5) {
alert("The confirmation ID is either missing or not enough characters in length.\n\nPlease correct it and try again.");
return false;
} else {
return true;
}
}
}
</script>
<?
}
else
{
echo "<script language=\"Javascript1.2\">\n";
echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n";
echo "</script>\n";
}
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad="document.forms[0].search_phone.focus(); setTimeout('document.forms[0].search_phone.focus()', 1000)">
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
$stmt="SELECT count(*) from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
#$monitor_channel = eregi_replace('Zap/', "", $channel);
$monitor_channel = eregi_replace('-1', "", $channel);
$SIPexten = $extension;
$filename = "$REC_TIME$US$SIPexten";
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: $monitor_channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_query($stmt, $link);
# $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$monitor_channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')";
# if ($DB) {echo "|$stmt|\n";}
# $rslt=mysql_query($stmt, $link);
# $stmt="SELECT recording_id FROM recording_log where filename='$filename'";
# $rslt=mysql_query($stmt, $link);
# if ($DB) {echo "$stmt\n";}
# $row=mysql_fetch_row($rslt);
# $recording_id = $row[0];
# echo "Recording command sent for channel $channel - $filename - $recording_id<BR>\n";
### insert a NEW record to the vicidial_manager table to be processed
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: $channel','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Redirect command sent for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
$stmt="SELECT full_name from vicidial_users where user='$parked_by'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
echo "Call Referred by: $parked_by - $full_name\n<BR><BR>\n";
$url = "http://10.10.10.196/vicidial/closer_dispo.php?lead_id=$parked_by&channel=$channel&server_ip=$server_ip&extension=$extension&call_began=$STARTtime&parked_time=$parked_time&DB=$DB";
echo "<a href=\"$url\">View Customer Info and Disposition Call</a>\n<BR><BR>\n";
$stmt="UPDATE park_log set grab_time='$NOW_TIME',status='TALKING',extension='$extension',user='$PHP_AUTH_USER' where parked_time='$parked_time' and server_ip='$server_ip' and channel='$channel'";
if ($DB) {echo "|$stmt|\n";}
$fp = fopen ("./closer_SQL_updates.txt", "a");
fwrite ($fp, "$date|$PHP_AUTH_USER|$stmt|\n");
fclose($fp);
$rslt=mysql_query($stmt, $link);
###########################################################################################
####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX
###########################################################################################
if (eregi('CL_TEST',$channel_group))
{
echo "GALLERIA TEST CLOSER GROUP: $channel_group\n";
$stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$fronter=$row[0];
$search_phone=$row[1];
?>
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$fronter ?>">
<input type=hidden name="closer" value="<?=$PHP_AUTH_USER ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor='#99FF99'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$search_phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<?
}
if (eregi('CL_MWCOF',$channel_group))
{
echo "GALLERIA INTERNAL CLOSER GROUP: $channel_group\n";
$stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$fronter=$row[0];
$search_phone=$row[1];
?>
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$fronter ?>">
<input type=hidden name="closer" value="<?=$PHP_AUTH_USER ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor='#99FF99'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$search_phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<?
}
if (eregi('CL_GAL',$channel_group))
{
echo "GALLERIA CLOSER GROUP: $channel_group\n";
$group_color='#CCCCCC';
if (eregi('CL_GALLERIA',$channel_group))
{
echo "<br><font color=green size=3><b>-- INTERNAL CALL GALLERIA FRONT --</b></font><br>\n";
$group_color='#99FF99';
}
if (eregi('CL_GALLER2',$channel_group))
{
echo "<br><font color=red size=3><b>-- TouchAsia CALL Simple Escapes FRONT --</b></font><br>\n";
$group_color='#FF9999';
}
if (eregi('CL_GALLER3',$channel_group))
{
echo "<br><font color=red size=3><b>-- DebitSupplies CALL Simple Escapes FRONT --</b></font><br>\n";
$group_color='#FF9999';
}
if (eregi('CL_GALLER4',$channel_group))
{
echo "<br><font color=red size=3><b>-- Vishnu CALL Simple Escapes FRONT --</b></font><br>\n";
$group_color='#FF9999';
}
?>
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$PHP_AUTH_USER ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>COF MW Customer Search</font></th>
</tr>
<tr bgcolor="<?=$group_color ?>">
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
<!----
<form action="http://10.10.10.196/vicidial/closer_lookup3.php" method="post">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$PHP_AUTH_USER ?>">
<table border=0 cellspacing=5 cellpadding=3 align=center width=90%>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold' color='white'>NEW COF BlueGreen Customer Search</font></th>
</tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone number</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10 name="search_phone" value="<?=$phone ?>"></td>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><input type=submit name="submit_COF" value="SEARCH"></th>
</tr>
</table>
</form>
<BR><BR>
---->
<?
}
if (eregi('CL_UNIV',$channel_group))
{
echo "UNIVERSAL CLOSER GROUP: $channel_group\n";
?>
<form action="uk_mail_lookup.php" method="post" onSubmit="return CheckForm()">
<input type=hidden name="fronter" value="<?=$parked_by ?>">
<input type=hidden name="closer" value="<?=$PHP_AUTH_USER ?>">
<input type=hidden name="group" value="<?=$channel_group ?>">
<input type=hidden name="recording_id" value="<?=$recording_id ?>">
<table border=0 width=80% cellpadding=5 cellspacing=0 align=center>
<tr>
<th colspan=2 bgcolor='#CCCCCC'><font class='standard_bold'>New Search</font></th>
</tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Reservation Number:</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10
name="reservation_no" value="" ONKEYPRESS="var keyCode = event.which ? event.which : event.keyCode; if (keyCode!=8 && keyCode!=9 && keyCode!=37 && keyCode!=39) return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()))"></td>
</tr>
<tr bgcolor='#CCCCCC'><td align=right width='50%' nowrap><font class='standard_bold'>Confirmation #:</font></td>
<td align=left width='50%' nowrap><input type=text name='confirmation_no' size=10 maxlength=20 value=''></td></tr>
<tr bgcolor='#CCCCCC'>
<td align=right width="50%" nowrap><font class='standard_bold'>Phone #:</font></td>
<td align=left width="50%" nowrap><input type=text size=10 maxlength=10
name="phone" value="" ONKEYPRESS="var keyCode = event.which ? event.which : event.keyCode; if (keyCode!=8 && keyCode!=9 && keyCode!=37 && keyCode!=39) return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()))"></td>
</tr><tr>
<th colspan=2 bgcolor='#CCCCCC'><input type=submit name="submit_COF" value="SEARCH" onClick="javascript:btn_name='search'"><br><br></th>
</tr>
<tr>
<th colspan=2 bgcolor='#666666'><font class='standard_bold'><a href='closer_popup.php'>Back</a></font></th>
</tr>
</table>
</form>
<?
}
###########################################################################################
####### END CUSTOM CONTENTS
###########################################################################################
# echo "<a href=\"#\">Close this window</a>\n<BR><BR>\n";
}
else
{
echo "Redirect command FAILED for channel $channel &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1 @@
@@ -0,0 +1,15 @@
<?
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
@@ -0,0 +1,252 @@
<?
### group_hourly_stats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];}
elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$date_with_hour_default = date("Y-m-d H");
$date_no_hour_default = $TODAY;
if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;}
$date_no_hour = $date_with_hour;
$date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour);
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
header ("Content-type: text/html; charset=utf-8");
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
# $stmt="SELECT full_name from vicidial_users where user='$user';";
# $rslt=mysql_query($stmt, $link);
# $row=mysql_fetch_row($rslt);
# $full_name = $row[0];
}
?>
<html>
<head>
<title>VICIDIAL ADMIN: Group Hourly Stats</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; VICIDIAL ADMIN: Group Hourly Stats <? echo $group ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<?
if ( ($group) and ($status) and ($date_with_hour) )
{
$stmt="SELECT user,full_name from vicidial_users where user_group = '" . mysql_real_escape_string($group) . "' order by full_name desc;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$tsrs_to_print = mysql_num_rows($rslt);
$o=0;
while($o < $tsrs_to_print)
{
$row=mysql_fetch_row($rslt);
$VDuser[$o] = "$row[0]";
$VDname[$o] = "$row[1]";
$o++;
}
$o=0;
while($o < $tsrs_to_print)
{
$stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDtotal[$o] = "$row[0]";
$stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDday[$o] = "$row[0]";
$stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDcount[$o] = "$row[0]";
$o++;
}
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
echo "<br><center>\n";
echo "<B>TSR HOUR COUNTS: $group | $status | $date_with_hour | $date_no_hour</B>\n";
echo "<center><TABLE width=600 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>TSR </td><td align=left><font size=2>ID </td><td align=right><font size=2> &nbsp; $status</td><td align=right><font size=2> &nbsp; TOTAL CALLS</td><td align=right><font size=2> &nbsp; $status DAY</td><td align=right><font size=2> &nbsp; &nbsp; </td></tr>\n";
$day_calls=0;
$hour_calls=0;
$total_calls=0;
$o=0;
while($o < $tsrs_to_print)
{
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$VDuser[$o]</td>";
echo "<td align=left><font size=2> $VDname[$o]</td>\n";
echo "<td align=right><font size=2> $VDcount[$o]</td>\n";
echo "<td align=right><font size=2> $VDtotal[$o]</td>\n";
echo "<td align=right><font size=2> $VDday[$o]</td>\n";
echo "<td align=right><font size=1><a href=\"./admin.php?ADD=3&user=$VDuser[$o]\">MODIFY</a> | <a href=\"./user_stats.php?user=$VDuser[$o]\">STATS</a></td></tr>\n";
$total_calls = ($total_calls + $VDtotal[$o]);
$hour_calls = ($hour_calls + $VDcount[$o]);
$day_calls = ($day_calls + $VDday[$o]);
$o++;
}
echo "<tr><td><font size=2>TOTAL </td><td align=right><font size=2> $status </td><td align=right><font size=2> $hour_calls</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $day_calls</td></tr>\n";
}
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<br>Please enter the group you want to get hourly stats for: <form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=DB value=$DB>\n";
echo "group: <select size=1 name=group>\n";
$stmt="SELECT * from vicidial_user_groups order by user_group";
$rslt=mysql_query($stmt, $link);
$groups_to_print = mysql_num_rows($rslt);
$o=0;
$groups_list='';
while ($groups_to_print > $o) {
$rowx=mysql_fetch_row($rslt);
if ($group == $group)
{$groups_list .= "<option selected value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
else
{$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
$o++;
}
echo "$groups_list</select><br>\n";
echo "status: <input type=text name=status size=10 maxlength=10 value=\"$status\"> &nbsp; (example: XFER)<br>\n";
echo "date with hour: <input type=text name=date_with_hour size=14 maxlength=13 value=\"$date_with_hour\"> &nbsp; (example: 2004-06-25 14)<br>\n";
echo "<input type=submit name=submit value=SUBMIT>\n";
echo "<BR><BR><BR>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

@@ -0,0 +1,698 @@
<?
# listloader.php
#
# Copyright (C) 2006 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: GPLv2
#
# AST Web GUI lead loader from formatted file
#
# CHANGES
# 50602-1640 - First version created by Joe Johnson
# 51128-1108 - Removed PHP global vars requirement
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60616-1006 - added listID override and gmt_offset lookup while loading
# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat
#
# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time.
#
$version = '1.1.12';
$build = '60619-1652';
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$leadfile=$_FILES["leadfile"];
$LF_orig = $_FILES['leadfile']['name'];
$LF_path = $_FILES['leadfile']['tmp_name'];
$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];}
$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];}
$list_id_override = (preg_replace("/\D/","",$list_id_override));
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
#$DB=1;
#$DBX=1;
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$list_id_override = ereg_replace("[^0-9]","",$list_id_override);
$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://';}
$admDIR = "$HTTPprotocol$server_name$script_name";
$admDIR = eregi_replace('listloader.php','',$admDIR);
$admSCR = 'admin.php';
$NWB = " &nbsp; <a href=\"javascript:openNewWindow('$admDIR$admSCR?ADD=99999";
$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>";
$secX = date("U");
$hour = date("H");
$min = date("i");
$sec = date("s");
$mon = date("m");
$mday = date("d");
$year = date("Y");
$isdst = date("I");
$Shour = date("H");
$Smin = date("i");
$Ssec = date("s");
$Smon = date("m");
$Smday = date("d");
$Syear = date("Y");
$pulldate0 = "$year-$mon-$mday $hour:$min:$sec";
$inSD = $pulldate0;
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
### Grab Server GMT value from the database
$stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';";
$rslt=mysql_query($stmt, $link);
$gmt_recs = mysql_num_rows($rslt);
if ($gmt_recs > 0)
{
$row=mysql_fetch_row($rslt);
$DBSERVER_GMT = "$row[0]";
if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
if ($isdst) {$SERVER_GMT++;}
}
else
{
$SERVER_GMT = date("O");
$SERVER_GMT = eregi_replace("\+","",$SERVER_GMT);
$SERVER_GMT = ($SERVER_GMT + 0);
$SERVER_GMT = ($SERVER_GMT / 100);
}
$LOCAL_GMT_OFF = $SERVER_GMT;
$LOCAL_GMT_OFF_STD = $SERVER_GMT;
#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";}
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build -->\n";
echo "<!-- SEED TIME $secX: $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF DST: $isdst -->\n";
?>
<script language="JavaScript1.2">
function openNewWindow(url) {
window.open (url,"",'width=500,height=300,scrollbars=yes,menubar=yes,address=yes');
}
function ShowProgress(good, bad, total) {
parent.lead_count.document.open();
parent.lead_count.document.write('<html><body><table border=0 width=200 cellpadding=10 cellspacing=0 align=center valign=top><tr bgcolor="#000000"><th colspan=2><font face="arial, helvetica" size=3 color=white>Current file status:</font></th></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Good:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+good+'</B></font></td></tr><tr bgcolor="#990000"><td align=right><font face="arial, helvetica" size=2 color=white><B>Bad:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+bad+'</B></font></td></tr><tr bgcolor="#000099"><td align=right><font face="arial, helvetica" size=2 color=white><B>Total:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+total+'</B></font></td></tr></table><body></html>');
parent.lead_count.document.close();
}
</script>
</head>
<body>
<form action=<?=$PHP_SELF ?> method=post enctype="multipart/form-data">
<table align=center width="500" border=0 cellpadding=5 cellspacing=0 bgcolor=#D9E6FE>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2>Load leads from this file:</font></td>
<td align=left width="75%"><input type=file name="leadfile" value="<?=$leadfile ?>"> <? echo "$NWB#vicidial_list_loader$NWE"; ?></td>
</tr>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2>List ID Override: </font></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><input type=text value="" name='list_id_override' size=10 maxlength=8> (numbers only or leave blank for values in the file)</td>
</tr>
<tr>
<td align=center><input type=submit value="SUBMIT" name='submit_file'></td>
<td align=center><input type=button onClick="javascript:document.location='listloader.php'" value="START OVER" name='reload_page'></td>
</tr>
<tr><td colspan=2><font size=1><a href="new_listloader_superL.php" target="_parent">CLICK HERE TO GO TO THE SUPER LEAD LOADER (BETA VERSION)</a> &nbsp; &nbsp; <a href="admin.php" target="_parent">BACK TO ADMIN</a></font></td></tr>
</table>
</form>
<?
#echo "|$LF_orig|$LF_path|\n";
if ($leadfile and filesize($LF_path)<=8388608) {
print "<script language='JavaScript1.2'>document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;</script>";
flush();
copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt");
$file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r");
if ($WeBRooTWritablE > 0)
{$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");}
$pulldate=date("Y-m-d H:i:s");
$buffer=fgets($file, 4096);
$tab_count=substr_count($buffer, "\t");
$pipe_count=substr_count($buffer, "|");
if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";}
$field_check=explode($delimiter, $buffer);
if (count($field_check)>=5) {
flush();
$file=fopen("./vicidial_temp_file.txt", "r");
$total=0; $good=0; $bad=0;
print "<center><font face='arial, helvetica' size=3 color='#009900'><B>Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n";
if (strlen($list_id_override)>0)
{
print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
}
while (!feof($file)) {
$record++;
$buffer=rtrim(fgets($file, 4096));
$buffer=stripslashes($buffer);
if (strlen($buffer)>0) {
$row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer));
$vendor_lead_code = $row[0];
$source_code = $row[1];
$source_id=$source_code;
$list_id = $row[2];
$phone_code = eregi_replace("[^0-9]", "", $row[3]);
$phone_number = eregi_replace("[^0-9]", "", $row[4]);
$USarea = substr($phone_number, 0, 3);
$title = $row[5];
$first_name = $row[6];
$middle_initial = $row[7];
$last_name = $row[8];
$address1 = $row[9];
$address2 = $row[10];
$address3 = $row[11];
$city = $row[12];
$state = $row[13];
$province = $row[14];
$postal_code = $row[15];
$country = $row[16];
$gender = $row[17];
$date_of_birth = $row[18];
$alt_phone = $row[19];
$email = $row[20];
$security_phrase = $row[21];
$comments = trim($row[22]);
if (strlen($phone_number)>8)
{
$entry_date = "$pulldate";
$modify_date = "";
$status = "NEW";
$user = "";
$gmt_offset = '0';
$called_since_last_reset='N';
if (strlen($list_id_override)>0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
}
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =='1')
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
### MEXICO ###
if ($phone_code =='52')
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
### AUSTRALIA ###
if ($phone_code =='61')
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$PC_processed++;
$stmt="select * from vicidial_phone_codes where country_code='$phone_code';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD);
$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear);
$hour = date("H",$AC_localtime);
$min = date("i",$AC_localtime);
$sec = date("s",$AC_localtime);
$mon = date("m",$AC_localtime);
$mday = date("d",$AC_localtime);
$wday = date("w",$AC_localtime);
$year = date("Y",$AC_localtime);
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
#**********************************************************************
# FSA-LSO
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in April and last Sunday in October at 2 am.
# INPUTS:
# mm INTEGER Month.
# dd INTEGER Day of the month.
# ns INTEGER Seconds into the day.
# dow INTEGER Day of week (0=Sunday, to 6=Saturday)
# OPTIONAL INPUT:
# timezone INTEGER hour difference UTC - local standard time
# (DEFAULT is blank)
# make calculations based on UTC time,
# which means shift at 10:00 UTC in April
# and 9:00 UTC in October
# OUTPUT:
# INTEGER 1 = DST, 0 = not DST
#**********************************************************************
$USA_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 4 || $mm > 10) {
$USA_DST=0;
} elseif ($mm >= 5 and $mm <= 9) {
$USA_DST=1;
} elseif ($mm == 4) {
if ($dd > 7) {
$USA_DST=1;
} elseif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 and $ns < (7200+$timezone*3600)) {
$USA_DST=0;
} else {
$USA_DST=1;
}
} else {
if ($dow == 0 and $ns < 7200) {
$USA_DST=0;
} else {
$USA_DST=1;
}
}
} else {
$USA_DST=0;
}
} elseif ($mm == 10) {
if ($dd < 25) {
$USA_DST=1;
} elseif ($dd < ($dow+25)) {
$USA_DST=1;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (7200+($timezone-1)*3600)) {
$USA_DST=1;
} else {
$USA_DST=0;
}
} else { # local time calculations
if ($ns < 7200) {
$USA_DST=1;
} else {
$USA_DST=0;
}
}
} else {
$USA_DST=0;
}
} # end of month checks
if ($DBX) {print " DST: $USA_DST\n";}
if ($USA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
#**********************************************************************
# This is s 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on last Sunday in March and last Sunday in October at 1 am.
#**********************************************************************
$GBR_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$GBR_DST=0;
} elseif ($mm >= 4 and $mm <= 9) {
$GBR_DST=1;
} elseif ($mm == 3) {
if ($dd < 25) {
$GBR_DST=0;
} elseif ($dd < ($dow+25)) {
$GBR_DST=0;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$GBR_DST=0;
} else {
$GBR_DST=1;
}
} else { # local time calculations
if ($ns < 3600) {
$GBR_DST=0;
} else {
$GBR_DST=1;
}
}
} else {
$GBR_DST=1;
}
} elseif ($mm == 10) {
if ($dd < 25) {
$GBR_DST=1;
} elseif ($dd < ($dow+25)) {
$GBR_DST=1;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$GBR_DST=1;
} else {
$GBR_DST=0;
}
} else { # local time calculations
if ($ns < 3600) {
$GBR_DST=1;
} else {
$GBR_DST=0;
}
}
} else {
$GBR_DST=0;
}
} # end of month checks
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
#**********************************************************************
# This is s 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on last Sunday in October and last Sunday in March at 1 am.
#**********************************************************************
$AUS_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$AUS_DST=1;
} elseif ($mm >= 4 and $mm <= 9) {
$AUS_DST=0;
} elseif ($mm == 3) {
if ($dd < 25) {
$AUS_DST=1;
} elseif ($dd < ($dow+25)) {
$AUS_DST=1;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUS_DST=1;
} else {
$AUS_DST=0;
}
} else { # local time calculations
if ($ns < 3600) {
$AUS_DST=1;
} else {
$AUS_DST=0;
}
}
} else {
$AUS_DST=0;
}
} elseif ($mm == 10) {
if ($dd < 25) {
$AUS_DST=0;
} elseif ($dd < ($dow+25)) {
$AUS_DST=0;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUS_DST=0;
} else {
$AUS_DST=1;
}
} else { # local time calculations
if ($ns < 3600) {
$AUS_DST=0;
} else {
$AUS_DST=1;
}
}
} else {
$AUS_DST=1;
}
} # end of month checks
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
#**********************************************************************
# TASMANIA ONLY
# This is s 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in October and last Sunday in March at 1 am.
#**********************************************************************
$AUST_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$AUST_DST=1;
} elseif ($mm >= 4 and $mm <= 9) {
$AUST_DST=0;
} elseif ($mm == 3) {
if ($dd < 25) {
$AUST_DST=1;
} elseif ($dd < ($dow+25)) {
$AUST_DST=1;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUST_DST=1;
} else {
$AUST_DST=0;
}
} else { # local time calculations
if ($ns < 3600) {
$AUST_DST=1;
} else {
$AUST_DST=0;
}
}
} else {
$AUST_DST=0;
}
} elseif ($mm == 10) {
if ($dd > 7) {
$AUST_DST=1;
} elseif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 and $ns < (7200+$timezone*3600)) {
$AUST_DST=0;
} else {
$AUST_DST=1;
}
} else {
if ($dow == 0 and $ns < 3600) {
$AUST_DST=0;
} else {
$AUST_DST=1;
}
}
} else {
$AUST_DST=0;
}
} # end of month checks
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
#**********************************************************************
# This is s 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in October and third Sunday in March at 1 am.
#**********************************************************************
$NZL_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$NZL_DST=1;
} elseif ($mm >= 4 and $mm <= 9) {
$NZL_DST=0;
} elseif ($mm == 3) {
if ($dd < 14) {
$NZL_DST=1;
} elseif ($dd < ($dow+14)) {
$NZL_DST=1;
} elseif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$NZL_DST=1;
} else {
$NZL_DST=0;
}
} else { # local time calculations
if ($ns < 3600) {
$NZL_DST=1;
} else {
$NZL_DST=0;
}
}
} else {
$NZL_DST=0;
}
} elseif ($mm == 10) {
if ($dd > 7) {
$NZL_DST=1;
} elseif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 and $ns < (7200+$timezone*3600)) {
$NZL_DST=0;
} else {
$NZL_DST=1;
}
} else {
if ($dow == 0 and $ns < 3600) {
$NZL_DST=0;
} else {
$NZL_DST=1;
}
}
} else {
$NZL_DST=0;
}
} # end of month checks
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
if ($multi_insert_counter > 8) {
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$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',0);";
$rslt=mysql_query($stmtZ, $link);
if ($WeBRooTWritablE > 0)
{fwrite($stmt_file, $stmtZ."\r\n");}
$multistmt='';
$multi_insert_counter=0;
} else {
$multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$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',0),";
$multi_insert_counter++;
}
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
usleep(1000);
flush();
}
}
}
if ($multi_insert_counter!=0) {
$stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";";
mysql_query($stmtZ, $link);
if ($WeBRooTWritablE > 0)
{fwrite($stmt_file, $stmtZ."\r\n");}
}
print "<BR><BR>Done</B> GOOD: $good &nbsp; &nbsp; &nbsp; BAD: $bad &nbsp; &nbsp; &nbsp; TOTAL: $total</font></center>";
} else {
print "<center><font face='arial, helvetica' size=3 color='#990000'><B>ERROR: The file does not have the required number of fields to process it.</B></font></center>";
}
print "<script language='JavaScript1.2'>document.forms[0].leadfile.disabled=false; document.forms[0].submit_file.disabled=false; document.forms[0].reload_page.disabled=false;</script>";
} else if (filesize($leadfile)>8388608) {
print "<center><font face='arial, helvetica' size=3 color='#990000'><B>ERROR: File exceeds the 8MB limit.</B></font></center>";
}
?>
</body>
</html>
@@ -0,0 +1,690 @@
#!/usr/bin/perl
### listloader.pl
###
### Copyright (C) 2006 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: GPLv2
###
#
#
# CHANGES
# 60616-1548 - Added listID override feature to force all leads into same list
# - Added gmt_offset_now lookup for each lead
#
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help|-h/i)
{
print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n";
}
else
{
if ($args =~ /--forcelistid=/i)
{
@data_in = split(/--forcelistid=/,$args);
$forcelistid = $data_in[1];
print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n";
}
else
{$forcelistid = '';}
}
}
### end parsing run-time options ###
use Spreadsheet::ParseExcel;
use Time::Local;
use Net::MySQL;
### Make sure this file is in a libs path or put the absolute path to it
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
if (!$DB_port) {$DB_port='3306';}
$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port")
or die "Couldn't connect to database: $DB_server - $DB_database\n";
$|=0;
$secX = time();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$mon++;
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
$pulldate0 = "$year-$mon-$mday $hour:$min:$sec";
$pulldate="$year-$mon-$mday $hour:$min:$sec";
$inSD = $pulldate0;
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
### Grab Server values from the database
$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';";
$dbhA->query("$stmtA");
if ($dbhA->has_selected_record)
{
$iter=$dbhA->create_record_iterator;
while ( $record = $iter->each)
{
$DBSERVER_GMT = "$record->[0]";
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
}
}
$LOCAL_GMT_OFF = $SERVER_GMT;
$LOCAL_GMT_OFF_STD = $SERVER_GMT;
if ($isdst) {$LOCAL_GMT_OFF++;}
if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";}
$total=0; $good=0; $bad=0;
print "<center><font face='arial, helvetica' size=3 color='#009900'><B>Processing Excel file...\n";
open(STMT_FILE, "> listloader_stmts.txt");
$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls");
my($iR, $iC, $oWkS, $oWkC);
foreach $oWkS (@{$oBook->{Worksheet}}) {
for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) {
$entry_date = "$pulldate";
$modify_date = "";
$status = "NEW";
$user = "";
$oWkC = $oWkS->{Cells}[$iR][0];
if ($oWkC) {$vendor_lead_code=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][1];
if ($oWkC) {$source_code=$oWkC->Value; }
$source_id=$source_code;
$oWkC = $oWkS->{Cells}[$iR][2];
if ($oWkC) {$list_id=$oWkC->Value; }
$gmt_offset = '0';
$called_since_last_reset='N';
$oWkC = $oWkS->{Cells}[$iR][3];
if ($oWkC) {$phone_code=$oWkC->Value; }
$phone_code=~s/[^0-9]//g;
$oWkC = $oWkS->{Cells}[$iR][4];
if ($oWkC) {$phone_number=$oWkC->Value; }
$phone_number=~s/[^0-9]//g;
$USarea = substr($phone_number, 0, 3);
$oWkC = $oWkS->{Cells}[$iR][5];
if ($oWkC) {$title=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][6];
if ($oWkC) {$first_name=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][7];
if ($oWkC) {$middle_initial=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][8];
if ($oWkC) {$last_name=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][9];
if ($oWkC) {$address1=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][10];
if ($oWkC) {$address2=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][11];
if ($oWkC) {$address3=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][12];
if ($oWkC) {$city=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][13];
if ($oWkC) {$state=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][14];
if ($oWkC) {$province=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][15];
if ($oWkC) {$postal_code=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][16];
if ($oWkC) {$country=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][17];
if ($oWkC) {$gender=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][18];
if ($oWkC) {$date_of_birth=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][19];
if ($oWkC) {$alt_phone=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][20];
if ($oWkC) {$email=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][21];
if ($oWkC) {$security_phrase=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][22];
if ($oWkC) {$comments=$oWkC->Value; }
$comments=~s/^\s*(.*?)\s*$/$1/;
if (length($phone_number)>8) {
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =~ /^1$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### MEXICO ###
if ($phone_code =~ /^52$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### AUSTRALIA ###
if ($phone_code =~ /^61$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD);
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
&USA_dstcalc;
if ($DBX) {print " DST: $USA_DST\n";}
if ($USA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
&GBR_dstcalc;
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
&AUS_dstcalc;
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
&AUST_dstcalc;
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
&NZL_dstcalc;
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
if ($multi_insert_counter > 8) {
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);";
$dbhA->query("$stmtZ");
print STMT_FILE $stmtZ."\r\n";
$multistmt='';
$multi_insert_counter=0;
} else {
$multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),";
$multi_insert_counter++;
}
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
sleep(1);
# flush();
}
}
}
if ($multi_insert_counter > 0) {
$stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";";
$dbhA->query("$stmtZ");
print STMT_FILE $stmtZ."\r\n";
}
print "<BR><BR>Done</B> GOOD: $good &nbsp; &nbsp; &nbsp; BAD: $bad &nbsp; &nbsp; &nbsp; TOTAL: $total</font></center>";
exit;
sub USA_dstcalc {
#**********************************************************************
# FSA-LSO
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in April and last Sunday in October at 2 am.
# INPUTS:
# mm INTEGER Month.
# dd INTEGER Day of the month.
# ns INTEGER Seconds into the day.
# dow INTEGER Day of week (0=Sunday, to 6=Saturday)
# OPTIONAL INPUT:
# timezone INTEGER hour difference UTC - local standard time
# (DEFAULT is blank)
# make calculations based on UTC time,
# which means shift at 10:00 UTC in April
# and 9:00 UTC in October
# OUTPUT:
# INTEGER 1 = DST, 0 = not DST
#**********************************************************************
$USA_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 4 || $mm > 10) {
$USA_DST=0; return 0;
} elsif ($mm >= 5 && $mm <= 9) {
$USA_DST=1; return 1;
} elsif ($mm == 4) {
if ($dd > 7) {
$USA_DST=1; return 1;
} elsif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
$USA_DST=0; return 0;
} else {
$USA_DST=1; return 1;
}
} else {
if ($dow == 0 && $ns < 7200) {
$USA_DST=0; return 0;
} else {
$USA_DST=1; return 1;
}
}
} else {
$USA_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd < 25) {
$USA_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$USA_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (7200+($timezone-1)*3600)) {
$USA_DST=1; return 1;
} else {
$USA_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 7200) {
$USA_DST=1; return 1;
} else {
$USA_DST=0; return 0;
}
}
} else {
$USA_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
sub GBR_dstcalc {
#**********************************************************************
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on last Sunday in March and last Sunday in October at 1 am.
#**********************************************************************
$GBR_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$GBR_DST=0; return 0;
} elsif ($mm >= 4 && $mm <= 9) {
$GBR_DST=1; return 1;
} elsif ($mm == 3) {
if ($dd < 25) {
$GBR_DST=0; return 0;
} elsif ($dd < ($dow+25)) {
$GBR_DST=0; return 0;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$GBR_DST=0; return 0;
} else {
$GBR_DST=1; return 1;
}
} else { # local time calculations
if ($ns < 3600) {
$GBR_DST=0; return 0;
} else {
$GBR_DST=1; return 1;
}
}
} else {
$GBR_DST=1; return 1;
}
} elsif ($mm == 10) {
if ($dd < 25) {
$GBR_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$GBR_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$GBR_DST=1; return 1;
} else {
$GBR_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$GBR_DST=1; return 1;
} else {
$GBR_DST=0; return 0;
}
}
} else {
$GBR_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
sub AUS_dstcalc {
#**********************************************************************
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on last Sunday in October and last Sunday in March at 1 am.
#**********************************************************************
$AUS_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$AUS_DST=1; return 1;
} elsif ($mm >= 4 && $mm <= 9) {
$AUS_DST=0; return 0;
} elsif ($mm == 3) {
if ($dd < 25) {
$AUS_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$AUS_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUS_DST=1; return 1;
} else {
$AUS_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$AUS_DST=1; return 1;
} else {
$AUS_DST=0; return 0;
}
}
} else {
$AUS_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd < 25) {
$AUS_DST=0; return 0;
} elsif ($dd < ($dow+25)) {
$AUS_DST=0; return 0;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUS_DST=0; return 0;
} else {
$AUS_DST=1; return 1;
}
} else { # local time calculations
if ($ns < 3600) {
$AUS_DST=0; return 0;
} else {
$AUS_DST=1; return 1;
}
}
} else {
$AUS_DST=1; return 1;
}
} # end of month checks
} # end of subroutine dstcalc
sub AUST_dstcalc {
#**********************************************************************
# TASMANIA ONLY
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in October and last Sunday in March at 1 am.
#**********************************************************************
$AUST_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$AUST_DST=1; return 1;
} elsif ($mm >= 4 && $mm <= 9) {
$AUST_DST=0; return 0;
} elsif ($mm == 3) {
if ($dd < 25) {
$AUST_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$AUST_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUST_DST=1; return 1;
} else {
$AUST_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$AUST_DST=1; return 1;
} else {
$AUST_DST=0; return 0;
}
}
} else {
$AUST_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd > 7) {
$AUST_DST=1; return 1;
} elsif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
$AUST_DST=0; return 0;
} else {
$AUST_DST=1; return 1;
}
} else {
if ($dow == 0 && $ns < 3600) {
$AUST_DST=0; return 0;
} else {
$AUST_DST=1; return 1;
}
}
} else {
$AUST_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
sub NZL_dstcalc {
#**********************************************************************
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in October and third Sunday in March at 1 am.
#**********************************************************************
$NZL_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$NZL_DST=1; return 1;
} elsif ($mm >= 4 && $mm <= 9) {
$NZL_DST=0; return 0;
} elsif ($mm == 3) {
if ($dd < 14) {
$NZL_DST=1; return 1;
} elsif ($dd < ($dow+14)) {
$NZL_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$NZL_DST=1; return 1;
} else {
$NZL_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$NZL_DST=1; return 1;
} else {
$NZL_DST=0; return 0;
}
}
} else {
$NZL_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd > 7) {
$NZL_DST=1; return 1;
} elsif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
$NZL_DST=0; return 0;
} else {
$NZL_DST=1; return 1;
}
} else {
if ($dow == 0 && $ns < 3600) {
$NZL_DST=0; return 0;
} else {
$NZL_DST=1; return 1;
}
}
} else {
$NZL_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
@@ -0,0 +1,79 @@
<?
# listloaderMAIN.php
#
# Copyright (C) 2006 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: GPLv2
#
# this is the main frame page for the lead loading section. This is where you
# would upload a file and have it inserted into vicidial_list
#
# changes:
# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_datetime = $STARTtime;
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
header ("Content-type: text/html; charset=utf-8");
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGload_leads =$row[0];
if ($LOGload_leads < 1)
{
echo "You do not have permissions to load leads\n";
exit;
}
fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?><HTML>
<HEAD>
<TITLE>VICIDIAL: Lead Loader Module</TITLE>
</HEAD>
<FRAMESET ROWS="300,*" border=0>
<FRAME SRC="listloader.php" NAME="main">
<FRAME SRC="count.htm" NAME="lead_count">
</HTML>
@@ -0,0 +1,56 @@
#!/usr/bin/perl
use Spreadsheet::ParseExcel;
use Time::Local;
use Net::MySQL;
### Make sure this file is in a libs path or put the absolute path to it
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
if (!$DB_port) {$DB_port='3306';}
$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port")
or die "Couldn't connect to database: $DB_server - $DB_database\n";
$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls");
my($iR, $iC, $oWkS, $oWkC);
$var_str="";
foreach $oWkS (@{$oBook->{Worksheet}}) {
for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) {
$oWkC = $oWkS->{Cells}[0][$iC];
if ($oWkC) {
$var_str.=$oWkC->Value."|";
} else {
$var_str.="|";
}
}
}
@xls_row=split(/\|/, $var_str);
$dbhA->query("select vendor_lead_code, source_id, list_id, 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 from vicidial_list limit 1");
if ($dbhA->has_selected_record) {
$rslt = $dbhA->create_record_iterator();
my @row = $rslt->get_field_names();
for ($i=0; $i<scalar(@row); $i++) {
# print "$i: $row[$i]\n";
$field_name=uc($row[$i]);
$field_name=~s/\_/ /g;
print " <tr bgcolor=#D9E6FE>\r\n";
print " <th><font class=standard>".$field_name.": </font></td>\r\n";
print " <th><select name='".$row[$i]."_field'>\r\n";
print " <option value=''>---------------------</option>\r\n";
for ($j=0; $j<scalar(@xls_row); $j++) {
$xls_row[$j]=~s/\"//g;
print " <option value='$j'>\"$xls_row[$j]\"</option>\r\n";
}
print " </select></td>\r\n";
print " </tr>\r\n";
}
}
@@ -0,0 +1,691 @@
#!/usr/bin/perl
### listloader_super.pl
###
### Copyright (C) 2006 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: GPLv2
###
#
#
# CHANGES
# 60616-1548 - Added listID override feature to force all leads into same list
# - Added gmt_offset_now lookup for each lead
#
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help|-h/i)
{
print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n";
}
else
{
if ($args =~ /--forcelistid=/i)
{
@data_in = split(/--forcelistid=/,$args);
$forcelistid = $data_in[1];
print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n";
}
else
{$forcelistid = '';}
}
}
### end parsing run-time options ###
use Spreadsheet::ParseExcel;
use Time::Local;
use Net::MySQL;
### Make sure this file is in a libs path or put the absolute path to it
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
if (!$DB_port) {$DB_port='3306';}
$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port")
or die "Couldn't connect to database: $DB_server - $DB_database\n";
$vars=$ARGV[0];
@xls_fields=split(/\,/, $vars);
$|=0;
$secX = time();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$mon++;
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
$pulldate0 = "$year-$mon-$mday $hour:$min:$sec";
$pulldate="$year-$mon-$mday $hour:$min:$sec";
$inSD = $pulldate0;
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
### Grab Server values from the database
$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';";
$dbhA->query("$stmtA");
if ($dbhA->has_selected_record)
{
$iter=$dbhA->create_record_iterator;
while ( $record = $iter->each)
{
$DBSERVER_GMT = "$record->[0]";
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
}
}
$LOCAL_GMT_OFF = $SERVER_GMT;
$LOCAL_GMT_OFF_STD = $SERVER_GMT;
if ($isdst) {$LOCAL_GMT_OFF++;}
if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";}
$total=0; $good=0; $bad=0;
open(STMT_FILE, "> listloader_stmts.txt");
$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls");
my($iR, $iC, $oWkS, $oWkC);
foreach $oWkS (@{$oBook->{Worksheet}}) {
for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) {
$entry_date = "$pulldate";
$modify_date = "";
$status = "NEW";
$user = "";
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[0]];
if ($oWkC) {$vendor_lead_code=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[1]];
if ($oWkC) {$source_code=$oWkC->Value; }
$source_id=$source_code;
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[2]];
if ($oWkC) {$list_id=$oWkC->Value; }
$gmt_offset = '0';
$called_since_last_reset='N';
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[3]];
if ($oWkC) {$phone_code=$oWkC->Value; }
$phone_code=~s/[^0-9]//g;
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[4]];
if ($oWkC) {$phone_number=$oWkC->Value; }
$phone_number=~s/[^0-9]//g;
$USarea = substr($phone_number, 0, 3);
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[5]];
if ($oWkC) {$title=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[6]];
if ($oWkC) {$first_name=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[7]];
if ($oWkC) {$middle_initial=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[8]];
if ($oWkC) {$last_name=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[9]];
if ($oWkC) {$address1=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[10]];
if ($oWkC) {$address2=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[11]];
if ($oWkC) {$address3=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[12]];
if ($oWkC) {$city=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[13]];
if ($oWkC) {$state=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[14]];
if ($oWkC) {$province=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[15]];
if ($oWkC) {$postal_code=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[16]];
if ($oWkC) {$country_code=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[17]];
if ($oWkC) {$gender=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[18]];
if ($oWkC) {$date_of_birth=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[19]];
if ($oWkC) {$alt_phone=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[20]];
if ($oWkC) {$email=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[21]];
if ($oWkC) {$security_phrase=$oWkC->Value; }
$oWkC = $oWkS->{Cells}[$iR][$xls_fields[22]];
if ($oWkC) {$comments=$oWkC->Value; }
$comments=~s/^\s*(.*?)\s*$/$1/;
if (length($phone_number)>8) {
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =~ /^1$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### MEXICO ###
if ($phone_code =~ /^52$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### AUSTRALIA ###
if ($phone_code =~ /^61$/)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$dbhA->query($stmtA);
$rec_countW=0;
if ($dbhA->has_selected_record)
{
$iterA=$dbhA->create_record_iterator;
while ($recordA = $iterA->each)
{
$gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi;
$dst = $recordA->[5];
$dst_range = $recordA->[6];
$PC_processed++;
}
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD);
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
$AC_processed=0;
if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) )
{
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
&USA_dstcalc;
if ($DBX) {print " DST: $USA_DST\n";}
if ($USA_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) )
{
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
&GBR_dstcalc;
if ($DBX) {print " DST: $GBR_DST\n";}
if ($GBR_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) )
{
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
&AUS_dstcalc;
if ($DBX) {print " DST: $AUS_DST\n";}
if ($AUS_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) )
{
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
&AUST_dstcalc;
if ($DBX) {print " DST: $AUST_DST\n";}
if ($AUST_DST) {$gmt_offset++;}
$AC_processed++;
}
if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) )
{
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
&NZL_dstcalc;
if ($DBX) {print " DST: $NZL_DST\n";}
if ($NZL_DST) {$gmt_offset++;}
$AC_processed++;
}
if (!$AC_processed)
{
if ($DBX) {print " No DST Method Found\n";}
if ($DBX) {print " DST: 0\n";}
$AC_processed++;
}
if ($multi_insert_counter > 8) {
### insert good deal into pending_transactions table ###
$stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$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',0);";
$dbhA->query("$stmtZ");
print STMT_FILE $stmtZ."\r\n";
$multistmt='';
$multi_insert_counter=0;
} else {
$multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$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',0),";
$multi_insert_counter++;
}
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
sleep(1);
# flush();
}
}
}
if ($multi_insert_counter > 0) {
$stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";";
$dbhA->query("$stmtZ");
print STMT_FILE $stmtZ."\r\n";
}
print "<BR><BR>Done</B> GOOD: $good &nbsp; &nbsp; &nbsp; BAD: $bad &nbsp; &nbsp; &nbsp; TOTAL: $total</font></center>";
exit;
sub USA_dstcalc {
#**********************************************************************
# FSA-LSO
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in April and last Sunday in October at 2 am.
# INPUTS:
# mm INTEGER Month.
# dd INTEGER Day of the month.
# ns INTEGER Seconds into the day.
# dow INTEGER Day of week (0=Sunday, to 6=Saturday)
# OPTIONAL INPUT:
# timezone INTEGER hour difference UTC - local standard time
# (DEFAULT is blank)
# make calculations based on UTC time,
# which means shift at 10:00 UTC in April
# and 9:00 UTC in October
# OUTPUT:
# INTEGER 1 = DST, 0 = not DST
#**********************************************************************
$USA_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 4 || $mm > 10) {
$USA_DST=0; return 0;
} elsif ($mm >= 5 && $mm <= 9) {
$USA_DST=1; return 1;
} elsif ($mm == 4) {
if ($dd > 7) {
$USA_DST=1; return 1;
} elsif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
$USA_DST=0; return 0;
} else {
$USA_DST=1; return 1;
}
} else {
if ($dow == 0 && $ns < 7200) {
$USA_DST=0; return 0;
} else {
$USA_DST=1; return 1;
}
}
} else {
$USA_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd < 25) {
$USA_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$USA_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (7200+($timezone-1)*3600)) {
$USA_DST=1; return 1;
} else {
$USA_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 7200) {
$USA_DST=1; return 1;
} else {
$USA_DST=0; return 0;
}
}
} else {
$USA_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
sub GBR_dstcalc {
#**********************************************************************
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on last Sunday in March and last Sunday in October at 1 am.
#**********************************************************************
$GBR_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$GBR_DST=0; return 0;
} elsif ($mm >= 4 && $mm <= 9) {
$GBR_DST=1; return 1;
} elsif ($mm == 3) {
if ($dd < 25) {
$GBR_DST=0; return 0;
} elsif ($dd < ($dow+25)) {
$GBR_DST=0; return 0;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$GBR_DST=0; return 0;
} else {
$GBR_DST=1; return 1;
}
} else { # local time calculations
if ($ns < 3600) {
$GBR_DST=0; return 0;
} else {
$GBR_DST=1; return 1;
}
}
} else {
$GBR_DST=1; return 1;
}
} elsif ($mm == 10) {
if ($dd < 25) {
$GBR_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$GBR_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$GBR_DST=1; return 1;
} else {
$GBR_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$GBR_DST=1; return 1;
} else {
$GBR_DST=0; return 0;
}
}
} else {
$GBR_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
sub AUS_dstcalc {
#**********************************************************************
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on last Sunday in October and last Sunday in March at 1 am.
#**********************************************************************
$AUS_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$AUS_DST=1; return 1;
} elsif ($mm >= 4 && $mm <= 9) {
$AUS_DST=0; return 0;
} elsif ($mm == 3) {
if ($dd < 25) {
$AUS_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$AUS_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUS_DST=1; return 1;
} else {
$AUS_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$AUS_DST=1; return 1;
} else {
$AUS_DST=0; return 0;
}
}
} else {
$AUS_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd < 25) {
$AUS_DST=0; return 0;
} elsif ($dd < ($dow+25)) {
$AUS_DST=0; return 0;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUS_DST=0; return 0;
} else {
$AUS_DST=1; return 1;
}
} else { # local time calculations
if ($ns < 3600) {
$AUS_DST=0; return 0;
} else {
$AUS_DST=1; return 1;
}
}
} else {
$AUS_DST=1; return 1;
}
} # end of month checks
} # end of subroutine dstcalc
sub AUST_dstcalc {
#**********************************************************************
# TASMANIA ONLY
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in October and last Sunday in March at 1 am.
#**********************************************************************
$AUST_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$AUST_DST=1; return 1;
} elsif ($mm >= 4 && $mm <= 9) {
$AUST_DST=0; return 0;
} elsif ($mm == 3) {
if ($dd < 25) {
$AUST_DST=1; return 1;
} elsif ($dd < ($dow+25)) {
$AUST_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$AUST_DST=1; return 1;
} else {
$AUST_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$AUST_DST=1; return 1;
} else {
$AUST_DST=0; return 0;
}
}
} else {
$AUST_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd > 7) {
$AUST_DST=1; return 1;
} elsif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
$AUST_DST=0; return 0;
} else {
$AUST_DST=1; return 1;
}
} else {
if ($dow == 0 && $ns < 3600) {
$AUST_DST=0; return 0;
} else {
$AUST_DST=1; return 1;
}
}
} else {
$AUST_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
sub NZL_dstcalc {
#**********************************************************************
# This is returns 1 if Daylight Savings Time is in effect and 0 if
# Standard time is in effect.
# Based on first Sunday in October and third Sunday in March at 1 am.
#**********************************************************************
$NZL_DST=0;
$mm = $mon;
$dd = $mday;
$ns = $dsec;
$dow= $wday;
if ($mm < 3 || $mm > 10) {
$NZL_DST=1; return 1;
} elsif ($mm >= 4 && $mm <= 9) {
$NZL_DST=0; return 0;
} elsif ($mm == 3) {
if ($dd < 14) {
$NZL_DST=1; return 1;
} elsif ($dd < ($dow+14)) {
$NZL_DST=1; return 1;
} elsif ($dow == 0) {
if ($timezone) { # UTC calculations
if ($ns < (3600+($timezone-1)*3600)) {
$NZL_DST=1; return 1;
} else {
$NZL_DST=0; return 0;
}
} else { # local time calculations
if ($ns < 3600) {
$NZL_DST=1; return 1;
} else {
$NZL_DST=0; return 0;
}
}
} else {
$NZL_DST=0; return 0;
}
} elsif ($mm == 10) {
if ($dd > 7) {
$NZL_DST=1; return 1;
} elsif ($dd >= ($dow+1)) {
if ($timezone) {
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
$NZL_DST=0; return 0;
} else {
$NZL_DST=1; return 1;
}
} else {
if ($dow == 0 && $ns < 3600) {
$NZL_DST=0; return 0;
} else {
$NZL_DST=1; return 1;
}
}
} else {
$NZL_DST=0; return 0;
}
} # end of month checks
} # end of subroutine dstcalc
@@ -0,0 +1,37 @@
<?
# log_test.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$fp = fopen ("./closer_SQL_updates.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
fwrite ($fp, "CLOSER SQL UPDATE|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
exit;
?>
Hello
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,156 @@
<?
### record_conf_1_hour.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# grab: $server_ip $station $session_id
#
# CHANGES
#
# 60620-1011 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["station"])) {$station=$_GET["station"];}
elseif (isset($_POST["station"])) {$station=$_POST["station"];}
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["NEW_RECORDING"])) {$NEW_RECORDING=$_GET["NEW_RECORDING"];}
elseif (isset($_POST["NEW_RECORDING"])) {$NEW_RECORDING=$_POST["NEW_RECORDING"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$MYSQL_datetime = date("Y-m-d H:i:s");
$FILE_datetime = date("Ymd-His_");
$secX = $STARTtime;
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
$stmt="SELECT full_name from vicidial_users where user='$user';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
}
?>
<html>
<head>
<title>VICIDIAL RECORD CONFERENCE: 1 hour</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<?
if ($NEW_RECORDING)
{
if ( (strlen($server_ip) > 8) && (strlen($session_id) > 3) && (strlen($station) > 3) )
{
$local_DEF = 'Local/';
$local_AMP = '@';
$conf_silent_prefix = '7';
$ext_context = 'demo';
$stmt="INSERT INTO vicidial_manager values('','','$MYSQL_datetime','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Originate','RB$FILE_datetime" . mysql_real_escape_string($station) . "','Channel: $local_DEF$conf_silent_prefix" . mysql_real_escape_string($session_id) . "$local_AMP$ext_context','Context: $ext_context','Exten: 8309','Priority: 1','Callerid: $FILE_datetime" . mysql_real_escape_string($station) . "','','','','','')";
echo "|$stmt|\n<BR><BR>\n";
$rslt=mysql_query($stmt, $link);
$stmt="INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('" . mysql_real_escape_string($session_id) . "','" . mysql_real_escape_string($server_ip) . "','" . mysql_real_escape_string($station) . "','$MYSQL_datetime','$secX','$FILE_datetime" . mysql_real_escape_string($station) . "')";
echo "|$stmt|\n<BR><BR>\n";
$rslt=mysql_query($stmt, $link);
echo "Recording started\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Back to main recording screen</a>\n<BR><BR>\n";
}
else
{
echo "ERROR!!!! Not all info entered properly\n<BR><BR>\n";
echo "|$server_ip| |$session_id| |$station|\n<BR><BR>\n";
echo "<a href=\"$PHP_SELF\">Back to main recording screen</a>\n<BR><BR>\n";
}
}
else
{
echo "<br>Start recording a conference for 1 hour: <form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=NEW_RECORDING value=1>\n";
echo "server_ip: <input type=text name=server_ip size=15 maxlength=15> | \n";
echo "session_id: <input type=text name=session_id size=7 maxlength=7> | \n";
echo "station: <input type=text name=station size=5 maxlength=5> | \n";
echo "<input type=submit name=submit value=submit>\n";
echo "<BR><BR><BR>\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,327 @@
<?
### remote_dispo.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call
# CHANGES
#
# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
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["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];}
elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];}
if (isset($_GET["city"])) {$city=$_GET["city"];}
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["email"])) {$email=$_GET["email"];}
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
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["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["pass"])) {$pass=$_GET["pass"];}
elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];}
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["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["security"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["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["session_id"])) {$session_id=$_GET["session_id"];}
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
if (isset($_GET["state"])) {$state=$_GET["state"];}
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_datetime = $STARTtime;
$ext_context = 'demo';
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$fullname = $row[0];
fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
?>
<html>
<head>
<title>VICIDIAL REMOTE: Call Disposition</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
echo "<!-- $call_began $lead_id -->";
if ($end_call > 0)
{
$call_length = ($STARTtime - $call_began);
### insert a NEW record to the vicidial_closer_log table
$stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
### update the lead record in the vicidial_list table
$stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Call has been dispositioned &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
echo "<form><input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\"></form>\n";
}
else
{
$stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_count = $row[0];
if ($lead_count > 0)
{
$stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_id = "$row[0]";
$tsr = "$row[4]";
$vendor_id = "$row[5]";
$list_id = "$row[7]";
$campaign_id = "$row[8]";
$phone_code = "$row[10]";
$phone_number = "$row[11]";
$title = "$row[12]";
$first_name = "$row[13]"; #
$middle_initial = "$row[14]";
$last_name = "$row[15]"; #
$address1 = "$row[16]"; #
$address2 = "$row[17]"; #
$address3 = "$row[18]"; #
$city = "$row[19]"; #
$state = "$row[20]"; #
$province = "$row[21]"; #
$postal_code = "$row[22]"; #
$country_code = "$row[23]"; #
$gender = "$row[24]";
$date_of_birth = "$row[25]";
$alt_phone = "$row[26]"; #
$email = "$row[27]"; #
$security = "$row[28]"; #
$comments = "$row[29]"; #
echo "<br>Call information: $first_name $last_name - $phone_number<br><br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=end_call value=1>\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
echo "<input type=hidden name=phone_code value=\"$phone_code\">\n";
echo "<input type=hidden name=phone_number value=\"$phone_number\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=channel value=\"$channel\">\n";
echo "<input type=hidden name=call_began value=\"$call_began\">\n";
echo "<input type=hidden name=parked_time value=\"$parked_time\">\n";
echo "<table cellpadding=1 cellspacing=0>\n";
echo "<tr><td colspan=2>Vendor ID: $vendor_id &nbsp; &nbsp; Campaign ID: $campaign_id</td></tr>\n";
echo "<tr><td colspan=2>Fronter: $tsr &nbsp; &nbsp; List ID: $list_id</td></tr>\n";
echo "<tr><td align=right>First Name: </td><td align=left><input type=text name=first_name size=15 maxlength=30 value=\"$first_name\"> &nbsp; \n";
echo " Last Name: <input type=text name=last_name size=15 maxlength=30 value=\"$last_name\"> </td></tr>\n";
echo "<tr><td align=right>Address 1 : </td><td align=left><input type=text name=address1 size=30 maxlength=30 value=\"$address1\"></td></tr>\n";
echo "<tr><td align=right>Address 2 : </td><td align=left><input type=text name=address2 size=30 maxlength=30 value=\"$address2\"></td></tr>\n";
echo "<tr><td align=right>Address 3 : </td><td align=left><input type=text name=address3 size=30 maxlength=30 value=\"$address3\"></td></tr>\n";
echo "<tr><td align=right>City : </td><td align=left><input type=text name=city size=30 maxlength=30 value=\"$city\"></td></tr>\n";
echo "<tr><td align=right>State: </td><td align=left><input type=text name=state size=2 maxlength=2 value=\"$state\"> &nbsp; \n";
echo " Postal Code: <input type=text name=postal_code size=10 maxlength=10 value=\"$postal_code\"> </td></tr>\n";
echo "<tr><td align=right>Province : </td><td align=left><input type=text name=province size=30 maxlength=30 value=\"$province\"></td></tr>\n";
echo "<tr><td align=right>Country : </td><td align=left><input type=text name=country_code size=3 maxlength=3 value=\"$country_code\"></td></tr>\n";
echo "<tr><td align=right>Alt Phone : </td><td align=left><input type=text name=alt_phone size=10 maxlength=10 value=\"$alt_phone\"></td></tr>\n";
echo "<tr><td align=right>Email : </td><td align=left><input type=text name=email size=30 maxlength=50 value=\"$email\"></td></tr>\n";
echo "<tr><td align=right>Security : </td><td align=left><input type=text name=security size=30 maxlength=100 value=\"$security\"></td></tr>\n";
echo "<tr><td align=right>Comments : </td><td align=left><input type=text name=comments size=30 maxlength=255 value=\"$comments\"></td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Disposition: </td><td align=left><select size=1 name=status>\n";
$stmt="SELECT * from vicidial_statuses where selectable='Y' order by status";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
$statuses_list='';
$o=0;
while ($statuses_to_print > $o) {
$rowx=mysql_fetch_row($rslt);
$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
$o++;
}
echo "$statuses_list";
echo "</select></td></tr>\n";
echo "<tr><td colspan=2><input type=submit name=submit value=\"DISPO CALL\"></td></tr>\n";
echo "</table></form>\n";
echo "<BR><BR><BR>\n";
}
else
{
echo "lead lookup FAILED for lead_id $lead_id &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
# echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,96 @@
<?
### server_stats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60620-1037 - Added Link back to Admin section
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select * from servers;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$servers_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $servers_to_print)
{
$row=mysql_fetch_row($rslt);
$server_id[$i] = $row[0];
$server_description[$i] = $row[1];
$server_ip[$i] = $row[2];
$active[$i] = $row[3];
$i++;
}
?>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>VICIDIAL: Server Stats and Reports</TITLE></HEAD><BODY BGCOLOR=WHITE>
<FONT SIZE=4><B>VICIDIAL: Server Stats and Reports</B></font> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<a href="./admin.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>BACK TO ADMIN</FONT></a><BR><BR>
<UL>
<LI><a href="AST_timeonVDADall.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>TIME ON VDAD (per campaign)</a> | <a href="AST_timeonVDADall_SIPmonitor.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>SIP Listen Version</a></FONT>
<LI><a href="AST_parkstats.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>PARK REPORT</a></FONT>
<LI><a href="AST_VDADstats.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>VDAD REPORT</a></FONT>
<LI><a href="AST_CLOSERstats.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>CLOSER REPORT</a></FONT>
<LI><a href="AST_agent_performance.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>AGENT PERFORMANCE</a></FONT>
<LI><a href="AST_agent_performance_detail.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>AGENT PERFORMANCE DETAIL</a></FONT>
<LI><a href="AST_server_performance.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>SERVER PERFORMANCE</a></FONT>
</UL>
<PRE><TABLE BORDER=1>
<TR><TD>SERVER</TD><TD>DESCRIPTION</TD><TD>IP ADDRESS</TD><TD>ACTIVE</TD><TD>VDAD time</TD><TD>VDcall time</TD><TD>PARK time</TD><TD>CLOSER/INBOUND time</TD></TR>
<?
$o=0;
while ($servers_to_print > $o)
{
echo "<TR>\n";
echo "<TD>$server_id[$o]</TD>\n";
echo "<TD>$server_description[$o]</TD>\n";
echo "<TD>$server_ip[$o]</TD>\n";
echo "<TD>$active[$o]</TD>\n";
echo "<TD><a href=\"AST_timeonVDAD.php?server_ip=$server_ip[$o]\">LINK</a></TD>\n";
echo "<TD><a href=\"AST_timeoncall.php?server_ip=$server_ip[$o]\">LINK</a></TD>\n";
echo "<TD><a href=\"AST_timeonpark.php?server_ip=$server_ip[$o]\">LINK</a></TD>\n";
echo "<TD><a href=\"AST_timeonVDAD_closer.php?server_ip=$server_ip[$o]\">LINK</a></TD>\n";
echo "</TR>\n";
$o++;
}
?>
</TABLE>
</BODY></HTML>
@@ -0,0 +1 @@
Hello world
@@ -0,0 +1,316 @@
<?
### user_stats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
$stmt="SELECT full_name from vicidial_users where user='$user';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
}
?>
<html>
<head>
<title>VICIDIAL ADMIN: User Stats</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; VICIDIAL ADMIN: User Stats for <? echo $user ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> &nbsp; \n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=user value=\"$user\">\n";
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> &nbsp;\n";
echo "<input type=submit name=submit value=submit>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
echo "<br><center>\n";
echo "<B>TALK TIME AND STATUS:</B>\n";
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>STATUS</td><td align=right><font size=2>COUNT</td><td align=right><font size=2>HOURS:MINUTES</td></tr>\n";
$total_calls=0;
$o=0;
while ($statuses_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_seconds = $row[2];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
echo "<td align=right><font size=2> $row[0]</td>\n";
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'";
$rslt=mysql_query($stmt, $link);
$counts_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$call_seconds = $row[0];
$call_hours = ($call_seconds / 3600);
$call_hours = round($call_hours, 2);
$call_hours_int = intval("$call_hours");
$call_minutes = ($call_hours - $call_hours_int);
$call_minutes = ($call_minutes * 60);
$call_minutes_int = round($call_minutes, 0);
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
echo "<tr><td><font size=2>TOTAL CALLS </td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>LOGIN/LOGOUT TIME:</B>\n";
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>EVENT </td><td align=right><font size=2> DATE</td><td align=right><font size=2> CAMPAIGN</td><td align=right><font size=2>HOURS:MINUTES</td></tr>\n";
$stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("LOGIN", $row[0]))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
if (ereg("LOGIN", $row[0]))
{
$event_start_seconds = $row[1];
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td>\n";
echo "<td align=right><font size=2> </td></tr>\n";
}
if (ereg("LOGOUT", $row[0]))
{
if ($event_start_seconds)
{
$event_stop_seconds = $row[1];
$event_seconds = ($event_stop_seconds - $event_start_seconds);
$total_login_time = ($total_login_time + $event_seconds);
$event_hours = ($event_seconds / 3600);
$event_hours = round($event_hours, 2);
$event_hours_int = intval("$event_hours");
$event_minutes = ($event_hours - $event_hours_int);
$event_minutes = ($event_minutes * 60);
$event_minutes_int = round($event_minutes, 0);
if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";}
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td>\n";
echo "<td align=right><font size=2> $event_hours_int:$event_minutes_int</td></tr>\n";
$event_start_seconds='';
$event_stop_seconds='';
}
else
{
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
echo "<td align=right><font size=2> $row[2]</td>\n";
echo "<td align=right><font size=2> $row[3]</td>\n";
echo "<td align=right><font size=2> </td></tr>\n";
}
}
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$total_login_hours = ($total_login_time / 3600);
$total_login_hours = round($total_login_hours, 2);
$total_login_hours_int = intval("$total_login_hours");
$total_login_minutes = ($total_login_hours - $total_login_hours_int);
$total_login_minutes = ($total_login_minutes * 60);
$total_login_minutes_int = round($total_login_minutes, 0);
if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";}
echo "<tr><td><font size=2>TOTAL</td>";
echo "<td align=right><font size=2> </td>\n";
echo "<td align=right><font size=2> </td>\n";
echo "<td align=right><font size=2> $total_login_hours_int:$total_login_minutes_int</td></tr>\n";
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<center>\n";
echo "<B>LAST 50 CALLS:</B>\n";
echo "<TABLE width=550 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>DATE/TIME </td><td align=left><font size=2>LENGTH</td><td align=left><font size=2> STATUS</td><td align=left><font size=2> PHONE</td><td align=right><font size=2> CAMPAIGN</td><td align=right><font size=2> LIST</td><td align=right><font size=2> LEAD</td></tr>\n";
$stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[4]</td>";
echo "<td align=left><font size=2> $row[7]</td>\n";
echo "<td align=left><font size=2> $row[8]</td>\n";
echo "<td align=left><font size=2> $row[10] </td>\n";
echo "<td align=right><font size=2> $row[3] </td>\n";
echo "<td align=right><font size=2> $row[2] </td>\n";
echo "<td align=right><font size=2> <A HREF=\"admin_modify_lead.php?lead_id=$row[1]\" target=\"_blank\">$row[1]</A> </td></tr>\n";
$u++;
}
echo "</TABLE></center>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,238 @@
<?
### user_status.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$change_agent_campaign=$row[1];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
$stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
$stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$agents_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $agents_to_print)
{
$row=mysql_fetch_row($rslt);
$Aserver_ip = $row[2];
$Asession_id = $row[3];
$Aextension = $row[4];
$Astatus = $row[5];
$Acampaign = $row[7];
$Alast_call = $row[14];
$Acl_campaigns = $row[15];
$i++;
}
}
$stmt="select * from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<html>
<head>
<title>VICIDIAL ADMIN: User Status</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; VICIDIAL ADMIN: User Status for <? echo $user ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<?
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B> &nbsp; \n";
if ($stage == "live_campaign_change")
{
$stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';";
$rslt=mysql_query($stmt, $link);
echo "Agent $user - $full_name changed to $group campaign<BR>\n";
exit;
}
if ($stage == "log_agent_out")
{
$stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';";
$rslt=mysql_query($stmt, $link);
echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser<BR>\n";
exit;
}
if ($agents_to_print > 0)
{
echo "<PRE>";
echo "Agent Logged in at server: $Aserver_ip\n";
echo " in session: $Asession_id\n";
echo " from phone: $Aextension\n";
echo "Agent is in campaign: $Acampaign\n";
echo " status: $Astatus\n";
echo " hungup last call at: $Alast_call\n";
echo " Closer groups: $Acl_campaigns\n\n";
echo "</PRE>";
if ($change_agent_campaign > 0)
{
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=user value=\"$user\">\n";
echo "<input type=hidden name=stage value=\"live_campaign_change\">\n";
echo "Current Campaign: <SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == "$Acampaign") {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<input type=submit name=submit value=CHANGE><BR></form>\n";
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=user value=\"$user\">\n";
echo "<input type=hidden name=stage value=\"log_agent_out\">\n";
echo "<input type=submit name=submit value=\"EMERGENCY LOG AGENT OUT\"><BR></form>\n";
}
}
else
{
echo "Agent is not logged in\n<BR>";
}
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $user - $full_name - \n";
echo "<a href=\"./AST_agent_time_sheet.php?agent=$user\">VICIDIAL Time Sheet</a>\n";
echo "</B></TD></TR>\n";
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
echo "|$stage|$group|";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,602 @@
<?
# vdremote.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# Changes
# 50307-1721 - First version
# 51123-1502 - removed requirement of PHP Globals=on
# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat
#
# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time
$version = '1.1.12';
$build = '60619-1603';
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];}
elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];}
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["force_logout"])) {$force_logout=$_GET["force_logout"];}
elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];}
if (isset($_GET["groups"])) {$groups=$_GET["groups"];}
elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];}
if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];}
elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];}
if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];}
elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];}
if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];}
elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];}
elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["groups"])) {$groups=$_GET["groups"];}
elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (!isset($force_logout)) {$force_logout = 0;}
if ($force_logout)
{
if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) )
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
}
echo "You have now logged out. Thank you\n";
exit;
}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$popup_page = './closer_popup.php';
$STARTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
header ("Content-type: text/html; charset=utf-8");
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$authx=$row[0];
if($authx>0)
{
$stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$remote_agent_id=$row[0];
$server_ip=$row[1];
if (!$number_of_lines) {$number_of_lines=$row[2];}
fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
echo "This remote agent does not exist: |$PHP_AUTH_USER|\n";
exit;
}
}
else
{
fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo "<html>\n";
echo "<head>\n";
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
if ($ADD==61111)
{
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF?ADD=61111&user=$user&DB=$DB\">\n";
}
echo "<!-- VERSION: $version BUILD: $build -->\n";
?>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
.orange {color: black; background-color: orange}
-->
</STYLE>
<?
echo "<title>VICIDIAL REMOTE AGENTS: $LOGfullname - $PHP_AUTH_USER ";
if (!$ADD) {$ADD="31111";}
if ($ADD==31111) {echo "Modify Remote Agents";}
if ($ADD==41111) {echo "Modify Remote Agents";}
if ($ADD==61111) {echo "Remote Agent Status";}
if ($ADD==71111) {echo "Remote Agent Closer Stats";}
if (strlen($ADD)>4)
{
##### get server listing for dynamic pulldown
$stmt="SELECT server_ip,server_description from servers order by server_ip";
$rslt=mysql_query($stmt, $link);
$servers_to_print = mysql_num_rows($rslt);
$servers_list='';
$o=0;
while ($servers_to_print > $o)
{
$rowx=mysql_fetch_row($rslt);
$servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
$o++;
}
##### get campaigns listing for dynamic pulldown
$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id";
$rslt=mysql_query($stmt, $link);
$campaigns_to_print = mysql_num_rows($rslt);
$campaigns_list='';
$o=0;
while ($campaigns_to_print > $o)
{
$rowx=mysql_fetch_row($rslt);
$campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";
$o++;
}
##### get inbound groups listing for checkboxes
if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) )
{
$stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$closer_campaigns = $row[0];
$closer_campaigns = preg_replace("/ -$/","",$closer_campaigns);
$groups = explode(" ", $closer_campaigns);
}
$stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id";
$rslt=mysql_query($stmt, $link);
$groups_to_print = mysql_num_rows($rslt);
$groups_list='';
$groups_value='';
$o=0;
while ($groups_to_print > $o)
{
$rowx=mysql_fetch_row($rslt);
$group_id_value = $rowx[0];
$group_name_value = $rowx[1];
$groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\"";
$p=0;
while ($p<50)
{
if ($group_id_value == $groups[$p])
{
$groups_list .= " CHECKED";
$groups_value .= " $group_id_value";
}
$p++;
}
$groups_list .= "> $group_id_value - $group_name_value<BR>\n";
$o++;
}
if (strlen($groups_value)>2) {$groups_value .= " -";}
}
?>
</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; VICIDIAL REMOTE AGENTS: <? echo "$PHP_AUTH_USER " ?> &nbsp; <a href="<? echo $PHP_SELF ?>?force_logout=1"><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=1>Logout</a></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1> &nbsp; <a href="./vdremote.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>MODIFY</a> | <a href="./vdremote.php?ADD=61111&user=<? echo "$PHP_AUTH_USER" ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>STATUS</a> | <a href="./vdremote.php?ADD=71111&user=<? echo "$PHP_AUTH_USER" ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>INBOUND STATS</a></TD></TR>
<TR><TD ALIGN=LEFT COLSPAN=2>
<?
######################
# ADD=31111 modify remote agents info in the system
######################
if ($ADD==31111)
{
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
$stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$remote_agent_id = $row[0];
$user_start = $row[1];
$number_of_lines = $row[2];
$server_ip = $row[3];
$conf_exten = $row[4];
$status = $row[5];
$campaign_id = $row[6];
echo "<br>MODIFY A REMOTE AGENTS ENTRY: $row[0]<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=ADD value=41111>\n";
echo "<input type=hidden name=remote_agent_id value=\"$row[0]\">\n";
echo "<center><TABLE width=600 cellspacing=3>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>User ID Start: </td><td align=left>$user_start</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Number of Lines: </td><td align=left><input type=text name=number_of_lines size=3 maxlength=3 value=\"$number_of_lines\"> (numbers only)</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Server IP: </td><td align=left>$row[3]</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>External Extension: </td><td align=left><input type=text name=conf_exten size=20 maxlength=20 value=\"$conf_exten\"> (number dialed to reach agents [i.e. 913125551212])</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Status: </td><td align=left><select size=1 name=status><option SELECTED>ACTIVE</option><option>INACTIVE</option><option SELECTED>$status</option></select></td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Campaign: </td><td align=left>$campaign_id</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Inbound Groups: </td><td align=left>\n";
echo "$groups_list";
echo "</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=submit value=submit></td></tr>\n";
echo "</TABLE></center>\n";
echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n";
}
######################
# ADD=41111 modify remote agents info in the system
######################
if ($ADD==41111)
{
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) )
{echo "<br>REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n";}
else
{
$stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';";
$rslt=mysql_query($stmt, $link);
# echo "$stmt\n";
echo "<br>REMOTE AGENTS MODIFIED\n";
### LOG CHANGES TO LOG FILE ###
$fp = fopen ("./admin_changes_log.txt", "a");
fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n");
fclose($fp);
}
$stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$remote_agent_id = $row[0];
$user_start = $row[1];
$number_of_lines = $row[2];
$server_ip = $row[3];
$conf_exten = $row[4];
$status = $row[5];
$campaign_id = $row[6];
echo "<br>MODIFY A REMOTE AGENTS ENTRY: $row[0]<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=ADD value=41111>\n";
echo "<input type=hidden name=remote_agent_id value=\"$row[0]\">\n";
echo "<center><TABLE width=600 cellspacing=3>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>User ID Start: </td><td align=left>$user_start</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Number of Lines: </td><td align=left><input type=text name=number_of_lines size=3 maxlength=3 value=\"$number_of_lines\"> (numbers only)</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Server IP: </td><td align=left>$row[3]</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>External Extension: </td><td align=left><input type=text name=conf_exten size=20 maxlength=20 value=\"$conf_exten\"> (number dialed to reach agents [i.e. 913125551212])</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Status: </td><td align=left><select size=1 name=status><option SELECTED>ACTIVE</option><option>INACTIVE</option><option SELECTED>$status</option></select></td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Campaign: </td><td align=left>$campaign_id</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Inbound Groups: </td><td align=left>\n";
echo "$groups_list";
echo "</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=submit value=submit></td></tr>\n";
echo "</TABLE></center>\n";
echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n";
}
######################
# ADD=61111 status of remote agent in the system and active calls and queue
######################
if ($ADD==61111)
{
echo "<FONT FACE=\"Courier\" COLOR=BLACK SIZE=2><PRE>";
if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
{echo "<br>REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";}
else
{
$users_list = '';
$k=0;
while($k < $number_of_lines)
{
$nextuser=($user + $k);
$users_list .= "'" . mysql_real_escape_string($nextuser) . "',";
$k++;
}
$users_list = preg_replace("/.$/","",$users_list);
echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n";
echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n";
echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n";
echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n";
$stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
while ($i < $talking_to_print)
{
$leadlink=0;
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[3]='';
$row[5]=' - WAITING - ';
$row[6]=$row[7];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$leadid = sprintf("%-12s", $row[2]);
if ($row[2] > 0)
{
$leadidLINK=$row[2];
$leadlink++;
if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;}
$leadid = "<a href=\"./remote_dispo.php?lead_id=$row[2]&call_began=$row[6]\" target=\"_blank\">$leadid</a>";
}
$channel = sprintf("%-10s", $row[3]);
$cc=0;
while ( (strlen($channel) > 10) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 10) {$cc=101;}
}
$status = sprintf("%-6s", $row[4]);
$start_time = sprintf("%-19s", $row[5]);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 10) {$G='<SPAN class="orange"><B>'; $EG='</B></SPAN>';}
echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n";
echo " $i agents logged in on server $server_ip\n\n";
echo " <SPAN class=\"yellow\"><B> </SPAN> - 5 minutes or more on call</B>\n";
echo " <SPAN class=\"orange\"><B> </SPAN> - Over 10 minutes on call</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "********************************* NO AGENTS ON CALLS *********************************\n";
echo "**************************************************************************************\n";
}
}
echo "</PRE>\n\n";
}
######################
# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log)
######################
if ($ADD==71111)
{
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<INPUT TYPE=HIDDEN NAME=ADD VALUE=\"71111\">\n";
echo "<INPUT TYPE=HIDDEN NAME=user VALUE=\"$user\">\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<FONT FACE=\"Courier\" COLOR=BLACK SIZE=2><PRE>";
if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
{echo "<br>REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";}
else
{
$users_list = '';
$k=0;
while($k < $number_of_lines)
{
$nextuser=($user + $k);
$users_list .= "'$nextuser',";
$k++;
}
$users_list = preg_replace("/.$/","",$users_list);
$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$in_calls = $row[0];
$in_time = $row[1];
$in_time_M = ($in_time / 60);
$in_time_M = round($in_time_M, 2);
$in_time_M_int = intval("$in_time_M");
$in_time_SEC = ($in_time_M - $in_time_M_int);
$in_time_SEC = ($in_time_SEC * 60);
$in_time_SEC = round($in_time_SEC, 0);
if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";}
$in_time_MS = "$in_time_M_int:$in_time_SEC";
$in_time_MS = sprintf("%7s", $in_time_MS);
echo "VICIDIAL: Remote Agent inbound stats $NOW_TIME\n\n";
echo "\n";
echo "Total calls taken $query_date: $in_calls\n";
echo "Total talk time on $query_date: $in_time_MS (minutes:seconds)\n";
echo "\n";
echo "\n";
echo "Call list for $query_date:\n";
echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n";
echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n";
echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n";
$stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
$user = sprintf("%-8s", $row[0]);
$leadid = sprintf("%-10s", $row[1]);
$group = sprintf("%-14s", $row[2]);
$phone = sprintf("%-10s", $row[3]);
$status = sprintf("%-6s", $row[4]);
$start_time = sprintf("%-19s", $row[5]);
$call_time_S = $row[6];
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
# if ($call_time_M_int >= 5) {$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 10) {$G='<SPAN class="orange"><B>'; $EG='</B></SPAN>';}
echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n";
# echo " $i agents logged in on server $server_ip\n\n";
# echo " <SPAN class=\"yellow\"><B> </SPAN> - 5 minutes or more on call</B>\n";
# echo " <SPAN class=\"orange\"><B> </SPAN> - Over 10 minutes on call</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "********************************* NO CALLS ON THIS DAY *******************************\n";
echo "**************************************************************************************\n";
}
}
echo "</PRE>\n\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,396 @@
<?
### AST_CLOSERstats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select group_id from vicidial_inbound_groups;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: VDAD Genauerer Notfall</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=3111&group_id=$group\">ÄNDERN Sie</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "WÄHLEN Sie BITTE Eine KAMPAGNE Vor UND DATUM OBEN UND KLICKEN REICHTEin\n";
}
else
{
echo "VICIDIAL: Automobil-Vorwahlknopf Genauerer Notfall $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Gesamtanrufe gesetzt von dieser Kampagne: $TOTALcalls\n";
echo "Durchschnittliche Anruf-Länge für alle benennt in den Sekunden: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Gesamt-TROPFEN Anrufe: $DROPcalls $DROPpercent%\n";
echo "Durchschnittliche Länge für TROPFEN Anrufe in den Sekunden: $average_hold_seconds\n";
##############################
######### USER STATS
echo "\n";
echo "---------- USER STATS\n";
echo "+--------------------------+------------+--------+--------+\n";
echo "| BENUTZER | CALLS | TIME M | AVRG M |\n";
echo "+--------------------------+------------+--------+--------+\n";
$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$user = sprintf("%-6s", $row[0]);
$full_name = sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$USERcalls = sprintf("%10s", $row[2]);
$USERtotTALK = $row[3];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$USERtotTALK_MS = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
$i++;
}
echo "+--------------------------+------------+--------+--------+\n";
##############################
######### TIME STATS
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN DER GESAMTANRUFE GESETZTVON DIESER KAMPAGNE\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,417 @@
<?
### AST_VDADstats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: VDAD Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">ÄNDERN Sie</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "WÄHLEN Sie BITTE Eine KAMPAGNE Vor UND DATUM OBEN UND KLICKEN REICHTEin\n";
}
else
{
echo "VICIDIAL: Auto-dial Stats $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Gesamtanrufe gesetzt von dieser Kampagne: $TOTALcalls\n";
echo "Durchschnittliche Anruf-Länge für alle benennt in den Sekunden: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 0);
$average_hold_seconds = ($row[1] / $row[0]);
$average_hold_seconds = round($average_hold_seconds, 0);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
echo "Gesamt-TROPFEN Anrufe: $DROPcalls $DROPpercent%\n";
echo "Durchschnittliche Länge für TROPFEN Anrufe in den Sekunden: $average_hold_seconds\n";
echo "\n";
echo "----------AUTO-DIAL KEINE ANTWORTEN\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$NAcalls = sprintf("%10s", $row[0]);
$NApercent = (($NAcalls / $TOTALcalls) * 100);
$NApercent = round($NApercent, 0);
$average_na_seconds = ($row[1] / $row[0]);
$average_na_seconds = round($average_na_seconds, 0);
$average_na_seconds = sprintf("%10s", $average_na_seconds);
echo "Gesamt-Na benennt - beschäftigt, Trennung, BTvoicemail: $NAcalls $NApercent%\n";
echo "Durchschnittliche Anruf-Länge für Na benennt in den Sekunden: $average_na_seconds\n";
##############################
######### USER STATS
echo "\n";
echo "---------- USER STATS\n";
echo "+--------------------------+------------+--------+--------+\n";
echo "| BENUTZER | CALLS | TIME M | AVRG M |\n";
echo "+--------------------------+------------+--------+--------+\n";
$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$user = sprintf("%-6s", $row[0]);
$full_name = sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
$USERcalls = sprintf("%10s", $row[2]);
$USERtotTALK = $row[3];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$USERtotTALK_MS = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
$i++;
}
echo "+--------------------------+------------+--------+--------+\n";
##############################
######### TIME STATS
echo "\n";
echo "---------- TIME STATS\n";
echo "<FONT SIZE=0>\n";
$hi_hour_count=0;
$last_full_record=0;
$i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$h++;
}
$hour_multiplier = (100 / $hi_hour_count);
#$hour_multiplier = round($hour_multiplier, 0);
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN DER GESAMTANRUFE GESETZTVON DIESER KAMPAGNE\n";
$k=1;
$Mk=0;
$call_scale = '0';
while ($k <= 102)
{
if ($Mk >= 5)
{
$Mk=0;
$scale_num=($k / $hour_multiplier);
$scale_num = round($scale_num, 0);
$LENscale_num = (strlen($scale_num));
$k = ($k + $LENscale_num);
$call_scale .= "$scale_num";
}
else
{
$call_scale .= " ";
$k++; $Mk++;
}
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
$ZZ = '00';
$i=0;
$h=4;
$hour= -1;
$no_lines_yet=1;
while ($i <= 96)
{
$char_counter=0;
$time = ' ';
if ($h >= 4)
{
$hour++;
$h=0;
if ($hour < 10) {$hour = "0$hour";}
$time = "+$hour$ZZ+";
}
if ($h == 1) {$time = " 15 ";}
if ($h == 2) {$time = " 30 ";}
if ($h == 3) {$time = " 45 ";}
$Ghour_count = $hour_count[$i];
if ($Ghour_count < 1)
{
if ( ($no_lines_yet) or ($i > $last_full_record) )
{
$do_nothing=1;
}
else
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|";
$k=0; while ($k <= 102) {echo " "; $k++;}
echo "| $hour_count[$i] |\n";
}
}
else
{
$no_lines_yet=0;
$Xhour_count = ($Ghour_count * $hour_multiplier);
$Yhour_count = (99 - $Xhour_count);
$Gdrop_count = $drop_count[$i];
if ($Gdrop_count < 1)
{
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
echo "|$time|<SPAN class=\"green\">";
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
echo "*X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 101) {echo " "; $char_counter++;}
echo "| 0 | $hour_count[$i] |\n";
}
else
{
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
echo "|$time|<SPAN class=\"red\">";
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
echo "X</SPAN>"; $char_counter++;
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
while ($char_counter <= 102) {echo " "; $char_counter++;}
echo "| $drop_count[$i] | $hour_count[$i] |\n";
}
}
$i++;
$h++;
}
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,161 @@
<?
### AST_VICIDIAL_hopperlist.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($server_ip)) {$server_ip = '10.10.10.15';}
$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$campaign_id[$i] =$row[0];
$campaign_name[$i] =$row[1];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Zufuhrbehälter-Liste</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
#echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
#echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($campaigns_to_print > $o)
{
if ($campaign_id[$o] == $group) {echo "<option selected value=\"$campaign_id[$o]\">$campaign_id[$o] - $campaign_name[$o]</option>\n";}
else {echo "<option value=\"$campaign_id[$o]\">$campaign_id[$o] - $campaign_name[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">ÄNDERN Sie</a> \n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
{
echo "\n\n";
echo "WÄHLEN Sie BITTE Eine KAMPAGNE OBEN Vor UND KLICKEN REICHT Ein\n";
}
else
{
echo "VICIDIAL: Gegenwärtige Zufuhrbehälter-Lebhaftliste $NOW_TIME\n";
echo "\n";
echo "---------- TOTALS\n";
$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
echo "Gesamtleitungen im Zufuhrbehälter im Augenblick: $TOTALcalls\n";
##############################
######### LEAD STATS
echo "\n";
echo "---------- LEADS IN HOPPER\n";
echo "+------+-----------+------------+-------+--------+-------+--------+\n";
echo "| | LEAD_ID | PHONE NUM | STATE | STATUS | COUNT | GMT |\n";
echo "+------+-----------+------------+-------+--------+-------+--------+\n";
$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysql_fetch_row($rslt);
$FMT_i = sprintf("%-4s", $i);
$lead_id = sprintf("%-9s", $row[0]);
$phone_number = sprintf("%-10s", $row[1]);
$state = sprintf("%-5s", $row[2]);
$status = sprintf("%-6s", $row[3]);
$count = sprintf("%-5s", $row[4]);
$gmt = sprintf("%-6s", $row[5]);
echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
$i++;
}
echo "+------+-----------+------------+-------+--------+-------+--------+\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,118 @@
<?
### AST_admin_log_display.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date);
# AST GUI database administration
# AST_admin_log_display.php
#
# CHANGES
# 50325-0932 - First build
# 51123-1443 - removed globals=on requirement
# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat
#
$version = '0.0.4';
$build = '60620-1044';
$STARTtime = date("U");
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
echo "<html>\n";
echo "<head>\n";
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<!-- VERSION: $version BAU: $build ADD: $ADD-->\n";
echo "<title>VICIDIAL ADMIN LOG DISPLAY</title>";
echo "</head>\n";
# Fri, 25 Mar 2005
$DAY_DATE = date("j");
if ($DAY_DATE < 10)
# {$GREP_DATE = date("D, j M Y");}
{$GREP_DATE = date("D, 0j M Y");}
else
{$GREP_DATE = date("D, j M Y");}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!$query_date) {$query_date = $GREP_DATE;}
$Gquery_date = eregi_replace(" ",'\ ',$query_date);
echo "<!-- |$query_date|$Gquery_date| -->\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=20 MAXLENGTH=20 VALUE=\"$query_date\">\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
echo "VICIDIAL ADMIN CHANGE LOG $NOW_TIME\n";
#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,232 @@
<?
### AST_agent_performance.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Performance</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($campaigns_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">ÄNDERN Sie</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n";
if (!$group)
{
echo "\n";
echo "PLEASE SELECT A BEDIENERAND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from 6 hour shift specified\n";
}
else
{
if ($shift == 'AM')
{
$query_date_BEGIN = "$query_date 08:45:00";
$query_date_END = "$query_date 15:33:00";
$time_BEGIN = "08:45:00";
$time_END = "15:33:00";
}
if ($shift == 'PM')
{
$query_date_BEGIN = "$query_date 15:33:00";
$query_date_END = "$query_date 23:15:00";
$time_BEGIN = "15:33:00";
$time_END = "23:15:00";
}
echo "VICIDIAL: Agent Performance $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENTS Details -------------\n\n";
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
echo "| USER NAME | ID | CALLS | TALK | TALKAVG| A | B | DC | DNC | N | NI | SALE |\n";
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
$TOTcalls=($TOTcalls + $row[0]);
$TOTtotTALK=($TOTtotTALK + $row[1]);
$calls[$i] = sprintf("%-6s", $row[0]);
$full_name[$i]= sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
$user[$i] = sprintf("%-6s", $row[3]);
$USERtotTALK = $row[1];
$USERavgTALK = $row[4];
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$pfUSERtotTALK_MS[$i] = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$pfUSERavgTALK_MS[$i] = sprintf("%6s", $USERavgTALK_MS);
$i++;
}
$k=0;
while($k < $i)
{
$ctA[$k]="0 "; $ctB[$k]="0 "; $ctDC[$k]="0 "; $ctDNC[$k]="0 "; $ctN[$k]="0 "; $ctNI[$k]="0 "; $ctSALE[$k]="0 ";
$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$m=0;
while ($m < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]); $TOT_A = ($TOT_A + $row[0]);}
if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]); $TOT_B = ($TOT_B + $row[0]);}
if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]); $TOT_DC = ($TOT_DC + $row[0]);}
if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]); $TOT_DNC = ($TOT_DNC + $row[0]);}
if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]); $TOT_N = ($TOT_N + $row[0]);}
if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]); $TOT_NI = ($TOT_NI + $row[0]);}
if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]); $TOT_SALE = ($TOT_SALE + $row[0]);}
$m++;
}
echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
$k++;
}
$TOTcalls = sprintf("%-7s", $TOTcalls);
$TOTtotTALK_M = ($TOTtotTALK / 60);
$TOTtotTALK_M = round($TOTtotTALK_M, 2);
$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
$TOTtotTALK_S = ($TOTtotTALK_S * 60);
$TOTtotTALK_S = round($TOTtotTALK_S, 0);
if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
$TOTtotTALK_MS = sprintf("%7s", $TOTtotTALK_MS);
while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
$TOT_A = sprintf("%-5s", $TOT_A);
$TOT_B = sprintf("%-5s", $TOT_B);
$TOT_DC = sprintf("%-5s", $TOT_DC);
$TOT_DNC = sprintf("%-5s", $TOT_DNC);
$TOT_N = sprintf("%-5s", $TOT_N);
$TOT_NI = sprintf("%-5s", $TOT_NI);
$TOT_SALE = sprintf("%-5s", $TOT_SALE);
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
echo "| TOTALS | $TOTcalls| $TOTtotTALK_MS| | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
echo "\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,406 @@
<?
### AST_agent_performance_detail.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Performance</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($campaigns_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">ÄNDERN Sie</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n";
if (!$group)
{
echo "\n";
echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from 6 hour shift specified\n";
}
else
{
if ($shift == 'AM')
{
$query_date_BEGIN = "$query_date 03:45:00";
$query_date_END = "$query_date 15:15:00";
$time_BEGIN = "03:45:00";
$time_END = "15:15:00";
}
if ($shift == 'PM')
{
$query_date_BEGIN = "$query_date 15:15:00";
$query_date_END = "$query_date 23:15:00";
$time_BEGIN = "15:15:00";
$time_END = "23:15:00";
}
echo "VICIDIAL: Agent Performance Detail $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENTS Details -------------\n\n";
echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
echo "| USER NAME | ID | CALLS | TIME | PAUSE | PAUSAVG| WAIT | WAITAVG| TALK | TALKAVG| DISPO | DISPAVG| A | B | DC | DNC | N | NI | CB | SALE |\n";
echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
$TOTcalls=($TOTcalls + $row[0]);
$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
$TOTtotTALK=($TOTtotTALK + $row[1]);
$TOTtotWAIT=($TOTtotWAIT + $row[7]);
$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
$TOTtotDISPO=($TOTtotDISPO + $row[9]);
$calls[$i] = sprintf("%-6s", $row[0]);
$full_name[$i]= sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
$user[$i] = sprintf("%-6s", $row[3]);
$USERtime = ($row[1] + $row[5] + $row[7] + $row[9]);
$USERtotTALK = $row[1];
$USERavgTALK = $row[4];
$USERtotPAUSE = $row[5];
$USERavgPAUSE = $row[6];
$USERtotWAIT = $row[7];
$USERavgWAIT = $row[8];
$USERtotDISPO = $row[9];
$USERavgDISPO = $row[10];
$USERtime_M = ($USERtime / 60);
$USERtime_M = round($USERtime_M, 2);
$USERtime_M_int = intval("$USERtime_M");
$USERtime_S = ($USERtime_M - $USERtime_M_int);
$USERtime_S = ($USERtime_S * 60);
$USERtime_S = round($USERtime_S, 0);
if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
$USERtime_MS = "$USERtime_M_int:$USERtime_S";
$pfUSERtime_MS[$i] = sprintf("%7s", $USERtime_MS);
$USERtotTALK_M = ($USERtotTALK / 60);
$USERtotTALK_M = round($USERtotTALK_M, 2);
$USERtotTALK_M_int = intval("$USERtotTALK_M");
$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
$USERtotTALK_S = ($USERtotTALK_S * 60);
$USERtotTALK_S = round($USERtotTALK_S, 0);
if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
$pfUSERtotTALK_MS[$i] = sprintf("%6s", $USERtotTALK_MS);
$USERavgTALK_M = ($USERavgTALK / 60);
$USERavgTALK_M = round($USERavgTALK_M, 2);
$USERavgTALK_M_int = intval("$USERavgTALK_M");
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
$USERavgTALK_S = ($USERavgTALK_S * 60);
$USERavgTALK_S = round($USERavgTALK_S, 0);
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
$pfUSERavgTALK_MS[$i] = sprintf("%6s", $USERavgTALK_MS);
$USERtotPAUSE_M = ($USERtotPAUSE / 60);
$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
$pfUSERtotPAUSE_MS[$i] = sprintf("%6s", $USERtotPAUSE_MS);
$USERavgPAUSE_M = ($USERavgPAUSE / 60);
$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
$pfUSERavgPAUSE_MS[$i] = sprintf("%6s", $USERavgPAUSE_MS);
$USERtotWAIT_M = ($USERtotWAIT / 60);
$USERtotWAIT_M = round($USERtotWAIT_M, 2);
$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
$USERtotWAIT_S = ($USERtotWAIT_S * 60);
$USERtotWAIT_S = round($USERtotWAIT_S, 0);
if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
$pfUSERtotWAIT_MS[$i] = sprintf("%6s", $USERtotWAIT_MS);
$USERavgWAIT_M = ($USERavgWAIT / 60);
$USERavgWAIT_M = round($USERavgWAIT_M, 2);
$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
$USERavgWAIT_S = ($USERavgWAIT_S * 60);
$USERavgWAIT_S = round($USERavgWAIT_S, 0);
if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
$pfUSERavgWAIT_MS[$i] = sprintf("%6s", $USERavgWAIT_MS);
$USERtotDISPO_M = ($USERtotDISPO / 60);
$USERtotDISPO_M = round($USERtotDISPO_M, 2);
$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
$USERtotDISPO_S = ($USERtotDISPO_S * 60);
$USERtotDISPO_S = round($USERtotDISPO_S, 0);
if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
$pfUSERtotDISPO_MS[$i] = sprintf("%6s", $USERtotDISPO_MS);
$USERavgDISPO_M = ($USERavgDISPO / 60);
$USERavgDISPO_M = round($USERavgDISPO_M, 2);
$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
$USERavgDISPO_S = ($USERavgDISPO_S * 60);
$USERavgDISPO_S = round($USERavgDISPO_S, 0);
if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
$pfUSERavgDISPO_MS[$i] = sprintf("%6s", $USERavgDISPO_MS);
$i++;
}
$k=0;
while($k < $i)
{
$ctA[$k]="0 "; $ctB[$k]="0 "; $ctDC[$k]="0 "; $ctDNC[$k]="0 "; $ctN[$k]="0 "; $ctNI[$k]="0 "; $ctSALE[$k]="0 "; $ctCB[$k]="0 ";
$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$m=0;
while ($m < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]); $TOT_A = ($TOT_A + $row[0]);}
if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]); $TOT_B = ($TOT_B + $row[0]);}
if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]); $TOT_DC = ($TOT_DC + $row[0]);}
if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]); $TOT_DNC = ($TOT_DNC + $row[0]);}
if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]); $TOT_N = ($TOT_N + $row[0]);}
if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]); $TOT_NI = ($TOT_NI + $row[0]);}
if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]); $TOT_SALE = ($TOT_SALE + $row[0]);}
if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]); $TOT_CB = ($TOT_CB + $row[0]);}
$m++;
}
echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
$k++;
}
$TOTcalls = sprintf("%-7s", $TOTcalls);
$TOTtime_M = ($TOTtime / 60);
$TOTtime_M = 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 ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
$TOTtime_MS = sprintf("%7s", $TOTtime_MS);
while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
$TOTtotTALK_M = ($TOTtotTALK / 60);
$TOTtotTALK_M = round($TOTtotTALK_M, 2);
$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
$TOTtotTALK_S = ($TOTtotTALK_S * 60);
$TOTtotTALK_S = round($TOTtotTALK_S, 0);
if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
$TOTtotTALK_MS = sprintf("%7s", $TOTtotTALK_MS);
while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
$TOTtotDISPO_M = ($TOTtotDISPO / 60);
$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
$TOTtotDISPO_MS = sprintf("%7s", $TOTtotDISPO_MS);
while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
$TOTtotPAUSE_MS = sprintf("%7s", $TOTtotPAUSE_MS);
while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
$TOTtotWAIT_M = ($TOTtotWAIT / 60);
$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
$TOTtotWAIT_MS = sprintf("%7s", $TOTtotWAIT_MS);
while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
$TOTavgTALK_M = round($TOTavgTALK_M, 2);
$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
$TOTavgTALK_S = ($TOTavgTALK_S * 60);
$TOTavgTALK_S = round($TOTavgTALK_S, 0);
if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
$TOTavgTALK_MS = sprintf("%6s", $TOTavgTALK_MS);
while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
$TOTavgDISPO_MS = sprintf("%6s", $TOTavgDISPO_MS);
while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
$TOTavgPAUSE_MS = sprintf("%6s", $TOTavgPAUSE_MS);
while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
$TOTavgWAIT_MS = sprintf("%6s", $TOTavgWAIT_MS);
while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
$TOT_A = sprintf("%-5s", $TOT_A);
$TOT_B = sprintf("%-5s", $TOT_B);
$TOT_DC = sprintf("%-5s", $TOT_DC);
$TOT_DNC = sprintf("%-5s", $TOT_DNC);
$TOT_N = sprintf("%-5s", $TOT_N);
$TOT_NI = sprintf("%-5s", $TOT_NI);
$TOT_CB = sprintf("%-5s", $TOT_CB);
$TOT_SALE = sprintf("%-5s", $TOT_SALE);
echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
echo "| TOTALS | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
echo "\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,281 @@
<?
### AST_agent_time_sheet.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["agent"])) {$agent=$_GET["agent"];}
elseif (isset($_POST["agent"])) {$agent=$_POST["agent"];}
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["calls_summary"])) {$calls_summary=$_GET["calls_summary"];}
elseif (isset($_POST["calls_summary"])) {$calls_summary=$_POST["calls_summary"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Agent Time Sheet</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<INPUT TYPE=TEXT NAME=agent SIZE=10 MAXLENGTH=20 VALUE=\"$agent\">\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=3>\n";
if (!$agent)
{
echo "\n";
echo "PLEASE SELECT AN MITTELID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from available agent log data\n";
}
else
{
$query_date_BEGIN = "$query_date 00:00:00";
$query_date_END = "$query_date 23:59:59";
$time_BEGIN = "00:00:00";
$time_END = "23:59:59";
$stmt="select full_name from vicidial_users where user='$agent';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$full_name = $row[0];
echo "VICIDIAL: Agent Time Sheet $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- MITTELTIME SHEET: $agent - $full_name -------------\n\n";
if ($calls_summary)
{
$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
$pfTOTAL_TIME_HMS = sprintf("%8s", $TOTAL_TIME_HMS);
$TALK_TIME_H = ($row[1] / 3600);
$TALK_TIME_H = round($TALK_TIME_H, 2);
$TALK_TIME_H_int = intval("$TALK_TIME_H");
$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
$TALK_TIME_M = ($TALK_TIME_M * 60);
$TALK_TIME_M = round($TALK_TIME_M, 2);
$TALK_TIME_M_int = intval("$TALK_TIME_M");
$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
$TALK_TIME_S = ($TALK_TIME_S * 60);
$TALK_TIME_S = round($TALK_TIME_S, 0);
if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
$pfTALK_TIME_HMS = sprintf("%8s", $TALK_TIME_HMS);
$PAUSE_TIME_H = ($row[3] / 3600);
$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
$pfPAUSE_TIME_HMS = sprintf("%8s", $PAUSE_TIME_HMS);
$WAIT_TIME_H = ($row[5] / 3600);
$WAIT_TIME_H = round($WAIT_TIME_H, 2);
$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
$WAIT_TIME_M = ($WAIT_TIME_M * 60);
$WAIT_TIME_M = round($WAIT_TIME_M, 2);
$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
$WAIT_TIME_S = ($WAIT_TIME_S * 60);
$WAIT_TIME_S = round($WAIT_TIME_S, 0);
if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
$pfWAIT_TIME_HMS = sprintf("%8s", $WAIT_TIME_HMS);
$WRAPUP_TIME_H = ($row[7] / 3600);
$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
$pfWRAPUP_TIME_HMS = sprintf("%8s", $WRAPUP_TIME_HMS);
$TALK_AVG_M = ($row[2] / 60);
$TALK_AVG_M = round($TALK_AVG_M, 2);
$TALK_AVG_M_int = intval("$TALK_AVG_M");
$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
$TALK_AVG_S = ($TALK_AVG_S * 60);
$TALK_AVG_S = round($TALK_AVG_S, 0);
if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
$pfTALK_AVG_MS = sprintf("%6s", $TALK_AVG_MS);
$PAUSE_AVG_M = ($row[4] / 60);
$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
$pfPAUSE_AVG_MS = sprintf("%6s", $PAUSE_AVG_MS);
$WAIT_AVG_M = ($row[6] / 60);
$WAIT_AVG_M = round($WAIT_AVG_M, 2);
$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
$WAIT_AVG_S = ($WAIT_AVG_S * 60);
$WAIT_AVG_S = round($WAIT_AVG_S, 0);
if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
$pfWAIT_AVG_MS = sprintf("%6s", $WAIT_AVG_MS);
$WRAPUP_AVG_M = ($row[8] / 60);
$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
$pfWRAPUP_AVG_MS = sprintf("%6s", $WRAPUP_AVG_MS);
echo "GESAMTANRUFETAKEN: $row[0]\n";
echo "TALK TIME: $pfTALK_TIME_HMS AVERAGE: $pfTALK_AVG_MS\n";
echo "PAUSE TIME: $pfPAUSE_TIME_HMS AVERAGE: $pfPAUSE_AVG_MS\n";
echo "WAIT TIME: $pfWAIT_TIME_HMS AVERAGE: $pfWAIT_AVG_MS\n";
echo "WRAPUP TIME: $pfWRAPUP_TIME_HMS AVERAGE: $pfWRAPUP_AVG_MS\n";
echo "----------------------------------------------------------------\n";
echo "TOTAL ACTIVE MITTELTIME: $pfTOTAL_TIME_HMS\n";
echo "\n";
}
else
{
echo "<a href=\"$PHP_SELF?calls_summary=1&agent=$agent&query_date=$query_date\">Call Activity Summary</a>\n\n";
}
$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
echo "FIRST LOGIN: $row[0]\n";
$start = $row[1];
$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
echo "LAST LOG ACTIVITY: $row[0]\n";
$end = $row[1];
$login_time = ($end - $start);
$LOGIN_TIME_H = ($login_time / 3600);
$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
$pfLOGIN_TIME_HMS = sprintf("%8s", $LOGIN_TIME_HMS);
echo "-----------------------------------------\n";
echo "TOTAL LOGGED-IN TIME: $pfLOGIN_TIME_HMS\n";
}
?>
</BODY></HTML>
@@ -0,0 +1,310 @@
<?
# AST_server_performance.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
#
# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
# path from root to where ploticus files will be stored
$DOCroot = "$WeBServeRRooT/vicidial/ploticus/";
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($group)) {$group = '';}
$stmt="select server_ip from servers;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$servers_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $servers_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: Server Performance</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($servers_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "</SELECT>\n";
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n";
if (!$group)
{
echo "\n";
echo "PLEASE SELECT A BEDIENERAND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from 6 hour shift specified\n";
}
else
{
if ($shift == 'AM')
{
$query_date_BEGIN = "$query_date 08:45:00";
$query_date_END = "$query_date 15:32:00";
$time_BEGIN = "08:45:00";
$time_END = "15:15:00";
}
if ($shift == 'PM')
{
$query_date_BEGIN = "$query_date 15:32:00";
$query_date_END = "$query_date 23:15:00";
$time_BEGIN = "15:15:00";
$time_END = "23:15:00";
}
echo "VICIDIAL: Server Performance $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- TOTALS, PEAKS and AVERAGES\n";
$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$HIGHload = sprintf("%10s", $row[0]);
$HIGHmulti = intval($HIGHload / 100);
#$HIGHmulti = ($HIGHload / 100);
$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$AVGload = sprintf("%10s", $row[0]);
$AVGchannels = sprintf("%10s", $row[1]);
$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$AVGcpuUSER = sprintf("%10s", $row[0]);
$AVGcpuSYSTEM = sprintf("%10s", $row[1]);
$AVGcpuIDLE = sprintf("%10s", $row[2]);
$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$USEDram = sprintf("%10s", $row[0]);
$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcalls = sprintf("%10s", $row[0]);
$OFFHOOKtime = sprintf("%10s", $row[1]);
echo "Total Calls in/out on this server: $TOTALcalls\n";
echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
echo "Average channels in use for server: $AVGchannels\n";
echo "Average load for server: $AVGload\n";
echo "Peak load for server: $HIGHload\n";
#echo "Peak used memory for server (in MB): $USEDram\n";
echo "Average USER process cpu percentage: $AVGcpuUSER %\n";
echo "Average SYSTEM process cpu percentage: $AVGcpuSYSTEM %\n";
echo "Average IDLE process cpu percentage: $AVGcpuIDLE %\n";
echo "\n";
echo "---------- LINE GRAPH:\n";
##############################
######### Graph stats
$DAT = '.dat';
$HTM = '.htm';
$PNG = '.png';
$filedate = date("Y-m-d_His");
$DATfile = "$group$query_date$shift$filedate$DAT";
$HTMfile = "$group$query_date$shift$filedate$HTM";
$PNGfile = "$group$query_date$shift$filedate$PNG";
$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
$DATfp = fopen ("$DOCroot/$DATfile", "a");
$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
$row[6] = intval($row[6] * $HIGHmulti);
fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
$i++;
}
fclose($DATfp);
$rows_to_max = ($rows_to_print + 100);
$HTMcontent = '';
$HTMcontent .= "#proc page\n";
$HTMcontent .= "#if @DEVICE in png,gif\n";
$HTMcontent .= " scale: 0.6\n";
$HTMcontent .= "\n";
$HTMcontent .= "#endif\n";
$HTMcontent .= "#proc getdata\n";
$HTMcontent .= "file: $DOCroot/$DATfile\n";
$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc areadef\n";
$HTMcontent .= "title: Server $group $query_date_BEGIN to $query_date_END\n";
$HTMcontent .= "titledetails: size=14 align=C\n";
$HTMcontent .= "rectangle: 1 1 14 7\n";
$HTMcontent .= "xscaletype: time hh:mm:ss\n";
$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
$HTMcontent .= "yrange: 0 $HIGHload\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc xaxis\n";
$HTMcontent .= "stubs: inc 30 minutes\n";
$HTMcontent .= "minorticinc: 5 minutes\n";
$HTMcontent .= "stubformat: hh:mm:ssa\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc yaxis\n";
$HTMcontent .= "stubs: inc 50\n";
$HTMcontent .= "grid: color=yellow\n";
$HTMcontent .= "gridskip: min\n";
$HTMcontent .= "ticincrement: 100 1000\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc lineplot\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: userproc\n";
$HTMcontent .= "linedetails: color=purple width=.5\n";
$HTMcontent .= "fill: lavender\n";
$HTMcontent .= "legendlabel: user proc%\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc lineplot\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: sysproc\n";
$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
$HTMcontent .= "fill: dullyellow\n";
$HTMcontent .= "legendlabel: system proc%\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc curvefit\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: load\n";
$HTMcontent .= "linedetails: color=blue width=.5\n";
$HTMcontent .= "legendlabel: load\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc curvefit\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: processes\n";
$HTMcontent .= "linedetails: color=red width=.5\n";
$HTMcontent .= "legendlabel: processes\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc curvefit\n";
$HTMcontent .= "xfield: time\n";
$HTMcontent .= "yfield: channels\n";
$HTMcontent .= "linedetails: color=green width=.5\n";
$HTMcontent .= "legendlabel: channels\n";
$HTMcontent .= "maxinpoints: $rows_to_max\n";
$HTMcontent .= "\n";
$HTMcontent .= "#proc legend\n";
$HTMcontent .= "location: max-2 max\n";
$HTMcontent .= "seglen: 0.2\n";
$HTMcontent .= "\n";
fwrite ($HTMfp, "$HTMcontent");
fclose($HTMfp);
passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
sleep(1);
echo "</PRE>\n";
echo "\n";
echo "<IMG SRC=\"./ploticus/$PNGfile\">\n";
echo "<!-- /usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile -->";
}
?>
</BODY></HTML>
@@ -0,0 +1,255 @@
<?
### AST_timeonVDAD.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# live real-time stats for the VICIDIAL Auto-Dialer
#
# changes:
# 50406-0920 - Added Paused agents < 1 min (Chris Doyle)
# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
$stmt="update park_log set status='HUNGUP' where hangup_time is not null;";
# $rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
if ($DB)
{
$stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');";
# $rslt=mysql_query($stmt, $link);
echo "$stmt\n";
}
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB&reset_counter=$reset_counter\">\n";
echo "<TITLE>VICIDIAL: Time On VDAD</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE><FONT SIZE=3>";
###################################################################################
###### TIME ON SYSTEM
###################################################################################
echo "VICIDIAL: Mittel Setzen Bei den Anrufen Zeit fest $NOW_TIME <a href=\"./server_stats.php\">REPORTS</a>\n\n";
echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
echo "| STATION | USER | SESSIONID | CHANNEL | STATUS | START TIME | MINUTES |\n";
echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[3]='';
$row[5]='- WARTEND -';
$row[6]=$row[7];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$sessionid = sprintf("%-9s", $row[2]);
$channel = sprintf("%-10s", $row[3]);
$cc=0;
while ( (strlen($channel) > 10) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 10) {$cc=101;}
}
$status = sprintf("%-6s", $row[4]);
$start_time = sprintf("%-19s", $row[5]);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
if (eregi("PAUSED",$row[4]))
{
if ($call_time_M_int >= 1)
{$i++; continue;}
else
{$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>';}
}
$agentcount++;
echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
echo " $agentcount Mittel geloggt innen auf Bediener $server_ip\n\n";
echo " <SPAN class=\"yellow\"><B> </SPAN> - Pausierte Mittel</B>\n";
echo " <SPAN class=\"blue\"><B> </SPAN> - 5 Minuten oder mehr beim Anruf</B>\n";
echo " <SPAN class=\"purple\"><B> </SPAN> - Über 10 Minuten beim Anruf</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n";
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Time On VDAD $NOW_TIME\n\n";
echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
echo "| CHANNEL | STATUS | CAMPAIGN | PHONE NUMBER | START TIME | MINUTES |\n";
echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");
$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-10s", $row[0]);
$cc=0;
while ( (strlen($channel) > 10) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 10) {$cc=101;}
}
$status = sprintf("%-6s", $row[1]);
$campaign = sprintf("%-8s", $row[2]);
$all_phone = "$row[3]$row[4]";
$number_dialed = sprintf("%-18s", $all_phone);
$start_time = sprintf("%-19s", $row[5]);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if (eregi("LIVE",$status)) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 6) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
echo " $i Anrufe, die auf Bediener gesetzt werden $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - PHASENCANKLOPFEN</B>\n";
# echo " <SPAN class=\"red\"><B> </SPAN> - Over 5 minutes on hold</B>\n";
}
else
{
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
echo "*******************************KEIN PHASENCANKLOPFEN*********************************\n";
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,316 @@
<?
### AST_timeonVDAD_closer.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# live real-time stats for the VICIDIAL Auto-Dialer
#
# CHANGES
#
# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
$stmt="update park_log set status='HUNGUP' where hangup_time is not null;";
# $rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
if ($DB)
{
$stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');";
# $rslt=mysql_query($stmt, $link);
echo "$stmt\n";
}
}
?>
<HTML>
<HEAD>
<?
echo "<STYLE type=\"text/css\">\n";
echo "<!--\n";
$stmt="select group_id,group_color from vicidial_inbound_groups;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
if ($groups_to_print > 0)
{
$g=0;
while ($g < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$group_id[$g] = $row[0];
$group_color[$g] = $row[1];
echo " .$group_id[$g] {color: black; background-color: $group_color[$g]}\n";
$g++;
}
}
?>
.DEAD {color: white; background-color: black}
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB&reset_counter=$reset_counter\">\n";
echo "<TITLE>VICIDIAL: Time On VDAD</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE><FONT SIZE=3>";
###################################################################################
###### TIME ON SYSTEM
###################################################################################
echo "VICIDIAL: Mittel Setzen Bei den Anrufen Zeit fest $NOW_TIME <a href=\"./server_stats.php\">REPORTS</a>\n\n";
echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
echo "| STATION | USER | SESSIONID | CHANNEL | STATUS | CALLTIME | MINUTES | CAMPAIGN | FRONT |\n";
echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED|CLOSER",$row[4]))
{
$row[3]='';
$row[5]='- WAIT -';
$row[6]=$row[7];
}
$extension[$i] = sprintf("%-10s", $row[0]);
$user[$i] = sprintf("%-6s", $row[1]);
$sessionid[$i] = sprintf("%-9s", $row[2]);
$channel[$i] = sprintf("%-19s", $row[3]);
$cc[$i]=0;
while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
{
$channel[$i] = eregi_replace(".$","",$channel[$i]);
$cc[$i]++;
if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
}
$status[$i] = sprintf("%-6s", $row[4]);
$start_time[$i] = sprintf("%-8s", $row[5]);
$cd[$i]=0;
while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
{
$start_time[$i] = eregi_replace("^.","",$start_time[$i]);
$cd[$i]++;
if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
}
$uniqueid[$i] = $row[8];
$lead_id[$i] = $row[9];
$closer[$i] = $row[1];
$call_time_S[$i] = ($STARTtime - $row[6]);
$call_time_M[$i] = ($call_time_S[$i] / 60);
$call_time_M[$i] = round($call_time_M[$i], 2);
$call_time_M_int[$i] = intval("$call_time_M[$i]");
$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
$call_time_MS[$i] = sprintf("%7s", $call_time_MS[$i]);
$i++;
}
$ext_count = $i;
$i=0;
while ($i < $ext_count)
{
$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$camp_to_print = mysql_num_rows($rslt);
if ($camp_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$campaign = sprintf("%-12s", $row[0]);
$camp_color = $row[0];
}
else
{$campaign = 'DEAD '; $camp_color = 'DEAD';}
if (eregi("READY|PAUSED|CLOSER",$status[$i]))
{$campaign = ' '; $camp_color = '';}
$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$xfer_to_print = mysql_num_rows($rslt);
if ($xfer_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$fronter = sprintf("%-6s", $row[0]);
}
else
{$fronter = ' ';}
$G = ''; $EG = '';
$G="<SPAN class=\"$camp_color\"><B>"; $EG='</B></SPAN>';
# if ($call_time_M_int[$i] >= 5) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int[$i] >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
$i++;
}
echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
echo " $i Mittel geloggt innen auf Bediener $server_ip\n\n";
# echo " <SPAN class=\"blue\"><B> </SPAN> - 5 Minuten oder mehr beim Anruf</B>\n";
# echo " <SPAN class=\"purple\"><B> </SPAN> - Über 10 Minuten beim Anruf</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n";
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
#echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Time On VDAD $NOW_TIME\n\n";
echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
echo "| CHANNEL | STATUS | CAMPAIGN | PHONE NUMBER | CALLTIME | MINUTES |\n";
echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");
$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-19s", $row[0]);
$cc=0;
while ( (strlen($channel) > 19) and ($cc < 100) )
{
$channel = eregi_replace(".$","",$channel);
$cc++;
if (strlen($channel) <= 19) {$cc=101;}
}
$start_time = sprintf("%-8s", $row[5]);
$cd=0;
while ( (strlen($start_time) > 8) and ($cd < 100) )
{
$start_time = eregi_replace("^.","",$start_time);
$cd++;
if (strlen($start_time) <= 8) {$cd=101;}
}
$status = sprintf("%-6s", $row[1]);
$campaign = sprintf("%-12s", $row[2]);
$all_phone = "$row[3]$row[4]";
$number_dialed = sprintf("%-18s", $all_phone);
$call_time_S = ($STARTtime - $row[6]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if (eregi("LIVE",$status)) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 6) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
echo " $i Anrufe, die auf Bediener gesetzt werden $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - PHASENCANKLOPFEN</B>\n";
# echo " <SPAN class=\"red\"><B> </SPAN> - Over 5 minutes on hold</B>\n";
}
else
{
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
echo "*******************************KEIN PHASENCANKLOPFEN*********************************\n";
echo "***************************************************************************************\n";
echo "***************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,349 @@
<?
# AST_timeonVDADall.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# live real-time stats for the VICIDIAL Auto-Dialer all servers
#
# changes:
# 50406-0920 - Added Paused agents < 1 min (Chris Doyle)
# 51130-1218 - Modified layout and info to show all servers in a vicidial system
# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60511-1343 - Added leads and drop info at the top of the screen
# 60608-1539 - Fixed CLOSER tallies for active calls
# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["RR"])) {$RR=$_GET["RR"];}
elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];}
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (!isset($group)) {$group='';}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$NOW_DAY = date("Y-m-d");
$NOW_HOUR = date("H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$stmt="select campaign_id from vicidial_campaigns where active='Y';";
$rslt=mysql_query($stmt, $link);
if (!isset($DB)) {$DB=0;}
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
if (!isset($RR)) {$RR=40;}
$NFB = '<b><font size=6 face="courier">';
$NFE = '</font></b>';
$F=''; $FG=''; $B=''; $BG='';
$reset_counter++;
if (!isset($reset_counter)) {$reset_counter=0;}
if ($reset_counter > 7)
{
$reset_counter=0;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
.orange {color: black; background-color: orange}
.r1 {color: black; background-color: #FFCCCC}
.r2 {color: black; background-color: #FF9999}
.r3 {color: black; background-color: #FF6666}
.r4 {color: white; background-color: #FF0000}
.b1 {color: black; background-color: #CCCCFF}
.b2 {color: black; background-color: #9999FF}
.b3 {color: black; background-color: #6666FF}
.b4 {color: white; background-color: #0000FF}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"$RR; URL=$PHP_SELF?RR=$RR&DB=$DB&group=$group\">\n";
echo "<TITLE>VICIDIAL: Time On VDAD Kampagne: $group</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "VICIDIAL: Realtime Kampagne: \n";
echo "<INPUT TYPE=HIDDEN NAME=RR VALUE=4>\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "<a href=\"$PHP_SELF?group=$group&RR=40&DB=$DB\">STOP</a> | <a href=\"$PHP_SELF?group=$group&RR=4&DB=$DB\">GO</a>";
echo " &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">ÄNDERN Sie</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "\n\n";
if (!$group) {echo "<BR><BR>please select a campaign from the pulldown above</FORM>\n"; exit;}
else
{
$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$HOPlev = $row[8];
echo "<BR><table cellpadding=0 cellspacing=0><TR>";
echo "<TD ALIGN=RIGHT><font size=2><B>DIAL LEVEL:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[0]&nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>STATUSES:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[1], $row[2], $row[3], $row[4], $row[5] &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>ORDER:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[6] &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>FILTER:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $row[7] &nbsp; &nbsp; </TD>";
echo "</TR>";
$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDhop = $row[0];
$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$DAleads = $row[0];
$callsTODAY = $row[1];
$dropsTODAY = $row[2];
$drpctTODAY = $row[3];
echo "<TR>";
echo "<TD ALIGN=RIGHT><font size=2><B>HOPPER LEVEL:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $HOPlev &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>LEADS IN HOPPER:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $VDhop &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>DIALABLE LEADS:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $DAleads &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=CENTER COLSPAN=2><font size=2> &nbsp; <B> TIME:</B> </TD>";
echo "</TR>";
echo "<TR>";
echo "<TD ALIGN=RIGHT><font size=2><B>CALLS TODAY:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $callsTODAY &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>CALLS DROPPED:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $dropsTODAY &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=RIGHT><font size=2><B>DROPPED PERCENT:</B></TD><TD ALIGN=LEFT><font size=2>&nbsp; $drpctTODAY% &nbsp; &nbsp; </TD>";
echo "<TD ALIGN=CENTER COLSPAN=2><font size=2> &nbsp; $NOW_TIME </TD>";
echo "</TR></TABLE>";
echo "</FORM>\n\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
if (eregi("CLOSER",$group))
{
$stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$closer_campaigns = preg_replace("/^ | -$/","",$row[0]);
$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
$closer_campaigns = "'$closer_campaigns'";
$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );";
}
else
{$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";}
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
$out_total=0;
$out_ring=0;
$out_live=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("LIVE",$row[0]))
{$out_live++;}
else
{
if (eregi("CLOSER",$row[0]))
{$nothing=1;}
else
{$out_ring++;}
}
$out_total++;
$i++;
}
if ($out_live > 0) {$F='<FONT class="r1">'; $FG='</FONT>';}
if ($out_live > 4) {$F='<FONT class="r2">'; $FG='</FONT>';}
if ($out_live > 9) {$F='<FONT class="r3">'; $FG='</FONT>';}
if ($out_live > 14) {$F='<FONT class="r4">'; $FG='</FONT>';}
if (eregi("CLOSER",$group))
{echo "$NFB$out_total$NFE current active calls&nbsp; &nbsp; &nbsp; \n";}
else
{echo "$NFB$out_total$NFE calls being placed &nbsp; &nbsp; &nbsp; \n";}
echo "$NFB$out_ring$NFE calls ringing &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$F &nbsp;$out_live $FG$NFE calls waiting for agents &nbsp; &nbsp; &nbsp; \n";
}
else
{
echo "KEIN PHASENCANKLOPFEN\n";
}
###################################################################################
###### TIME ON SYSTEM
###################################################################################
$agent_incall=0;
$agent_ready=0;
$agent_paused=0;
$agent_total=0;
$Aecho = '';
$Aecho .= "VICIDIAL: Agents Time On Calls Kampagne: $group $NOW_TIME\n\n";
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= "| STATION | USER | SESSIONID | STATUS | BEDIENERIP | CALL BEDIENERIP | MM:SS | CAMPAIGN |\n";
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[5]=$row[6];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$sessionid = sprintf("%-9s", $row[2]);
$status = sprintf("%-6s", $row[3]);
$server_ip = sprintf("%-15s", $row[4]);
$call_server_ip = sprintf("%-15s", $row[7]);
$campaign_id = sprintf("%-10s", $row[8]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
if (eregi("PAUSED",$row[3]))
{
if ($call_time_M_int >= 1)
{$i++; continue;}
else
{$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>'; $agent_paused++; $agent_total++;}
}
# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") )
# {$G='<SPAN class="orange"><B>'; $EG='</B></SPAN>';}
if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
$agentcount++;
$Aecho .= "| $G$extension$EG | <a href=\"./user_status.php?user=$user\" target=\"_blank\">$G$user$EG</a> | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n";
$i++;
}
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= " $agentcount agents logged in on all servers\n\n";
$Aecho .= " <SPAN class=\"yellow\"><B> </SPAN> - Pausierte Mittel</B>\n";
# $Aecho .= " <SPAN class=\"orange\"><B> </SPAN> - Balanced call</B>\n";
$Aecho .= " <SPAN class=\"blue\"><B> </SPAN> - Agent waiting for call</B>\n";
$Aecho .= " <SPAN class=\"purple\"><B> </SPAN> - Over 5 minutes on call</B>\n";
if ($agent_ready > 0) {$B='<FONT class="b1">'; $BG='</FONT>';}
if ($agent_ready > 4) {$B='<FONT class="b2">'; $BG='</FONT>';}
if ($agent_ready > 9) {$B='<FONT class="b3">'; $BG='</FONT>';}
if ($agent_ready > 14) {$B='<FONT class="b4">'; $BG='</FONT>';}
echo "\n<BR>\n";
echo "$NFB$agent_total$NFE agents logged in &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_incall$NFE agents in calls &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$B &nbsp;$agent_ready $BG$NFE agents waiting &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_paused$NFE paused agents &nbsp; &nbsp; &nbsp; \n";
echo "<PRE><FONT SIZE=2>";
echo "";
echo "$Aecho";
}
else
{
echo "KEINE MITTEL BEI DEN ANRUFEN\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,301 @@
<?
### AST_timeonVDADall.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# live real-time stats for the VICIDIAL Auto-Dialer all servers
#
# changes:
# 50406-0920 - Added Paused agents < 1 min (Chris Doyle)
# 51130-1218 - Modified layout and info to show all servers in a vicidial system
# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala
# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
header ("Content-type: text/html; charset=utf-8");
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];}
$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];}
$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];}
$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];}
$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];}
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$epochSIXhoursAGO = ($STARTtime - 21600);
$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO);
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
if (!$RR) {$RR=40;}
$NFB = '<b><font size=6 face="courier">';
$NFE = '</font></b>';
$F=''; $FG=''; $B=''; $BG='';
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
.yellow {color: black; background-color: yellow}
.orange {color: black; background-color: orange}
.r1 {color: black; background-color: #FFCCCC}
.r2 {color: black; background-color: #FF9999}
.r3 {color: black; background-color: #FF6666}
.r4 {color: white; background-color: #FF0000}
.b1 {color: black; background-color: #CCCCFF}
.b2 {color: black; background-color: #9999FF}
.b3 {color: black; background-color: #6666FF}
.b4 {color: white; background-color: #0000FF}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"$RR; URL=$PHP_SELF?RR=$RR&DB=$DB&group=$group\">\n";
echo "<TITLE>VF DIALER: Time On VDAD Kampagne: $group</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "VF DIALER: Realtime Kampagne: \n";
echo "<INPUT TYPE=HIDDEN NAME=RR VALUE=4>\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "<a href=\"$PHP_SELF?group=$group&RR=40&DB=$DB\">STOP</a> | <a href=\"$PHP_SELF?group=$group&RR=4&DB=$DB\">GO</a>";
echo " &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">ÄNDERN Sie</a> | <a href=\"./server_stats.php\">REPORTS</a> </FONT>\n";
echo "\n\n";
if (!$group) {echo "<BR><BR>please select a campaign from the pulldown above</FORM>\n"; exit;}
else
{
$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
echo "<BR><font size=2>";
echo "<B>DIAL LEVEL:</B> $row[0] &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<B>STATUSES:</B> $row[1], $row[2], $row[3], $row[4], $row[5] &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<B>ORDER:</B> $row[6]</font>";
echo "</FORM>\n\n";
}
###################################################################################
###### OUTBOUND CALLS
###################################################################################
if (eregi("CLOSER",$group))
{$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";}
else
{$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";}
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
$out_total=0;
$out_ring=0;
$out_live=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("LIVE",$row[0]))
{$out_live++;}
else
{
if (eregi("CLOSER",$row[0]))
{$nothing=1;}
else
{$out_ring++;}
}
$out_total++;
$i++;
}
if ($out_live > 0) {$F='<FONT class="r1">'; $FG='</FONT>';}
if ($out_live > 4) {$F='<FONT class="r2">'; $FG='</FONT>';}
if ($out_live > 9) {$F='<FONT class="r3">'; $FG='</FONT>';}
if ($out_live > 14) {$F='<FONT class="r4">'; $FG='</FONT>';}
if (eregi("CLOSER",$group))
{echo "$NFB$out_total$NFE current active calls&nbsp; &nbsp; &nbsp; \n";}
else
{echo "$NFB$out_total$NFE calls being placed &nbsp; &nbsp; &nbsp; \n";}
echo "$NFB$out_ring$NFE calls ringing &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$F &nbsp;$out_live $FG$NFE calls waiting for agents &nbsp; &nbsp; &nbsp; \n";
}
else
{
echo "KEIN PHASENCANKLOPFEN\n";
}
###################################################################################
###### TIME ON SYSTEM
###################################################################################
$agent_incall=0;
$agent_ready=0;
$agent_paused=0;
$agent_total=0;
$Aecho = '';
$Aecho .= "VF DIALER: Agents Time On Calls Kampagne: $group $NOW_TIME\n\n";
$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= "| STATION | USER | SESSIONID | STATUS | BEDIENERIP | CALL BEDIENERIP | MM:SS | CAMPAIGN |\n";
$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n";
$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (eregi("READY|PAUSED",$row[4]))
{
$row[5]=$row[6];
}
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$sessionid = sprintf("%-9s", $row[2]);
$status = sprintf("%-6s", $row[3]);
$server_ip = sprintf("%-15s", $row[4]);
$call_server_ip = sprintf("%-15s", $row[7]);
$campaign_id = sprintf("%-10s", $row[8]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 5) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
# if ($call_time_M_int >= 10) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
if (eregi("PAUSED",$row[3]))
{
if ($call_time_M_int >= 1)
{$i++; continue;}
else
{$G='<SPAN class="yellow"><B>'; $EG='</B></SPAN>'; $agent_paused++; $agent_total++;}
}
# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") )
# {$G='<SPAN class="orange"><B>'; $EG='</B></SPAN>';}
if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;}
if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
$sessionid = trim($sessionid);
$agentcount++;
$Aecho .= "| $G$extension$EG | <a href=\"./user_status.php?user=$user\" target=\"_blank\">$G$user$EG</a> | $G$sessionid$EG <a href=\"sip:6$sessionid@$server_ip\">LISTEN</a> | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n";
$i++;
}
$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n";
$Aecho .= " $agentcount agents logged in on all servers\n";
$Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n";
$Aecho .= " <SPAN class=\"yellow\"><B> </SPAN> - Pausierte Mittel</B>\n";
# $Aecho .= " <SPAN class=\"orange\"><B> </SPAN> - Balanced call</B>\n";
$Aecho .= " <SPAN class=\"blue\"><B> </SPAN> - Agent waiting for call</B>\n";
$Aecho .= " <SPAN class=\"purple\"><B> </SPAN> - Over 5 minutes on call</B>\n";
if ($agent_ready > 0) {$B='<FONT class="b1">'; $BG='</FONT>';}
if ($agent_ready > 4) {$B='<FONT class="b2">'; $BG='</FONT>';}
if ($agent_ready > 9) {$B='<FONT class="b3">'; $BG='</FONT>';}
if ($agent_ready > 14) {$B='<FONT class="b4">'; $BG='</FONT>';}
echo "\n<BR>\n";
echo "$NFB$agent_total$NFE agents logged in &nbsp; &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_incall$NFE agents in calls &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$B &nbsp;$agent_ready $BG$NFE agents waiting &nbsp; &nbsp; &nbsp; \n";
echo "$NFB$agent_paused$NFE paused agents &nbsp; &nbsp; &nbsp; \n";
echo "<PRE><FONT SIZE=2>";
echo "";
echo "$Aecho";
}
else
{
echo "KEINE MITTEL BEI DEN ANRUFEN\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,180 @@
<?
### AST_timeoncall.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"15; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
echo "<TITLE>VICIDIAL: Time On Call</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE>\n\n";
echo "VICIDIAL: Time On Call $NOW_TIME\n\n";
echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
echo "| STATION | SESSIONID | CHANNEL | NUMBER DIALED | START TIME | MINUTES |\n";
echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$parked_count = $row[0];
if ($parked_count > 0)
{
$stmt="select extension from live_channels where server_ip='$server_ip';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$ext_to_print = mysql_num_rows($rslt);
$i=0;
$live_zap_counter=0;
$sessions = '';
while ($i < $ext_to_print)
{
$row=mysql_fetch_row($rslt);
if (preg_match("/^8600/i",$row[0]))
{
$sessions .= "$row[0]|";
}
$i++;
}
$sessions = preg_replace("/\|$/",'',$sessions);
if ($DB) {echo "SESSIONS: -$sessions-\n";}
$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$i=0;
$live_calls_counter=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
{
if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
$session_id = '';
}
else
{
if (preg_match("/$row[3]/i",$sessions))
{
if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
$session_id = $row[3];
$station = preg_replace("/SIP\//",'',$row[0]);
$station = preg_replace("/-.*/",'',$station);
$LIVE_sessions[$live_calls_counter] = "$session_id";
$LIVE_sessions_FORMAT[$live_calls_counter] = sprintf("%-9s", $session_id);
$LIVE_stations[$live_calls_counter] = "$station";
$LIVE_stations_FORMAT[$live_calls_counter] = sprintf("%-10s", $station);
# echo "| $station | $session_id | \n";
$live_calls_counter++;
}
else
{
if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
$session_id = '';
}
}
$i++;
}
if ($live_calls_counter > 0)
{
$i=0;
$LC_counter = $live_calls_counter;
while ($i < $live_calls_counter)
{
$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-9s", $row[0]);
$number_dialed = sprintf("%-16s", $row[2]);
$start_time = sprintf("%-19s", $row[3]);
$call_time_S = ($STARTtime - $row[4]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 12) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 31) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
echo " $i stations on live calls on server $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - 12 minutes or more on live call\n";
echo " <SPAN class=\"red\"><B> </SPAN> - Over 30 minutes on live call\n";
}
else
{
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
echo "*************************************** NO LIVE STATIONS ********************************\n";
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
}
}
else
{
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
echo "*************************************** NO LIVE STATIONS ********************************\n";
echo "*****************************************************************************************\n";
echo "*****************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
@@ -0,0 +1,197 @@
<?
### AST_timeonpark.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];}
elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
$timeONEhoursAGO = ($STARTtime - 3600);
$epochHALFhoursAGO = ($STARTtime - 1860);
$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO);
$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO);
$reset_counter++;
if ($reset_counter > 7)
{
$reset_counter=0;
$stmt="update park_log set status='HUNGUP' where hangup_time is not null;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
if ($DB)
{
$stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');";
$rslt=mysql_query($stmt, $link);
echo "$stmt\n";
$stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');";
$rslt=mysql_query($stmt, $link);
echo "$stmt\n";
}
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: white; background-color: green}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB&reset_counter=$reset_counter\">\n";
echo "<TITLE>VICIDIAL: Time On Park</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<PRE><FONT SIZE=3>\n\n";
echo "VICIDIAL: Time On Park $NOW_TIME\n\n";
echo "+------------+-----------------+---------------------+---------+\n";
echo "| CHANNEL | GROUP | START TIME | MINUTES |\n";
echo "+------------+-----------------+---------------------+---------+\n";
#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");
$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
$channel = sprintf("%-10s", $row[2]);
$number_dialed = sprintf("%-15s", $row[3]);
$start_time = sprintf("%-19s", $row[4]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 1) {$G='<SPAN class="green"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 6) {$G='<SPAN class="red"><B>'; $EG='</B></SPAN>';}
echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------+-----------------+---------------------+---------+\n";
echo " $i callers waiting on server $server_ip\n\n";
echo " <SPAN class=\"green\"><B> </SPAN> - 1 minute or more on hold</B>\n";
echo " <SPAN class=\"red\"><B> </SPAN> - Over 5 minutes on hold</B>\n";
}
else
{
echo "****************************************************************\n";
echo "****************************************************************\n";
echo "********************KEIN PHASENCANKLOPFEN*********************\n";
echo "****************************************************************\n";
echo "****************************************************************\n";
}
###################################################################################
###### TIME ON INBOUND CALLS
###################################################################################
echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Agents Time On Inbound Calls $NOW_TIME\n\n";
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
echo "| STATION | USER | CHANNEL | GROUP | START TIME | MINUTES |\n";
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
$extension = sprintf("%-10s", $row[0]);
$user = sprintf("%-6s", $row[1]);
$channel = sprintf("%-10s", $row[2]);
$number_dialed = sprintf("%-15s", $row[3]);
$start_time = sprintf("%-19s", $row[4]);
$call_time_S = ($STARTtime - $row[5]);
$call_time_M = ($call_time_S / 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";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if ($call_time_M_int >= 12) {$G='<SPAN class="blue"><B>'; $EG='</B></SPAN>';}
if ($call_time_M_int >= 31) {$G='<SPAN class="purple"><B>'; $EG='</B></SPAN>';}
echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
$i++;
}
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
echo " $i agents on calls on server $server_ip\n\n";
echo " <SPAN class=\"blue\"><B> </SPAN> - 12 minutes or more on call</B>\n";
echo " <SPAN class=\"purple\"><B> </SPAN> - Over 30 minutes on call</B>\n";
}
else
{
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n";
echo "**************************************************************************************\n";
echo "**************************************************************************************\n";
}
?>
</PRE>
</BODY></HTML>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,476 @@
<?
# admin_modify_lead.php
#
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
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["postal_code"])) {$postal_code=$_GET["postal_code"];}
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
if (isset($_GET["province"])) {$province=$_GET["province"];}
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
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"])) {$security=$_GET["security"];}
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];}
elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];}
if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];}
elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];}
if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];}
elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];}
if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];}
elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];}
if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];}
elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
### AST GUI database administration modify lead in vicidial_list
### admin_modify_lead.php
# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead
# CHANGES
#
# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user
# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES
# 60609-1112 - Added DNC list addition if status changed to DNC
# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat
#
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./project_auth_entries.txt", "a");}
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname =$row[0];
$LOGmodify_leads =$row[1];
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
}
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>VICIDIAL ADMIN: Leitung notieren Änderung</title>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
<?
if ($end_call > 0)
{
$call_length = ($STARTtime - $call_began);
### insert a NEW record to the vicidial_closer_log table
$stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
### update the lead record in the vicidial_list table
$stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "Informationen geändert<BR><BR>\n";
echo "<form><input type=button value=\"Schließen Sie Dieses Fenster\" onClick=\"javascript:window.close();\"></form>\n";
if ( ($dispo != $status) and ($dispo == 'CBHOLD') )
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record inactivated: $lead_id<BR>\n";
}
if ( ($dispo != $status) and ($dispo == 'CALLBK') )
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record inactivated: $lead_id<BR>\n";
}
if ( ($dispo != $status) and ($status == 'DNC') )
{
### add lead to the internal DNC list
$stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>Lead added to DNC List: $lead_id - $phone_number<BR>\n";
}
}
else
{
if ($CBchangeUSERtoANY == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record changed to ANYONE<BR>\n";
}
if ($CBchangeUSERtoUSER == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record user changed to $CBuser<BR>\n";
}
if ($CBchangeANYtoUSER == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "<BR>vicidial_callback record changed to USERONLY, user: $CBuser<BR>\n";
}
$stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_count = $row[0];
if ($lead_count > 0)
{
$stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_id = "$row[0]";
$dispo = "$row[3]";
$tsr = "$row[4]";
$vendor_id = "$row[5]";
$list_id = "$row[7]";
$campaign_id = "$row[8]";
$phone_code = "$row[10]";
$phone_number = "$row[11]";
$title = "$row[12]";
$first_name = "$row[13]"; #
$middle_initial = "$row[14]";
$last_name = "$row[15]"; #
$address1 = "$row[16]"; #
$address2 = "$row[17]"; #
$address3 = "$row[18]"; #
$city = "$row[19]"; #
$state = "$row[20]"; #
$province = "$row[21]"; #
$postal_code = "$row[22]"; #
$country_code = "$row[23]"; #
$gender = "$row[24]";
$date_of_birth = "$row[25]";
$alt_phone = "$row[26]"; #
$email = "$row[27]"; #
$security = "$row[28]"; #
$comments = "$row[29]"; #
echo "<br>Anrufinformationen: $first_name $last_name - $phone_number<br><br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=end_call value=1>\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=dispo value=\"$dispo\">\n";
echo "<input type=hidden name=list_id value=\"$list_id\">\n";
echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
echo "<input type=hidden name=phone_code value=\"$phone_code\">\n";
echo "<input type=hidden name=phone_number value=\"$phone_number\">\n";
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
echo "<input type=hidden name=extension value=\"$extension\">\n";
echo "<input type=hidden name=channel value=\"$channel\">\n";
echo "<input type=hidden name=call_began value=\"$call_began\">\n";
echo "<input type=hidden name=parked_time value=\"$parked_time\">\n";
echo "<table cellpadding=1 cellspacing=0>\n";
echo "<tr><td colspan=2>Vendor ID: $vendor_id &nbsp; &nbsp; Lead ID: $lead_id</td></tr>\n";
echo "<tr><td colspan=2>Fronter: <A HREF=\"user_stats.php?user=$tsr\">$tsr</A> &nbsp; &nbsp; Liste Identifikation: $list_id</td></tr>\n";
echo "<tr><td align=right>Vorname: </td><td align=left><input type=text name=first_name size=15 maxlength=30 value=\"$first_name\"> &nbsp; \n";
echo " Letzter Name: <input type=text name=last_name size=15 maxlength=30 value=\"$last_name\"> </td></tr>\n";
echo "<tr><td align=rightAdresse1 : </td><td align=left><input type=text name=address1 size=30 maxlength=30 value=\"$address1\"></td></tr>\n";
echo "<tr><td align=rightAdresse2 : </td><td align=left><input type=text name=address2 size=30 maxlength=30 value=\"$address2\"></td></tr>\n";
echo "<tr><td align=rightAdresse3 : </td><td align=left><input type=text name=address3 size=30 maxlength=30 value=\"$address3\"></td></tr>\n";
echo "<tr><td align=rightStadt: </td><td align=left><input type=text name=city size=30 maxlength=30 value=\"$city\"></td></tr>\n";
echo "<tr><td align=rightZustand: </td><td align=left><input type=text name=state size=2 maxlength=2 value=\"$state\"> &nbsp; \n";
echo "Postcode: <input type=text name=postal_code size=10 maxlength=10 value=\"$postal_code\"> </td></tr>\n";
echo "<tr><td align=rightProvinz: </td><td align=left><input type=text name=province size=30 maxlength=30 value=\"$province\"></td></tr>\n";
echo "<tr><td align=rightLand: </td><td align=left><input type=text name=country_code size=3 maxlength=3 value=\"$country_code\"></td></tr>\n";
echo "<tr><td align=rightAlt Telefon: </td><td align=left><input type=text name=alt_phone size=10 maxlength=10 value=\"$alt_phone\"></td></tr>\n";
echo "<tr><td align=rightEmail: </td><td align=left><input type=text name=email size=30 maxlength=50 value=\"$email\"></td></tr>\n";
echo "<tr><td align=rightSicherheit: </td><td align=left><input type=text name=security size=30 maxlength=100 value=\"$security\"></td></tr>\n";
echo "<tr><td align=rightAnmerkungen: </td><td align=left><input type=text name=comments size=30 maxlength=255 value=\"$comments\"></td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=rightEinteilung: </td><td align=left><select size=1 name=status>\n";
$stmt="SELECT * from vicidial_statuses where selectable='Y' order by status";
$rslt=mysql_query($stmt, $link);
$statuses_to_print = mysql_num_rows($rslt);
$statuses_list='';
$o=0;
$DS=0;
while ($statuses_to_print > $o)
{
$rowx=mysql_fetch_row($rslt);
if ($dispo == "$rowx[0]")
{$statuses_list .= "<option SELECTED value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; $DS++;}
else
{$statuses_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
$o++;
}
if ($DS < 1) {$statuses_list .= "<option SELECTED value=\"$dispo\">$dispo</option>\n";}
echo "$statuses_list";
echo "</select></td></tr>\n";
echo "<tr><td colspan=2><input type=submit name=submit value=\"SUBMIT\"></td></tr>\n";
echo "</table></form>\n";
echo "<BR><BR><BR>\n";
if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') )
{
### find any vicidial_callback records for this lead
$stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$CB_to_print = mysql_num_rows($rslt);
$rowx=mysql_fetch_row($rslt);
if ($CB_to_print>0)
{
if ($rowx[9] == 'USERONLY')
{
echo "<br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=CBchangeUSERtoANY value=\"YES\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=callback_id value=\"$rowx[0]\">\n";
echo "<input type=submit name=submit value=\"CHANGE TO ANYONE CALLBACK\"></form><BR>\n";
echo "<br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=CBchangeUSERtoUSER value=\"YES\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=callback_id value=\"$rowx[0]\">\n";
echo "New Callback Owner UserID: <input type=text name=CBuser size=8 maxlength=10 value=\"$rowx[8]\"> \n";
echo "<input type=submit name=submit value=\"CHANGE USERONLY CALLBACK USER\"></form><BR>\n";
}
else
{
echo "<br><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=CBchangeANYtoUSER value=\"YES\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<input type=hidden name=lead_id value=\"$lead_id\">\n";
echo "<input type=hidden name=callback_id value=\"$rowx[0]\">\n";
echo "New Callback Owner UserID: <input type=text name=CBuser size=8 maxlength=10 value=\"$rowx[8]\"> \n";
echo "<input type=submit name=submit value=\"CHANGE TO USERONLY CALLBACK\"></form><BR>\n";
}
}
else
{
echo "<BR>No Callback records found<BR>\n";
}
}
}
else
{
echo "Leitung Nachschlagen FIEL für lead_id aus $lead_id &nbsp; &nbsp; &nbsp; $NOW_TIME\n<BR><BR>\n";
# echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
}
echo "<br><br>\n";
echo "<center>\n";
echo "<B>ANRUFE ZU DIESEM LEITUNG:</B>\n";
echo "<TABLE width=550 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>DATE/TIME </td><td align=left><font size=2>LENGTH</td><td align=left><font size=2> STATUS</td><td align=left><font size=2> TSR</td><td align=right><font size=2> KAMPAGNE</td><td align=right><font size=2> LIST</td><td align=right><font size=2> LEAD</td></tr>\n";
$stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$row[4]</td>";
echo "<td align=left><font size=2> $row[7]</td>\n";
echo "<td align=left><font size=2> $row[8]</td>\n";
echo "<td align=left><font size=2> <A HREF=\"user_stats.php?user=$row[11]\" target=\"_blank\">$row[11]</A> </td>\n";
echo "<td align=right><font size=2> $row[3] </td>\n";
echo "<td align=right><font size=2> $row[2] </td>\n";
echo "<td align=right><font size=2> $row[1] </td></tr>\n";
$u++;
}
echo "</TABLE></center>\n";
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
?>
</body>
</html>
<?
exit;
?>
@@ -0,0 +1,224 @@
<?
### admin_search_lead.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
### AST GUI database administration search for lead info
### admin_modify_lead.php
#
# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead
#
# changes:
# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
# - Changed results to multi-record
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if ($WeBRooTWritablE > 0)
{$fp = fopen ("./project_auth_entries.txt", "a");}
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname =$row[0];
$LOGmodify_leads =$row[1];
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
}
else
{
if ($WeBRooTWritablE > 0)
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
}
}
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>VICIDIAL ADMIN: Leitung Suche</title>
</head>
<title>Leitung Nachschlagen</title>
</head>
<body bgcolor=white>
<?
if ( (!$vendor_id) and (!$phone) and (!$lead_id) )
{
echo date("l F j, Y G:i:s A");
echo "\n<br><br><center>\n";
echo "<form method=post name=search action=\"$PHP_SELF\">\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
echo "<b>Tragen Sie bitte a ein:<br> Vendor ID(Verkäuferleitung Code): <input type=text name=vendor_id size=10 maxlength=10> or \n";
echo "<br><b>eine Haupttelefonnummer: <input type=text name=phone size=10 maxlength=10> or\n";
echo "<br><b>eine Leitung Identifikation: <input type=text name=lead_id size=10 maxlength=10> <br><br>\n";
echo "<input type=submit name=submit value=SUBMIT></b>\n";
echo "</form>\n</center>\n";
echo "</body></html>\n";
exit;
}
else
{
if ($vendor_id)
{
$stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000";
}
else
{
if ($phone)
{
$stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000";
}
else
{
if ($lead_id)
{
$stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000";
}
else
{
print "ERROR: you must search for something! Go back and search for something";
exit;
}
}
}
if ($DB)
{
echo "\n\n$stmt\n\n";
}
$rslt=mysql_query($stmt, $link);
$results_to_print = mysql_num_rows($rslt);
if ($results_to_print < 1)
{
echo date("l F j, Y G:i:s A");
echo "\n<br><br><center>\n";
echo "<b>Die Suchvariablen, die Sie eintrugen, sind nicht im System aktiv</b><br><br>\n";
echo "<b>Bitte zurück und verdoppeln Überprüfung gehen die Informationen,die Sie eintrugen und reichen wieder ein</b>\n";
echo "</center>\n";
echo "</body></html>\n";
exit;
}
else
{
echo "<b>RESULTS: $results_to_print</b><BR><BR>\n";
echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0>\n";
echo "<TR BGCOLOR=BLACK>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LEAD ID</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>STATUS</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>VENDOR ID</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LAST AGENT</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LISTE IDENTIFIKATION</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>PHONE</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>NAME</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CITY</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>SECURITY</B></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LAST CALL</B></FONT></TD>\n";
echo "</TR>\n";
$o=0;
while ($results_to_print > $o)
{
$row=mysql_fetch_row($rslt);
$o++;
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<TR $bgcolor>\n";
echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><a href=\"admin_modify_lead.php?lead_id=$row[0]\">$row[0]</a></FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[11]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[13] $row[15]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[19]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[28]</FONT></TD>\n";
echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
}
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n<a href=\"$PHP_SELF\">NEUE SUCHE</a>";
echo "\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds";
?>
</body>
</html>
@@ -0,0 +1 @@
@@ -0,0 +1,15 @@
<?
$link=mysql_connect("localhost", "cron", "1234");
mysql_select_db("asterisk");
$local_DEF = 'Local/';
$conf_silent_prefix = '7';
$local_AMP = '@';
$ext_context = 'demo';
$recording_exten = '8309';
$WeBServeRRooT = '/usr/local/apache2/htdocs';
$WeBRooTWritablE = '1';
?>
@@ -0,0 +1,252 @@
<?
### group_hourly_stats.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
# CHANGES
#
# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat
# - Added required user/pass to gain access to this page
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["group"])) {$group=$_GET["group"];}
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];}
elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$date_with_hour_default = date("Y-m-d H");
$date_no_hour_default = $TODAY;
if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;}
$date_no_hour = $date_with_hour;
$date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour);
if (!isset($begin_date)) {$begin_date = $TODAY;}
if (!isset($end_date)) {$end_date = $TODAY;}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$fp = fopen ("./project_auth_entries.txt", "a");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
header ("Content-type: text/html; charset=utf-8");
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
else
{
fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
fclose($fp);
}
# $stmt="SELECT full_name from vicidial_users where user='$user';";
# $rslt=mysql_query($stmt, $link);
# $row=mysql_fetch_row($rslt);
# $full_name = $row[0];
}
?>
<html>
<head>
<title>VICIDIAL ADMIN: Gruppe Stündlicher Notfall</title>
<?
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
?>
</head>
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<CENTER>
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; VICIDIAL ADMIN: Gruppe Stündlicher Notfall <? echo $group ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> &nbsp; </TD></TR>
<?
if ( ($group) and ($status) and ($date_with_hour) )
{
$stmt="SELECT user,full_name from vicidial_users where user_group = '" . mysql_real_escape_string($group) . "' order by full_name desc;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$tsrs_to_print = mysql_num_rows($rslt);
$o=0;
while($o < $tsrs_to_print)
{
$row=mysql_fetch_row($rslt);
$VDuser[$o] = "$row[0]";
$VDname[$o] = "$row[1]";
$o++;
}
$o=0;
while($o < $tsrs_to_print)
{
$stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDtotal[$o] = "$row[0]";
$stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDday[$o] = "$row[0]";
$stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDcount[$o] = "$row[0]";
$o++;
}
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
echo "<br><center>\n";
echo "<B>TSR STUNDE ZÄHLIMPULSE: $group | $status | $date_with_hour | $date_no_hour</B>\n";
echo "<center><TABLE width=600 cellspacing=0 cellpadding=1>\n";
echo "<tr><td><font size=2>TSR </td><td align=left><font size=2>ID </td><td align=right><font size=2> &nbsp; $status</td><td align=right><font size=2> &nbsp; GESAMTANRUFE</td><td align=right><font size=2> &nbsp; $status DAY</td><td align=right><font size=2> &nbsp; &nbsp; </td></tr>\n";
$day_calls=0;
$hour_calls=0;
$total_calls=0;
$o=0;
while($o < $tsrs_to_print)
{
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "<tr $bgcolor><td><font size=2>$VDuser[$o]</td>";
echo "<td align=left><font size=2> $VDname[$o]</td>\n";
echo "<td align=right><font size=2> $VDcount[$o]</td>\n";
echo "<td align=right><font size=2> $VDtotal[$o]</td>\n";
echo "<td align=right><font size=2> $VDday[$o]</td>\n";
echo "<td align=right><font size=1><a href=\"./admin.php?ADD=3&user=$VDuser[$o]\">ÄNDERN Sie</a> | <a href=\"./user_stats.php?user=$VDuser[$o]\">Notfall</a></td></tr>\n";
$total_calls = ($total_calls + $VDtotal[$o]);
$hour_calls = ($hour_calls + $VDcount[$o]);
$day_calls = ($day_calls + $VDday[$o]);
$o++;
}
echo "<tr><td><font size=2>TOTAL </td><td align=right><font size=2> $status </td><td align=right><font size=2> $hour_calls</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $day_calls</td></tr>\n";
}
echo "</TABLE></center>\n";
echo "<br><br>\n";
echo "<br>Melden Sie bitte die Gruppe an, die Sie stündlichen Notfall fürerhalten möchten: <form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=DB value=$DB>\n";
echo "group: <select size=1 name=group>\n";
$stmt="SELECT * from vicidial_user_groups order by user_group";
$rslt=mysql_query($stmt, $link);
$groups_to_print = mysql_num_rows($rslt);
$o=0;
$groups_list='';
while ($groups_to_print > $o) {
$rowx=mysql_fetch_row($rslt);
if ($group == $group)
{$groups_list .= "<option selected value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
else
{$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";}
$o++;
}
echo "$groups_list</select><br>\n";
echo "status: <input type=text name=status size=10 maxlength=10 value=\"$status\"> &nbsp; (example: XFER)<br>\n";
echo "date with hour: <input type=text name=date_with_hour size=14 maxlength=13 value=\"$date_with_hour\"> &nbsp; (example: 2004-06-25 14)<br>\n";
echo "<input type=submit name=submit value=SUBMIT>\n";
echo "<BR><BR><BR>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?
exit;
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

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