Remove carriage return per line and leave only line feeds

This commit is contained in:
markjcrane 2024-09-19 17:24:16 -06:00
parent 26530d6fe0
commit 00c0fbe06d
13 changed files with 5412 additions and 5412 deletions

View File

@ -1,356 +1,356 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2024 Portions created by the Initial Developer are Copyright (C) 2018-2024
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//check permissions //check permissions
if (permission_exists('call_recording_view')) { if (permission_exists('call_recording_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//add the settings object //add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]); $settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
$transcribe_enabled = $settings->get('transcribe', 'enabled', 'false'); $transcribe_enabled = $settings->get('transcribe', 'enabled', 'false');
$transcribe_engine = $settings->get('transcribe', 'engine', ''); $transcribe_engine = $settings->get('transcribe', 'engine', '');
//set additional variables //set additional variables
$search = $_GET["search"] ?? ''; $search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? ''; $show = $_GET["show"] ?? '';
//get the http post data //get the http post data
if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) { if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) {
$action = $_POST['action']; $action = $_POST['action'];
$search = $_POST['search']; $search = $_POST['search'];
$call_recordings = $_POST['call_recordings']; $call_recordings = $_POST['call_recordings'];
} }
//process the http post data by action //process the http post data by action
if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) { if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) {
switch ($action) { switch ($action) {
case 'download': case 'download':
if (permission_exists('call_recording_download')) { if (permission_exists('call_recording_download')) {
$obj = new call_recordings; $obj = new call_recordings;
$obj->download($call_recordings); $obj->download($call_recordings);
} }
break; break;
case 'transcribe': case 'transcribe':
if (permission_exists('call_recording_download')) { if (permission_exists('call_recording_download')) {
$obj = new call_recordings; $obj = new call_recordings;
$obj->transcribe($call_recordings); $obj->transcribe($call_recordings);
} }
break; break;
case 'delete': case 'delete':
if (permission_exists('call_recording_delete')) { if (permission_exists('call_recording_delete')) {
$obj = new call_recordings; $obj = new call_recordings;
$obj->delete($call_recordings); $obj->delete($call_recordings);
} }
break; break;
} }
//redirect the user //redirect the user
header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null)); header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null));
exit; exit;
} }
//get order and order by //get order and order by
$order_by = $_GET["order_by"] ?? ''; $order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? ''; $order = $_GET["order"] ?? '';
//add the search string //add the search string
if (!empty($search)) { if (!empty($search)) {
$search = strtolower($_GET["search"]); $search = strtolower($_GET["search"]);
} }
//set the time zone //set the time zone
if (!empty($_SESSION['domain']['time_zone']['name'])) { if (!empty($_SESSION['domain']['time_zone']['name'])) {
$time_zone = $_SESSION['domain']['time_zone']['name']; $time_zone = $_SESSION['domain']['time_zone']['name'];
} }
else { else {
$time_zone = date_default_timezone_get(); $time_zone = date_default_timezone_get();
} }
$parameters['time_zone'] = $time_zone; $parameters['time_zone'] = $time_zone;
//get the count //get the count
//$sql = "select count(*) "; //$sql = "select count(*) ";
//$sql .= "from view_call_recordings "; //$sql .= "from view_call_recordings ";
//$sql .= "where true "; //$sql .= "where true ";
//if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) { //if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) {
// $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; // $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
// $parameters['domain_uuid'] = $_SESSION['domain_uuid']; // $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
//} //}
//if (isset($search)) { //if (isset($search)) {
// $sql .= "and ("; // $sql .= "and (";
// $sql .= " lower(call_recording_name) like :search "; // $sql .= " lower(call_recording_name) like :search ";
// $sql .= " or lower(call_recording_path) like :search "; // $sql .= " or lower(call_recording_path) like :search ";
// $sql .= ") "; // $sql .= ") ";
// $parameters['search'] = '%'.$search.'%'; // $parameters['search'] = '%'.$search.'%';
//} //}
//$database = new database; //$database = new database;
//$num_rows = $database->select($sql, $parameters, 'column'); //$num_rows = $database->select($sql, $parameters, 'column');
//prepare some of the paging values //prepare some of the paging values
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$page = $_GET['page'] ?? ''; $page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; } if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list //get the list
$sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, "; $sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, ";
$sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, "; $sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, ";
$sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, "; $sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, ";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n"; $sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n"; $sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n";
$sql .= "from view_call_recordings as r, v_domains as d "; $sql .= "from view_call_recordings as r, v_domains as d ";
//$sql .= "from v_call_recordings as r, v_domains as d "; //$sql .= "from v_call_recordings as r, v_domains as d ";
$sql .= "where true "; $sql .= "where true ";
if ($show != "all" || !permission_exists('call_recording_all')) { if ($show != "all" || !permission_exists('call_recording_all')) {
$sql .= "and (r.domain_uuid = :domain_uuid or r.domain_uuid is null) "; $sql .= "and (r.domain_uuid = :domain_uuid or r.domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
} }
$sql .= "and r.domain_uuid = d.domain_uuid "; $sql .= "and r.domain_uuid = d.domain_uuid ";
if (!empty($search)) { if (!empty($search)) {
$sql .= "and ("; $sql .= "and (";
$sql .= " lower(r.call_direction) like :search "; $sql .= " lower(r.call_direction) like :search ";
$sql .= " or lower(r.caller_id_name) like :search "; $sql .= " or lower(r.caller_id_name) like :search ";
$sql .= " or lower(r.caller_id_number) like :search "; $sql .= " or lower(r.caller_id_number) like :search ";
$sql .= " or lower(r.caller_destination) like :search "; $sql .= " or lower(r.caller_destination) like :search ";
$sql .= " or lower(r.destination_number) like :search "; $sql .= " or lower(r.destination_number) like :search ";
$sql .= " or lower(r.call_recording_name) like :search "; $sql .= " or lower(r.call_recording_name) like :search ";
$sql .= " or lower(r.call_recording_path) like :search "; $sql .= " or lower(r.call_recording_path) like :search ";
$sql .= ") "; $sql .= ") ";
$parameters['search'] = '%'.$search.'%'; $parameters['search'] = '%'.$search.'%';
} }
$sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc'); $sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset); $sql .= limit_offset($rows_per_page, $offset);
$database = new database; $database = new database;
$call_recordings = $database->select($sql, $parameters ?? null, 'all'); $call_recordings = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//detect if any transcriptions available //detect if any transcriptions available
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings) && is_array($call_recordings)) { if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings) && is_array($call_recordings)) {
$transcriptions_exists = false; $transcriptions_exists = false;
foreach ($call_recordings as $row) { foreach ($call_recordings as $row) {
if (!empty($row['call_recording_transcription'])) { $transcriptions_exists = true; } if (!empty($row['call_recording_transcription'])) { $transcriptions_exists = true; }
} }
} }
//count the results //count the results
$result_count = is_array($call_recordings) ? sizeof($call_recordings) : 0; $result_count = is_array($call_recordings) ? sizeof($call_recordings) : 0;
//limit the number of results //limit the number of results
if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) { if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) {
$num_rows = $_SESSION['cdr']['limit']['numeric']; $num_rows = $_SESSION['cdr']['limit']['numeric'];
} }
//prepare to page the results //prepare to page the results
$param = "&search=".urlencode($search); $param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_recording_all')) { if ($show == "all" && permission_exists('call_recording_all')) {
$param .= "&show=all"; $param .= "&show=all";
} }
list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//include the header //include the header
$document['title'] = $text['title-call_recordings']; $document['title'] = $text['title-call_recordings'];
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-call_recordings']." </b></div>\n"; echo " <div class='heading'><b>".$text['title-call_recordings']." </b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
if (permission_exists('call_recording_download') && !empty($call_recordings)) { if (permission_exists('call_recording_download') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'id'=>'btn_download','name'=>'btn_download','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]); echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'id'=>'btn_download','name'=>'btn_download','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]);
} }
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings)) { if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('transcribe'); list_form_submit('form_list');"]); echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('transcribe'); list_form_submit('form_list');"]);
} }
if (permission_exists('call_recording_delete') && !empty($call_recordings)) { if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]); echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]);
} }
echo "<form id='form_search' class='inline' method='get'>\n"; echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('call_recording_all')) { if (permission_exists('call_recording_all')) {
if ($show == 'all') { if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>"; echo " <input type='hidden' name='show' value='all'>";
} }
else { else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]); echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
} }
} }
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">"; echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']); echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
if (!empty($paging_controls_mini)) { if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n"; echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
} }
echo " </form>\n"; echo " </form>\n";
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
if (permission_exists('call_recording_delete') && !empty($call_recordings)) { if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
} }
echo $text['title_description-call_recordings']."\n"; echo $text['title_description-call_recordings']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n"; echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\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='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table class='list'>\n"; echo "<table class='list'>\n";
echo "<tr class='list-header'>\n"; echo "<tr class='list-header'>\n";
$col_count = 8; $col_count = 8;
if ($show == "all" && permission_exists('call_recording_all')) { if ($show == "all" && permission_exists('call_recording_all')) {
$col_count++; $col_count++;
} }
if (permission_exists('call_recording_delete')) { if (permission_exists('call_recording_delete')) {
echo " <th class='checkbox'>\n"; echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n"; echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n"; echo " </th>\n";
$col_count++; $col_count++;
} }
if ($show == "all" && permission_exists('call_recording_all')) { if ($show == "all" && permission_exists('call_recording_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='hide-sm-dn shrink'"); echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='hide-sm-dn shrink'");
} }
echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn'"); echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-15'"); echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-15'");
echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='pct-10 hide-sm-dn'"); echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='pct-10 hide-sm-dn'");
echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='pct-10'"); echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='pct-10'");
echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-20 hide-sm-dn'"); echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-20 hide-sm-dn'");
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) { if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo "<th class='shrink center'>".$text['label-recording']."</th>\n"; echo "<th class='shrink center'>".$text['label-recording']."</th>\n";
$col_count++; $col_count++;
} }
echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'"); echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'");
echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='pct-20 center'"); echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='pct-20 center'");
echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'"); echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'");
if (permission_exists('xml_cdr_details')) { if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>&nbsp;</td>\n"; echo " <td class='action-button'>&nbsp;</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
if (is_array($call_recordings) && @sizeof($call_recordings) != 0) { if (is_array($call_recordings) && @sizeof($call_recordings) != 0) {
$x = 0; $x = 0;
foreach ($call_recordings as $row) { foreach ($call_recordings as $row) {
//add padding to the call recording length //add padding to the call recording length
$call_recording_length_padding = (!empty($row['call_recording_length'])) ? str_pad($row['call_recording_length'], 2, '0', STR_PAD_LEFT) : ''; $call_recording_length_padding = (!empty($row['call_recording_length'])) ? str_pad($row['call_recording_length'], 2, '0', STR_PAD_LEFT) : '';
//playback progress bar //playback progress bar
if (permission_exists('call_recording_play')) { if (permission_exists('call_recording_play')) {
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;' onclick=\"recording_play('".escape($row['call_recording_uuid'])."')\"><td id='playback_progress_bar_background_".escape($row['call_recording_uuid'])."' class='playback_progress_bar_background' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n"; echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;' onclick=\"recording_play('".escape($row['call_recording_uuid'])."')\"><td id='playback_progress_bar_background_".escape($row['call_recording_uuid'])."' class='playback_progress_bar_background' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
} }
if (permission_exists('call_recording_play')) { if (permission_exists('call_recording_play')) {
$list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');"; $list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');";
} }
echo "<tr class='list-row' href=\"".$list_row_url."\">\n"; echo "<tr class='list-row' href=\"".$list_row_url."\">\n";
if (permission_exists('call_recording_delete')) { if (permission_exists('call_recording_delete')) {
echo " <td class='checkbox'>\n"; echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n"; echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n"; echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n";
echo " </td>\n"; echo " </td>\n";
} }
if ($show == "all" && permission_exists('call_recording_all')) { if ($show == "all" && permission_exists('call_recording_all')) {
echo " <td class='overflow hide-sm-dn shrink'>".escape($row['domain_name'])."</td>\n"; echo " <td class='overflow hide-sm-dn shrink'>".escape($row['domain_name'])."</td>\n";
} }
echo " <td class='hide-sm-dn shrink'>".escape($row['caller_id_name'])."</td>\n"; echo " <td class='hide-sm-dn shrink'>".escape($row['caller_id_name'])."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['caller_id_number'], 0, 20)))."</td>\n"; echo " <td class='shrink'>".escape(format_phone(substr($row['caller_id_number'], 0, 20)))."</td>\n";
echo " <td class='hide-sm-dn shrink'>".escape(format_phone(substr($row['caller_destination'], 0, 20)))."</td>\n"; echo " <td class='hide-sm-dn shrink'>".escape(format_phone(substr($row['caller_destination'], 0, 20)))."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['destination_number'], 0, 20)))."</td>\n"; echo " <td class='shrink'>".escape(format_phone(substr($row['destination_number'], 0, 20)))."</td>\n";
echo " <td class='overflow hide-sm-dn nowrap'>".escape($row['call_recording_name'])."</td>\n"; echo " <td class='overflow hide-sm-dn nowrap'>".escape($row['call_recording_name'])."</td>\n";
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) { if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo " <td class='middle button center no-link no-wrap'>"; echo " <td class='middle button center no-link no-wrap'>";
if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) { if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) {
if (permission_exists('call_recording_play')) { if (permission_exists('call_recording_play')) {
$recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION); $recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION);
switch ($recording_file_ext) { switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break; case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break; case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break; case "ogg" : $recording_type = "audio/ogg"; break;
} }
echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>"; echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]); echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]);
} }
if (permission_exists('call_recording_download')) { if (permission_exists('call_recording_download')) {
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']); echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']);
} }
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && $transcriptions_exists === true) { if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && $transcriptions_exists === true) {
echo button::create(['type'=>'button','title'=>$text['label-transcription'],'icon'=>'quote-right','style'=>(empty($row['call_recording_transcription']) ? 'visibility:hidden;' : null),'onclick'=>"document.getElementById('transcription_".$row['call_recording_uuid']."').style.display = document.getElementById('transcription_".$row['call_recording_uuid']."').style.display == 'none' ? 'table-row' : 'none'; this.blur(); return false;"]); echo button::create(['type'=>'button','title'=>$text['label-transcription'],'icon'=>'quote-right','style'=>(empty($row['call_recording_transcription']) ? 'visibility:hidden;' : null),'onclick'=>"document.getElementById('transcription_".$row['call_recording_uuid']."').style.display = document.getElementById('transcription_".$row['call_recording_uuid']."').style.display == 'none' ? 'table-row' : 'none'; this.blur(); return false;"]);
} }
} }
echo " </td>\n"; echo " </td>\n";
} }
echo " <td class='right overflow hide-sm-dn shrink'>".($row['call_recording_length'] <= 59 ? '0:' : null).escape($call_recording_length_padding)."</td>\n"; echo " <td class='right overflow hide-sm-dn shrink'>".($row['call_recording_length'] <= 59 ? '0:' : null).escape($call_recording_length_padding)."</td>\n";
echo " <td class='overflow center no-wrap'>".escape($row['call_recording_date_formatted'])." <span class='hide-sm-dn'>".escape($row['call_recording_time_formatted'])."</span></td>\n"; echo " <td class='overflow center no-wrap'>".escape($row['call_recording_date_formatted'])." <span class='hide-sm-dn'>".escape($row['call_recording_time_formatted'])."</span></td>\n";
echo " <td class='left hide-sm-dn shrink'>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n"; echo " <td class='left hide-sm-dn shrink'>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n";
if (permission_exists('xml_cdr_details')) { if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>\n"; echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]); echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]);
echo " </td>\n"; echo " </td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($row['call_recording_transcription'])) { if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($row['call_recording_transcription'])) {
echo "<tr style='display: none;'><td></td></tr>\n"; // dummy row to maintain same background color for transcription row echo "<tr style='display: none;'><td></td></tr>\n"; // dummy row to maintain same background color for transcription row
echo "<tr id='transcription_".$row['call_recording_uuid']."' class='list-row' style='display: none;'>\n"; echo "<tr id='transcription_".$row['call_recording_uuid']."' class='list-row' style='display: none;'>\n";
echo " <td style='padding: 10px 20px 15px 20px;' colspan='".$col_count."'>\n"; echo " <td style='padding: 10px 20px 15px 20px;' colspan='".$col_count."'>\n";
echo " <strong style='display: inline-block; font-size: 90%; margin-bottom: 10px;'>".$text['label-transcription']."...</strong><br />\n"; echo " <strong style='display: inline-block; font-size: 90%; margin-bottom: 10px;'>".$text['label-transcription']."...</strong><br />\n";
echo escape($row['call_recording_transcription'])."\n"; echo escape($row['call_recording_transcription'])."\n";
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
} }
$x++; $x++;
} }
unset($call_recordings); unset($call_recordings);
} }
echo "</table>\n"; echo "</table>\n";
echo "</div>\n"; echo "</div>\n";
echo "<br />\n"; echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n"; echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n"; echo "</form>\n";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,48 +1,48 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016-2020 Portions created by the Initial Developer are Copyright (C) 2016-2020
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check permisions //check permisions
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) { if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//download //download
if (is_uuid($_GET['id'])) { if (is_uuid($_GET['id'])) {
$obj = new call_recordings; $obj = new call_recordings;
$obj->recording_uuid = $_GET['id']; $obj->recording_uuid = $_GET['id'];
$obj->binary = isset($_GET['binary']) ? true : false; $obj->binary = isset($_GET['binary']) ? true : false;
$obj->download(); $obj->download();
} }
?> ?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,384 +1,384 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2023 Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
*/ */
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check permissions //check permissions
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit')) { if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//set the defaults //set the defaults
$extension_uuid = ''; $extension_uuid = '';
$extension_setting_uuid = ''; $extension_setting_uuid = '';
$extension_setting_name = ''; $extension_setting_name = '';
$extension_setting_value = ''; $extension_setting_value = '';
$extension_setting_description = ''; $extension_setting_description = '';
//action add or update //action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
$extension_setting_uuid = $_REQUEST["id"]; $extension_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"]; $id = $_REQUEST["id"];
} }
else { else {
$action = "add"; $action = "add";
} }
//get the extension id //get the extension id
if (!empty($_REQUEST["extension_setting_uuid"]) && is_uuid($_REQUEST["extension_setting_uuid"])) { if (!empty($_REQUEST["extension_setting_uuid"]) && is_uuid($_REQUEST["extension_setting_uuid"])) {
$extension_setting_uuid = $_REQUEST["extension_setting_uuid"]; $extension_setting_uuid = $_REQUEST["extension_setting_uuid"];
} }
if (!empty($_REQUEST["extension_uuid"]) && is_uuid($_REQUEST["extension_uuid"])) { if (!empty($_REQUEST["extension_uuid"]) && is_uuid($_REQUEST["extension_uuid"])) {
$extension_uuid = $_REQUEST["extension_uuid"]; $extension_uuid = $_REQUEST["extension_uuid"];
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (!empty($_POST)) { if (!empty($_POST)) {
$domain_uuid = $_POST["domain_uuid"] ?? null; $domain_uuid = $_POST["domain_uuid"] ?? null;
$extension_setting_type = $_POST["extension_setting_type"]; $extension_setting_type = $_POST["extension_setting_type"];
$extension_setting_name = $_POST["extension_setting_name"]; $extension_setting_name = $_POST["extension_setting_name"];
$extension_setting_value = $_POST["extension_setting_value"]; $extension_setting_value = $_POST["extension_setting_value"];
$extension_setting_enabled = $_POST["extension_setting_enabled"] ?? 'false'; $extension_setting_enabled = $_POST["extension_setting_enabled"] ?? 'false';
$extension_setting_description = $_POST["extension_setting_description"]; $extension_setting_description = $_POST["extension_setting_description"];
} }
//process the user data and save it to the database //process the user data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) { if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php?id='.$extension_uuid); header('Location: extension_settings.php?id='.$extension_uuid);
exit; exit;
} }
//process the http post data by submitted action //process the http post data by submitted action
if (!empty($_POST['action'])) { if (!empty($_POST['action'])) {
//prepare the array(s) //prepare the array(s)
//send the array to the database class //send the array to the database class
switch ($_POST['action']) { switch ($_POST['action']) {
case 'copy': case 'copy':
if (permission_exists('extension_setting_add')) { if (permission_exists('extension_setting_add')) {
$obj = new database; $obj = new database;
$obj->copy($array); $obj->copy($array);
} }
break; break;
case 'delete': case 'delete':
if (permission_exists('extension_setting_delete')) { if (permission_exists('extension_setting_delete')) {
$obj = new database; $obj = new database;
$obj->delete($array); $obj->delete($array);
} }
break; break;
case 'toggle': case 'toggle':
if (permission_exists('extension_setting_update')) { if (permission_exists('extension_setting_update')) {
$obj = new database; $obj = new database;
$obj->toggle($array); $obj->toggle($array);
} }
break; break;
} }
//redirect the user //redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) { if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) {
header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid); header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid);
exit; exit;
} }
} }
//check for all required data //check for all required data
$msg = ''; $msg = '';
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; } //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; } if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; }
if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; } if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; }
//if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; } //if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; }
if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; } if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; }
//if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."<br>\n"; } //if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) { if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add the extension_setting_uuid //add the extension_setting_uuid
if (empty($extension_setting_uuid)) { if (empty($extension_setting_uuid)) {
$extension_setting_uuid = uuid(); $extension_setting_uuid = uuid();
} }
//prepare the array //prepare the array
$array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid; $array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid;
$array['extension_settings'][0]['extension_uuid'] = $extension_uuid; $array['extension_settings'][0]['extension_uuid'] = $extension_uuid;
$array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//$array['extension_settings'][0]['domain_uuid'] = $domain_uuid; //$array['extension_settings'][0]['domain_uuid'] = $domain_uuid;
$array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type; $array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type;
$array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name; $array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name;
$array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value; $array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value;
$array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled; $array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled;
$array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description; $array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description;
//save the data //save the data
$database = new database; $database = new database;
$database->app_name = 'extension settings'; $database->app_name = 'extension settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd'; $database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array); $database->save($array);
//clear the cache //clear the cache
$sql = "select extension, number_alias, user_context from v_extensions "; $sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid "; $sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid; $parameters['extension_uuid'] = $extension_uuid;
$database = new database; $database = new database;
$extension = $database->select($sql, $parameters, 'row'); $extension = $database->select($sql, $parameters, 'row');
$cache = new cache; $cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]); $cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]); $cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
//redirect the user //redirect the user
if (isset($action)) { if (isset($action)) {
if ($action == "add") { if ($action == "add") {
$_SESSION["message"] = $text['message-add']; $_SESSION["message"] = $text['message-add'];
} }
if ($action == "update") { if ($action == "update") {
$_SESSION["message"] = $text['message-update']; $_SESSION["message"] = $text['message-update'];
} }
//header('Location: extension_settings.php'); //header('Location: extension_settings.php');
header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid); header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid);
return; return;
} }
} }
//pre-populate the form //pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) { if (!empty($_GET) && empty($_POST["persistformvar"])) {
$sql = "select "; $sql = "select ";
//$sql .= "extension_uuid, "; //$sql .= "extension_uuid, ";
//$sql .= "domain_uuid, "; //$sql .= "domain_uuid, ";
$sql .= "extension_setting_uuid, "; $sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, "; $sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, "; $sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, "; $sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), "; $sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description "; $sql .= "extension_setting_description ";
$sql .= "from v_extension_settings "; $sql .= "from v_extension_settings ";
$sql .= "where extension_setting_uuid = :extension_setting_uuid "; $sql .= "where extension_setting_uuid = :extension_setting_uuid ";
//$sql .= "and domain_uuid = :domain_uuid "; //$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid']; //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_setting_uuid'] = $extension_setting_uuid ?? ''; $parameters['extension_setting_uuid'] = $extension_setting_uuid ?? '';
$database = new database; $database = new database;
$row = $database->select($sql, $parameters, 'row'); $row = $database->select($sql, $parameters, 'row');
if (!empty($row)) { if (!empty($row)) {
if (!empty($row["extension_uuid"]) && is_uuid($row["extension_uuid"])) { if (!empty($row["extension_uuid"]) && is_uuid($row["extension_uuid"])) {
$extension_uuid = $row["extension_uuid"]; $extension_uuid = $row["extension_uuid"];
} }
//$domain_uuid = $row["domain_uuid"]; //$domain_uuid = $row["domain_uuid"];
$extension_setting_type = $row["extension_setting_type"]; $extension_setting_type = $row["extension_setting_type"];
$extension_setting_name = $row["extension_setting_name"]; $extension_setting_name = $row["extension_setting_name"];
$extension_setting_value = $row["extension_setting_value"]; $extension_setting_value = $row["extension_setting_value"];
$extension_setting_enabled = $row["extension_setting_enabled"]; $extension_setting_enabled = $row["extension_setting_enabled"];
$extension_setting_description = $row["extension_setting_description"]; $extension_setting_description = $row["extension_setting_description"];
} }
unset($sql, $parameters, $row); unset($sql, $parameters, $row);
} }
//set the defaults //set the defaults
if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; } if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; }
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//show the header //show the header
$document['title'] = $text['title-extension_setting']; $document['title'] = $text['title-extension_setting'];
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n"; echo "<input class='formfld' type='hidden' name='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_setting']."</b></div>\n"; echo " <div class='heading'><b>".$text['title-extension_setting']."</b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'extension_settings.php?id='.$extension_uuid]); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'extension_settings.php?id='.$extension_uuid]);
if ($action == 'update') { if ($action == 'update') {
if (permission_exists('_add')) { if (permission_exists('_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
} }
if (permission_exists('_delete')) { if (permission_exists('_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
} }
} }
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']); echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
echo $text['title_description-extension_settings']."\n"; echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
if ($action == 'update') { if ($action == 'update') {
if (permission_exists('extension_setting_add')) { if (permission_exists('extension_setting_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]); echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
} }
if (permission_exists('extension_setting_delete')) { if (permission_exists('extension_setting_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
} }
} }
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//echo "<tr>\n"; //echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; //echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-domain_uuid']."\n"; //echo " ".$text['label-domain_uuid']."\n";
//echo "</td>\n"; //echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n"; //echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <select class='formfld' name='domain_uuid'>\n"; //echo " <select class='formfld' name='domain_uuid'>\n";
//if (empty($domain_uuid)) { //if (empty($domain_uuid)) {
// echo " <option value='' selected='selected'>".$text['select-global']."</option>\n"; // echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
//} //}
//else { //else {
// echo " <option value=''>".$text['label-global']."</option>\n"; // echo " <option value=''>".$text['label-global']."</option>\n";
//} //}
//foreach ($_SESSION['domains'] as $row) { //foreach ($_SESSION['domains'] as $row) {
// if ($row['domain_uuid'] == $domain_uuid) { // if ($row['domain_uuid'] == $domain_uuid) {
// echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n"; // echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
// } // }
// else { // else {
// echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n"; // echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
// } // }
//} //}
//echo " </select>\n"; //echo " </select>\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-domain_uuid']."\n"; //echo $text['description-domain_uuid']."\n";
//echo "</td>\n"; //echo "</td>\n";
//echo "</tr>\n"; //echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_type']."\n"; echo " ".$text['label-extension_setting_type']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_type'>\n"; echo " <select class='formfld' name='extension_setting_type'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if (!empty($extension_setting_type) && $extension_setting_type == "param") { if (!empty($extension_setting_type) && $extension_setting_type == "param") {
echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n"; echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n";
} }
else { else {
echo " <option value='param'>".$text['label-param']."</option>\n"; echo " <option value='param'>".$text['label-param']."</option>\n";
} }
if (!empty($extension_setting_type) && $extension_setting_type == "variable") { if (!empty($extension_setting_type) && $extension_setting_type == "variable") {
echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n"; echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n";
} }
else { else {
echo " <option value='variable'>".$text['label-variable']."</option>\n"; echo " <option value='variable'>".$text['label-variable']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-extension_setting_type']."\n"; echo $text['description-extension_setting_type']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_name']."\n"; echo " ".$text['label-extension_setting_name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n"; echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-extension_setting_name']."\n"; echo $text['description-extension_setting_name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_value']."\n"; echo " ".$text['label-extension_setting_value']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n"; echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-extension_setting_value']."\n"; echo $text['description-extension_setting_value']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_enabled']."\n"; echo " ".$text['label-extension_setting_enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') { if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n"; echo " <label class='switch'>\n";
echo " <input type='checkbox' id='extension_setting_enabled' name='extension_setting_enabled' value='true' ".($extension_setting_enabled == 'true' ? "checked='checked'" : null).">\n"; echo " <input type='checkbox' id='extension_setting_enabled' name='extension_setting_enabled' value='true' ".($extension_setting_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n"; echo " <span class='slider'></span>\n";
echo " </label>\n"; echo " </label>\n";
} }
else { else {
echo " <select class='formfld' id='extension_setting_enabled' name='extension_setting_enabled'>\n"; echo " <select class='formfld' id='extension_setting_enabled' name='extension_setting_enabled'>\n";
echo " <option value='true' ".($extension_setting_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n"; echo " <option value='true' ".($extension_setting_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($extension_setting_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n"; echo " <option value='false' ".($extension_setting_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n"; echo " </select>\n";
} }
echo "<br />\n"; echo "<br />\n";
echo $text['description-extension_setting_enabled']."\n"; echo $text['description-extension_setting_enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_description']."\n"; echo " ".$text['label-extension_setting_description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n"; echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-extension_setting_description']."\n"; echo $text['description-extension_setting_description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "</div>\n"; echo "</div>\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n"; echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>"; echo "</form>";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,334 +1,334 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2023 Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
*/ */
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check permissions //check permissions
if (permission_exists('extension_setting_view')) { if (permission_exists('extension_setting_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//set the defaults //set the defaults
$search = ''; $search = '';
$paging_controls = ''; $paging_controls = '';
$id = ''; $id = '';
//set from session variables //set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the http post data //get the http post data
if (!empty($_POST['extension_settings'])) { if (!empty($_POST['extension_settings'])) {
$action = $_POST['action']; $action = $_POST['action'];
$search = $_POST['search']; $search = $_POST['search'];
$extension_settings = $_POST['extension_settings']; $extension_settings = $_POST['extension_settings'];
} }
//action add or update //action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$extension_uuid = $_REQUEST["id"]; $extension_uuid = $_REQUEST["id"];
} }
//process the http post data by action //process the http post data by action
if (!empty($action) && !empty($extension_settings)) { if (!empty($action) && !empty($extension_settings)) {
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php'); header('Location: extension_settings.php');
exit; exit;
} }
//prepare the database object //prepare the database object
$obj = new extension_settings; $obj = new extension_settings;
//send the array to the database class //send the array to the database class
switch ($action) { switch ($action) {
case 'copy': case 'copy':
if (permission_exists('extension_setting_add')) { if (permission_exists('extension_setting_add')) {
$obj->copy($extension_settings); $obj->copy($extension_settings);
} }
break; break;
case 'toggle': case 'toggle':
if (permission_exists('extension_setting_edit')) { if (permission_exists('extension_setting_edit')) {
$obj->toggle($extension_settings); $obj->toggle($extension_settings);
} }
break; break;
case 'delete': case 'delete':
if (permission_exists('extension_setting_delete')) { if (permission_exists('extension_setting_delete')) {
$obj->extension_uuid = $extension_uuid; $obj->extension_uuid = $extension_uuid;
$obj->delete($extension_settings); $obj->delete($extension_settings);
} }
break; break;
} }
//redirect the user //redirect the user
header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($search != '' ? '?search='.urlencode($search) : null)); header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($search != '' ? '?search='.urlencode($search) : null));
exit; exit;
} }
//get order and order by //get order and order by
$order_by = $_GET["order_by"] ?? ''; $order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? ''; $order = $_GET["order"] ?? '';
//add the search //add the search
if (isset($_GET["search"])) { if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]); $search = strtolower($_GET["search"]);
} }
//get the count //get the count
$sql = "select count(extension_setting_uuid) "; $sql = "select count(extension_setting_uuid) ";
$sql .= "from v_extension_settings "; $sql .= "from v_extension_settings ";
$sql .= "where extension_uuid = :extension_uuid "; $sql .= "where extension_uuid = :extension_uuid ";
if (isset($search)) { if (isset($search)) {
$sql .= "and ("; $sql .= "and (";
$sql .= " lower(extension_setting_type) like :search "; $sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search "; $sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search "; $sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") "; $sql .= ") ";
$parameters['search'] = '%'.$search.'%'; $parameters['search'] = '%'.$search.'%';
} }
else { else {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (isset($sql_search)) { if (isset($sql_search)) {
$sql .= "and ".$sql_search; $sql .= "and ".$sql_search;
} }
$parameters['domain_uuid'] = $domain_uuid; $parameters['domain_uuid'] = $domain_uuid;
} }
$parameters['extension_uuid'] = $extension_uuid; $parameters['extension_uuid'] = $extension_uuid;
$database = new database; $database = new database;
$num_rows = $database->select($sql, $parameters, 'column'); $num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters); unset($sql, $parameters);
//get the list //get the list
$sql = "select "; $sql = "select ";
//$sql .= "d.domain_name, "; //$sql .= "d.domain_name, ";
$sql .= "extension_setting_uuid, "; $sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, "; $sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, "; $sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, "; $sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), "; $sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description "; $sql .= "extension_setting_description ";
$sql .= "from v_extension_settings as e "; $sql .= "from v_extension_settings as e ";
//$sql .= ",v_domains as d "; //$sql .= ",v_domains as d ";
$sql .= "where extension_uuid = :extension_uuid "; $sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) "; $sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) ";
//$sql .= "and d.domain_uuid = e.domain_uuid "; //$sql .= "and d.domain_uuid = e.domain_uuid ";
if (isset($_GET["search"])) { if (isset($_GET["search"])) {
$sql .= "and ("; $sql .= "and (";
$sql .= " lower(extension_setting_type) like :search "; $sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search "; $sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search "; $sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") "; $sql .= ") ";
$parameters['search'] = '%'.$search.'%'; $parameters['search'] = '%'.$search.'%';
} }
$sql .= order_by($order_by, $order, 'extension_setting_type', 'asc'); $sql .= order_by($order_by, $order, 'extension_setting_type', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null); $sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$parameters['extension_uuid'] = $extension_uuid; $parameters['extension_uuid'] = $extension_uuid;
$parameters['domain_uuid'] = $domain_uuid; $parameters['domain_uuid'] = $domain_uuid;
$database = new database; $database = new database;
$extension_settings = $database->select($sql, $parameters, 'all'); $extension_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//additional includes //additional includes
$document['title'] = $text['title-extension_settings']; $document['title'] = $text['title-extension_settings'];
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_settings']."</b><div class='count'>".number_format($num_rows)."</div></div>\n"; echo " <div class='heading'><b>".$text['title-extension_settings']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_add','name'=>'btn_add','style'=>'margin-right: 15px;','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_add','name'=>'btn_add','style'=>'margin-right: 15px;','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]);
if (permission_exists('extension_setting_add')) { if (permission_exists('extension_setting_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]); echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]);
} }
if (permission_exists('extension_setting_add') && $extension_settings) { if (permission_exists('extension_setting_add') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
} }
if (permission_exists('extension_setting_edit') && $extension_settings) { if (permission_exists('extension_setting_edit') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
} }
if (permission_exists('extension_setting_delete') && $extension_settings) { if (permission_exists('extension_setting_delete') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
} }
echo "<form id='form_search' class='inline' method='get'>\n"; echo "<form id='form_search' class='inline' method='get'>\n";
//if (permission_exists('extension_setting_all')) { //if (permission_exists('extension_setting_all')) {
// if ($_GET['show'] == 'all') { // if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n"; // echo " <input type='hidden' name='show' value='all'>\n";
// } // }
// else { // else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]); // echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]);
// } // }
//} //}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>"; 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'=>(!empty($search) ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'extension_settings.php?id='.$extension_uuid,'style'=>(empty($search) ? 'display: none;' : null)]); echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'extension_settings.php?id='.$extension_uuid,'style'=>(empty($search) ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) { if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n"; echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
} }
echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n"; echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n";
echo " </form>\n"; echo " </form>\n";
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
if (permission_exists('extension_setting_add') && $extension_settings) { if (permission_exists('extension_setting_add') && $extension_settings) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
} }
if (permission_exists('extension_setting_edit') && $extension_settings) { if (permission_exists('extension_setting_edit') && $extension_settings) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
} }
if (permission_exists('extension_setting_delete') && $extension_settings) { if (permission_exists('extension_setting_delete') && $extension_settings) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
} }
echo $text['title_description-extension_settings']."\n"; echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n"; echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\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='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table class='list'>\n"; echo "<table class='list'>\n";
if (!empty($extension_settings)) { if (!empty($extension_settings)) {
//define the variable //define the variable
$previous_extension_setting_type = ''; $previous_extension_setting_type = '';
//set the initial value //set the initial value
$x = 0; $x = 0;
//show the extension settings //show the extension settings
foreach ($extension_settings as $row) { foreach ($extension_settings as $row) {
$extension_setting_type = $row['extension_setting_type']; $extension_setting_type = $row['extension_setting_type'];
$extension_setting_type = strtolower($extension_setting_type); $extension_setting_type = strtolower($extension_setting_type);
$label_extension_setting_type = $row['extension_setting_type']; $label_extension_setting_type = $row['extension_setting_type'];
$label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type); $label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type);
$label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type); $label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type);
$label_extension_setting_type = ucwords($label_extension_setting_type); $label_extension_setting_type = ucwords($label_extension_setting_type);
if ($previous_extension_setting_type !== $row['extension_setting_type']) { if ($previous_extension_setting_type !== $row['extension_setting_type']) {
echo " <tr>"; echo " <tr>";
echo " <td align='left' colspan='999'>&nbsp;</td>\n"; echo " <td align='left' colspan='999'>&nbsp;</td>\n";
echo " </tr>"; echo " </tr>";
echo " <tr>"; echo " <tr>";
echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n"; echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n";
echo " </tr>"; echo " </tr>";
echo "<tr class='list-header'>\n"; echo "<tr class='list-header'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) { if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <th class='checkbox'>\n"; echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n"; echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n";
echo " </th>\n"; echo " </th>\n";
} }
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) { //if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); // echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//} //}
//echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order); //echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order);
//echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order); //echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order);
//echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order); //echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order);
//echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'"); //echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'");
echo " <th>".$text['label-extension_setting_type']."</th>\n"; echo " <th>".$text['label-extension_setting_type']."</th>\n";
echo " <th>".$text['label-extension_setting_name']."</th>\n"; echo " <th>".$text['label-extension_setting_name']."</th>\n";
echo " <th>".$text['label-extension_setting_value']."</th>\n"; echo " <th>".$text['label-extension_setting_value']."</th>\n";
echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n"; echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n"; echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') { if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n"; echo " <td class='action-button'>&nbsp;</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
} }
if (permission_exists('extension_setting_edit')) { if (permission_exists('extension_setting_edit')) {
$list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid); $list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid);
} }
echo "<tr class='list-row' href='".$list_row_url."'>\n"; echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) { if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <td class='checkbox'>\n"; echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n"; echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n";
echo " <input type='hidden' name='extension_settings[$x][uuid]' value='".escape($row['extension_setting_uuid'])."' />\n"; echo " <input type='hidden' name='extension_settings[$x][uuid]' value='".escape($row['extension_setting_uuid'])."' />\n";
echo " </td>\n"; echo " </td>\n";
} }
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) { //if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo " <td>".escape($row['domain_name'])."</td>\n"; // echo " <td>".escape($row['domain_name'])."</td>\n";
//} //}
echo " <td>".escape($row['extension_setting_type'])."</td>\n"; echo " <td>".escape($row['extension_setting_type'])."</td>\n";
echo " <td>".escape($row['extension_setting_name'])."</td>\n"; echo " <td>".escape($row['extension_setting_name'])."</td>\n";
echo " <td>".escape($row['extension_setting_value'])."</td>\n"; echo " <td>".escape($row['extension_setting_value'])."</td>\n";
if (permission_exists('extension_setting_edit')) { if (permission_exists('extension_setting_edit')) {
echo " <td class='no-link center'>\n"; echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n"; echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]); echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
} }
else { else {
echo " <td class='center'>\n"; echo " <td class='center'>\n";
echo $text['label-'.$row['extension_setting_enabled']]; echo $text['label-'.$row['extension_setting_enabled']];
} }
echo " </td>\n"; echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n"; echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') { if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n"; echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n"; echo " </td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
//set the previous category //set the previous category
$previous_extension_setting_type = $row['extension_setting_type']; $previous_extension_setting_type = $row['extension_setting_type'];
$x++; $x++;
} }
unset($extension_settings); unset($extension_settings);
} }
echo "</table>\n"; echo "</table>\n";
echo "</div>\n"; echo "</div>\n";
echo "<br />\n"; echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n"; echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n"; echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n"; echo "</form>\n";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,464 +1,464 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2020 Portions created by the Initial Developer are Copyright (C) 2018-2020
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check permissions //check permissions
if (permission_exists('extension_import')) { if (permission_exists('extension_import')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//initialize the database object //initialize the database object
$database = new database; $database = new database;
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher //built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
if (!function_exists('str_getcsv')) { if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") { function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fp = fopen("php://memory", 'r+'); $fp = fopen("php://memory", 'r+');
fputs($fp, $input); fputs($fp, $input);
rewind($fp); rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape); $data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
fclose($fp); fclose($fp);
return $data; return $data;
} }
} }
//get the http get values and set them as php variables //get the http get values and set them as php variables
$action = $_POST["action"] ?? null; $action = $_POST["action"] ?? null;
$from_row = $_POST["from_row"] ?? null; $from_row = $_POST["from_row"] ?? null;
$delimiter = $_POST["data_delimiter"] ?? null; $delimiter = $_POST["data_delimiter"] ?? null;
$enclosure = $_POST["data_enclosure"] ?? null; $enclosure = $_POST["data_enclosure"] ?? null;
//save the data to the csv file //save the data to the csv file
if (isset($_POST['data'])) { if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv"; $file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']); file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
//copy the csv file //copy the csv file
//$_POST['submit'] == "Upload" && //$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) { if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) {
if ($_POST['type'] == 'csv') { if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); $save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); //system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
unset($_POST['txtCommand']); unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
} }
//get the schema //get the schema
if (!empty($delimiter)) { if (!empty($delimiter)) {
//get the first line //get the first line
$line = fgets(fopen($_SESSION['file'], 'r')); $line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line); $line_fields = explode($delimiter, $line);
//get the schema //get the schema
$x = 0; $x = 0;
include "app/extensions/app_config.php"; include "app/extensions/app_config.php";
$i = 0; $i = 0;
foreach ($apps[0]['db'] as $table) { foreach ($apps[0]['db'] as $table) {
//get the table name and parent name //get the table name and parent name
$table_name = $table["table"]['name']; $table_name = $table["table"]['name'];
$parent_name = $table["table"]['parent']; $parent_name = $table["table"]['parent'];
//remove the v_ table prefix //remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') { if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2); $table_name = substr($table_name, 2);
} }
if (substr($parent_name, 0, 2) == 'v_') { if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2); $parent_name = substr($parent_name, 2);
} }
//filter for specific tables and build the schema array //filter for specific tables and build the schema array
if ($table_name == "extensions") { if ($table_name == "extensions") {
$schema[$i]['table'] = $table_name; $schema[$i]['table'] = $table_name;
$schema[$i]['parent'] = $parent_name; $schema[$i]['parent'] = $parent_name;
foreach ($table['fields'] as $row) { foreach ($table['fields'] as $row) {
if (empty($row['deprecated']) || $row['deprecated'] !== 'true') { if (empty($row['deprecated']) || $row['deprecated'] !== 'true') {
if (is_array($row['name'])) { if (is_array($row['name'])) {
$field_name = $row['name']['text']; $field_name = $row['name']['text'];
} }
else { else {
$field_name = $row['name']; $field_name = $row['name'];
} }
$schema[$i]['fields'][] = $field_name; $schema[$i]['fields'][] = $field_name;
} }
} }
$i++; $i++;
} }
} }
$i++; $i++;
$schema[$i]['table'] = 'extension_users'; $schema[$i]['table'] = 'extension_users';
$schema[$i]['parent'] = 'extensions'; $schema[$i]['parent'] = 'extensions';
$schema[$i]['fields'][] = 'username'; $schema[$i]['fields'][] = 'username';
} }
//match the column names to the field names //match the column names to the field names
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') { if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php'); header('Location: extension_imports.php');
exit; exit;
} }
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//include header //include header
$document['title'] = $text['title-extension_import']; $document['title'] = $text['title-extension_import'];
require_once "resources/header.php"; require_once "resources/header.php";
//form to match the fields to the column names //form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n"; echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n"; echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extension_imports.php']); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extension_imports.php']);
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']); echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
echo $text['description-import']."\n"; echo $text['description-import']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//loop through user columns //loop through user columns
$x = 0; $x = 0;
foreach ($line_fields as $line_field) { foreach ($line_fields as $line_field) {
$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field); $line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
echo "<tr>\n"; echo "<tr>\n";
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n"; //echo " ".$text['label-zzz']."\n";
echo $line_field; echo $line_field;
echo " </td>\n"; echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n"; echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]'>\n"; echo " <select class='formfld' style='' name='fields[$x]'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach($schema as $row) { foreach($schema as $row) {
echo " <optgroup label='".$row['table']."'>\n"; echo " <optgroup label='".$row['table']."'>\n";
if (!empty($row['fields'])) { if (!empty($row['fields'])) {
foreach($row['fields'] as $field) { foreach($row['fields'] as $field) {
$selected = ''; $selected = '';
if ($field == $line_field) { if ($field == $line_field) {
$selected = "selected='selected'"; $selected = "selected='selected'";
} }
if ($field !== 'domain_uuid') { if ($field !== 'domain_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n"; echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
} }
} }
} }
echo " </optgroup>\n"; echo " </optgroup>\n";
} }
echo " </select>\n"; echo " </select>\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-zzz']."\n"; //echo $text['description-zzz']."\n";
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
$x++; $x++;
} }
echo "</table>\n"; echo "</table>\n";
echo "</div>\n"; echo "</div>\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<input name='action' type='hidden' value='import'>\n"; echo "<input name='action' type='hidden' value='import'>\n";
echo "<input name='from_row' type='hidden' value='$from_row'>\n"; echo "<input name='from_row' type='hidden' value='$from_row'>\n";
echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n"; echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n"; echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n"; echo "</form>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
//normalize the column names //normalize the column names
//$line = strtolower($line); //$line = strtolower($line);
//$line = str_replace("-", "_", $line); //$line = str_replace("-", "_", $line);
//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line); //$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
//$line = str_replace("firstname", "name_given", $line); //$line = str_replace("firstname", "name_given", $line);
//$line = str_replace("lastname", "name_family", $line); //$line = str_replace("lastname", "name_family", $line);
//$line = str_replace("company", "organization", $line); //$line = str_replace("company", "organization", $line);
//$line = str_replace("company", "contact_email", $line); //$line = str_replace("company", "contact_email", $line);
//end the script //end the script
exit; exit;
} }
//get the parent table //get the parent table
function get_parent($schema,$table_name) { function get_parent($schema,$table_name) {
foreach ($schema as $row) { foreach ($schema as $row) {
if ($row['table'] == $table_name) { if ($row['table'] == $table_name) {
return $row['parent']; return $row['parent'];
} }
} }
} }
//upload the csv //upload the csv
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') { if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php'); header('Location: extension_imports.php');
exit; exit;
} }
//user selected fields //user selected fields
$fields = $_POST['fields']; $fields = $_POST['fields'];
//set the domain_uuid //set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid']; $domain_uuid = $_SESSION['domain_uuid'];
//get the users //get the users
$sql = "select * from v_users where domain_uuid = :domain_uuid "; $sql = "select * from v_users where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid; $parameters['domain_uuid'] = $domain_uuid;
$users = $database->select($sql, $parameters, 'all'); $users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//get the contents of the csv file and convert them into an array //get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r"); $handle = @fopen($_SESSION['file'], "r");
if ($handle) { if ($handle) {
//set the starting identifiers //set the starting identifiers
$row_id = 0; $row_id = 0;
$row_number = 1; $row_number = 1;
//loop through the array //loop through the array
while (($line = fgets($handle, 4096)) !== false) { while (($line = fgets($handle, 4096)) !== false) {
if ($from_row <= $row_number) { if ($from_row <= $row_number) {
//format the data //format the data
$y = 0; $y = 0;
foreach ($fields as $key => $value) { foreach ($fields as $key => $value) {
//get the line //get the line
$result = str_getcsv($line, $delimiter, $enclosure); $result = str_getcsv($line, $delimiter, $enclosure);
//get the table and field name //get the table and field name
$field_array = explode(".",$value); $field_array = explode(".",$value);
$table_name = $field_array[0]; $table_name = $field_array[0];
$field_name = $field_array[1] ?? null; $field_name = $field_array[1] ?? null;
//echo "value: $value<br />\n"; //echo "value: $value<br />\n";
//echo "table_name: $table_name<br />\n"; //echo "table_name: $table_name<br />\n";
//echo "field_name: $field_name<br />\n"; //echo "field_name: $field_name<br />\n";
//get the parent table name //get the parent table name
$parent = get_parent($schema, $table_name); $parent = get_parent($schema, $table_name);
//remove formatting from the phone number //remove formatting from the phone number
if ($field_name == "phone_number") { if ($field_name == "phone_number") {
$result[$key] = preg_replace('{\D}', '', $result[$key]); $result[$key] = preg_replace('{\D}', '', $result[$key]);
} }
//set various fields to lower case //set various fields to lower case
if (in_array($field_name, array('enabled','directory_visible','directory_exten_visible','call_screen_enabled','user_record','do_not_disturb','forward_all_enabled','forward_busy_enabled','forward_no_answer_enabled','forward_user_not_registered_enabled'))) { if (in_array($field_name, array('enabled','directory_visible','directory_exten_visible','call_screen_enabled','user_record','do_not_disturb','forward_all_enabled','forward_busy_enabled','forward_no_answer_enabled','forward_user_not_registered_enabled'))) {
$result[$key] = strtolower($result[$key]); $result[$key] = strtolower($result[$key]);
} }
//build the data array //build the data array
if (!empty($table_name)) { if (!empty($table_name)) {
if (empty($parent)) { if (empty($parent)) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key]; $array[$table_name][$row_id][$field_name] = $result[$key];
} }
elseif ($field_name != "username") { elseif ($field_name != "username") {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid; $array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key]; $array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
} }
if ($field_name == "username") { if ($field_name == "username") {
foreach ($users as $field) { foreach ($users as $field) {
if ($field['username'] == $result[$key]) { if ($field['username'] == $result[$key]) {
//$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid(); //$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid();
$array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid; $array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid;
//$array[$parent][$row_id]['extension_users'] = $row['extension_uuid']; //$array[$parent][$row_id]['extension_users'] = $row['extension_uuid'];
$array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid']; $array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid'];
} }
} }
} }
} }
} }
//process a chunk of the array //process a chunk of the array
if ($row_id === 1000) { if ($row_id === 1000) {
//save to the data //save to the data
$database->app_name = 'extensions'; $database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array); $database->save($array);
//clear the array //clear the array
unset($array); unset($array);
//set the row id back to 0 //set the row id back to 0
$row_id = 0; $row_id = 0;
} }
} //if ($from_row <= $row_number) } //if ($from_row <= $row_number)
$row_number++; $row_number++;
$row_id++; $row_id++;
} //end while } //end while
fclose($handle); fclose($handle);
//save to the data //save to the data
if (!empty($array) && is_array($array)) { if (!empty($array) && is_array($array)) {
$database->app_name = 'extensions'; $database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array); $database->save($array);
unset($array); unset($array);
} }
//send the redirect header //send the redirect header
header("Location: extensions.php"); header("Location: extensions.php");
exit; exit;
} }
} }
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//include the header //include the header
$document['title'] = $text['title-extension_import']; $document['title'] = $text['title-extension_import'];
require_once "resources/header.php"; require_once "resources/header.php";
//show content //show content
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n"; echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n"; echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extensions.php']); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extensions.php']);
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']); echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
echo $text['description-import']."\n"; echo $text['description-import']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n"; echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n"; echo " ".$text['label-import_data']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>".($data ?? null)."</textarea>\n"; echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>".($data ?? null)."</textarea>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-import_data']."\n"; echo $text['description-import_data']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-from_row']."\n"; echo " ".$text['label-from_row']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='from_row'>\n"; echo " <select class='formfld' name='from_row'>\n";
$i=2; $i=2;
while($i<=99) { while($i<=99) {
$selected = ($i == $from_row) ? "selected" : null; $selected = ($i == $from_row) ? "selected" : null;
echo " <option value='$i' ".$selected.">$i</option>\n"; echo " <option value='$i' ".$selected.">$i</option>\n";
$i++; $i++;
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-from_row']."\n"; echo $text['description-from_row']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_delimiter']."\n"; echo " ".$text['label-import_delimiter']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n"; echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
echo " <option value=','>,</option>\n"; echo " <option value=','>,</option>\n";
echo " <option value='|'>|</option>\n"; echo " <option value='|'>|</option>\n";
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-import_delimiter']."\n"; echo $text['description-import_delimiter']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_enclosure']."\n"; echo " ".$text['label-import_enclosure']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n"; echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
echo " <option value='\"'>\"</option>\n"; echo " <option value='\"'>\"</option>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-import_enclosure']."\n"; echo $text['description-import_enclosure']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n"; echo " ".$text['label-import_file_upload']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n"; echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
echo "<br />\n"; echo "<br />\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "</div>\n"; echo "</div>\n";
echo "<br><br>"; echo "<br><br>";
echo "<input name='type' type='hidden' value='csv'>\n"; echo "<input name='type' type='hidden' value='csv'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>"; echo "</form>";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -1,236 +1,236 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2023 Portions created by the Initial Developer are Copyright (C) 2008-2023
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check permissions //check permissions
if (permission_exists('menu_add') || permission_exists('menu_edit')) { if (permission_exists('menu_add') || permission_exists('menu_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//connect to the database //connect to the database
$database = new database; $database = new database;
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
$menu_uuid = $_REQUEST["id"]; $menu_uuid = $_REQUEST["id"];
} }
else { else {
$action = "add"; $action = "add";
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (!empty($_POST) && count($_POST) > 0) { if (!empty($_POST) && count($_POST) > 0) {
$menu_uuid = $_POST["menu_uuid"] ?? null; $menu_uuid = $_POST["menu_uuid"] ?? null;
$menu_name = $_POST["menu_name"]; $menu_name = $_POST["menu_name"];
$menu_language = $_POST["menu_language"]; $menu_language = $_POST["menu_language"];
$menu_description = $_POST["menu_description"]; $menu_description = $_POST["menu_description"];
} }
//process the http post //process the http post
if (count($_POST) > 0 && empty($_POST["persistformvar"])) { if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: menu.php'); header('Location: menu.php');
exit; exit;
} }
//check for all required data //check for all required data
$msg = ''; $msg = '';
if (empty($menu_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; } if (empty($menu_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (empty($menu_language)) { $msg .= $text['message-required'].$text['label-language']."<br>\n"; } if (empty($menu_language)) { $msg .= $text['message-required'].$text['label-language']."<br>\n"; }
//if (empty($menu_description)) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; } //if (empty($menu_description)) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) { if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add or update the database //add or update the database
if (empty($_POST["persistformvar"])) { if (empty($_POST["persistformvar"])) {
if ($action == "add") { if ($action == "add") {
//create a new unique id //create a new unique id
$menu_uuid = uuid(); $menu_uuid = uuid();
//start a new menu //start a new menu
$array['menus'][0]['menu_uuid'] = $menu_uuid; $array['menus'][0]['menu_uuid'] = $menu_uuid;
$array['menus'][0]['menu_name'] = $menu_name; $array['menus'][0]['menu_name'] = $menu_name;
$array['menus'][0]['menu_language'] = $menu_language; $array['menus'][0]['menu_language'] = $menu_language;
$array['menus'][0]['menu_description'] = $menu_description; $array['menus'][0]['menu_description'] = $menu_description;
$database->app_name = 'menu'; $database->app_name = 'menu';
$database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7'; $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
$database->save($array); $database->save($array);
unset($array); unset($array);
//redirect the user back to the main menu //redirect the user back to the main menu
message::add($text['message-add']); message::add($text['message-add']);
header("Location: menu.php"); header("Location: menu.php");
return; return;
} //if ($action == "add") } //if ($action == "add")
if ($action == "update") { if ($action == "update") {
//update the menu //update the menu
$array['menus'][0]['menu_uuid'] = $menu_uuid; $array['menus'][0]['menu_uuid'] = $menu_uuid;
$array['menus'][0]['menu_name'] = $menu_name; $array['menus'][0]['menu_name'] = $menu_name;
$array['menus'][0]['menu_language'] = $menu_language; $array['menus'][0]['menu_language'] = $menu_language;
$array['menus'][0]['menu_description'] = $menu_description; $array['menus'][0]['menu_description'] = $menu_description;
$database->app_name = 'menu'; $database->app_name = 'menu';
$database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7'; $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
$database->save($array); $database->save($array);
unset($array); unset($array);
//redirect the user back to the main menu //redirect the user back to the main menu
message::add($text['message-update']); message::add($text['message-update']);
header("Location: menu.php"); header("Location: menu.php");
return; return;
} }
} }
} }
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && is_uuid($_GET["id"]) && empty($_POST["persistformvar"])) { if (count($_GET) > 0 && is_uuid($_GET["id"]) && empty($_POST["persistformvar"])) {
$menu_uuid = $_GET["id"]; $menu_uuid = $_GET["id"];
$sql = "select * from v_menus "; $sql = "select * from v_menus ";
$sql .= "where menu_uuid = :menu_uuid "; $sql .= "where menu_uuid = :menu_uuid ";
$parameters['menu_uuid'] = $menu_uuid; $parameters['menu_uuid'] = $menu_uuid;
$row = $database->select($sql, $parameters, 'row'); $row = $database->select($sql, $parameters, 'row');
if (!empty($row)) { if (!empty($row)) {
$menu_uuid = $row["menu_uuid"]; $menu_uuid = $row["menu_uuid"];
$menu_name = $row["menu_name"]; $menu_name = $row["menu_name"];
$menu_language = $row["menu_language"]; $menu_language = $row["menu_language"];
$menu_description = $row["menu_description"]; $menu_description = $row["menu_description"];
} }
unset($sql, $parameters, $row); unset($sql, $parameters, $row);
} }
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//show the header //show the header
$document['title'] = $text['title-menu']; $document['title'] = $text['title-menu'];
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form method='post' name='frm' id='frm'>\n"; echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-menu']."</b></div>\n"; echo " <div class='heading'><b>".$text['header-menu']."</b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','link'=>'menu.php']); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','link'=>'menu.php']);
echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'collapse'=>'hide-xs','style'=>'margin-left: 15px;','link'=>'menu_reload.php?menu_uuid='.urlencode($menu_uuid ?? '').'&menu_language='.urlencode($menu_language ?? '')]); echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'collapse'=>'hide-xs','style'=>'margin-left: 15px;','link'=>'menu_reload.php?menu_uuid='.urlencode($menu_uuid ?? '').'&menu_language='.urlencode($menu_language ?? '')]);
if (permission_exists('menu_restore') && $action == "update") { if (permission_exists('menu_restore') && $action == "update") {
echo button::create(['type'=>'button','label'=>$text['button-restore_default'],'icon'=>'undo-alt','collapse'=>'hide-xs','onclick'=>"modal_open('modal-restore','btn_restore');"]); echo button::create(['type'=>'button','label'=>$text['button-restore_default'],'icon'=>'undo-alt','collapse'=>'hide-xs','onclick'=>"modal_open('modal-restore','btn_restore');"]);
} }
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']); echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
if (permission_exists('menu_restore') && $action == "update") { if (permission_exists('menu_restore') && $action == "update") {
echo modal::create(['id'=>'modal-restore','type'=>'confirmation','message'=>$text['confirm-restore'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_restore','style'=>'float: right; margin-left: 15px;','collapse'=>'never','link'=>'menu_restore_default.php?menu_uuid='.urlencode($menu_uuid).'&menu_language='.urlencode($menu_language),'onclick'=>'modal_close();'])]); echo modal::create(['id'=>'modal-restore','type'=>'confirmation','message'=>$text['confirm-restore'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_restore','style'=>'float: right; margin-left: 15px;','collapse'=>'never','link'=>'menu_restore_default.php?menu_uuid='.urlencode($menu_uuid).'&menu_language='.urlencode($menu_language),'onclick'=>'modal_close();'])]);
} }
echo $text['description-menu']."\n"; echo $text['description-menu']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='menu_name' maxlength='255' value=\"".escape($menu_name ?? '')."\">\n"; echo " <input class='formfld' type='text' name='menu_name' maxlength='255' value=\"".escape($menu_name ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo "\n"; echo "\n";
echo $text['description-name']."</td>\n"; echo $text['description-name']."</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-language']."\n"; echo " ".$text['label-language']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='menu_language' maxlength='255' value=\"".escape($menu_language ?? '')."\">\n"; echo " <input class='formfld' type='text' name='menu_language' maxlength='255' value=\"".escape($menu_language ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-language']."\n"; echo $text['description-language']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n"; echo " ".$text['label-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='menu_description' maxlength='255' value=\"".escape($menu_description ?? '')."\">\n"; echo " <input class='formfld' type='text' name='menu_description' maxlength='255' value=\"".escape($menu_description ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-description']."\n"; echo $text['description-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "</div>"; echo "</div>";
echo "<br>"; echo "<br>";
if ($action == "update") { if ($action == "update") {
echo "<input type='hidden' name='menu_uuid' value='".escape($menu_uuid)."'>\n"; echo "<input type='hidden' name='menu_uuid' value='".escape($menu_uuid)."'>\n";
} }
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>"; echo "</form>";
//show the menu items //show the menu items
if ($action == "update") { if ($action == "update") {
require_once "core/menu/menu_item_list.php"; require_once "core/menu/menu_item_list.php";
} }
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,115 +1,115 @@
<?php <?php
//application details //application details
$apps[$x]['name'] = 'User Logs'; $apps[$x]['name'] = 'User Logs';
$apps[$x]['uuid'] = '582a13cf-7d75-4ea3-b2d9-60914352d76e'; $apps[$x]['uuid'] = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
$apps[$x]['category'] = 'system'; $apps[$x]['category'] = 'system';
$apps[$x]['subcategory'] = 'users'; $apps[$x]['subcategory'] = 'users';
$apps[$x]['version'] = '1.1'; $apps[$x]['version'] = '1.1';
$apps[$x]['license'] = 'Mozilla Public License 1.1'; $apps[$x]['license'] = 'Mozilla Public License 1.1';
$apps[$x]['url'] = 'http://www.fusionpbx.com'; $apps[$x]['url'] = 'http://www.fusionpbx.com';
$apps[$x]['description']['en-us'] = ''; $apps[$x]['description']['en-us'] = '';
//permission details //permission details
$y = 0; $y = 0;
$apps[$x]['permissions'][$y]['name'] = 'user_log_view'; $apps[$x]['permissions'][$y]['name'] = 'user_log_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++; $y++;
$apps[$x]['permissions'][$y]['name'] = 'user_log_all'; $apps[$x]['permissions'][$y]['name'] = 'user_log_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++; $y++;
$apps[$x]['permissions'][$y]['name'] = 'user_log_delete'; $apps[$x]['permissions'][$y]['name'] = 'user_log_delete';
$y++; $y++;
//User Logs //User Logs
$y = 0; $y = 0;
$apps[$x]['db'][$y]['table']['name'] = 'v_user_logs'; $apps[$x]['db'][$y]['table']['name'] = 'v_user_logs';
$apps[$x]['db'][$y]['table']['parent'] = ''; $apps[$x]['db'][$y]['table']['parent'] = '';
$z = 0; $z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_log_uuid'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_log_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary'; $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains'; $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid'; $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hostname'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'hostname';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'timestamp'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'timestamp';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz'; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = ''; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Set the datetime.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Set the datetime.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_uuid'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = ''; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the user.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the user.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'username'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'username';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the Username.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the Username.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'type'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'type';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the type.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the type.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'result'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'result';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the result.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the result.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'remote_address'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'remote_address';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the IP address.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the IP address.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_agent'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_agent';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the user agent.'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the user agent.';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'session_id'; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'session_id';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_date"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_date";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz'; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_user"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_user";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "update_date"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "update_date";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz'; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "update_user"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "update_user";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
?> ?>

View File

@ -1,156 +1,156 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version 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 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 the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2019-2024 Portions created by the Initial Developer are Copyright (C) 2019-2024
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
/** /**
* user_logs class * user_logs class
* *
* @method null delete * @method null delete
* @method null toggle * @method null toggle
* @method null copy * @method null copy
*/ */
if (!class_exists('user_logs')) { if (!class_exists('user_logs')) {
class user_logs { class user_logs {
/** /**
* declare the variables * declare the variables
*/ */
private $app_name; private $app_name;
private $app_uuid; private $app_uuid;
private $name; private $name;
private $table; private $table;
private $toggle_field; private $toggle_field;
private $toggle_values; private $toggle_values;
private $location; private $location;
/** /**
* called when the object is created * called when the object is created
*/ */
public function __construct() { public function __construct() {
//assign the variables //assign the variables
$this->app_name = 'user_logs'; $this->app_name = 'user_logs';
$this->app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e'; $this->app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
$this->name = 'user_log'; $this->name = 'user_log';
$this->table = 'user_logs'; $this->table = 'user_logs';
$this->toggle_field = ''; $this->toggle_field = '';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
$this->location = 'user_logs.php'; $this->location = 'user_logs.php';
} }
/** /**
* add user_logs * add user_logs
*/ */
public static function add($result) { public static function add($result) {
//prepare the array //prepare the array
$array = []; $array = [];
$array['user_logs'][0]["timestamp"] = 'now()'; $array['user_logs'][0]["timestamp"] = 'now()';
$array['user_logs'][0]["domain_uuid"] = $result['domain_uuid']; $array['user_logs'][0]["domain_uuid"] = $result['domain_uuid'];
$array['user_logs'][0]["user_uuid"] = $result['user_uuid']; $array['user_logs'][0]["user_uuid"] = $result['user_uuid'];
$array['user_logs'][0]["username"] = $result['username']; $array['user_logs'][0]["username"] = $result['username'];
$array['user_logs'][0]["hostname"] = gethostname(); $array['user_logs'][0]["hostname"] = gethostname();
$array['user_logs'][0]["type"] = 'login'; $array['user_logs'][0]["type"] = 'login';
$array['user_logs'][0]["remote_address"] = $_SERVER['REMOTE_ADDR']; $array['user_logs'][0]["remote_address"] = $_SERVER['REMOTE_ADDR'];
$array['user_logs'][0]["user_agent"] = $_SERVER['HTTP_USER_AGENT']; $array['user_logs'][0]["user_agent"] = $_SERVER['HTTP_USER_AGENT'];
$array['user_logs'][0]["session_id"] = session_id(); $array['user_logs'][0]["session_id"] = session_id();
$array['user_logs'][0]["type"] = 'login'; $array['user_logs'][0]["type"] = 'login';
if ($result["authorized"] == "true") { if ($result["authorized"] == "true") {
$array['user_logs'][0]["result"] = 'success'; $array['user_logs'][0]["result"] = 'success';
} }
else { else {
$array['user_logs'][0]["result"] = 'failure'; $array['user_logs'][0]["result"] = 'failure';
} }
//add the dialplan permission //add the dialplan permission
$p = new permissions; $p = new permissions;
$p->add("user_log_add", 'temp'); $p->add("user_log_add", 'temp');
//save to the data //save to the data
$database = new database; $database = new database;
$database->app_name = 'authentication'; $database->app_name = 'authentication';
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1'; $database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
if (strlen($user_log_uuid ?? '')>0) if (strlen($user_log_uuid ?? '')>0)
$database->uuid($user_log_uuid); $database->uuid($user_log_uuid);
$database->save($array, false); $database->save($array, false);
$message = $database->message; $message = $database->message;
//remove the temporary permission //remove the temporary permission
$p->delete("user_log_add", 'temp'); $p->delete("user_log_add", 'temp');
} }
/** /**
* delete rows from the database * delete rows from the database
*/ */
public function delete($records) { public function delete($records) {
if (permission_exists($this->name.'_delete')) { if (permission_exists($this->name.'_delete')) {
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location); header('Location: '.$this->location);
exit; exit;
} }
//delete multiple records //delete multiple records
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//build the delete array //build the delete array
$x = 0; $x = 0;
foreach ($records as $record) { foreach ($records as $record) {
//add to the array //add to the array
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
} }
//increment the id //increment the id
$x++; $x++;
} }
//delete the checked rows //delete the checked rows
if (is_array($array) && @sizeof($array) != 0) { if (is_array($array) && @sizeof($array) != 0) {
//execute delete //execute delete
$database = new database; $database = new database;
$database->app_name = $this->app_name; $database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid; $database->app_uuid = $this->app_uuid;
$database->delete($array); $database->delete($array);
unset($array); unset($array);
//set message //set message
message::add($text['message-delete']); message::add($text['message-delete']);
} }
unset($records); unset($records);
} }
} }
} }
} }
} }
?> ?>

View File

@ -1,214 +1,214 @@
<?php <?php
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check permissions //check permissions
if (permission_exists('user_log_view')) { if (permission_exists('user_log_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the uuid //get the uuid
$user_log_uuid = $_GET['id']; $user_log_uuid = $_GET['id'];
//pre-populate the form //pre-populate the form
if (!empty($_GET) && is_array($_GET) && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) { if (!empty($_GET) && is_array($_GET) && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) {
$sql = "select * from v_user_logs "; $sql = "select * from v_user_logs ";
$sql .= "where user_log_uuid = :user_log_uuid "; $sql .= "where user_log_uuid = :user_log_uuid ";
//$sql .= "and domain_uuid = :domain_uuid "; //$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid']; //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['user_log_uuid'] = $user_log_uuid; $parameters['user_log_uuid'] = $user_log_uuid;
$database = new database; $database = new database;
$row = $database->select($sql, $parameters, 'row'); $row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) { if (is_array($row) && @sizeof($row) != 0) {
$domain_uuid = $row["domain_uuid"]; $domain_uuid = $row["domain_uuid"];
$timestamp = $row["timestamp"]; $timestamp = $row["timestamp"];
$user_uuid = $row["user_uuid"]; $user_uuid = $row["user_uuid"];
$username = $row["username"]; $username = $row["username"];
$type = $row["type"]; $type = $row["type"];
$result = $row["result"]; $result = $row["result"];
$remote_address = $row["remote_address"]; $remote_address = $row["remote_address"];
$user_agent = $row["user_agent"]; $user_agent = $row["user_agent"];
} }
unset($sql, $parameters, $row); unset($sql, $parameters, $row);
} }
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//show the header //show the header
$document['title'] = $text['title-user_log']; $document['title'] = $text['title-user_log'];
require_once "resources/header.php"; require_once "resources/header.php";
//get the users //get the users
$sql = "SELECT user_uuid, username FROM v_users "; $sql = "SELECT user_uuid, username FROM v_users ";
$sql .= "WHERE domain_uuid = :domain_uuid "; $sql .= "WHERE domain_uuid = :domain_uuid ";
$sql .= "ORDER by username asc "; $sql .= "ORDER by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database; $database = new database;
$users = $database->execute($sql, $parameters, 'all'); $users = $database->execute($sql, $parameters, 'all');
unset ($sql, $parameters); unset ($sql, $parameters);
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='user_log_uuid' value='".escape($user_log_uuid)."'>\n"; echo "<input class='formfld' type='hidden' name='user_log_uuid' value='".escape($user_log_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-user_log']."</b></div>\n"; echo " <div class='heading'><b>".$text['title-user_log']."</b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'user_logs.php']); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'user_logs.php']);
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
echo $text['title_description-user_logs']."\n"; echo $text['title_description-user_logs']."\n";
echo "<br /><br />\n"; echo "<br /><br />\n";
echo "<div class='card'>\n"; echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain_uuid']."\n"; echo " ".$text['label-domain_uuid']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n"; echo " <select class='formfld' name='domain_uuid'>\n";
if (empty($domain_uuid)) { if (empty($domain_uuid)) {
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n"; echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
} }
else { else {
echo " <option value=''>".$text['label-global']."</option>\n"; echo " <option value=''>".$text['label-global']."</option>\n";
} }
foreach ($_SESSION['domains'] as $row) { foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) { if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n"; echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
} }
else { else {
echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n"; echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
} }
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-domain_uuid']."\n"; echo $text['description-domain_uuid']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-timestamp']."\n"; echo " ".$text['label-timestamp']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='timestamp' maxlength='255' value='".escape($timestamp)."'>\n"; echo " <input class='formfld' type='text' name='timestamp' maxlength='255' value='".escape($timestamp)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-timestamp']."\n"; echo $text['description-timestamp']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-user_uuid']."\n"; echo " ".$text['label-user_uuid']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='user_uuid'>\n"; echo " <select class='formfld' name='user_uuid'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach($users as $field) { foreach($users as $field) {
if ($field['user_uuid'] == $user_uuid) { $selected = "selected='selected'"; } else { $selected = ''; } if ($field['user_uuid'] == $user_uuid) { $selected = "selected='selected'"; } else { $selected = ''; }
echo " <option value='".$field['user_uuid']."' $selected>".escape($field['username'])."</option>\n"; echo " <option value='".$field['user_uuid']."' $selected>".escape($field['username'])."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-user_uuid']."\n"; echo $text['description-user_uuid']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-username']."\n"; echo " ".$text['label-username']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='username' maxlength='255' value='".escape($username)."'>\n"; echo " <input class='formfld' type='text' name='username' maxlength='255' value='".escape($username)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-username']."\n"; echo $text['description-username']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-type']."\n"; echo " ".$text['label-type']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='type' maxlength='255' value='".escape($type)."'>\n"; echo " <input class='formfld' type='text' name='type' maxlength='255' value='".escape($type)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-type']."\n"; echo $text['description-type']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-result']."\n"; echo " ".$text['label-result']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='result'>\n"; echo " <select class='formfld' name='result'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($result == "success") { if ($result == "success") {
echo " <option value='success' selected='selected'>".$text['label-success']."</option>\n"; echo " <option value='success' selected='selected'>".$text['label-success']."</option>\n";
} }
else { else {
echo " <option value='success'>".$text['label-success']."</option>\n"; echo " <option value='success'>".$text['label-success']."</option>\n";
} }
if ($result == "failure") { if ($result == "failure") {
echo " <option value='failure' selected='selected'>".$text['label-failure']."</option>\n"; echo " <option value='failure' selected='selected'>".$text['label-failure']."</option>\n";
} }
else { else {
echo " <option value='failure'>".$text['label-failure']."</option>\n"; echo " <option value='failure'>".$text['label-failure']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-result']."\n"; echo $text['description-result']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-remote_address']."\n"; echo " ".$text['label-remote_address']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='remote_address' maxlength='255' value='".escape($remote_address)."'>\n"; echo " <input class='formfld' type='text' name='remote_address' maxlength='255' value='".escape($remote_address)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-remote_address']."\n"; echo $text['description-remote_address']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-user_agent']."\n"; echo " ".$text['label-user_agent']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='user_agent' maxlength='255' value='".escape($user_agent)."'>\n"; echo " <input class='formfld' type='text' name='user_agent' maxlength='255' value='".escape($user_agent)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-user_agent']."\n"; echo $text['description-user_agent']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "</div>"; echo "</div>";
echo "<br /><br />"; echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>"; echo "</form>";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

File diff suppressed because it is too large Load Diff