asterisk-queue-manager/php/ami_set.php

47 lines
849 B
PHP
Raw Permalink Normal View History

2023-07-31 14:50:26 +02:00
<?php
include('../config.php');
// Read GET data
$section = $_GET['s'];
$value = $_GET['v'];
// Open socket to ami server
$socket = fsockopen($ami_host, $ami_port);
// Login
fputs($socket, "Action: Login\r\n");
fputs($socket, 'UserName: ' . $ami_user . "\r\n");
fputs($socket, 'Secret: ' . $ami_pass . "\r\n\r\n");
//
// Section: sippeers
//
if($section == 'sippeers') {
fputs($socket, "Action: QueueAdd\r\n");
fputs($socket, 'Interface: SIP/' . $value . "\r\n");
fputs($socket, "Queue: " . $queue_name . "\r\n\r\n");
2023-07-31 14:50:26 +02:00
}
//
// Section: queuemembers
//
if($section == 'queuemembers') {
fputs($socket, "Action: QueueRemove\r\n");
fputs($socket, 'Interface: SIP/' . $value . "\r\n");
fputs($socket, "Queue: " . $queue_name . "\r\n\r\n");
2023-07-31 14:50:26 +02:00
}
// It seems that it needs some time to execute
sleep(1);
// Close socket
fclose($socket);
?>