Skip to content

Commit cb413ef

Browse files
author
root
committed
First commit
0 parents  commit cb413ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+10325
-0
lines changed

agents.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2nX9F,Agent 1

answered.php

Lines changed: 615 additions & 0 deletions
Large diffs are not rendered by default.

asmanager.php

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?php
2+
/*
3+
Copyright 2007, 2008 Nicolás Gudiño
4+
5+
This file is part of Asternic Call Center Stats.
6+
7+
Asternic Call Center Stats is free software: you can redistribute it
8+
and/or modify it under the terms of the GNU General Public License as
9+
published by the Free Software Foundation, either version 3 of the
10+
License, or (at your option) any later version.
11+
12+
Asternic Call Center Stats is distributed in the hope that it will be
13+
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Asternic Call Center Stats. If not, see
19+
<http://www.gnu.org/licenses/>.
20+
*/
21+
22+
// AMI Class based on phpagi-asmanager.php by
23+
// Matthew Asham <[email protected]>
24+
25+
class AsteriskManager
26+
{
27+
var $socket = NULL;
28+
var $server;
29+
var $port;
30+
31+
function AsteriskManager() { }
32+
33+
function send_request($action, $parameters=array()) {
34+
$command = "Action: $action\r\n";
35+
foreach($parameters as $var=>$val) {
36+
$command .= "$var: $val\r\n";
37+
}
38+
$command .= "\r\n";
39+
fwrite($this->socket, $command);
40+
return $this->get_response(true);
41+
}
42+
43+
function get_response($allow_timeout=false) {
44+
$timeout = false;
45+
do {
46+
$type = NULL;
47+
$parameters = array();
48+
49+
if (feof($this->socket)) {
50+
return false;
51+
}
52+
$buffer = trim(fgets($this->socket, 4096));
53+
while($buffer != '') {
54+
$a = strpos($buffer, ':');
55+
if($a) {
56+
if(!count($parameters)) { // first line in a response?
57+
$type = strtolower(substr($buffer, 0, $a));
58+
if(substr($buffer, $a + 2) == 'Follows') {
59+
// A follows response means there is a multiline field that follows.
60+
$parameters['data'] = '';
61+
$buff = fgets($this->socket, 4096);
62+
while(substr($buff, 0, 6) != '--END ') {
63+
$parameters['data'] .= $buff;
64+
$buff = fgets($this->socket, 4096);
65+
}
66+
}
67+
}
68+
69+
// store parameter in $parameters
70+
$parameters[substr($buffer, 0, $a)] = substr($buffer, $a + 2);
71+
}
72+
$buffer = trim(fgets($this->socket, 4096));
73+
}
74+
75+
// process response
76+
switch($type) {
77+
case '': // timeout occured
78+
$timeout = $allow_timeout;
79+
break;
80+
case 'event':
81+
// Process event with $parameters ?
82+
break;
83+
case 'response':
84+
break;
85+
default:
86+
// $this->log('Unhandled response packet from Manager: ' . print_r($parameters, true));
87+
break;
88+
}
89+
} while($type != 'response' && !$timeout);
90+
return $parameters;
91+
}
92+
93+
function connect($server='localhost', $username='admin', $secret='amp111') {
94+
// Extract port if specified
95+
if(strpos($server, ':') !== false) {
96+
$parts = explode(':', $server);
97+
$this->server = $parts[0];
98+
$this->port = $parts[1];
99+
} else {
100+
$this->server = $server;
101+
$this->port = "5038";
102+
}
103+
104+
$errno = $errstr = NULL;
105+
$this->socket = @fsockopen($this->server, $this->port, $errno, $errstr);
106+
if(!$this->socket) {
107+
$this->log("Unable to connect to manager {$this->server}:{$this->port} ($errno): $errstr");
108+
return false;
109+
}
110+
111+
// read the header
112+
$str = fgets($this->socket);
113+
if($str == false) {
114+
$this->log("Asterisk Manager header not received.");
115+
return false;
116+
}
117+
// login
118+
$res = $this->send_request('login', array('Username'=>$username, 'Secret'=>$secret));
119+
120+
if(false) {
121+
$this->log("Failed to login.");
122+
$this->disconnect();
123+
return false;
124+
}
125+
return true;
126+
}
127+
128+
function disconnect() {
129+
$this->logoff();
130+
fclose($this->socket);
131+
}
132+
133+
function Command($command) {
134+
return $this->send_request('Command', array('Command'=>$command));
135+
}
136+
137+
function ExtensionState($exten, $context='', $actionid='') {
138+
return $this->send_request('ExtensionState', array('Exten'=>$exten, 'Context'=>$context, 'ActionID'=>$actionid));
139+
}
140+
141+
function Hangup($channel) {
142+
return $this->send_request('Hangup', array('Channel'=>$channel));
143+
}
144+
145+
function Logoff() {
146+
return $this->send_request('Logoff');
147+
}
148+
149+
function log($message, $level=1)
150+
{
151+
error_log(date('r') . ' - ' . $message);
152+
}
153+
}
154+
?>

auxstate_helper.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/*
3+
Copyright 2007, 2008 Nicolás Gudiño
4+
5+
This file is part of Asternic Call Center Stats.
6+
7+
Asternic Call Center Stats is free software: you can redistribute it
8+
and/or modify it under the terms of the GNU General Public License as
9+
published by the Free Software Foundation, either version 3 of the
10+
License, or (at your option) any later version.
11+
12+
Asternic Call Center Stats is distributed in the hope that it will be
13+
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Asternic Call Center Stats. If not, see
19+
<http://www.gnu.org/licenses/>.
20+
*/
21+
22+
$time = microtime();
23+
$time = explode(' ', $time);
24+
$time = $time[1] + $time[0];
25+
$begintime = $time;
26+
$inuse = Array();
27+
$dict_queue = Array();
28+
29+
require("config.php");
30+
require("asmanager.php");
31+
require("realtime_functions.php");
32+
if(isset($_SESSION['QSTATS']['hideloggedoff'])) {
33+
$ocultar= $_SESSION['QSTATS']['hideloggedoff'];
34+
} else {
35+
$ocultar="false";
36+
}
37+
if(isset($_SESSION['QSTATS']['filter'])) {
38+
$filter= $_SESSION['QSTATS']['filter'];
39+
} else {
40+
$filter="";
41+
}
42+
43+
44+
$am=new AsteriskManager();
45+
$am->connect($manager_host,$manager_user,$manager_secret);
46+
47+
$channels = get_channels ($am);
48+
//echo "<pre>";print_r($channels);echo "</pre>";
49+
foreach($channels as $ch=>$chv) {
50+
list($chan,$ses) = explode("-",$ch,2);
51+
$inuse["$chan"]=$ch;
52+
}
53+
54+
$queues = get_queues ($am,$channels);
55+
//echo "<pre> queue";print_r($queues);echo "</pre>";
56+
57+
foreach ($queues as $key=>$val) {
58+
$queue[] = $key;
59+
}
60+
61+
echo "<input type=checkbox name='hidelogedoff' onClick='sethide(this)' ";
62+
if($ocultar=="true") echo " checked ";
63+
echo "> ".$lang[$language]['hide_loggedoff']."\n";
64+
65+
include("realtime_agents.php");
66+
include("realtime_qsummary.php");
67+
include("realtime_qdetail.php");
68+
69+
$time = microtime();
70+
$time = explode(" ", $time);
71+
$time = $time[1] + $time[0];
72+
$endtime = $time;
73+
$totaltime = ($endtime - $begintime);
74+
echo "<br/><br/>".$lang[$language]['server_time']." ".date('Y-m-d H:i:s')."<br/>";
75+
echo $lang[$language]['php_parsed']." $totaltime ".$lang[$language]['seconds'];
76+
?>
77+

bar.swf

58.2 KB
Binary file not shown.

barstack.swf

58.8 KB
Binary file not shown.

config.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
require_once("dblib.php");
3+
require_once("misc.php");
4+
5+
// Credentials for MYSQL database
6+
$dbhost = 'localhost';
7+
$dbname = 'asterisk';
8+
$dbuser = 'asterisk';
9+
$dbpass = 'somepass';
10+
11+
// Credentials for AMI (for the realtime tab to work)
12+
// See /etc/asterisk/manager.conf
13+
14+
$manager_host = "127.0.0.1";
15+
$manager_user = "admin";
16+
$manager_secret = "somepass";
17+
18+
// Available languages "es", "en", "ru", "de", "fr"
19+
$language = "ru";
20+
21+
require_once("lang/$language.php");
22+
23+
$midb = conecta_db($dbhost,$dbname,$dbuser,$dbpass);
24+
$self = $_SERVER['PHP_SELF'];
25+
26+
$DB_DEBUG = false;
27+
28+
session_start();
29+
//session_register("QSTATS");
30+
header('content-type: text/html; charset: utf-8');
31+
32+
?>

css/basic.css

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
html { min-width: 600px; }
2+
3+
body {
4+
font-size: 12px;
5+
font-family: verdana,sans-serif;
6+
}
7+
8+
div, caption, td, th, h2, h3, h4 { /* redundant rules for bad browsers */
9+
font-size: 12px;
10+
font-family: verdana,sans-serif;
11+
voice-family: "\"}\"";
12+
voice-family: inherit;
13+
color: #333;
14+
}
15+
.clearhack { display: inline; } /*Clears Box Model Hack in IE5*/
16+
17+
body {
18+
background: #99cccc;
19+
color: #333;
20+
margin: 0; /* margin and padding only necessary to cater for Mac IE5 */
21+
padding: 0;
22+
}
23+
24+
a { color: #06C; }
25+
a:hover { color: #333; }
26+
a:active { color: #000; }
27+
28+
p { line-height: 140%; }
29+
30+
h1,h2 {
31+
font-family: trebuchet ms;
32+
font-weight: bold;
33+
color: #333;
34+
}
35+
36+
h1 {
37+
font-size: 180%;
38+
margin: 0;
39+
}
40+
41+
h1 a { text-decoration: none; color: #333; }
42+
h1 a:hover { border-bottom: 1px dotted #666; color: #000; }
43+
44+
h2 {
45+
font-size: 140%;
46+
padding-bottom: 2px;
47+
padding-top: 15px;
48+
border-bottom: 1px solid #CCC;
49+
margin: 0;
50+
}
51+
52+
p.note {
53+
background: #EEE;
54+
padding: 4px;
55+
font-family: tahoma;
56+
font-size: 85%;
57+
line-height: 130%;
58+
margin-top: 0;
59+
}
60+
61+
#icon {
62+
width: 16px;
63+
height: 16px;
64+
padding: 0;
65+
margin-top: 12px;
66+
margin-bottom: 12px;
67+
}
68+
69+
#rest {
70+
width: 100%;
71+
}
72+
73+
#left {
74+
float: left;
75+
width:45%;
76+
}
77+
#right {
78+
width: 45%;
79+
float: right;
80+
}
81+
82+
83+
* {
84+
margin: 0;
85+
}
86+
html, body {
87+
height: 100%;
88+
}
89+
.wrapper {
90+
min-height: 100%;
91+
height: auto !important;
92+
height: 100%;
93+
margin: 0 auto -4em;
94+
}
95+
.footer, .push {
96+
height: 4em;
97+
}
98+

0 commit comments

Comments
 (0)