diff --git a/Database/create-database.sql b/Database/create-database.sql new file mode 100644 index 0000000..a28d0ed --- /dev/null +++ b/Database/create-database.sql @@ -0,0 +1,31 @@ +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) 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; \ No newline at end of file diff --git a/database_version.php b/database_version.php new file mode 100644 index 0000000..0bf5cdd --- /dev/null +++ b/database_version.php @@ -0,0 +1,8 @@ +"; +echo "Version: $versionString
"; +echo "Version Number: $versionNumber" ; +?> \ No newline at end of file diff --git a/index.php b/index.php index 885efcc..5fd133c 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,7 @@ + This is a test @@ -20,19 +21,11 @@ -
- test - "; - echo ""; - ?> - +
+ Test
diff --git a/main.js b/main.js new file mode 100644 index 0000000..d175cf8 --- /dev/null +++ b/main.js @@ -0,0 +1,11 @@ +function request_sqlite_version () { + var request = new XMLHttpRequest(); + request.open("GET", 'http://localhost:8000/database_version.php', false); + request.send(null); + return request.responseText; +} + +function setInfoSection (string) { + var info_section = document.getElementById("content"); + info_section.innerHTML = request_sqlite_version(); +} \ No newline at end of file diff --git a/php.ini b/php.ini new file mode 100644 index 0000000..7ee602b --- /dev/null +++ b/php.ini @@ -0,0 +1 @@ +extension=sqlite3