Portions created by the Initial Developer are Copyright (C) 2008-2019 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists("registration_domain") || permission_exists("registration_all") || if_group("superadmin")) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get common submitted data $show = $_REQUEST['show']; $search = $_REQUEST['search']; $profile = $_REQUEST['profile']; //define query string array if ($show) { $qs['show'] = "&show=".urlencode($show); } 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']; } //process posted data if ($action != '' && is_array($registrations) && @sizeof($registrations) != 0) { $obj = new registrations; switch ($action) { case 'unregister': $obj->unregister($registrations); break; case 'provision': $obj->provision($registrations); break; case 'reboot': $obj->reboot($registrations); break; } header('Location: registrations.php'.($show || $search || $profile ? '?' : null).$qs['show'].$qs['search'].$qs['profile']); exit; } //get the registrations $obj = new registrations; $obj->show = $show; $registrations = $obj->get($profile); //order the array require_once "resources/classes/array_order.php"; $order = new array_order(); $registrations = $order->sort($registrations, 'sip-auth-realm', 'user'); //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 = ($reload ? 'registration_reload.php' : 'registrations.php'); //include the header if (!$reload) { $document['title'] = $text['header-registrations']; require_once "resources/header.php"; } //show the content echo "
\n"; echo "
".$text['header-registrations']." (".$num_rows.")
\n"; echo "
\n"; if (!$reload) { echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$_SESSION['theme']['button_icon_refresh'],'link'=>$location.($qs ? '?' : null).$qs['show'].$qs['search'].$qs['profile']]); } if ($registrations) { echo button::create(['type'=>'button','label'=>$text['button-unregister'],'title'=>$text['button-unregister'],'icon'=>'user-slash','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-unregister','btn_unregister');"]); echo button::create(['type'=>'button','label'=>$text['button-provision'],'title'=>$text['button-provision'],'icon'=>'fax','onclick'=>"modal_open('modal-provision','btn_provision');"]); echo button::create(['type'=>'button','label'=>$text['button-reboot'],'title'=>$text['button-reboot'],'icon'=>'power-off','onclick'=>"modal_open('modal-reboot','btn_reboot');"]); } echo "\n"; echo "
\n"; echo "
\n"; echo "
\n"; if ($registrations) { echo modal::create(['id'=>'modal-unregister','type'=>'general','message'=>$text['confirm-unregister'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_unregister','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('unregister'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-provision','type'=>'general','message'=>$text['confirm-provision'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_provision','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('provision'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-reboot','type'=>'general','message'=>$text['confirm-reboot'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_reboot','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('reboot'); list_form_submit('form_list');"])]); } echo $text['description-registrations']."\n"; echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if (is_array($registrations) && @sizeof($registrations) != 0) { $x = 0; foreach ($registrations as $row) { $matches = preg_grep('/'.$search.'/i', $row); if ($matches != false) { //prepare the user variable $user = explode('@', $row['user']); if ($user[1] == $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name']) { $user = "".escape($row['user'])."".escape($user[0]).""; } else { $user = escape($row['user']); } //reformat the status $patterns = array(); $patterns[] = '/(\d{4})-(\d{2})-(\d{2})/'; $patterns[] = '/(\d{2}):(\d{2}):(\d{2})/'; $patterns[] = '/unknown/'; $patterns[] = '/exp\(/'; $patterns[] = '/\(/'; $patterns[] = '/\)/'; $patterns[] = '/\s+/'; $status = preg_replace($patterns, ' ', $row['status']); //show the content echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; $x++; } } } unset($registrations); echo "
\n"; echo " \n"; echo " ".$text['label-user']."".$text['label-agent']."".$text['label-contact']."".$text['label-lan_ip']."".$text['label-ip']."".$text['label-port']."".$text['label-hostname']."".$text['label-status']."".$text['label-ping']."".$text['label-sip_profile_name']." 
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " ".$user."".escape($row['agent'])."".escape(explode('"',$row['contact'])[1])."".escape($row['network-port'])."".escape($row['host'])."".escape($status)."".escape($row['ping-time'])."".escape($row['sip_profile_name'])."\n"; if ($_SESSION['registrations']['list_row_button_unregister']['boolean'] == 'true') { echo button::create(['type'=>'submit','title'=>$text['button-unregister'],'icon'=>'user-slash fa-fw','style'=>'margin-left: 2px; margin-right: 0;','onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('unregister'); list_form_submit('form_list')"]); } if ($_SESSION['registrations']['list_row_button_provision']['boolean'] == 'true') { echo button::create(['type'=>'submit','title'=>$text['button-provision'],'icon'=>'fax fa-fw','style'=>'margin-left: 2px; margin-right: 0;','onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('provision'); list_form_submit('form_list')"]); } if ($_SESSION['registrations']['list_row_button_reboot']['boolean'] == 'true') { echo button::create(['type'=>'submit','title'=>$text['button-reboot'],'icon'=>'power-off fa-fw','style'=>'margin-left: 2px; margin-right: 0;','onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('reboot'); list_form_submit('form_list')"]); } echo "
\n"; echo "
\n"; echo "
".$paging_controls."
\n"; echo "\n"; echo "
\n"; //get the footer if (!$reload) { require_once "resources/footer.php"; } ?>