Browse Source

Remove carriage return per line and leave only line feeds

markjcrane 10 months ago
parent
commit
664233fe40

+ 236 - 236
core/menu/menu_edit.php

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

+ 115 - 115
core/user_logs/app_config.php

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

+ 156 - 156
core/user_logs/resources/classes/user_logs.php

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

+ 213 - 213
core/user_logs/user_log_edit.php

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

+ 506 - 506
core/users/user_imports.php

@@ -1,506 +1,506 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2023
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-//includes files
-	require_once dirname(__DIR__, 2) . "/resources/require.php";
-	require_once "resources/check_auth.php";
-
-//check permissions
-	if (permission_exists('user_import')) {
-		//access granted
-	}
-	else {
-		echo "access denied";
-		exit;
-	}
-
-//connect to the database
-	$database = new database;
-
-//add multi-lingual support
-	$language = new text;
-	$text = $language->get();
-
-//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduce the functionality but requires PHP 5.1.0 or higher
-	if (!function_exists('str_getcsv')) {
-		function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
-			$fp = fopen("php://memory", 'r+');
-			fputs($fp, $input);
-			rewind($fp);
-			$data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0
-			fclose($fp);
-			return $data;
-		}
-	}
-
-//get the http get values and set them as php variables
-	$action = $_POST["action"] ?? '';
-	$from_row = $_POST["from_row"] ?? '';
-	$delimiter = $_POST["data_delimiter"] ?? '';
-	$enclosure = $_POST["data_enclosure"] ?? '';
-
-//save the data to the csv file
-	if (isset($_POST['data'])) {
-		$file = $_SESSION['server']['temp']['dir'].'/users-'.$_SESSION['domain_name'].'.csv';
-		if (file_put_contents($file, $_POST['data'])) {
-			$_SESSION['file'] = $file;
-		}
-	}
-
-//copy the csv file
-	//$_POST['submit'] == "Upload" &&
-	if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('user_import')) {
-		if (!empty($_POST['type']) && $_POST['type'] == 'csv') {
-			$file = $_SESSION['server']['temp']['dir'].'/users-'.$_SESSION['domain_name'].'.csv';
-			if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) {
-				$_SESSION['file'] = $file;
-			}
-		}
-	}
-
-//get the schema
-	if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '')) {
-		//get the first line
-			$line = fgets(fopen($_SESSION['file'], 'r'));
-			$line_fields = explode($delimiter, $line);
-
-		//get the schema
-			$x = 0;
-			include ("core/users/app_config.php");
-			$i = 0;
-			foreach ($apps[0]['db'] as $table) {
-				//get the table name and parent name
-				if (is_array($table["table"]['name'])) {
-					$table_name = $table["table"]['name']['text'];
-				}
-				else {
-					$table_name = $table["table"]['name'];
-				}
-				$parent_name = $table["table"]['parent'];
-
-				//remove the v_ table prefix
-				if (substr($table_name, 0, 2) == 'v_') {
-						$table_name = substr($table_name, 2);
-				}
-				if (substr($parent_name, 0, 2) == 'v_') {
-						$parent_name = substr($parent_name, 2);
-				}
-
-				//filter for specific tables and build the schema array
-				if ($table_name == "users") {
-					$schema[$i]['table'] = $table_name;
-					$schema[$i]['parent'] = $parent_name;
-					foreach($table['fields'] as $row) {
-						$row['deprecated'] = $row['deprecated'] ?? '';
-						if ($row['deprecated'] !== 'true') {
-							if (is_array($row['name'])) {
-								$field_name = $row['name']['text'];
-							}
-							else {
-								$field_name = $row['name'];
-							}
-							$schema[$i]['fields'][] = $field_name;
-						}
-					}
-					$i++;
-				}
-			}
-			$schema[$i]['table'] = 'user_groups';
-			$schema[$i]['parent'] = 'users';
-			$schema[$i]['fields'][] = 'group_name';
-
-		//debug info
-			//view_array($schema);
-	}
-
-//match the column names to the field names
-	if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '') && $action != 'import') {
-
-		//create token
-			$object = new token;
-			$token = $object->create($_SERVER['PHP_SELF']);
-
-		//include header
-			$document['title'] = $text['title-user_import'];
-			require_once "resources/header.php";
-
-		//form to match the fields to the column names
-			echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
-
-			echo "<div class='action_bar' id='action_bar'>\n";
-			echo "	<div class='heading'><b>".$text['header-user_import']."</b></div>\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'=>'user_imports.php']);
-			echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
-			echo "	</div>\n";
-			echo "	<div style='clear: both;'></div>\n";
-			echo "</div>\n";
-
-			echo $text['description-import']."\n";
-			echo "<br /><br />\n";
-
-			echo "<div class='card'>\n";
-			echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
-
-			//loop through user columns
-			$x = 0;
-			foreach ($line_fields as $line_field) {
-				$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
-				echo "<tr>\n";
-				echo "	<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-				//echo "    ".$text['label-zzz']."\n";
-				echo $line_field;
-				echo "	</td>\n";
-				echo "	<td width='70%' class='vtable' align='left'>\n";
-				echo "		<select class='formfld' style='' name='fields[$x]'>\n";
-				echo "			<option value=''></option>\n";
-				foreach($schema as $row) {
-					echo "			<optgroup label='".$row['table']."'>\n";
-					foreach($row['fields'] as $field) {
-						$selected = '';
-						if ($field == $line_field) {
-							$selected = "selected='selected'";
-						}
-						if ($field !== 'domain_uuid') {
-							echo "				<option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
-						}
-					}
-					echo "			</optgroup>\n";
-				}
-				echo "		</select>\n";
-				//echo "<br />\n";
-				//echo $text['description-zzz']."\n";
-				echo "	</td>\n";
-				echo "</tr>\n";
-				$x++;
-			}
-
-			echo "</table>\n";
-			echo "</div>\n";
-			echo "<br /><br />\n";
-
-			echo "<input name='action' type='hidden' value='import'>\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_enclosure' type='hidden' value='$enclosure'>\n";
-			echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
-
-			echo "</form>\n";
-
-			require_once "resources/footer.php";
-
-		//normalize the column names
-			//$line = strtolower($line);
-			//$line = str_replace("-", "_", $line);
-			//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
-			//$line = str_replace("firstname", "name_given", $line);
-			//$line = str_replace("lastname", "name_family", $line);
-			//$line = str_replace("company", "organization", $line);
-			//$line = str_replace("company", "contact_email", $line);
-
-		//end the script
-			exit;
-	}
-
-//get the parent table
-	function get_parent($schema,$table_name) {
-		foreach ($schema as $row) {
-			if ($row['table'] == $table_name) {
-				return $row['parent'];
-			}
-		}
-	}
-
-//upload the csv
-	if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
-
-		//validate the token
-			$token = new token;
-			if (!$token->validate($_SERVER['PHP_SELF'])) {
-				message::add($text['message-invalid_token'],'negative');
-				header('Location: users.php');
-				exit;
-			}
-
-		//form to match the fields to the column names
-			//$document['title'] = $text['title-user_import'];
-			//require_once "resources/header.php";
-
-		//user selected fields
-			$fields = $_POST['fields'];
-
-		//set the domain_uuid
-			$domain_uuid = $_SESSION['domain_uuid'];
-
-
-		//get the groups
-			$sql = "select * from v_groups where domain_uuid is null ";
-			$groups = $database->select($sql, null, 'all');
-			unset($sql);
-
-		//get the contents of the csv file and convert them into an array
-			$handle = @fopen($_SESSION['file'], "r");
-			if ($handle) {
-				//set the starting identifiers
-					$row_id = 0;
-					$row_number = 1;
-
-				//loop through the array
-					while (($line = fgets($handle, 4096)) !== false) {
-						if ($from_row <= $row_number) {
-							//get the user_uuid
-								$user_uuid = uuid();
-
-							//format the data
-								$y = 0;
-								foreach ($fields as $key => $value) {
-
-									//get the line
-									$result = str_getcsv($line, $delimiter, $enclosure);
-
-									//get the table and field name
-									$field_array = explode(".",$value);
-									$table_name = $field_array[0];
-									$field_name = $field_array[1];
-									//echo "value: $value<br />\n";
-									//echo "table_name: $table_name<br />\n";
-									//echo "field_name: $field_name<br />\n";
-
-									//get the parent table name
-									$parent = get_parent($schema, $table_name);
-
-									//clean the phone number
-									//if ($field_name == "phone") {
-									//	$result[$key] = preg_replace('{\D}', '', $result[$key]);
-									//}
-
-									//build the data array
-									if (!empty($table_name)) {
-										if (empty($parent)) {
-											$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
-											$array[$table_name][$row_id][$field_name] = $result[$key];
-										}
-										else {
-											if ($field_name != "group_name") {
-												$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
-												$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
-											}
-										}
-
-										if ($field_name == "group_name") {
-												$group_name = '';
-												foreach ($groups as $field) {
-													if ($field['group_name'] == $result[$key]) {
-														$group_name = $field['group_name'];
-														$array['user_groups'][$row_id]['user_group_uuid'] = uuid();
-														$array['user_groups'][$row_id]['domain_uuid'] = $domain_uuid;
-														$array['user_groups'][$row_id]['group_name'] = $field['group_name'];
-														$array['user_groups'][$row_id]['group_uuid'] = $field['group_uuid'];
-														$array['user_groups'][$row_id]['user_uuid'] = $user_uuid;
-													}
-												}
-
-												//remove superadmin if not the correct permission
-												if ($group_name == 'superadmin') {
-													if (!permission_exists('group_domain')) {
-														unset($array['user_groups'][$row_id]);
-													}
-												}
-										}
-									}
-								}
-
-							//set the password hash cost
-								$options = array('cost' => 10);
-
-							//set the hash the user password
-								$password = $array['users'][$row_id]['password'];
-								$array['users'][$row_id]['password'] = password_hash($password, PASSWORD_DEFAULT, $options);
-
-							//set the user_uuid
-								$array['users'][$row_id]['user_uuid'] = $user_uuid;
-
-							//debug
-								//echo "<pre>\n";
-								//print_r($array);
-								//echo "</pre>\n";
-								//exit;
-
-							//process a chunk of the array
-								if ($row_id === 1000) {
-
-									//save to the data
-										$database->app_name = 'users';
-										$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
-										$database->save($array);
-										//$message = $database->message;
-
-									//clear the array
-										unset($array);
-
-									//set the row id back to 0
-										$row_id = 0;
-								}
-
-						} //if ($from_row <= $row_id)
-						$row_number++;
-						$row_id++;
-					} //end while
-					fclose($handle);
-
-				//debug info
-					//echo "<pre>\n";
-					//print_r($array);
-					//echo "</pre>\n";
-					//exit;
-
-				//save to the data
-					if (!empty($array)) {
-						$database->app_name = 'users';
-						$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
-						$database->save($array);
-						//$message = $database->message;
-						unset($array);
-					}
-
-				//send the redirect header
-					header("Location: users.php");
-					return;
-			}
-	}
-
-//create token
-	$object = new token;
-	$token = $object->create($_SERVER['PHP_SELF']);
-
-//include the header
-	$document['title'] = $text['title-user_import'];
-	require_once "resources/header.php";
-
-//show content
-	echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
-
-	echo "<div class='action_bar' id='action_bar'>\n";
-	echo "	<div class='heading'><b>".$text['header-user_import']."</b></div>\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'=>'users.php']);
-	echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
-	echo "	</div>\n";
-	echo "	<div style='clear: both;'></div>\n";
-	echo "</div>\n";
-
-	echo $text['description-import']."\n";
-	echo "<br /><br />\n";
-
-
-	echo "<div class='card'>\n";
-	echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
-
-	echo "<tr>\n";
-	echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-	echo "    ".$text['label-import_data']."\n";
-	echo "</td>\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'></textarea>\n";
-	echo "<br />\n";
-	echo $text['description-import_data']."\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-	echo "    ".$text['label-from_row']."\n";
-	echo "</td>\n";
-	echo "<td class='vtable' align='left'>\n";
-	echo "		<select class='formfld' name='from_row'>\n";
-	$i=2;
-	while($i<=99) {
-		$selected = ($i == $from_row) ? "selected" : null;
-		echo "			<option value='$i' ".$selected.">$i</option>\n";
-		$i++;
-	}
-	echo "		</select>\n";
-	echo "<br />\n";
-	echo $text['description-from_row']."\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-	echo "    ".$text['label-import_delimiter']."\n";
-	echo "</td>\n";
-	echo "<td class='vtable' align='left'>\n";
-	echo "    <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
-	echo "    <option value=','>,</option>\n";
-	echo "    <option value='|'>|</option>\n";
-	echo "    </select>\n";
-	echo "<br />\n";
-	echo $text['description-import_delimiter']."\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-	echo "    ".$text['label-import_enclosure']."\n";
-	echo "</td>\n";
-	echo "<td class='vtable' align='left'>\n";
-	echo "    <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
-	echo "    <option value='\"'>\"</option>\n";
-	echo "    <option value=''></option>\n";
-	echo "    </select>\n";
-	echo "<br />\n";
-	echo $text['description-import_enclosure']."\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-	echo "			".$text['label-import_file_upload']."\n";
-	echo "</td>\n";
-	echo "<td class='vtable' align='left'>\n";
-	echo "			<input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
-	echo "<br />\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "	<tr>\n";
-	echo "		<td valign='bottom'>\n";
-	echo "			&nbsp;\n";
-	echo "		</td>\n";
-	echo "		<td valign='bottom' align='right' nowrap>\n";
-	echo "			<input name='type' type='hidden' value='csv'>\n";
-	echo "			<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
-	echo "		</td>\n";
-	echo "	</tr>\n";
-	echo "	</table>\n";
-	echo "</div>\n";
-	echo "</form>";
-	echo "<br><br>";
-
-//include the footer
-	require_once "resources/footer.php";
-
-?>
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('user_import')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//connect to the database
+	$database = new database;
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduce the functionality but requires PHP 5.1.0 or higher
+	if (!function_exists('str_getcsv')) {
+		function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
+			$fp = fopen("php://memory", 'r+');
+			fputs($fp, $input);
+			rewind($fp);
+			$data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0
+			fclose($fp);
+			return $data;
+		}
+	}
+
+//get the http get values and set them as php variables
+	$action = $_POST["action"] ?? '';
+	$from_row = $_POST["from_row"] ?? '';
+	$delimiter = $_POST["data_delimiter"] ?? '';
+	$enclosure = $_POST["data_enclosure"] ?? '';
+
+//save the data to the csv file
+	if (isset($_POST['data'])) {
+		$file = $_SESSION['server']['temp']['dir'].'/users-'.$_SESSION['domain_name'].'.csv';
+		if (file_put_contents($file, $_POST['data'])) {
+			$_SESSION['file'] = $file;
+		}
+	}
+
+//copy the csv file
+	//$_POST['submit'] == "Upload" &&
+	if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('user_import')) {
+		if (!empty($_POST['type']) && $_POST['type'] == 'csv') {
+			$file = $_SESSION['server']['temp']['dir'].'/users-'.$_SESSION['domain_name'].'.csv';
+			if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) {
+				$_SESSION['file'] = $file;
+			}
+		}
+	}
+
+//get the schema
+	if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '')) {
+		//get the first line
+			$line = fgets(fopen($_SESSION['file'], 'r'));
+			$line_fields = explode($delimiter, $line);
+
+		//get the schema
+			$x = 0;
+			include ("core/users/app_config.php");
+			$i = 0;
+			foreach ($apps[0]['db'] as $table) {
+				//get the table name and parent name
+				if (is_array($table["table"]['name'])) {
+					$table_name = $table["table"]['name']['text'];
+				}
+				else {
+					$table_name = $table["table"]['name'];
+				}
+				$parent_name = $table["table"]['parent'];
+
+				//remove the v_ table prefix
+				if (substr($table_name, 0, 2) == 'v_') {
+						$table_name = substr($table_name, 2);
+				}
+				if (substr($parent_name, 0, 2) == 'v_') {
+						$parent_name = substr($parent_name, 2);
+				}
+
+				//filter for specific tables and build the schema array
+				if ($table_name == "users") {
+					$schema[$i]['table'] = $table_name;
+					$schema[$i]['parent'] = $parent_name;
+					foreach($table['fields'] as $row) {
+						$row['deprecated'] = $row['deprecated'] ?? '';
+						if ($row['deprecated'] !== 'true') {
+							if (is_array($row['name'])) {
+								$field_name = $row['name']['text'];
+							}
+							else {
+								$field_name = $row['name'];
+							}
+							$schema[$i]['fields'][] = $field_name;
+						}
+					}
+					$i++;
+				}
+			}
+			$schema[$i]['table'] = 'user_groups';
+			$schema[$i]['parent'] = 'users';
+			$schema[$i]['fields'][] = 'group_name';
+
+		//debug info
+			//view_array($schema);
+	}
+
+//match the column names to the field names
+	if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '') && $action != 'import') {
+
+		//create token
+			$object = new token;
+			$token = $object->create($_SERVER['PHP_SELF']);
+
+		//include header
+			$document['title'] = $text['title-user_import'];
+			require_once "resources/header.php";
+
+		//form to match the fields to the column names
+			echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
+
+			echo "<div class='action_bar' id='action_bar'>\n";
+			echo "	<div class='heading'><b>".$text['header-user_import']."</b></div>\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'=>'user_imports.php']);
+			echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
+			echo "	</div>\n";
+			echo "	<div style='clear: both;'></div>\n";
+			echo "</div>\n";
+
+			echo $text['description-import']."\n";
+			echo "<br /><br />\n";
+
+			echo "<div class='card'>\n";
+			echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+			//loop through user columns
+			$x = 0;
+			foreach ($line_fields as $line_field) {
+				$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
+				echo "<tr>\n";
+				echo "	<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+				//echo "    ".$text['label-zzz']."\n";
+				echo $line_field;
+				echo "	</td>\n";
+				echo "	<td width='70%' class='vtable' align='left'>\n";
+				echo "		<select class='formfld' style='' name='fields[$x]'>\n";
+				echo "			<option value=''></option>\n";
+				foreach($schema as $row) {
+					echo "			<optgroup label='".$row['table']."'>\n";
+					foreach($row['fields'] as $field) {
+						$selected = '';
+						if ($field == $line_field) {
+							$selected = "selected='selected'";
+						}
+						if ($field !== 'domain_uuid') {
+							echo "				<option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
+						}
+					}
+					echo "			</optgroup>\n";
+				}
+				echo "		</select>\n";
+				//echo "<br />\n";
+				//echo $text['description-zzz']."\n";
+				echo "	</td>\n";
+				echo "</tr>\n";
+				$x++;
+			}
+
+			echo "</table>\n";
+			echo "</div>\n";
+			echo "<br /><br />\n";
+
+			echo "<input name='action' type='hidden' value='import'>\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_enclosure' type='hidden' value='$enclosure'>\n";
+			echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
+
+			echo "</form>\n";
+
+			require_once "resources/footer.php";
+
+		//normalize the column names
+			//$line = strtolower($line);
+			//$line = str_replace("-", "_", $line);
+			//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
+			//$line = str_replace("firstname", "name_given", $line);
+			//$line = str_replace("lastname", "name_family", $line);
+			//$line = str_replace("company", "organization", $line);
+			//$line = str_replace("company", "contact_email", $line);
+
+		//end the script
+			exit;
+	}
+
+//get the parent table
+	function get_parent($schema,$table_name) {
+		foreach ($schema as $row) {
+			if ($row['table'] == $table_name) {
+				return $row['parent'];
+			}
+		}
+	}
+
+//upload the csv
+	if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
+
+		//validate the token
+			$token = new token;
+			if (!$token->validate($_SERVER['PHP_SELF'])) {
+				message::add($text['message-invalid_token'],'negative');
+				header('Location: users.php');
+				exit;
+			}
+
+		//form to match the fields to the column names
+			//$document['title'] = $text['title-user_import'];
+			//require_once "resources/header.php";
+
+		//user selected fields
+			$fields = $_POST['fields'];
+
+		//set the domain_uuid
+			$domain_uuid = $_SESSION['domain_uuid'];
+
+
+		//get the groups
+			$sql = "select * from v_groups where domain_uuid is null ";
+			$groups = $database->select($sql, null, 'all');
+			unset($sql);
+
+		//get the contents of the csv file and convert them into an array
+			$handle = @fopen($_SESSION['file'], "r");
+			if ($handle) {
+				//set the starting identifiers
+					$row_id = 0;
+					$row_number = 1;
+
+				//loop through the array
+					while (($line = fgets($handle, 4096)) !== false) {
+						if ($from_row <= $row_number) {
+							//get the user_uuid
+								$user_uuid = uuid();
+
+							//format the data
+								$y = 0;
+								foreach ($fields as $key => $value) {
+
+									//get the line
+									$result = str_getcsv($line, $delimiter, $enclosure);
+
+									//get the table and field name
+									$field_array = explode(".",$value);
+									$table_name = $field_array[0];
+									$field_name = $field_array[1];
+									//echo "value: $value<br />\n";
+									//echo "table_name: $table_name<br />\n";
+									//echo "field_name: $field_name<br />\n";
+
+									//get the parent table name
+									$parent = get_parent($schema, $table_name);
+
+									//clean the phone number
+									//if ($field_name == "phone") {
+									//	$result[$key] = preg_replace('{\D}', '', $result[$key]);
+									//}
+
+									//build the data array
+									if (!empty($table_name)) {
+										if (empty($parent)) {
+											$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
+											$array[$table_name][$row_id][$field_name] = $result[$key];
+										}
+										else {
+											if ($field_name != "group_name") {
+												$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
+												$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
+											}
+										}
+
+										if ($field_name == "group_name") {
+												$group_name = '';
+												foreach ($groups as $field) {
+													if ($field['group_name'] == $result[$key]) {
+														$group_name = $field['group_name'];
+														$array['user_groups'][$row_id]['user_group_uuid'] = uuid();
+														$array['user_groups'][$row_id]['domain_uuid'] = $domain_uuid;
+														$array['user_groups'][$row_id]['group_name'] = $field['group_name'];
+														$array['user_groups'][$row_id]['group_uuid'] = $field['group_uuid'];
+														$array['user_groups'][$row_id]['user_uuid'] = $user_uuid;
+													}
+												}
+
+												//remove superadmin if not the correct permission
+												if ($group_name == 'superadmin') {
+													if (!permission_exists('group_domain')) {
+														unset($array['user_groups'][$row_id]);
+													}
+												}
+										}
+									}
+								}
+
+							//set the password hash cost
+								$options = array('cost' => 10);
+
+							//set the hash the user password
+								$password = $array['users'][$row_id]['password'];
+								$array['users'][$row_id]['password'] = password_hash($password, PASSWORD_DEFAULT, $options);
+
+							//set the user_uuid
+								$array['users'][$row_id]['user_uuid'] = $user_uuid;
+
+							//debug
+								//echo "<pre>\n";
+								//print_r($array);
+								//echo "</pre>\n";
+								//exit;
+
+							//process a chunk of the array
+								if ($row_id === 1000) {
+
+									//save to the data
+										$database->app_name = 'users';
+										$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
+										$database->save($array);
+										//$message = $database->message;
+
+									//clear the array
+										unset($array);
+
+									//set the row id back to 0
+										$row_id = 0;
+								}
+
+						} //if ($from_row <= $row_id)
+						$row_number++;
+						$row_id++;
+					} //end while
+					fclose($handle);
+
+				//debug info
+					//echo "<pre>\n";
+					//print_r($array);
+					//echo "</pre>\n";
+					//exit;
+
+				//save to the data
+					if (!empty($array)) {
+						$database->app_name = 'users';
+						$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
+						$database->save($array);
+						//$message = $database->message;
+						unset($array);
+					}
+
+				//send the redirect header
+					header("Location: users.php");
+					return;
+			}
+	}
+
+//create token
+	$object = new token;
+	$token = $object->create($_SERVER['PHP_SELF']);
+
+//include the header
+	$document['title'] = $text['title-user_import'];
+	require_once "resources/header.php";
+
+//show content
+	echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
+
+	echo "<div class='action_bar' id='action_bar'>\n";
+	echo "	<div class='heading'><b>".$text['header-user_import']."</b></div>\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'=>'users.php']);
+	echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
+	echo "	</div>\n";
+	echo "	<div style='clear: both;'></div>\n";
+	echo "</div>\n";
+
+	echo $text['description-import']."\n";
+	echo "<br /><br />\n";
+
+
+	echo "<div class='card'>\n";
+	echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
+
+	echo "<tr>\n";
+	echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-import_data']."\n";
+	echo "</td>\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'></textarea>\n";
+	echo "<br />\n";
+	echo $text['description-import_data']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-from_row']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "		<select class='formfld' name='from_row'>\n";
+	$i=2;
+	while($i<=99) {
+		$selected = ($i == $from_row) ? "selected" : null;
+		echo "			<option value='$i' ".$selected.">$i</option>\n";
+		$i++;
+	}
+	echo "		</select>\n";
+	echo "<br />\n";
+	echo $text['description-from_row']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-import_delimiter']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
+	echo "    <option value=','>,</option>\n";
+	echo "    <option value='|'>|</option>\n";
+	echo "    </select>\n";
+	echo "<br />\n";
+	echo $text['description-import_delimiter']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-import_enclosure']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
+	echo "    <option value='\"'>\"</option>\n";
+	echo "    <option value=''></option>\n";
+	echo "    </select>\n";
+	echo "<br />\n";
+	echo $text['description-import_enclosure']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "			".$text['label-import_file_upload']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "			<input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
+	echo "<br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "	<tr>\n";
+	echo "		<td valign='bottom'>\n";
+	echo "			&nbsp;\n";
+	echo "		</td>\n";
+	echo "		<td valign='bottom' align='right' nowrap>\n";
+	echo "			<input name='type' type='hidden' value='csv'>\n";
+	echo "			<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+	echo "	</table>\n";
+	echo "</div>\n";
+	echo "</form>";
+	echo "<br><br>";
+
+//include the footer
+	require_once "resources/footer.php";
+
+?>