Registrations: List view updates, bulk unregister, provision, reboot.

This commit is contained in:
Nate
2019-11-29 15:27:51 -07:00
parent e607d1b911
commit df58dc0af5
4 changed files with 540 additions and 294 deletions

View File

@@ -361,6 +361,26 @@ $text['header-registrations']['ru-ru'] = "Регистрация";
$text['header-registrations']['sv-se'] = "Registreringar";
$text['header-registrations']['uk-ua'] = "Реєстрації";
$text['description-registrations']['en-us'] = "Manage current extensions registered to the system.";
$text['description-registrations']['ar-eg'] = "Manage current extensions registered to the system.";
$text['description-registrations']['de-at'] = "Manage current extensions registered to the system.";
$text['description-registrations']['de-ch'] = "Manage current extensions registered to the system.";
$text['description-registrations']['de-de'] = "Manage current extensions registered to the system.";
$text['description-registrations']['es-cl'] = "Manage current extensions registered to the system.";
$text['description-registrations']['es-mx'] = "Manage current extensions registered to the system.";
$text['description-registrations']['fr-ca'] = "Manage current extensions registered to the system.";
$text['description-registrations']['fr-fr'] = "Manage current extensions registered to the system.";
$text['description-registrations']['he-il'] = "Manage current extensions registered to the system.";
$text['description-registrations']['it-it'] = "Manage current extensions registered to the system.";
$text['description-registrations']['nl-nl'] = "Manage current extensions registered to the system.";
$text['description-registrations']['pl-pl'] = "Manage current extensions registered to the system.";
$text['description-registrations']['pt-br'] = "Manage current extensions registered to the system.";
$text['description-registrations']['pt-pt'] = "Manage current extensions registered to the system.";
$text['description-registrations']['ro-ro'] = "Manage current extensions registered to the system.";
$text['description-registrations']['ru-ru'] = "Manage current extensions registered to the system.";
$text['description-registrations']['sv-se'] = "Manage current extensions registered to the system.";
$text['description-registrations']['uk-ua'] = "Manage current extensions registered to the system.";
$text['error-event-socket']['en-us'] = "Connection to Event Socket failed.";
$text['error-event-socket']['ar-eg'] = "";
$text['error-event-socket']['de-at'] = "Verbindung zum Event Socket fehlgeschlagen."; //copied from de-de
@@ -441,4 +461,164 @@ $text['button-provision']['ru-ru'] = "Обеспечение";
$text['button-provision']['sv-se'] = "Provisionera";
$text['button-provision']['uk-ua'] = "Provision ";
?>
$text['button-all_profiles']['en-us'] = "All Profiles";
$text['button-all_profiles']['ar-eg'] = "All Profiles";
$text['button-all_profiles']['de-at'] = "All Profiles";
$text['button-all_profiles']['de-ch'] = "All Profiles";
$text['button-all_profiles']['de-de'] = "All Profiles";
$text['button-all_profiles']['es-cl'] = "All Profiles";
$text['button-all_profiles']['es-mx'] = "All Profiles";
$text['button-all_profiles']['fr-ca'] = "All Profiles";
$text['button-all_profiles']['fr-fr'] = "All Profiles";
$text['button-all_profiles']['he-il'] = "All Profiles";
$text['button-all_profiles']['it-it'] = "All Profiles";
$text['button-all_profiles']['nl-nl'] = "All Profiles";
$text['button-all_profiles']['pl-pl'] = "All Profiles";
$text['button-all_profiles']['pt-br'] = "All Profiles";
$text['button-all_profiles']['pt-pt'] = "All Profiles";
$text['button-all_profiles']['ro-ro'] = "All Profiles";
$text['button-all_profiles']['ru-ru'] = "All Profiles";
$text['button-all_profiles']['sv-se'] = "All Profiles";
$text['button-all_profiles']['uk-ua'] = "All Profiles";
$text['button-single_profile']['en-us'] = "Single Profile";
$text['button-single_profile']['ar-eg'] = "Single Profile";
$text['button-single_profile']['de-at'] = "Single Profile";
$text['button-single_profile']['de-ch'] = "Single Profile";
$text['button-single_profile']['de-de'] = "Single Profile";
$text['button-single_profile']['es-cl'] = "Single Profile";
$text['button-single_profile']['es-mx'] = "Single Profile";
$text['button-single_profile']['fr-ca'] = "Single Profile";
$text['button-single_profile']['fr-fr'] = "Single Profile";
$text['button-single_profile']['he-il'] = "Single Profile";
$text['button-single_profile']['it-it'] = "Single Profile";
$text['button-single_profile']['nl-nl'] = "Single Profile";
$text['button-single_profile']['pl-pl'] = "Single Profile";
$text['button-single_profile']['pt-br'] = "Single Profile";
$text['button-single_profile']['pt-pt'] = "Single Profile";
$text['button-single_profile']['ro-ro'] = "Single Profile";
$text['button-single_profile']['ru-ru'] = "Single Profile";
$text['button-single_profile']['sv-se'] = "Single Profile";
$text['button-single_profile']['uk-ua'] = "Single Profile";
$text['message-registrations_unregistered']['en-us'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['ar-eg'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['de-at'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['de-ch'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['de-de'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['es-cl'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['es-mx'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['fr-ca'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['fr-fr'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['he-il'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['it-it'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['nl-nl'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['pl-pl'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['pt-br'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['pt-pt'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['ro-ro'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['ru-ru'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['sv-se'] = "Registrations Unregistered";
$text['message-registrations_unregistered']['uk-ua'] = "Registrations Unregistered";
$text['message-registrations_provisioned']['en-us'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['ar-eg'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['de-at'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['de-ch'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['de-de'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['es-cl'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['es-mx'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['fr-ca'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['fr-fr'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['he-il'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['it-it'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['nl-nl'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['pl-pl'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['pt-br'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['pt-pt'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['ro-ro'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['ru-ru'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['sv-se'] = "Registrations Provisioned";
$text['message-registrations_provisioned']['uk-ua'] = "Registrations Provisioned";
$text['message-registrations_rebooted']['en-us'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['ar-eg'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['de-at'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['de-ch'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['de-de'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['es-cl'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['es-mx'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['fr-ca'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['fr-fr'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['he-il'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['it-it'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['nl-nl'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['pl-pl'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['pt-br'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['pt-pt'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['ro-ro'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['ru-ru'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['sv-se'] = "Registrations Rebooted";
$text['message-registrations_rebooted']['uk-ua'] = "Registrations Rebooted";
$text['confirm-unregister']['en-us'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['ar-eg'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['de-at'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['de-ch'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['de-de'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['es-cl'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['es-mx'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['fr-ca'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['fr-fr'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['he-il'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['it-it'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['nl-nl'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['pl-pl'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['pt-br'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['pt-pt'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['ro-ro'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['ru-ru'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['sv-se'] = "Do you really want to UNREGISTER these?";
$text['confirm-unregister']['uk-ua'] = "Do you really want to UNREGISTER these?";
$text['confirm-provision']['en-us'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['ar-eg'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['de-at'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['de-ch'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['de-de'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['es-cl'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['es-mx'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['fr-ca'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['fr-fr'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['he-il'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['it-it'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['nl-nl'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['pl-pl'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['pt-br'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['pt-pt'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['ro-ro'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['ru-ru'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['sv-se'] = "Do you really want to PROVISION these?";
$text['confirm-provision']['uk-ua'] = "Do you really want to PROVISION these?";
$text['confirm-reboot']['en-us'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['ar-eg'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['de-at'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['de-ch'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['de-de'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['es-cl'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['es-mx'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['fr-ca'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['fr-fr'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['he-il'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['it-it'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['nl-nl'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['pl-pl'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['pt-br'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['pt-pt'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['ro-ro'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['ru-ru'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['sv-se'] = "Do you really want to REBOOT these?";
$text['confirm-reboot']['uk-ua'] = "Do you really want to REBOOT these?";
?>

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2018
Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -86,7 +86,7 @@
}
var requestTime = function() {
var url = 'registrations.php?template=false&profile=&show=<?php echo escape($show); ?>';
var url = 'registrations.php?reload&show=<?php echo escape($show); ?>';
new loadXmlHttp(url, 'ajax_response');
<?php
if (strlen($_SESSION["ajax_refresh_rate"]) == 0) { $_SESSION["ajax_refresh_rate"] = "1800"; }
@@ -124,4 +124,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2018
Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -43,300 +43,189 @@
$language = new text;
$text = $language->get();
//get the http values and set them as variables
$search = $_REQUEST["search"];
//get common submitted data
$search = $_REQUEST['search'];
$profile = $_REQUEST['profile'];
//set the format
$template = true;
if ($_REQUEST["template"] == "false" && permission_exists('registration_reload')) {
$template = false;
//define query string array
if ($search) { $qs['search'] = "&search=".urlencode($search); }
if ($profile) { $qs['profile'] = "&profile=".urlencode($profile); }
//get posted data
if (is_array($_POST['registrations'])) {
$action = $_POST['action'];
$registrations = $_POST['registrations'];
}
//show the header
if ($template) {
require_once "resources/header.php";
$document['title'] = $text['header-registrations'];
//process posted data
if ($action != '' && is_array($registrations) && @sizeof($registrations) != 0) {
//perform action
switch ($action) {
//unregister the registrations
case 'unregister':
$obj = new registrations;
$obj->unregister($registrations);
break;
//provision the registrations
case 'provision':
$obj = new registrations;
$obj->provision($registrations);
break;
//reboot the registrations
case 'reboot':
$obj = new registrations;
$obj->reboot($registrations);
break;
}
//redirect
header('Location: registrations.php'.($search || $profile ? '?' : null).$qs['search'].$qs['profile']);
exit;
}
//check permissions
if (permission_exists("registration_domain") || permission_exists("registration_all") || if_group("superadmin")) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the registrations
$obj = new registrations;
$registrations = $obj->get(!$profile ? 'all' : $profile);
//add multi-lingual support
$language = new text;
$text = $language->get();
//order the array
require_once "resources/classes/array_order.php";
$order = new array_order();
$registrations = $order->sort($registrations, 'sip-auth-realm', 'user');
//debug
//echo "<pre>\n";
//print_r($_REQUEST);
//echo "</pre>\n";
//get the HTTP values and set as variables
$profile = trim($_REQUEST["profile"]);
$search = trim($_REQUEST["search"]);
$show = trim($_REQUEST["show"]);
if ($show == "all") {
$profile = 'all';
}
//set the registrations variable
$registrations = $_REQUEST["registrations"];
//get the action and remove items from the array that are not checked
//get registration count
$num_rows = 0;
if (is_array($registrations)) {
foreach ($registrations as $row) {
$matches = preg_grep("/".$search."/i", $row);
if ($matches != false) {
$num_rows++;
}
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//detect page reload via ajax
$reload = isset($_GET['reload']) && permission_exists('registration_reload') ? true : false;
//define location url
$location = 'registrations'.($reload ? '_reload' : null).'.php';
//include the header
if (!$reload) {
$document['title'] = $text['header-registrations'];
require_once "resources/header.php";
}
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-registrations']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (!$reload) {
echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$_SESSION['theme']['button_icon_refresh'],'link'=>$location.($qs ? '?' : null).$qs['search'].$qs['profile']]);
}
echo button::create(['type'=>'button','label'=>$text['button-unregister'],'title'=>$text['button-unregister'],'icon'=>'user-slash','style'=>'margin-left: 15px;','onclick'=>"if (confirm('".$text['confirm-unregister']."')) { list_action_set('unregister'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
echo button::create(['type'=>'button','label'=>$text['button-provision'],'title'=>$text['button-provision'],'icon'=>'fax','onclick'=>"if (confirm('".$text['confirm-provision']."')) { list_action_set('provision'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
echo button::create(['type'=>'button','label'=>$text['button-reboot'],'title'=>$text['button-reboot'],'icon'=>'power-off','onclick'=>"if (confirm('".$text['confirm-reboot']."')) { list_action_set('reboot'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('registration_all')) {
echo "<input type='hidden' name='profile' value='".escape($profile)."'>";
if ($profile != '') {
echo button::create(['type'=>'button','label'=>$text['button-all_profiles'],'icon'=>'network-wired','style'=>'margin-left: 15px;','link'=>$location.'?'.$qs['search']]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>$location.($qs['profile'] ? '?' : null).$qs['profile'],'style'=>($search == '' ? 'display: none;' : null)]);
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-registrations']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<input type='hidden' name='profile' value='".escape($profile)."'>";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($registrations ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
echo " <th>".$text['label-user']."</th>\n";
echo " <th class='min-pct-25'>".$text['label-agent']."</th>\n";
echo " <th class='hide-md-dn'>".$text['label-contact']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-lan_ip']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-ip']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-port']."</th>\n";
echo " <th class='hide-md-dn'>".$text['label-hostname']."</th>\n";
echo " <th class='min-pct-35'>".$text['label-status']."</th>\n";
echo " <th class='hide-md-dn'>".$text['label-ping']."</th>\n";
echo " <th class='hide-md-dn'>".$text['label-sip_profile_name']."</th>\n";
echo " <td class='action-button'>&nbsp;</td>\n";
echo "</tr>\n";
if (is_array($registrations) && @sizeof($registrations) != 0) {
$x = 0;
foreach ($registrations as &$row) {
//get the action
switch ($row['action']) {
case "unregister":
$row['checked'] = 'true';
$action = 'unregister';
break;
case "provision":
$row['checked'] = 'true';
$action = 'provision';
break;
case "reboot":
$row['checked'] = 'true';
$action = 'reboot';
break;
foreach ($registrations as $row) {
$matches = preg_grep('/'.$search.'/i', $row);
if ($matches != false) {
$user = explode('@', $row['user']);
if ($user[1] == $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name']) {
$user = "<span class='hide-sm-dn'>".escape($row['user'])."</span><span class='hide-md-up cursor-help' title='".$row['user']."'>".escape($user[0])."@...</span>";
}
//unset rows that were not selected
if (!isset($row['checked'])) {
unset($registrations[$x]);
else {
$user = escape($row['user']);
}
//increment the id
echo "<tr class='list-row' href='#'>\n";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='registrations[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='registrations[$x][user]' value='".escape($row['user'])."' />\n";
echo " <input type='hidden' name='registrations[$x][profile]' value='".escape($row['sip_profile_name'])."' />\n";
echo " <input type='hidden' name='registrations[$x][agent]' value='".escape($row['agent'])."' />\n";
echo " <input type='hidden' name='registrations[$x][host]' value='".escape($row['host'])."' />\n";
echo " <input type='hidden' name='registrations[$x][domain]' value='".escape($row['sip-auth-realm'])."' />\n";
echo " </td>\n";
echo " <td>".$user."</td>\n";
echo " <td class='overflow' title=\"".escape($row['agent'])."\"><span class='cursor-help'>".escape($row['agent'])."</span></td>\n";
echo " <td class='hide-md-dn'>".escape(explode('"',$row['contact'])[1])."</td>\n";
echo " <td class='hide-sm-dn no-link'><a href='https://".urlencode($row['lan-ip'])."' target='_blank'>".escape($row['lan-ip'])."</a></td>\n";
echo " <td class='hide-sm-dn no-link'><a href='https://".urlencode($row['network-ip'])."' target='_blank'>".escape($row['network-ip'])."</a></td>\n";
echo " <td class='hide-sm-dn'>".escape($row['network-port'])."</td>\n";
echo " <td class='hide-md-dn'>".escape($row['host'])."</td>\n";
echo " <td class='overflow' title=\"".escape($row['status'])."\"><span class='cursor-help'>".escape($row['status'])."</span></td>\n";
echo " <td class='hide-md-dn'>".escape($row['ping-time'])."</td>\n";
echo " <td class='hide-md-dn'>".escape($row['sip_profile_name'])."</td>\n";
echo " <td class='action-button'>\n";
echo button::create(['type'=>'submit','title'=>$text['button-unregister'],'icon'=>'user-slash fa-fw','onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('unregister'); list_form_submit('form_list')"]);
echo button::create(['type'=>'submit','title'=>$text['button-provision'],'icon'=>'fax fa-fw','onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('provision'); list_form_submit('form_list')",'style'=>'margin-left: 0; margin-right: 0;']);
echo button::create(['type'=>'submit','title'=>$text['button-reboot'],'icon'=>'power-off fa-fw','onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('reboot'); list_form_submit('form_list')"]);
echo "</td>\n";
echo "</tr>\n";
$x++;
}
}
//get the list
$sql = "select sip_profile_name as name from v_sip_profiles ";
$database = new database;
$sip_profiles = $database->select($sql, null, 'all');
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
//user registrations
if (isset($action)) {
if (is_array($registrations)) {
foreach ($registrations as $row) {
if ($fp) {
//validate the profile
foreach($sip_profiles as $field) {
if ($field['name'] == $row['profile']) {
$profile = $row['profile'];
}
}
//validate the user
if (strlen($row['user']) > 0) {
$user = preg_replace('#[^a-zA-Z0-9_\-\.\@]#', '', $row['user']);
}
//validate the host
if (strlen($row['host']) > 0) {
$host = preg_replace('#[^a-zA-Z0-9_\-\.]#', '', $row['host']);
}
//get the vendor
$vendor = device::get_vendor_by_agent($row['agent']);
//prepare and send the command
if (strlen($profile) > 0 && strlen($user) > 0) {
if ($action == "unregister") {
$command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot";
}
if (strlen($vendor) > 0 && $action == "provision" && strlen($host) > 0) {
$command = "lua app.lua event_notify ".$profile." check_sync ".$user." ".$vendor." ".$host;
}
if (strlen($vendor) > 0 && $action == "reboot" && strlen($host) > 0) {
$command = "lua app.lua event_notify ".$profile." reboot ".$user." ".$vendor." ".$host;
}
$response = event_socket_request($fp, "api ".$command);
$response = event_socket_request($fp, "api log notice ".$command);
}
}
}
}
}
unset($registrations);
//show the response
if (isset($response)) {
message::add($text['label-event']." ".escape(ucwords($cmd))."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$text['label-response'].escape($response));
}
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
//define variables
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
//show the error message or show the content
if (strlen($msg) > 0) {
echo "<div style='align: center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
echo "<th align='left'>".$text['label-message']."</th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='row_style1'><strong>$msg</strong></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
}
else {
//get the registrations
$obj = new registrations;
$registrations = $obj->get($profile);
//count the registrations
$registration_count = 0;
if (is_array($registrations)) {
foreach ($registrations as $row) {
$matches = preg_grep ("/$search/i",$row);
if ($matches != FALSE) {
$registration_count++;
}
}
}
//define the checkbox_toggle function
echo "<script type=\"text/javascript\">\n";
echo " function checkbox_toggle(item) {\n";
echo " var inputs = document.getElementsByTagName(\"input\");\n";
echo " for (var i = 0, max = inputs.length; i < max; i++) {\n";
echo " if (inputs[i].type === 'checkbox') {\n";
echo " if (document.getElementById('checkbox_all').checked == true) { \n";
echo " inputs[i].checked = true;\n";
echo " }\n";
echo " else {\n";
echo " inputs[i].checked = false;\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo "</script>\n";
//show the registrations
echo "<form method='post' action=''>\n";
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
echo "<tr>\n";
echo "<td width='100%'>\n";
echo " <b>".$text['header-registrations']." (".escape($registration_count).")</b>\n";
echo "</td>\n";
echo "<td nowrap='nowrap' style='padding-right: 15px;'>";
if ($template) {
echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".escape($search)."'>";
echo " <input type='hidden' name='show' value='".escape($show)."'>";
echo " <input type='hidden' name='profile' value='".escape($sip_profile_name)."'>";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
}
echo "</td>";
echo "<td valign='top' nowrap='nowrap'>";
if (permission_exists('registration_all')) {
if ($template) {
$location = 'registrations.php';
}
else {
$location = 'registration_reload.php';
}
if ($show == "all") {
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='".escape($location)."?profile=".escape($sip_profile_name)."'\" value='".$text['button-back']."'>\n";
}
else {
echo " <input type='button' class='btn' name='' alt='".$text['button-show_all']."' onclick=\"window.location='".escape($location)."?profile=".escape($sip_profile_name)."&show=all'\" value='".$text['button-show_all']."'>\n";
}
}
if ($template) {
echo " <input type='button' class='btn' name='' alt='".$text['button-refresh']."' onclick=\"window.location='".escape($location)."?search=".escape($search)."&show=".escape($show)."'\" value='".$text['button-refresh']."'>\n";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
echo "<tr>\n";
echo " <th style='width:30px; vertical-align:middle; display: table-cell;'>\n";
echo " <input type='checkbox' name='checkbox_all' id='checkbox_all' style='' value='' onclick=\"checkbox_toggle();\">";
echo " </th>\n";
echo " <th>".$text['label-user']."</th>\n";
echo " <th>".$text['label-agent']."</th>\n";
echo " <th>".$text['label-contact']."</th>\n";
echo " <th>".$text['label-lan_ip']."</th>\n";
echo " <th>".$text['label-ip']."</th>\n";
echo " <th>".$text['label-port']."</th>\n";
echo " <th>".$text['label-hostname']."</th>\n";
echo " <th>".$text['label-status']."</th>\n";
echo " <th>".$text['label-ping']."</th>\n";
echo " <th>".$text['label-sip_profile_name']."</th>\n";
echo " <th>".$text['label-tools']."&nbsp;</th>\n";
echo "</tr>\n";
//order the array
require_once "resources/classes/array_order.php";
$order = new array_order();
$registrations = $order->sort($registrations, 'sip-auth-realm', 'user');
//display the array
if (is_array($registrations)) {
$x = 0;
foreach ($registrations as $row) {
//search
$matches = preg_grep ("/$search/i",$row);
if ($matches != FALSE) {
//set the user agent
$agent = $row['agent'];
//set the user id
$user_id = str_replace('@', '_', $row['user']);
//show the registrations
echo "<tr>\n";
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='vertical-align:middle; display: table-cell; align: center;'>\n";
echo " <input type='checkbox' name=\"registrations[$x][checked]\" id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('chk_all_".escape($row['user'])."').checked = false; }\">\n";
echo " <input type='hidden' name=\"registrations[$x][user]\" value='".escape($row['user'])."' />\n";
echo " <input type='hidden' name=\"registrations[$x][profile]\" value='".escape($row['sip_profile_name'])."' />\n";
echo " <input type='hidden' name=\"registrations[$x][agent]\" value='".escape($row['agent'])."' />\n";
echo " <input type='hidden' name=\"registrations[$x][host]\" value='".escape($row['host'])."' />\n";
echo " <input type='hidden' name=\"registrations[$x][domain]\" value='".escape($row['sip-auth-realm'])."' />\n";
echo " </td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['user'])."&nbsp;</td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['agent'])."&nbsp;</td>\n";
echo " <td class='".$row_style[$c]."'>".escape(explode('"',$row['contact'])[1])."</td>\n";
echo " <td class='".$row_style[$c]."'><a href='https://".escape($row['lan-ip'])."' target='_blank'>".escape($row['lan-ip'])."</a></td>\n";
echo " <td class='".$row_style[$c]."'><a href='https://".escape($row['network-ip'])."' target='_blank'>".escape($row['network-ip'])."</a></td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['network-port'])."</td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['host'])."</td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['status'])."</td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['ping-time'])."</td>\n";
echo " <td class='".$row_style[$c]."'>".escape($row['sip_profile_name'])."</td>\n";
echo " <td class='".$row_style[$c]."' style='text-align: right;' nowrap='nowrap'>\n";
echo " <button type='submit' class='btn-default' name=\"registrations[$x][action]\" value='unregister'>".$text['button-unregister']."</button>\n";
echo " <button type='submit' class='btn-default' name=\"registrations[$x][action]\" value='provision'>".$text['button-provision']."</button>\n";
echo " <button type='submit' class='btn-default' name=\"registrations[$x][action]\" value='reboot'>".$text['button-reboot']."</button>\n";
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
$x++;
}
}
}
echo "</table>\n";
echo "<input type='hidden' name=\"show\" value='".escape($show)."' />\n";
echo "</form>\n";
//close the connection and unset the variable
fclose($fp);
unset($xml);
}
echo "</form>\n";
//get the footer
if ($template) {
if (!$reload) {
require_once "resources/footer.php";
}
?>
?>

View File

@@ -1,22 +1,56 @@
<?php
/*
FusionPBX
Version: MPL 1.1
/**
* registrations class
*
* @method array get
*/
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>
Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//define the registrations class
if (!class_exists('registrations')) {
class registrations {
/**
* Called when the object is created
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
/**
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'registrations';
$this->app_uuid = '5d9e7cd7-629e-3553-4cf5-f26e39fefa39';
$this->permission_prefix = 'registration_';
$this->list_page = 'registrations.php';
}
/**
* Called when there are no references to a particular object
* called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
@@ -204,13 +238,156 @@ if (!class_exists('registrations')) {
return $count;
}
}
/**
* unregister registrations
*/
public function unregister($registrations) {
$this->switch('unregister', $registrations);
}
/**
* provision registrations
*/
public function provision($registrations) {
$this->switch('provision', $registrations);
}
/**
* reboot registrations
*/
public function reboot($registrations) {
$this->switch('reboot', $registrations);
}
/**
* switch api calls
*/
private function switch($action, $records) {
if (permission_exists($this->permission_prefix.'domain') || permission_exists($this->permission_prefix.'all') || if_group('superadmin')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//filter out unchecked registrations
if (is_array($records) && @sizeof($records) != 0) {
foreach($records as $record) {
if (
$record['checked'] == 'true' &&
$record['user'] != '' &&
$record['profile'] != ''
) {
$registrations[] = $record;
}
}
}
//process checked registrations
if (is_array($registrations) && @sizeof($registrations) != 0) {
//retrieve sip profiles list
$sql = "select sip_profile_name as name from v_sip_profiles ";
$database = new database;
$sip_profiles = $database->select($sql, null, 'all');
unset($sql);
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
//loop through registrations
if ($fp) {
foreach ($registrations as $registration) {
//validate the submitted profile
if ($registration['profile'] != '' && is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
foreach ($sip_profiles as $field) {
if ($field['name'] == $registration['profile']) {
$profile = $registration['profile'];
break;
}
}
}
else {
header('Location: '.$this->list_page);
exit;
}
//validate the submitted user
if ($registration['user'] != '') {
$user = preg_replace('#[^a-zA-Z0-9_\-\.\@]#', '', $registration['user']);
}
//validate the submitted host
if ($registration['host'] != '') {
$host = preg_replace('#[^a-zA-Z0-9_\-\.]#', '', $registration['host']);
}
//lookup vendor by agent
if ($registration['agent'] != '') {
$vendor = device::get_vendor_by_agent($registration['agent']);
}
//prepare the api command
if ($profile && $user) {
switch ($action) {
case 'unregister':
$command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot";
$response_message = $text['message-registrations_unregistered'];
break;
case 'provision':
if ($vendor && $host) {
$command = "lua app.lua event_notify ".$profile." check_sync ".$user." ".$vendor." ".$host;
$response_message = $text['message-registrations_provisioned'];
}
break;
case 'reboot':
if ($vendor && $host) {
$command = "lua app.lua event_notify ".$profile." reboot ".$user." ".$vendor." ".$host;
$response_message = $text['message-registrations_rebooted'];
}
break;
default:
header('Location: '.$this->list_page);
exit;
}
}
//send the api command
if ($command && $fp) {
$response_api[$registration['user']]['command'] = event_socket_request($fp, "api ".$command);
$response_api[$registration['user']]['log'] = event_socket_request($fp, "api log notice ".$command);
}
}
//set message
if (is_array($response_api)) {
$message = $response_message;
foreach ($response_api as $registration_user => $response) {
$message .= "<br>\n<strong>".$registration_user."</strong>: ".$response['command'];
}
message::add($message, 'positive', '7000');
}
}
else {
message::add($text['error-event-socket'], 'negative', 5000);
}
}
}
} //method
} //class
}
/*
$obj = new registrations;
$registrations = $obj->get('all');
print($registrations);
*/
?>
?>