Compare commits

...

6 Commits

11 changed files with 101 additions and 144 deletions

View File

@@ -1,7 +1,7 @@
<?php
namespace table;
require("class.php");
use table\Table;
function get_main () {
$db = $GLOBALS["db"];
/*

3
admin/api/login.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
?>

48
admin/index.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
require "$root/Libraries/table/class.php";
use table\Table;
$db = new SQLite3("../webcron.db");
?>
<!Doctype html>
<!--
Color pallet: https://colorhunt.co/palette/b9eddd87cbb9569daa577d86
-->
<html>
<head>
<link rel="stylesheet" href="/css/main.css">
<script src="/js/admin.js"> </script>
<title>Administration</title>
</head>
<body>
<nav>
<a class='nav-button' href='/index.php'>Back to Site</a>
<?php
$items = scandir(".");
foreach ($items as $item){
if (preg_match('/\.php$/', $item) && $item != "index.php"){
$item_name=ucfirst(explode('.', $item)[0]);
echo "<a class='nav-button' href='$item'>$item_name</a>";
}
}
?>
<a class='nav-button' href='/admin/index.php'>Administration</a>
</nav>
<div class="content_area bordered rounded_border">
<div class="single_width menu_bar bordered_right cell border_rounded_left">
<button class="menu_button">View Login History</button>
<button class="menu_button">User Activity History</button>
</div>
<div id="content" class="content cell">
</div>
<div class="double_width menu_bar bordered_left cell border_rounded_right">
</div>
</div>
</body>
</html>

View File

@@ -10,11 +10,15 @@ GET:
*/
require('../Libraries/table/get.php');
namespace table;
use SQLite3;
$root = $_SERVER['DOCUMENT_ROOT'];
$GLOBALS['db'] = new SQLite3("../../webcron.db");
require("$root/Libraries/table/get.php");
# Setting up DB connection
$GLOBALS['db'] = new SQLite3("../../webcron.db");
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':

View File

@@ -1,3 +1,3 @@
<?php
echo $_SERVER['DOCUMENT_ROOT'];
phpinfo();
?>

View File

@@ -8,8 +8,8 @@ $db = new SQLite3("../webcron.db");
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script>
<link rel="stylesheet" href="/css/main.css">
<script src="/js/main.js"> </script>
<title><?php
$filename = ucfirst(explode('.',basename($_SERVER['SCRIPT_FILENAME']))[0]);
echo $filename;
@@ -17,9 +17,9 @@ $db = new SQLite3("../webcron.db");
</head>
<body>
<nav>
<a class='nav-button' href='index.php'>Log Management</a>
<a class='nav-button' href='/index.php'>Log Management</a>
<?php
$items = scandir(".");
$items = scandir($root);
foreach ($items as $item){
if (preg_match('/\.php$/', $item) && $item != "index.php"){
$item_name=ucfirst(explode('.', $item)[0]);
@@ -27,11 +27,12 @@ $db = new SQLite3("../webcron.db");
}
}
?>
<a class='nav-button' href='/admin/index.php'>Administration</a>
</nav>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<div class="single_width menu_bar bordered_right cell border_rounded_left">
<button class="menu_button" onclick="setCrontabStats()"> View Crontab Statistics </button>
<button class="menu_button" onclick="getTable('job_history')">View Script Run History</button>
<button class="menu_button" onclick="listCrontabs()">View Crontabs</button>
@@ -41,7 +42,7 @@ $db = new SQLite3("../webcron.db");
<div id="content" class="content cell">
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="double_width menu_bar bordered_left cell border_rounded_right">
<?php
$columns = array(
'crontab_path AS "Crontab Path"',

View File

@@ -16,6 +16,7 @@ body {
border-radius: 5px;
border: 1px solid black;
padding: 0.5rem 1.2rem;
margin-right: 0.5rem;
}
.nav-button:hover {
@@ -38,10 +39,6 @@ body {
}
.content_area {
/*
display: flex;
flex-direction: row;
*/
display: table;
width: 100%;
}
@@ -52,12 +49,12 @@ body {
margin-bottom: 0.5rem;
}
.double_width_menu_bar {
display: flexbox;
background-color: #569DAA;
padding: 1rem;
.single_width {
width: 15rem;
}
.double_width {
width: 30rem;
margin-right: 1rem;
}
.wrapper {
@@ -78,6 +75,7 @@ body {
display: table-cell;
text-align: center;
background-color: #bcc5c3;
padding: 0.2rem;
}
.table_header:not(:last-child){
@@ -99,6 +97,7 @@ body {
.table_cell {
display: table-cell;
padding: 0.2rem;
}
.table_cell:not(:last-child){
@@ -107,11 +106,24 @@ body {
.menu_bar {
display: flexbox;
visibility: visible;
background-color: #569DAA;
padding: 1rem;
width: 10rem;
margin-right: 1rem;
}
.menu_bar.double_width:not(:has(.log_table)){
display:none;
visibility: hidden;
}
.border_rounded_left {
border-radius: 5px 0px 0px 5px;
}
.border_rounded_right {
border-radius: 0px 5px 5px 0px;
}
.cell {
display: table-cell;

View File

@@ -11,8 +11,8 @@ $db = new SQLite3("../webcron.db");
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script>
<link rel="stylesheet" href="/css/main.css">
<script src="/js/main.js"> </script>
<title><?php
$filename = ucfirst(explode('.',basename($_SERVER['SCRIPT_FILENAME']))[0]);
echo $filename;
@@ -20,7 +20,7 @@ $db = new SQLite3("../webcron.db");
</head>
<body>
<nav>
<a class='nav-button' href='index.php'>Log Management</a>
<a class='nav-button' href='/index.php'>Log Management</a>
<?php
$items = scandir(".");
foreach ($items as $item){
@@ -30,11 +30,12 @@ $db = new SQLite3("../webcron.db");
}
}
?>
<a class='nav-button' href='/admin/index.php'>Administration</a>
</nav>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<div class="single_width menu_bar bordered_right cell border_rounded_left">
<button class="menu_button" onclick="setDatabaseVersion()"> View Database Version</button>
<button class="menu_button" onclick="listTables()"> View Tables </button>
</div>
@@ -42,8 +43,8 @@ $db = new SQLite3("../webcron.db");
<div id="content" class="content cell">
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="double_width menu_bar bordered_left cell border_rounded_right">
</div>
</div>

View File

@@ -10,14 +10,13 @@ $db = new SQLite3("../webcron.db");
-->
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script>
<link rel="stylesheet" href="/css/main.css">
<script src="/js/main.js"> </script>
<title>Overview</title>
</head>
<body>
<nav>
<a class='nav-button' href='index.php'>Log Management</a>
<a class='nav-button' href='/index.php'>Log Management</a>
<?php
$items = scandir(".");
foreach ($items as $item){
@@ -27,11 +26,12 @@ $db = new SQLite3("../webcron.db");
}
}
?>
<a class='nav-button' href='admin/index.php'>Administration</a>
</nav>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<div class="single_width menu_bar bordered_right cell border_rounded_left">
<button class="menu_button" onclick="getLogHistory()"> Check Logs </button>
</div>
@@ -48,20 +48,16 @@ $db = new SQLite3("../webcron.db");
?>
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="double_width menu_bar bordered_left cell border_rounded_right">
<?php
$table = new Table("log_statistics_last_7_days");
$table->set_pretty_name("Log Statistics (Last 7 Days)");
$query = $table->get_query();
$table->Load($db);
echo $query->get_query_string();
echo $table->get_html();
$table = new Table("last_ten_failed_jobs");
$table->set_pretty_name("Script Failures (Last 10)");
$query = $table->get_query();
$table->Load($db);
echo $query->get_query_string();
echo $table->get_html();
@@ -71,7 +67,6 @@ $db = new SQLite3("../webcron.db");
$query->set_order_by_column("job_timestamp DESC");
$query->set_limit(10);
$table->Load($db);
echo $query->get_query_string();
echo $table->get_html();
?>
</div>

View File

@@ -1,96 +0,0 @@
<!Doctype html>
<!--
Color pallet: https://colorhunt.co/palette/b9eddd87cbb9569daa577d86
-->
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script>
<title>Overview</title>
</head>
<body>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<button class="menu_button"> Check Logs </button>
<button class="menu_button"> View Crontab Statistics</button>
<button class="menu_button" onclick="setInfoSection()"> View Database Version</button>
</div>
<div id="content" class="content cell">
Test
<br>
<?php
$user=shell_exec("whoami");
echo "User: $user<br>";
$db = new SQLite3('../webcron.db');
$res = $db->querySingle("SELECT COUNT(job_id) FROM job_history;");
echo "Job History Entries: $res<br>";
$res = $db->querySingle("SELECT COUNT(log_id) FROM logs;");
echo "Log Entries: $res<br>";
?>
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="wrapper bordered center_text">
Log Statistics (This Week)
<div id="log_statistics_table" class="log_table bordered">
<div class="table_row">
<div class="table_header">Level</div>
<div class="table_header"># of occurances</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT * FROM log_statistics_last_7_days;");
while ($row = $res->fetchArray()){
echo "<div class='table_row'>";
echo "<div class='table_cell'>{$row['log_level_name']}</div> <div class='table_cell'>{$row['count']}</div>";
echo "</div>";
}
?>
</div>
</div>
<div class="wrapper bordered center_text">
Script Failures (Last 10)
<div id="script_failures" class="log_table">
<div class="table_row">
<div class="table_header">Date/Time</div> <div class="table_header">Script</div> <div class="table_header">Exit Code</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT * FROM last_ten_failed_jobs;");
while ($row = $res->fetchArray()){
echo "<div class='table_row'>";
echo "<div class='table_cell'>{$row['job_timestamp']}</div> <div class='table_cell'>{$row['job_source']}</div><div class='table_cell'>{$row['job_exit_code']}</div>";
echo "</div>";
}
?>
</div>
</div>
<div class="wrapper bordered center_text">
Jobs Run (Last 10)
<div id="jobs_run_table" class="log_table">
<div class="table_row">
<div class="table_header">Date/Time</div> <div class="table_header">Script</div> <div class="table_header">Exit Code</div> <div class="table_header">Job Result</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT * FROM job_history ORDER BY job_timestamp DESC LIMIT 10;");
while ($row = $res->fetchArray()){
echo "<div class='table_row'>";
echo "<div class='table_cell'>{$row['job_timestamp']}</div> <div class='table_cell'>{$row['job_source']}</div><div class='table_cell'>{$row['job_exit_code']}</div><div class='table_cell'>{$row['job_result']}</div>";
echo "</div>";
}
?>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,11 +0,0 @@
#!/usr/bin/php
<?php
require("Libraries/db/query.php");
use db\Query;
$query = new Query("crontabs");
$query->set_limit(-1);
echo $query->get_query_string();
?>