2014-01-08 10:08:48 +01:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2014-07-04 11:47:37 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2014
|
2014-01-08 10:08:48 +01:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
include "root.php";
|
|
|
|
|
require_once "resources/require.php";
|
|
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
if (permission_exists("registration_domain") || permission_exists("registration_all") || if_group("superadmin")) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-16 03:32:03 +02:00
|
|
|
//add multi-lingual support
|
|
|
|
|
require_once "app_languages.php";
|
|
|
|
|
foreach($text as $key => $value) {
|
|
|
|
|
$text[$key] = $value[$_SESSION['domain']['language']['code']];
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-08 10:08:48 +01:00
|
|
|
//set the variables
|
|
|
|
|
$cmd = check_str($_GET['cmd']);
|
|
|
|
|
$rdr = check_str($_GET['rdr']);
|
2014-06-10 05:32:35 +02:00
|
|
|
$profile = check_str($_GET['profile']);
|
2014-01-08 10:08:48 +01:00
|
|
|
$domain = check_str($_GET['domain']);
|
2014-07-04 11:47:37 +02:00
|
|
|
$show = check_str($_GET['show']);
|
2014-01-08 10:08:48 +01:00
|
|
|
$user = check_str($_GET['user']);
|
|
|
|
|
$agent = check_str($_GET['agent']);
|
|
|
|
|
|
|
|
|
|
//get the vendor
|
2014-01-22 22:39:27 +01:00
|
|
|
if (preg_replace('/^.*?(aastra).*$/i', '$1', strtolower($agent)) == "aastra") {
|
2014-01-08 10:08:48 +01:00
|
|
|
$vendor = "aastra";
|
|
|
|
|
}
|
2014-01-22 22:39:27 +01:00
|
|
|
if (preg_replace('/^.*?(cisco).*$/i', '$1', strtolower($agent)) == "cisco") {
|
2014-01-08 10:08:48 +01:00
|
|
|
$vendor = "cisco";
|
|
|
|
|
}
|
2014-01-22 22:39:27 +01:00
|
|
|
if (preg_replace('/^.*?(grandstream).*$/i', '$1', strtolower($agent)) == "grandstream") {
|
2014-01-08 10:08:48 +01:00
|
|
|
$vendor = "grandstream";
|
|
|
|
|
}
|
2014-01-22 22:39:27 +01:00
|
|
|
if (preg_replace('/^.*?(polycom).*$/i', '$1', strtolower($agent)) == "polycom") {
|
2014-01-08 10:08:48 +01:00
|
|
|
$vendor = "polycom";
|
|
|
|
|
}
|
2014-01-22 22:39:27 +01:00
|
|
|
if (preg_replace('/^.*?(yealink).*$/i', '$1', strtolower($agent)) == "yealink") {
|
2014-01-08 10:08:48 +01:00
|
|
|
$vendor = "yealink";
|
|
|
|
|
}
|
2014-01-22 22:39:27 +01:00
|
|
|
if (preg_replace('/^.*?(vp530p).*$/i', '$1', strtolower($agent)) == "vp530p") {
|
|
|
|
|
$vendor = "yealink";
|
|
|
|
|
}
|
|
|
|
|
if (preg_replace('/^.*?(snom).*$/i', '$1', strtolower($agent)) == "snom") {
|
|
|
|
|
$vendor = "snom";
|
|
|
|
|
}
|
2014-01-08 10:08:48 +01:00
|
|
|
|
|
|
|
|
//create the event socket connection
|
|
|
|
|
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
|
|
|
|
if ($fp) {
|
2014-06-10 05:32:35 +02:00
|
|
|
//prepare the command
|
2014-06-27 21:50:15 +02:00
|
|
|
if ($cmd == "unregister") {
|
|
|
|
|
$command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot";
|
2014-01-08 10:08:48 +01:00
|
|
|
}
|
2014-06-10 05:32:35 +02:00
|
|
|
else {
|
2014-07-04 11:47:37 +02:00
|
|
|
$command = "lua app.lua event_notify ".$profile." ".$cmd." ".$user." ".$vendor;
|
2014-06-27 21:50:15 +02:00
|
|
|
|
|
|
|
|
//if ($cmd == "check_sync") {
|
|
|
|
|
// $command = "sofia profile ".$profile." check_sync ".$user;
|
|
|
|
|
//}
|
2014-05-13 03:27:18 +02:00
|
|
|
}
|
|
|
|
|
//send the command
|
2014-06-10 05:32:35 +02:00
|
|
|
$response = event_socket_request($fp, "api ".$command);
|
|
|
|
|
$response = event_socket_request($fp, "api log notice ".$command);
|
2014-05-13 03:27:18 +02:00
|
|
|
//show the response
|
|
|
|
|
$_SESSION['message'] = $text['label-event']." ".ucwords($cmd)." ".$text['label-response'].$response;
|
2014-01-08 10:08:48 +01:00
|
|
|
//close the connection
|
|
|
|
|
fclose($fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//redirect the user
|
|
|
|
|
if ($rdr == "false") {
|
|
|
|
|
//redirect false
|
|
|
|
|
echo $response;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2014-07-04 11:47:37 +02:00
|
|
|
header("Location: status_registrations.php?profile=".$profile."&show=".$show);
|
2014-01-08 10:08:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|