data = [ 'secure_key' => false, 'gen_key' => NULL, 'users_created' => false, 'empty_users' => false, 'show_login' => false, 'token' => $ctx->session->get('token'), 'pageclass' => 'novaconium', 'title' => 'Novaconium Admin' ]; // Check if SECURE KEY is Set in if ($ctx->config['secure_key'] !== null && strlen($ctx->config['secure_key']) === 64) { $ctx->data['secure_key'] = true; } else { $ctx->data['gen_key'] = substr(bin2hex(random_bytes(32)), 0, 64); $ctx->log->warn('secure_key not detected'); } // Check if user table exists $query = <<db->query($query); if ($result->num_rows === 0) { $query = <<db->query($query); $ctx->data['users_created'] = true; $ctx->log->info('Users Table Created'); } // Check Usergroup $query = <<db->query($query); if ($result->num_rows === 0) { $query = <<db->query($query); $ctx->log->info('User_groups Table Created'); } // Check Pages Table $query = <<db->query($query); if ($result->num_rows === 0) { $query = <<db->query($query); $ctx->log->info('Pages Table Created'); } // Check ContactForm Table $query = <<db->query($query); if ($result->num_rows === 0) { $query = <<db->query($query); $ctx->log->info('ContactForm Table Created'); } // Check if a user exists $result = $ctx->db->query("SELECT COUNT(*) as total FROM users"); $row = $result->fetch_assoc(); if ($row['total'] < 1) { $ctx->data['empty_users'] = true; } else { $ctx->log->info('Init Run complete, all sql tables exist with a user.'); // Everything is working, send them to login page $ctx->redirect->url('/novaconium/login'); makeitso(); } // Check Tags Table $query = <<db->query($query); if ($result->num_rows === 0) { $query = <<db->query($query); $ctx->log->info('Tags Table Created'); } // Check Page Tags Junction Table (after tags table) $query = <<db->query($query); if ($result->num_rows === 0) { $query = <<db->query($query); $ctx->log->info('Page Tags Junction Table Created'); } view('@novacore/init', $ctx->data);