Subversion Repositories ALCASAR

Rev

Rev 2093 | Rev 2191 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

<?php
# $Id $

$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        $Language = strtolower(substr(chop($Langue[0]), 0, 2)); 
}

if ($Language === 'fr') {
        $l_title_amdin_log = "Connexion à l'ALCASAR Control Center (ACC)";
} else {
        $l_title_amdin_log = "Connection to ALCASAR Control Center (ACC)";
}

// Read access log
$accessLogs = [];
$accessLogFilename = 'admin_log.txt';
$filePtn = fopen($accessLogFilename, 'r');
if ($filePtn !== false){
        while (!feof($filePtn)) {
                $ligne = fgets($filePtn);
                if (empty($ligne)) {
                        continue;
                }
                $infos = explode('|||', $ligne);
                $accessLogs[] = (object) [
                        'date'     => trim($infos[0]),
                        'username' => trim($infos[1]),
                        'ip'       => trim($infos[2])
                ];
        }
        fclose($filePtn);
}
$accessLogs = array_reverse($accessLogs);

?>
<!doctype html>
<html>
<head>
        <meta charset="utf-8">
        <title>Admin Logs</title>
        <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
        <style>
        body {
                background-color: #EFEFEF;
        }
        </style>
        <script src="../js/jquery.min.js"></script>
        <script src="../js/bootstrap.min.js"></script>
</head>
<body>
        <div class="container">
                <center>
                        <h3><?= $l_title_amdin_log ?></h3>
                </center>
                <table class="table table-striped">
                        <thead>
                                <tr>
                                        <th>Date</th>
                                        <th>User</th>
                                        <th>IP address</th>
                                </tr>
                        </thead>
                        <tbody>
                                <?php if (empty($accessLogs)): ?>
                                        <tr>
                                                <td colspan="3"><center>Empty</center></td>
                                        </tr>
                                <?php else: ?>
                                        <?php foreach ($accessLogs as $access): ?>
                                                <tr>
                                                        <td><?= $access->date ?></td>
                                                        <td><?= $access->username ?></td>
                                                        <td><?= $access->ip ?></td>
                                                </tr>
                                        <?php endforeach; ?>
                                <?php endif; ?>
                        </tbody>
                </table>
        </div>
</body>
</html>