Changed <title> tag to auto set the title based off of the file/page name.

Also started made php additions to auto create anchors for pages in the root directory.
This commit is contained in:
Tristan Ancelet 2023-05-13 13:21:52 -05:00
parent 0bfb668e95
commit f58b9c945f
4 changed files with 116 additions and 58 deletions

View File

@ -1,54 +0,0 @@
CREATE TABLE IF NOT EXISTS log_levels (
log_level_id INTEGER PRIMARY KEY,
log_level_name VARCHAR(10) NOT NULL
);
INSERT INTO log_levels (log_level_id, log_level_name) VALUES
(0, 'INFO'),
(1, 'CRITICAL'),
(2, 'WARNING');
CREATE TABLE IF NOT EXISTS logs (
log_id INTEGER PRIMARY KEY AUTOINCREMENT,
log_level_id INTEGER NOT NULL DEFAULT 0,
log_source VARCHAR NOT NULL, -- This will be a unix path '/path/to/script'
log_message TEXT NOT NULl,
log_entry_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (log_level_id) REFERENCES log_levels(log_level_id)
);
CREATE VIEW IF NOT EXISTS log_statistics AS
SELECT levels.log_level_name, COUNT(logs.log_id) FROM logs
JOIN log_levels levels ON log_levels.log_level_id = logs.log_level_id
GROUP BY logs.log_level_id;
CREATE VIEW IF NOT EXISTS log_statistics_last_7_days AS
SELECT log_levels.log_level_name, COUNT(logs.log_id) as count FROM logs
JOIN log_levels ON log_levels.log_level_id = logs.log_level_id
WHERE logs.log_entry_timestamp > DATETIME(CURRENT_TIMESTAMP, '-7 day')
GROUP BY logs.log_level_id;
CREATE TABLE IF NOT EXISTS job_history (
job_id INTEGER PRIMARY KEY AUTOINCREMENT,
job_source TEXT NOT NULL, -- This will be the path to the script
job_result VARCHAR(7) NOT NULL, -- will be N/A, Fail or Success
job_exit_code INTEGER NOT NULL,
job_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE VIEW IF NOT EXISTS last_ten_failed_jobs AS
SELECT job_timestamp, job_source, job_exit_code FROM job_history
WHERE job_result = "Fail"
ORDER BY job_timestamp DESC
LIMIT 10;
CREATE TABLE IF NOT EXISTS crontabs (
crontab_id INTEGER PRIMARY KEY AUTOINCREMENT,
crontab_path VARCHAR NOT NULL UNIQUE, -- this will be the parent directory of the crontab file
crontab_created_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
crontab_modified_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
crontab_data BLOB NOT NULL
);

61
crontab.php Normal file
View File

@ -0,0 +1,61 @@
<!Doctype html>
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script>
<title><?php
$filename = ucfirst(explode('.',basename($_SERVER['SCRIPT_FILENAME']))[0]);
echo $filename;
?> Management</title>
</head>
<body>
<nav>
<a class='nav-button' href='index.php'>Log Management</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 Management</a>";
}
}
?>
</nav>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<button class="menu_button" onclick="setCrontabStats()"> View Crontab Statistics </button>
<button class="menu_button" onclick="getTable('job_history')">Test</button>
</div>
<div id="content" class="content cell">
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="wrapper bordered center_text">
All Crontabs
<div id="log_statistics_table" class="log_table bordered">
<div class="table_row">
<div class="table_header">Crontab</div> <div class="table_header">Created At</div><div class="table_header">Last Modified</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT crontab_path, crontab_created_timestamp, crontab_modified_timestamp FROM crontabs;");
while ($row = $res->fetchArray()){
echo "<div class=\"table_row\">";
echo "<div class=\"table_cell\">{$row['crontab_path']}</div> <div class=\"table_cell\">{$row['crontab_created_timestamp']}</div><div class=\"table_cell\">{$row['crontab_modified_timestamp']}</div>";
echo "</div>";
}
?>
</div>
</div>
</div>
</div>
</body>
</html>

44
database.php Normal file
View File

@ -0,0 +1,44 @@
<!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><?php
$filename = ucfirst(explode('.',basename($_SERVER['SCRIPT_FILENAME']))[0]);
echo $filename;
?> Management</title>
</head>
<body>
<nav>
<a class='nav-button' href='index.php'>Log Management</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 Management</a>";
}
}
?>
</nav>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<button class="menu_button" onclick="setDatabaseVersion()"> View Database Version</button>
<button class="menu_button" onclick="setTableNames()"> View Tables </button>
</div>
<div id="content" class="content cell">
</div>
<div class="double_width_menu_bar bordered_left cell">
</div>
</div>
</body>
</html>

View File

@ -7,13 +7,20 @@
<!-- <script src="https://cdn.tailwindcss.com"></script> --> <!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css"> <link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script> <script src="main.js"> </script>
<title>This is a test</title> <title>Overview</title>
</head> </head>
<body> <body>
<nav> <nav>
<a class="nav-button" href='/'>Logs/Statistics</a> <a class='nav-button' href='index.php'>Log Management</a>
<a class="nav-button" href='/crontabs.php'>Crontab Management</a> <?php
<a class="nav-button" href='contact.php'>Contact</a> $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 Management</a>";
}
}
?>
</nav> </nav>
<div class="content_area bordered rounded_border"> <div class="content_area bordered rounded_border">