Files
agc_1-X/agc/park_calls_display.php
T
root 9c9de75826 1.1.10 release
git-svn-id: svn://192.168.202.10@1 3d104415-ff17-0410-8863-d5cf3c621b8a
2006-07-07 14:57:59 +00:00

139 lines
3.7 KiB
PHP

<?
### park_calls_display.php
###
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
###
### This script is designed purely to send the details on the parked calls on the server
### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
###
### required variables:
### - $server_ip
### - $session_name
### - $user
### - $pass
### optional variables:
### - $format - ('text','debug')
### - $exten - ('cc101','testphone','49-1','1234','913125551212',...)
### - $protocol - ('SIP','Zap','IAX2',...)
###
# changes
# 50524-1515 First build of script
# 50711-1208 removed HTTP authentication in favor of user/pass vars
#
require("dbconnect.php");
#require_once("htglobalize.php");
### If you have globals turned off uncomment these lines
$user=$_GET["user"]; if (!$user) {$user=$_POST["user"];}
$pass=$_GET["pass"]; if (!$pass) {$pass=$_POST["pass"];}
$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];}
$session_name=$_GET["session_name"]; if (!$session_name) {$session_name=$_POST["session_name"];}
$format=$_GET["format"]; if (!$format) {$format=$_POST["format"];}
$exten=$_GET["exten"]; if (!$exten) {$exten=$_POST["exten"];}
$protocol=$_GET["protocol"]; if (!$protocol) {$protocol=$_POST["protocol"];}
# default optional vars if not set
if (!$format) {$format="text";}
if (!$park_limit) {$park_limit="1000";}
$version = '0.0.2';
$build = '50711-1208';
$StarTtime = date("U");
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
if (!$query_date) {$query_date = $NOW_DATE;}
$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))
{
echo "Invalid Username/Password: |$user|$pass|\n";
exit;
}
else
{
if( ( (strlen($server_ip)<6) or (!$server_ip) ) or ( (strlen($session_name)<12) or (!$session_name) ) )
{
echo "Invalid server_ip: |$server_ip| or Invalid 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)
{
echo "Invalid session_name: |$session_name|$server_ip|\n";
exit;
}
else
{
# do nothing for now
}
}
}
if ($format=='debug')
{
echo "<html>\n";
echo "<head>\n";
echo "<!-- VERSION: $version BUILD: $build EXTEN: $exten server_ip: $server_ip-->\n";
echo "<title>Parked Calls Display";
echo "</title>\n";
echo "</head>\n";
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
}
$row=''; $rowx='';
$channel_live=1;
if ( (strlen($exten)<1) or (strlen($protocol)<3) )
{
$channel_live=0;
echo "Exten $exten is not valid or protocol $protocol is not valid\n";
exit;
}
else
{
##### print parked calls from the parked_channels table
$stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
$park_calls_count = mysql_num_rows($rslt);
echo "$park_calls_count\n";
$loop_count=0;
while ($park_calls_count>$loop_count)
{
$loop_count++;
$row=mysql_fetch_row($rslt);
echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|";
}
echo "\n";
}
if ($format=='debug')
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- script runtime: $RUNtime seconds -->";
echo "\n</body>\n</html>\n";
}
exit;
?>