git commit all base code

This commit is contained in:
2026-06-30 21:34:42 -04:00
parent 11fdf7b164
commit 1a643d7935
1452 changed files with 433360 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
<style>
body {
background-color: #333333;
color: white;
font-family: sans-serif;
padding: 1em;
}
.success {
color: #8fd19e;
}
.error {
color: #ff9999;
}
</style>
<?php
define("INITIALIZATION_FILE_NAME", "../xml/settings.xml");
// Load Application Settings
$applicationSettings = simplexml_load_file(INITIALIZATION_FILE_NAME);
if (empty($applicationSettings)) {
echo "Unable to load Application Settings.";
exit();
}
// Connect to Database
$host = ((string) $applicationSettings->Environment === "Production") ? "localhost" : "192.168.1.190";
$database = (string) $applicationSettings->DatabaseName;
$user = (string) $applicationSettings->DatabaseUser;
$password = (string) $applicationSettings->DatabasePassword;
try {
$connection = new PDO(
"mysql:host={$host};dbname={$database};charset=utf8mb4",
$user,
$password,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]
);
} catch (PDOException | Exception $e) {
echo "Unable to connect to the database.";
exit();
}
// Get View Files
$views = glob("view_*.php");
if (empty($views)) {
echo "No views found. Views not created.";
exit();
}
sort($views);
// Create Views
$created = 0;
$not_created = 0;
foreach ($views as $viewFile) {
$viewName = basename($viewFile, ".php");
if (!preg_match('/^view_[a-zA-Z0-9_]+$/', $viewName)) {
echo "<div class='error'>Invalid view file skipped: " . htmlspecialchars($viewFile, ENT_QUOTES, "UTF-8") . "</div>";
$not_created++;
continue;
}
$SQL = null;
include $viewFile;
if (empty($SQL)) {
echo "<div class='error'>No SQL found in {$viewFile}. View not created.</div>";
$not_created++;
continue;
}
try {
$connection->exec("DROP VIEW IF EXISTS `{$viewName}`");
$connection->exec($SQL);
$created++;
echo "<div class='success'>" . htmlspecialchars($viewName, ENT_QUOTES, "UTF-8") . " was created.</div>";
} catch (PDOException | Exception $e) {
$not_created++;
echo "<div class='error'>Error creating " . htmlspecialchars($viewName, ENT_QUOTES, "UTF-8") . ".</div>";
}
}
echo "<br/>";
echo htmlspecialchars("{$created} views were created. {$not_created} were not created due to errors.", ENT_QUOTES, "UTF-8");
?>
+69
View File
@@ -0,0 +1,69 @@
<style>
body {
background-color: #333333;
color: white;
}
</style>
<?php
// Simple Script to create a MySQL View.
define("INITIALIZATION_FILE_NAME", "../xml/settings.xml");
// Retrieve the View Name.
$view = $_GET["view"] ?? "";
if (empty($view)) {
echo "No view name given. View not created.";
exit();
}
if ((include "{$view}.php") != true) {
echo "{$view}.php not found. View not created.";
exit;
}
// Retrieve Application Settings
$applicationSettings = simplexml_load_file(INITIALIZATION_FILE_NAME);
if (empty($applicationSettings)) {
echo "Unable to load Application Settings." . PHP_EOL;
exit();
}
// Connect to the Database.
$host = (string) $applicationSettings->DatabaseServer;
$database = (string) $applicationSettings->DatabaseName;
$user = (string) $applicationSettings->DatabaseUser;
$password = (string) $applicationSettings->DatabasePassword;
try {
$connection = new PDO("mysql:host={$host};dbname={$database}", $user, $password);
} catch (PDOException | Exception $e) {
echo "Unable to connect to the database. <br/>";
echo "Error is: {$e->getMessage()}";
exit();
}
// Create the view.
$connection->exec("drop view if exists {$view}");
try {
$connection->exec($SQL);
} catch (Exception $e) {
echo "Error creating view. <br/>";
echo "Error is: {$e->getMessage()}";
exit();
}
if ($connection->errorCode() != 0) {
echo "Error creating view. <br/>";
echo "<pre>";
print_r($connection->errorInfo());
} else {
echo "View {$view} was created.";
}
?>
+16
View File
@@ -0,0 +1,16 @@
<?php
$SQL = "create view view_alerts as
select alerts.*,
date_format(alert_created, '%c/%e/%Y %l:%i %p') as alert_created_verbose,
date_format(alert_changed, '%c/%e/%Y %l:%i %p') as alert_changed_verbose,
date_format(alert_started, '%c/%e/%Y %l:%i %p') as alert_started_verbose,
date_format(alert_expired, '%c/%e/%Y %l:%i %p') as alert_expires_verbose
from alerts
order by alert_created";
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
$SQL = "create view view_dropdowns as
select dropdowns.*,
date_format(dropdowntype_created, '%c/%e/%Y %l:%i %p') as dropdowntype_created_verbose,
date_format(dropdowntype_changed, '%c/%e/%Y %l:%i %p') as dropdowntype_changed_verbose,
dropdowntypes.*
from dropdowns
join dropdowntypes
on dropdowntypes.dropdowntype_serial = dropdowns.dropdown_dropdowntype
order by dropdown_dropdowntype, dropdown_value";
?>
+12
View File
@@ -0,0 +1,12 @@
<?php
$SQL = "create view view_dropdowntypes as
select dropdowntypes.*,
date_format(dropdowntype_created, '%c/%e/%Y %l:%i %p') as dropdowntype_created_verbose,
date_format(dropdowntype_changed, '%c/%e/%Y %l:%i %p') as dropdowntype_changed_verbose
from dropdowntypes
order by dropdowntype_title";
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
$SQL = "create view view_journal as
select journal.*,
date_format(journal.journal_timestamp, '%m/%d/%Y %l:%i %p') as journal_timestamp_verbose
from journal
order by journal_timestamp desc";
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
$SQL = "create view view_notes as
select notes.*,
date_format(note_timestamp, '%c/%e/%Y %l:%i %p') as note_timestamp_verbose
from notes
order by note_type, note_reference, note_timestamp desc";
?>
+14
View File
@@ -0,0 +1,14 @@
<?php
$SQL = "create view view_popovers as
select popovers.*,
date_format(popover_created, '%c/%e/%Y %l:%i %p') as popover_created_verbose,
date_format(popover_changed, '%c/%e/%Y %l:%i %p') as popover_changed_verbose
from popovers
order by popover_title";
?>
+14
View File
@@ -0,0 +1,14 @@
<?php
$SQL = "create view view_reports as
select reports.*,
date_format(report_created, '%c/%e/%Y %l:%i %p') as report_created_verbose,
date_format(report_changed, '%c/%e/%Y %l:%i %p') as report_changed_verbose
from reports
order by report_description";
?>
+14
View File
@@ -0,0 +1,14 @@
<?php
$SQL = "create view view_statuses as
select statuses.*,
date_format(status_created, '%c/%e/%Y %l:%i %p') as status_created_verbose,
date_format(status_changed, '%c/%e/%Y %l:%i %p') as status_changed_verbose
from statuses
order by status_name";
?>
+12
View File
@@ -0,0 +1,12 @@
<?php
$SQL = "create view view_users as
select users.*,
date_format(user_login, '%c/%e/%Y %l:%i %p') as user_login_verbose,
date_format(user_created, '%c/%e/%Y %l:%i %p') as user_created_verbose,
date_format(user_changed, '%c/%e/%Y %l:%i %p') as user_changed_verbose
from users
order by users.user_name";
?>