rendered paste body<?php
# Parked Calls for Cisco Phones
# Programmed by Tim
#
include ("include/phpagi/misc.php");
include ("include/phpagi/phpagi-asmanager.php");
# Connect to AGI
$as = new AGI_AsteriskManager();
$res = $as->connect("localhost","phpagi","phpagi");
# Check current list
$res = $as->command('show parkedcalls');
$line = split("\n", $res['data']);
$index=0;
$count=0;
foreach ($line as $myline)
{
if((!strstr($myline,"Privilege")) && (!strstr($myline,"Extension")) && (!strstr($myline,"parked")) && ($myline!=""))
{
$linevalue= preg_split("/ /", $myline,-1,PREG_SPLIT_NO_EMPTY);
if($linevalue[0]!="")
{
$park[$count][0]=$linevalue[0];
$res_i = $as->Command('show channel '.$linevalue[1]);
$line_i= @split("\n", $res_i['data']);
foreach ($line_i as $myline_i)
{
if (strstr($myline_i,"Caller ID Name")) $park[$count][1]=substr(substr(strrchr($myline_i,":"),1),1);
else if (strstr($myline_i,"Caller ID")) $park[$count][1]=substr(substr(strrchr($myline_i,":"),1),1);
}
$count++;
}
}
$index++;
}
# Disconnect properly
$as->disconnect();
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
echo "<CiscoIPPhoneText>
<Title>Parked Calls</Title>";
# Update display
if($count==0)
{
echo "<Text>No Parked Calls</Text>";
}
else
{
for ($index=0;$index<$count;$index++)
echo "<Text>{$park[$index][0]} {$park[$index][1]}</Text>";
}
echo " <Prompt>Extention List</Prompt>
</CiscoIPPhoneText>";
exit;
?>