Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Add support for action viewers.
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaruplaha committed May 22, 2020
1 parent 37081a1 commit 1252f86
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
99 changes: 99 additions & 0 deletions actions/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

require_once "../login.php";
require_once "../teacher/defs.php";

use \ScA\Student\TGLogin\TGLogin;
use \ScA\Teacher;

$is_logged_in = (TGLogin::from_cookie() != NULL) || (Teacher\is_logged_in());

if (!$is_logged_in) {
header("Location: ../?nauth");
exit;
}


require_once "../defs.php";

use const ScA\DB;
use const ScA\DB_HOST;
use const ScA\DB_PWD;
use const ScA\DB_USER;

$table = 'actions';

$conn = new mysqli(DB_HOST, DB_USER, DB_PWD, DB);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

?>

<html lang='en'>

<head>
<meta charset="utf-8">
<title>XII Sc A - actions</title>
<script src='script.js'>
</script>
<link rel='stylesheet' type='text/css' href='stylesheet.css' />
</head>

<body onload="clean()">

<h1 align='center'>XII Sc A - actions</h1>
<hr />
<p align='center'>
<i>
<?php
date_default_timezone_set("Asia/Kolkata");
echo "Report generated on " . date("d M Y h:i:sa") . " IST."
?>
</i>
<hr />
</p>

<?php
// Query
$result = $conn->query("SELECT * FROM {$table} ORDER BY `{$table}`.`Timestamp` ASC");

if (!$result) {
die("Query to show fields from table failed.");
}

echo "
<div class='tab' id='{$sub}'>
<table>
<tr>
<th>Timestamp</th>
<th>Action</th>
<th>Log</th>
</tr>";

while ($action = $result->fetch_assoc()) {
echo "<tr>";

echo "<td>" . $action["Timestamp"] . "</td>";
echo "<td>" . $action["Action"] . "</td>";

if ($r = $action["Log"]) {
$r = str_replace("\n", "\n<br/>", htmlspecialchars($r));
echo "<td class='code'>{$r}</td>";
} else {
echo "<td></td>";
}

echo "</tr>";
}

echo "</table>";
$result->free();


?>
</body>

</html>
52 changes: 52 additions & 0 deletions actions/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
body {
background-color: #222222;
font-family: "Arial", "Courier", "Letter Gothic";
color: #BBBBBB;
}

p {
text-align: center;
}

.center {
margin: auto;
}


table {
margin: auto;
border-style: solid;
color: #BFBFBF;
border-collapse: collapse;
}

th {
padding: 15px 20px;
border-style: solid;
}

tr {
border-style: solid;
}

td {
padding: 10px 15px;
border-style: solid;
text-align: center;
vertical-align: middle;
}

h1 {
margin: auto;
padding: 10px 0px;
}

hr {
color: #888888;
fill: #888888;
}

.code {
font-family: "Consolas";
text-align: left;
}

0 comments on commit 1252f86

Please sign in to comment.