Changed variables.

This commit is contained in:
2026-07-04 07:43:33 -07:00
parent 7ee47a0b1e
commit 4484f88d8d
21 changed files with 197 additions and 197 deletions
+30 -30
View File
@@ -1,22 +1,22 @@
<?php
$data = [
$ctx->data = [
'secure_key' => false,
'gen_key' => NULL,
'users_created' => false,
'empty_users' => false,
'show_login' => false,
'token' => $session->get('token'),
'token' => $ctx->session->get('token'),
'pageclass' => 'novaconium',
'title' => 'Novaconium Admin'
];
// Check if SECURE KEY is Set in
if ($config['secure_key'] !== null && strlen($config['secure_key']) === 64) {
$data['secure_key'] = true;
if ($ctx->config['secure_key'] !== null && strlen($ctx->config['secure_key']) === 64) {
$ctx->data['secure_key'] = true;
} else {
$data['gen_key'] = substr(bin2hex(random_bytes(32)), 0, 64);
$log->warn('secure_key not detected');
$ctx->data['gen_key'] = substr(bin2hex(random_bytes(32)), 0, 64);
$ctx->log->warn('secure_key not detected');
}
// Check if user table exists
@@ -26,7 +26,7 @@ FROM information_schema.tables
WHERE table_schema = DATABASE()
AND TABLE_NAME = 'users';
EOSQL;
$result = $db->query($query);
$result = $ctx->db->query($query);
if ($result->num_rows === 0) {
$query = <<<EOSQL
@@ -46,9 +46,9 @@ if ($result->num_rows === 0) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
EOSQL;
$db->query($query);
$data['users_created'] = true;
$log->info('Users Table Created');
$ctx->db->query($query);
$ctx->data['users_created'] = true;
$ctx->log->info('Users Table Created');
}
@@ -59,7 +59,7 @@ FROM information_schema.tables
WHERE table_schema = DATABASE()
AND TABLE_NAME = 'user_groups';
EOSQL;
$result = $db->query($query);
$result = $ctx->db->query($query);
if ($result->num_rows === 0) {
$query = <<<EOSQL
@@ -72,8 +72,8 @@ if ($result->num_rows === 0) {
EOSQL;
$db->query($query);
$log->info('User_groups Table Created');
$ctx->db->query($query);
$ctx->log->info('User_groups Table Created');
}
@@ -84,7 +84,7 @@ FROM information_schema.tables
WHERE table_schema = DATABASE()
AND TABLE_NAME = 'pages';
EOSQL;
$result = $db->query($query);
$result = $ctx->db->query($query);
if ($result->num_rows === 0) {
$query = <<<EOSQL
@@ -109,8 +109,8 @@ if ($result->num_rows === 0) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
EOSQL;
$db->query($query);
$log->info('Pages Table Created');
$ctx->db->query($query);
$ctx->log->info('Pages Table Created');
}
// Check ContactForm Table
@@ -120,7 +120,7 @@ FROM information_schema.tables
WHERE table_schema = DATABASE()
AND TABLE_NAME = 'contactForm';
EOSQL;
$result = $db->query($query);
$result = $ctx->db->query($query);
if ($result->num_rows === 0) {
$query = <<<EOSQL
@@ -135,20 +135,20 @@ if ($result->num_rows === 0) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
EOSQL;
$db->query($query);
$log->info('ContactForm Table Created');
$ctx->db->query($query);
$ctx->log->info('ContactForm Table Created');
}
// Check if a user exists
$result = $db->query("SELECT COUNT(*) as total FROM users");
$result = $ctx->db->query("SELECT COUNT(*) as total FROM users");
$row = $result->fetch_assoc();
if ($row['total'] < 1) {
$data['empty_users'] = true;
$ctx->data['empty_users'] = true;
} else {
$log->info('Init Run complete, all sql tables exist with a user.');
$ctx->log->info('Init Run complete, all sql tables exist with a user.');
// Everything is working, send them to login page
$redirect->url('/novaconium/login');
$ctx->redirect->url('/novaconium/login');
makeitso();
}
@@ -159,7 +159,7 @@ FROM information_schema.tables
WHERE table_schema = DATABASE()
AND TABLE_NAME = 'tags';
EOSQL;
$result = $db->query($query);
$result = $ctx->db->query($query);
if ($result->num_rows === 0) {
$query = <<<EOSQL
CREATE TABLE IF NOT EXISTS `tags` (
@@ -170,8 +170,8 @@ CREATE TABLE IF NOT EXISTS `tags` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
EOSQL;
$db->query($query);
$log->info('Tags Table Created');
$ctx->db->query($query);
$ctx->log->info('Tags Table Created');
}
// Check Page Tags Junction Table (after tags table)
@@ -181,7 +181,7 @@ FROM information_schema.tables
WHERE table_schema = DATABASE()
AND TABLE_NAME = 'page_tags';
EOSQL;
$result = $db->query($query);
$result = $ctx->db->query($query);
if ($result->num_rows === 0) {
$query = <<<EOSQL
CREATE TABLE IF NOT EXISTS `page_tags` (
@@ -195,8 +195,8 @@ CREATE TABLE IF NOT EXISTS `page_tags` (
FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
EOSQL;
$db->query($query);
$log->info('Page Tags Junction Table Created');
$ctx->db->query($query);
$ctx->log->info('Page Tags Junction Table Created');
}
view('@novacore/init', $data);
view('@novacore/init', $ctx->data);