From 83a8e0112a52c7be5eeb3d95343034fd60d424a7 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 13 Apr 2020 18:18:56 -0600 Subject: [PATCH] Dashboard / Devices: Update layout code to match other Dashboard components. --- app/devices/device_dashboard.php | 189 +++++++++++++------------------ 1 file changed, 81 insertions(+), 108 deletions(-) diff --git a/app/devices/device_dashboard.php b/app/devices/device_dashboard.php index 3ef9f56b8e..b2d4dc7901 100644 --- a/app/devices/device_dashboard.php +++ b/app/devices/device_dashboard.php @@ -17,16 +17,17 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2016 All Rights Reserved. + Portions created by the Initial Developer are Copyright (C) 2016-2020 + the Initial Developer. All Rights Reserved. */ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; //check permissions - require_once "resources/check_auth.php"; if (permission_exists('device_key_add') || permission_exists('device_key_edit')) { //access granted } @@ -39,9 +40,6 @@ $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'app/devices'); -//include the device class - //require_once "app/devices/resources/classes/device.php"; - //get the vendor functions $sql = "select v.name as vendor_name, f.name, f.value "; $sql .= "from v_device_vendors as v, v_device_vendor_functions as f "; @@ -75,6 +73,14 @@ //add or update the database if ($_POST["persistformvar"] != "true") { + //validate the token + $token = new token; + if (!$token->validate('/app/devices/device_dashboard.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.PROJECT_PATH."/core/user_settings/user_dashboard.php"); + exit; + } + //get device $sql = "select device_uuid, device_profile_uuid from v_devices "; $sql .= "where device_user_uuid = :device_user_uuid "; @@ -274,7 +280,7 @@ } //set the message - message::add($text["message-$action"]); + message::add($text["message-".$action]); //redirect the browser header("Location: /core/user_settings/user_dashboard.php"); @@ -419,53 +425,49 @@ } } -//show the header - //require_once "resources/header.php"; +//create token + $object = new token; + $token = $object->create('/app/devices/device_dashboard.php'); //show the content - echo "
\n"; - - echo "
"; - echo " ".$text['title-device_keys']."
"; - if (!$is_included) { - echo " ".$text['description-device_keys']."
"; - } - echo "
"; + echo "
\n"; + echo "
".$text['title-device_keys']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-apply'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".$user_id."@".$server_address."&domain=".$server_address."&agent=".$device_key_vendor."';"]); + echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"list_form_submit('form_list_device_keys');"]); echo "
\n"; - - echo "
"; - echo "
\n"; - - echo "
\n"; - echo "  \n"; - echo " "; + echo "
\n"; echo "
\n"; + if (!$is_included) { + echo $text['description-device_keys']."\n"; + echo "

\n"; + } + + echo "\n"; + if (permission_exists('device_key_edit')) { - echo " \n"; + echo "
\n"; $x = 0; if (is_array($device_keys) && @sizeof($device_keys) != 0) { - foreach($device_keys as $row) { + foreach ($device_keys as $row) { //set the variables $device_key_vendor = $row['device_key_vendor']; $device_vendor = $row['device_key_vendor']; - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor']) { - echo " \n"; - //echo " \n"; - echo " \n"; + if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') { + echo " \n"; + echo " \n"; if (strlen($row['device_key_vendor']) > 0) { - echo " \n"; - } else { - echo " \n"; + echo " \n"; } - //echo " \n"; - echo " \n"; - //echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + else { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; } //determine whether to hide the element if (strlen($device_key_uuid) == 0) { @@ -479,10 +481,7 @@ //add the primary key uuid if (strlen($row['device_key_uuid']) > 0) { echo " \n"; - - } - //show all the rows in the array /* echo " \n"; @@ -538,113 +537,87 @@ echo " \n"; } } - + } echo " \n"; echo "\n"; */ - - echo "\n"; + echo " \n"; + echo " \n"; - echo "\n"; - //echo "\n"; - - echo "\n"; - - //echo "\n"; - - echo "\n"; - - //echo " \n"; - //echo " \n"; - - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; //set the previous vendor $previous_device_key_vendor = $row['device_key_vendor']; //increment the array key $x++; - //alternate the value - $c = ($c) ? 0 : 1; } } - echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."
".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']."".$text['label-device_key_icon']."
".$text['label-device_key_type']."".$text['label-device_key_value']."".$text['label-device_key_label']."".$text['label-device_key_icon']."
\n"; + //output form rows + echo "
\n"; if (permission_exists('device_key_id') || permission_exists('device_key_add')) { $selected = "selected='selected'"; - echo " \n"; + echo " \n"; $i = 1; while ($i < 100) { - echo " \n"; + echo " \n"; $i++; } - echo " \n"; + echo " \n"; } else { echo "  ".$row['device_key_id']; } - echo "\n"; - //echo " \n"; - ?> - - - - - \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; - echo "\n"; - //echo " \n"; - //echo "\n"; - echo " \n"; - echo "\n"; - //echo " \n"; - //echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - //echo " \n"; - //echo " \n"; - //echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; - //if (strlen($text['description-keys']) > 0) { - // echo "
".$text['description-keys']."\n"; - //} + echo "\n"; } + echo "\n"; echo ""; -//show the footer - //require_once "resources/footer.php"; - -?> +?> \ No newline at end of file