Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lgaetz
committed
Apr 20, 2012
1 parent
46c9a97
commit 10b08ec
Showing
8 changed files
with
594 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Show callers and members in a queue using Asterisk | ||
by Mark Veenstra <belgie@markinthedark.nl> | ||
================================================================ | ||
|
||
** Background | ||
When I search the Internet there are better and more | ||
improved add-ons for Asterisk to list/show all callers and | ||
members of an Asterisk queue. But most of them are too complex | ||
or too expensive for my needs, therefore I created this simple | ||
PHP page. Hopefully you enjoy! | ||
|
||
** Security concerns | ||
This PHP page doesn't include any user authentication. | ||
This is a feature I didn't need because I don' allow any other | ||
people on port 80 of Apache. If you do want some kind of user | ||
authentication, you can: | ||
1. Expand this PHP page with this feature (please let me | ||
know) | ||
2. Make use of a .htaccess with a .htpasswd | ||
|
||
** Installation | ||
- Upload the *.tgz file to your webroot folder of you Asterisk | ||
server (For example: /var/www/html/). | ||
- Login to your Asterisk server and execute the next commands: | ||
cd /var/www/html/ | ||
tar xzvf queue-list-v0.5.tgz | ||
|
||
** Configure PHP page | ||
- Edit the file inc/defines.php and change the MySQL database | ||
settings. | ||
|
||
** Check installation | ||
Open your browser and point in to http://<asterisk_server>/queue_list/ | ||
|
||
** Credits | ||
Special thanks to everyone in the Asterisk community. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
body { | ||
margin-top: 0px; | ||
text-align:center; | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: 100%; | ||
font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular; | ||
font-size: 13px; | ||
} | ||
|
||
a { | ||
color: #2E78A7; | ||
text-decoration : underline; | ||
} | ||
a:hover { | ||
color: #ee9a47; | ||
} | ||
div#page { | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: 85%; | ||
text-align: left; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
} | ||
|
||
div.header { | ||
border-bottom: 1px solid #808080; | ||
height: 82px; /* img height (100px) + img margin */ | ||
color: #A96046; | ||
width: 100%; | ||
margin-top: 10px; | ||
} | ||
|
||
div.header-left { | ||
float: left; | ||
border: none; | ||
} | ||
|
||
div.header-right { | ||
float:right; | ||
border: none; | ||
} | ||
|
||
div.header img { | ||
border: none; | ||
} | ||
|
||
div.refresh { | ||
text-align: right; | ||
border: none; | ||
} | ||
|
||
div.queue { | ||
margin-top: 50px; | ||
text-align: right; | ||
border: none; | ||
} | ||
|
||
div.content { | ||
width: 100%; | ||
text-align:justify; | ||
} | ||
|
||
div.htable { | ||
margin-top: 10px; | ||
text-align:justify; | ||
font-size: 16px; | ||
color:#A96046; | ||
font-weight:bold; | ||
} | ||
|
||
/* BEGIN TABLE CSS */ | ||
div.table-base { | ||
border: none; | ||
margin: 0; | ||
padding: 0; | ||
width: auto; | ||
} | ||
|
||
div.table-row-hdr { | ||
border: solid #000000 1px; | ||
margin-top: 0; | ||
margin-right: auto; | ||
margin-bottom: 0; | ||
margin-left: auto; | ||
padding: 0; | ||
text-align: center; | ||
width: 100%; | ||
} | ||
|
||
div.table-row { | ||
border-left: solid #000000 1px; | ||
border-top: none; | ||
border-right: solid #000000 1px; | ||
border-bottom: solid #000000 1px; | ||
margin-top: 0; | ||
margin-right: auto; | ||
margin-bottom: 0; | ||
margin-left: auto; | ||
padding: 0; | ||
text-align: center; | ||
width: 100%; | ||
} | ||
|
||
div.cal-small-layer { | ||
border: none; | ||
float: left; | ||
margin: 0; | ||
padding: 0; | ||
width: 10%; | ||
text-align: center; | ||
} | ||
|
||
div.cal-big-layer { | ||
border: none; | ||
float: left; | ||
margin: 0; | ||
padding: 0; | ||
width: 70%; | ||
text-align: left; | ||
} | ||
|
||
div.mem-small-layer { | ||
border: none; | ||
float: left; | ||
margin: 0; | ||
padding: 0; | ||
width: 10%; | ||
text-align: center; | ||
} | ||
|
||
div.mem-big-layer { | ||
border: none; | ||
float: left; | ||
margin: 0; | ||
padding: 0; | ||
width: 35%; | ||
text-align: left; | ||
} | ||
|
||
div.space-line { | ||
clear: both; | ||
margin: 0; | ||
padding: 0; | ||
width: auto; | ||
} | ||
|
||
h5.colhdr { | ||
background: none #ffffcc; | ||
border: none; | ||
color: #993333; | ||
font-weight: bold; | ||
margin: 0; | ||
padding: 0.3em 0.3em 0 0.3em; | ||
width: auto; | ||
} | ||
|
||
p.text { | ||
border: none; | ||
margin: 0; padding: 0.3em 0.3em 0 0.3em; | ||
text-indent: 0; | ||
width: auto; | ||
} | ||
*/ END TABLE CSS */ |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
$asdb = mysql_connect(ASDBHOST.":".ASDBPORT, ASDBUSER, ASDBPASS) or die("Could not connect: ".mysql_error()); | ||
//$asdb = mysql_connect(localhost, root, passw0rd) or die("Could not connect: ".mysql_error()); | ||
mysql_select_db(ASDBNAME, $asdb) or die("Could not select database"); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/* Database connection information */ | ||
define("ASDBNAME","asterisk"); | ||
define("ASDBUSER","root"); | ||
define("ASDBPASS","passw0rd"); | ||
define("ASDBHOST","localhost"); | ||
define("ASDBPORT","3307"); | ||
|
||
/* Query to select the queues from the Asterisk database */ | ||
define("ASSQLQUEUE","SELECT extension, descr FROM queues_config ORDER BY descr ASC"); | ||
|
||
/* Asterisk CLI command specifics */ | ||
define("ASCLI","asterisk -rx 'queue show ?' | sed 1d"); | ||
//define("ASCLI","asterisk -rx 'queue show ?'"); | ||
define("ASCLINOMEM","No Members"); | ||
define("ASCLINOCAL","No Callers"); | ||
define("ASCLICAL","Callers:"); | ||
define("ASCLIMEM","Members:"); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?php | ||
function resolveAsteriskCommand() { | ||
$array = array(); | ||
if(isset($_POST['queue']) && trim($_POST['queue'])) { | ||
$cli = str_replace("?", $_POST["queue"], ASCLI); | ||
exec($cli, $output, $return_var); | ||
// for($i=0; $i<=(count($output) - 3); $i++) { | ||
for($i=0; $i<=(count($output) - 2); $i++) { //changed by lcg to display all callers in queue | ||
array_push($array, trim($output[$i])); | ||
} | ||
} | ||
else { | ||
array_push($array, ASCLINOMEM); | ||
array_push($array, ASCLINOCAL); | ||
} | ||
return $array; | ||
} | ||
|
||
function getCallers($command) { | ||
$array = array(); | ||
if(in_array(ASCLINOCAL, $command)) { | ||
$array[0] = array(); | ||
$array[0]["no"] = ""; | ||
$array[0]["cid"] = "No callers yet!"; | ||
$array[0]["wait"] = ""; | ||
$array[0]["prio"] = ""; | ||
$array[0]["debug"] = ""; | ||
} | ||
else { | ||
$ckeys = array_keys($command, ASCLICAL); | ||
|
||
$mkeys = array_keys($command, ASCLIMEM); | ||
if(trim($mkeys[0]) == "") { | ||
$mkeys = array_keys($command, ASCLINOMEM); | ||
} | ||
if($ckeys[0] > $mkeys[0]) { | ||
$goto = count($command); | ||
} | ||
else { | ||
$goto = $mkeys[0]; | ||
} | ||
$x = 0; | ||
for($i = ($ckeys[0] + 1); $i < $goto; $i++) { | ||
|
||
$no = ereg_replace(" .*", "", $command[$i]); | ||
$temp = ereg_replace("^[0-9]*\. ", "", $command[$i]); | ||
$cid = ereg_replace(" \(.*", "", $temp); | ||
$temp = ereg_replace(".* \(wait: ", "", $command[$i]); | ||
$wait = ereg_replace(",.*", "", $temp); | ||
$temp = ereg_replace(".*, prio: ", "", $command[$i]); | ||
$prio = ereg_replace("\).*", "", $temp); | ||
|
||
$array[$x] = array(); | ||
$array[$x]["no"] = $no; | ||
$array[$x]["cid"] = $cid; | ||
$array[$x]["wait"] = $wait; | ||
$array[$x]["prio"] = $prio; | ||
$array[$x]["debug"] = $command[$i]; | ||
|
||
$x++; | ||
} | ||
} | ||
return $array; | ||
} | ||
|
||
function getMembers($command) { | ||
$array = array(); | ||
if(in_array(ASCLINOMEM, $command)) { | ||
$array[0] = array(); | ||
$array[0]["name"] = "No agent logged in!"; | ||
$array[0]["source"] = ""; | ||
$array[0]["status"] = ""; | ||
$array[0]["calls"] = ""; | ||
$array[0]["last"] = ""; | ||
$array[0]["debug"] = ""; | ||
} | ||
else { | ||
$ckeys = array_keys($command, ASCLICAL); | ||
if(trim($ckeys[0]) == "") { | ||
$ckeys = array_keys($command, ASCLINOCAL); | ||
} | ||
$mkeys = array_keys($command, ASCLIMEM); | ||
if($ckeys[0] > $mkeys[0]) { | ||
$goto = ($ckeys[0] - 1); | ||
} | ||
else { | ||
$goto = count($command); | ||
} | ||
$x = 0; | ||
for($i = ($mkeys[0] + 1); $i <= $goto; $i++) { | ||
$name = ereg_replace("\(.*", "", $command[$i]); | ||
$temp = str_replace($name, "", $command[$i]); | ||
$source = substr(ereg_replace("\).*", "", $temp), 1); | ||
$temp = ereg_replace(".*\) \(", "", $command[$i]); | ||
$status = ereg_replace("\).*", "", $temp); | ||
$temp = ereg_replace(".* has taken ", "", $command[$i]); | ||
$calls = ereg_replace(" calls.*", "", $temp); | ||
$temp = ereg_replace(".* \(last was ", "", $command[$i]); | ||
$last = ereg_replace(" secs.*", "", $temp); | ||
if(preg_match("/[^0-9]/", $last)) { $last = "N/A"; } else { $last = sec2hms($last); } | ||
|
||
$array[$x] = array(); | ||
$array[$x]["name"] = trim($name); | ||
$array[$x]["source"] = trim($source); | ||
$array[$x]["status"] = trim($status); | ||
$array[$x]["calls"] = trim($calls); | ||
$array[$x]["last"] = trim($last); | ||
$array[$x]["debug"] = trim($command[$i]); | ||
|
||
$x++; | ||
} | ||
} | ||
return $array; | ||
} | ||
|
||
function sec2hms ($sec, $padHours = false) | ||
{ | ||
|
||
// start with a blank string | ||
$hms = ""; | ||
|
||
// do the hours first: there are 3600 seconds in an hour, so if we divide | ||
// the total number of seconds by 3600 and throw away the remainder, we're | ||
// left with the number of hours in those seconds | ||
$hours = intval(intval($sec) / 3600); | ||
|
||
// add hours to $hms (with a leading 0 if asked for) | ||
$hms .= ($padHours) | ||
? str_pad($hours, 2, "0", STR_PAD_LEFT). ":" | ||
: $hours. ":"; | ||
|
||
// dividing the total seconds by 60 will give us the number of minutes | ||
// in total, but we're interested in *minutes past the hour* and to get | ||
// this, we have to divide by 60 again and then use the remainder | ||
$minutes = intval(($sec / 60) % 60); | ||
|
||
// add minutes to $hms (with a leading 0 if needed) | ||
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ":"; | ||
|
||
// seconds past the minute are found by dividing the total number of seconds | ||
// by 60 and using the remainder | ||
$seconds = intval($sec % 60); | ||
|
||
// add seconds to $hms (with a leading 0 if needed) | ||
$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); | ||
|
||
// done! | ||
return $hms; | ||
|
||
} | ||
?> |
Oops, something went wrong.