Ejemplo n.º 1
0
function _gs_send_event($data)
{
    $command = '';
    foreach ($data as $line) {
        if (strlen($line['parm']) > 0) {
            $command = $command . $line['parm'] . ': ';
            $command = $command . $line['value'] . "\r\n";
        }
    }
    $command = $command . "\r\n";
    $ami = new AMI();
    $ami->ami_login('uevg', 'eSd58', '127.0.0.1', 5038);
    $res = $ami->ami_send_command($command);
    $ami->ami_logout();
}
Ejemplo n.º 2
0
		AND `_id` IN (' . implode(",", $queue_ids) . ') 
		AND `_id` NOT IN 
		(SELECT `_queue_id` FROM `ast_queue_members` WHERE `_user_id`=' . $user['id'] . ')');
    while ($queue_map = $rs->fetchRow()) {
        $penalty = $DB->executeGetOne('SELECT `penalty` FROM `penalties` WHERE `_user_id`=' . $user['id'] . ' AND `_queue_id`=' . $queue_map['_id']);
        if (!$penalty) {
            $penalty = 'DEFAULT';
        }
        $interface = 'SIP/' . $agent;
        $DB->execute('INSERT INTO `ast_queue_members` SET 
			`_user_id` =' . (int) $user['id'] . ', ' . '`_queue_id` =' . (int) $queue_map['_id'] . ', ' . '`queue_name`= \'' . $queue_map['name'] . '\',
			`interface` = \'' . $interface . '\',
			`penalty`=' . $penalty);
        $ami->ami_send_command('Action: Queuelog' . "\n" . 'Queue: ' . $queue_map['name'] . "\n" . 'Interface: ' . $agent . "\n" . 'Event: AGENTLOGIN' . "\r\n\r\n");
    }
    $ami->ami_logout();
}
if (@$_REQUEST['action'] == 'logoutqueue' && !empty($queue_ids)) {
    $ami = new AMI();
    $ami->ami_login('gscc', 'gspass', '127.0.0.1', 5038);
    $agent = $DB->executeGetOne('SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`=' . $user['id']);
    $interface = 'SIP/' . $agent;
    $queue_ids = array_intersect($queue_ids, $queues_allowed);
    $rs = $DB->execute('SELECT `queue_name`, `_queue_id`  FROM `ast_queue_members` WHERE 
		`_user_id`=' . $user['id'] . '
		AND `static`= 0
		AND `_queue_id` IN (' . implode(",", $queue_ids) . ')');
    while ($queue_map = $rs->fetchRow()) {
        $agent_on = $DB->executeGetOne('SELECT count(`_queue_id`) FROM `ast_queue_members` WHERE `_queue_id` =' . (int) $queue_map['_queue_id']);
        $min_agent = $DB->executeGetOne('SELECT `_min_agents` FROM `ast_queues` WHERE `_id`=' . (int) $queue_map['_queue_id']);
        if ($agent_on > $min_agent) {