PHP Classes

File: examples/material-design/manage-devices.php

Recommend this page to a friend!
  Classes of Subin Siby   Secure PHP Login System   examples/material-design/manage-devices.php   Download  
File: examples/material-design/manage-devices.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Secure PHP Login System
Register and login users using a database via PDO
Author: By
Last change: Update of examples/material-design/manage-devices.php
Date: 2 months ago
Size: 1,640 bytes
 

Contents

Class file image Download
<?php
require 'config.php';
if (isset(
$_GET['revoke_device']) && $LS->csrf()) {
    if (
$LS->revokeDevice($_GET['revoke_device'])) {
       
$revoked = true;
    } else {
       
$revoked = false;
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <?php printHead('Manage Devices');?>
</head>
    <body>
        <?php
        showHeader
();
       
?>
<div class="container">
            <h2>Manage Devices</h2>
            <p>The list shows the devices currently authorized to login using your account</p>
            <?php
           
if (isset($revoked)) {
                if (
$revoked) {
                    echo
'<h2>Successfully Revoked Device</h2>';
                } else {
                    echo
'<h2>Failed to Revoke Device</h2>';
                }
            }
           
$devices = $LS->getDevices();
            if (
count($devices) == 0) {
                echo
'<p>No devices are authorized to use your account by skipping 2 Step Verification.</p>';
            } else {
                echo <<<HTML
<table>
    <thead>
        <th>Device ID</th>
        <th>Last Accessed</th>
        <th></th>
    </thead>
    <tbody>
HTML;
                foreach (
$devices as $device) {
                   
$lastAccess = date('Y-m-d H:i:s e', $device['last_access']);

                    echo <<<HTML
<tr>
    <td>
{$device['token']}</td>
    <td>
$lastAccess</td>
    <td><a href="?revoke_device=
{$device['token']}{$LS->csrf('g')}" class="btn red">Revoke Access</a></td>
</tr>
HTML;
                }
                echo <<<HTML
</tbody>
</table>
HTML;
            }
           
?>
</div>
    </body>
</html>