LICENSE: GPLv2 ### ### This script is designed to open up when a live_inbound call comes in giving the user ### options of what to do with the call or options to lookup the callerID on various web sites ### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table ### ### required variables: ### - $server_ip ### - $session_name ### - $uniqueid - ('1234567890.123456',...) ### - $user ### - $pass ### optional variables: ### - $format - ('text','debug') ### - $vmail_box - ('101','1234',...) ### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) ### - $ext_context - ('default','demo',...) ### - $ext_priority - ('1','2',...) ### - $voicemail_dump_exten - ('85026666666666') ### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) ### # changes # 50428-1500 - First build of script display only # 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links # 50503-1244 - added session_name checking for extra security # 50711-1203 - removed HTTP authentication in favor of user/pass vars # 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES # 60619-1205 - Added variable filters to close security holes for login form # require("dbconnect.php"); ### If you have globals turned off uncomment these lines if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} if (isset($_GET["format"])) {$format=$_GET["format"];} elseif (isset($_POST["format"])) {$format=$_POST["format"];} if (isset($_GET["exten"])) {$exten=$_GET["exten"];} elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} else {$local_web_callerID_URL = '';} $user=ereg_replace("[^0-9a-zA-Z]","",$user); $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); # default optional vars if not set if (!isset($format)) {$format="text";} $version = '0.0.6'; $build = '60619-1205'; $StarTtime = date("U"); $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); if (!isset($query_date)) {$query_date = $NOW_DATE;} $DO = '-1'; if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $auth=$row[0]; if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) { echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; exit; } else { if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; exit; } else { $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $SNauth=$row[0]; if($SNauth==0) { echo "Inválido session_name: |$session_name|$server_ip|\n"; exit; } else { # do nothing for now } } } if ($format=='debug') { $forever_stop=0; $user_abb = "$user$user$user$user"; while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} echo "\n"; echo "\n"; echo "\n"; ?> LLAMADA DE ENTRADA ACTIVA"; echo "\n"; echo "\n"; echo "\n"; echo "

LLAMADA DE ENTRADA ACTIVA

\n"; echo "$NOW_TIME

\n"; } $MT[0]=''; $row=''; $rowx=''; $channel_live=1; if (strlen($uniqueid)<9) { $channel_live=0; echo "Uniqueid $uniqueid No es válido\n"; exit; } else { $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); $channels_list = mysql_num_rows($rslt); if ($channels_list>0) { $row=mysql_fetch_row($rslt); # echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; # Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| if ($format=='debug') {echo "\n";} echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Canal: $row[1]
LlamadorID: $row[3]
\n"; $phone = eregi_replace(".*\<","",$row[3]); $phone = eregi_replace("\>.*","",$phone); $NPA = substr($phone, 0, 3); $NXX = substr($phone, 3, 3); $XXXX = substr($phone, 6, 4); $D='-'; echo "GOOGLE - \n"; echo "ANYWHO - \n"; echo "SWITCHBOARD - \n"; echo "VERIZON - \n"; echo "WHITEPAGES - \n"; echo "411.COM - \n"; echo "411.COM - \n"; $local_web_callerID_QUERY_STRING =''; $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; $local_web_callerID_QUERY_STRING.="&callerID_Canal=$row[1]"; $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; echo "A MEDIDA - \n"; echo "
Número Marcado: $row[8]
Notas: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; echo "COLGAR - \n"; echo "ENVIAR A MI BUZÓN DE VOZ\n"; echo "
\n"; $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); } } if ($format=='debug') { $ENDtime = date("U"); $RUNtime = ($ENDtime - $StarTtime); echo "\n"; echo "\n\n\n"; } exit; ?>