Exemplo n.º 1
0
}
// show help
if (in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
    die("Usage: syslog_server [bind_ip] [xml|csv|url|php] [on_hook,off_hook...] <packet_count>\n");
}
if (!($address = @$argv[1])) {
    $address = '0.0.0.0';
}
// format
if (!($format = $argv[2])) {
    $format = 'csv';
}
$types = @$argv[3];
$max_packets = @$argv[4];
// establish socket
$s = new GrandstreamSYSLOG();
$s->bind($address);
// prepare XML
if ('xml' == $format) {
    $xml = new XmlWriter();
    $xml->push('messages');
}
// messages to listen for
$messages = array_filter(explode(',', $types));
// start listening on callback
$s->listen('printPacket', $max_packets, $messages);
function printPacket($result)
{
    global $format, $xml;
    switch ($format) {
        case 'php':
#!/usr/bin/php -q
<?php 
/*
 * @desc   Interpret Grandstream SYSLOG onhook/powerup and request it picks up a new idle screen
 * @author Leo Brown
 * @date   2009-02-21
 */
// dependencies
require_once '../syslog/grandstream_syslog_decoder.php';
require_once '../telnet/GrandstreamAudioControl.class.php';
// establish socket
$s = new GrandstreamSYSLOG();
if (!$s->bind($address = @$argv[1])) {
    exit;
}
// tapping driver_start, currently only for syslog, but could be reviewed
$messages = array('on_hook', 'driver_start');
// start listening on callback
$s->listen('notify', null, $messages);
$device_states = array();
function notify($result)
{
    $argv[1] = $result['ip'];
    $argv[2] = 'screen';
    require '../sip/notify.php';
}
Exemplo n.º 3
0
#!/usr/bin/php -q
<?php 
/*
 * @desc   Interpret Grandstream SYSLOG messages and dispatch tones
 * @author Leo Brown
 * @date   2008-08-19
 */
// dependencies
require_once '../syslog/grandstream_syslog_decoder.php';
if (!class_exists('XmlWriter')) {
    require_once '../syslog/XmlWriter.class.php';
}
require_once '../telnet/GrandstreamAudioControl.class.php';
// establish socket
$s = new GrandstreamSYSLOG();
$s->bind($address = @$argv[1]);
// messages to listen for
$messages = array('off_hook', 'callmode_change');
// start listening on callback
$s->listen('playTones', null, $messages);
$device_states = array();
function playTones($result)
{
    global $device_states;
    $ip = $result['ip'];
    switch ($result['message']['type']) {
        case 'callmode_change':
            $device_states[$ip] = $result['message']['new_mode'];
            break;
            // GXP unfortunately sends callmode/voicemode/audio path changes AFTER
            // off-hook for handset. Handsfree and headset set mode FIRST.