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
+3 -3
View File
@@ -1,11 +1,11 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Login Page',
'pageclass' => 'novaconium'
]);
// Don't come here if logged in
if ($session->get('username')) {
$redirect->url('/novaconium/dashboard');
if ($ctx->session->get('username')) {
$ctx->redirect->url('/novaconium/dashboard');
makeitso();
}
view('@novacore/auth/login');
+3 -3
View File
@@ -1,5 +1,5 @@
<?php
$session->kill();
$log->info("Logout - Logout Success - " . $_SERVER['REMOTE_ADDR']);
$redirect->url('/');
$ctx->session->kill();
$ctx->log->info("Logout - Logout Success - " . ($_SERVER['REMOTE_ADDR'] ?? 'unknown'));
$ctx->redirect->url('/');
makeitso();
+26 -26
View File
@@ -8,63 +8,63 @@ $url_fail = '/novaconium/login';
// Don't go further if already logged in
if ( !empty($session->get('username')) ) {
$redirect->url($url_success);
if ( !empty($ctx->session->get('username')) ) {
$ctx->redirect->url($url_success);
makeitso();
}
// Make sure Session Token is correct
if ($session->get('token') != $post->get('token')) {
$messages->addMessage('error', "Invalid Session.");
$log->error("Login Authentication - Invalid Session Token");
if ($ctx->session->get('token') != $ctx->post->get('token')) {
$ctx->messages->addMessage('error', "Invalid Session.");
$ctx->log->error("Login Authentication - Invalid Session Token");
}
// Handle Username
$rawUsername = $post->get('username', null);
$rawUsername = $ctx->post->get('username', null);
$cleanUsername = $v->clean($rawUsername); // Clean the input
$username = strtolower($cleanUsername); // Convert to lowercase
if (!$username) {
$messages->addMessage('error', "No Username given.");
}
$ctx->messages->addMessage('error', "No Username given.");
}
// Handle Password
$password = $v->clean($post->get('password', null));
$password = $v->clean($ctx->post->get('password', null));
if ( empty($password) ) {
$messages->addMessage('error', "Password Empty.");
$ctx->messages->addMessage('error', "Password Empty.");
}
/*************************************************************************************************************
* Query Database
************************************************************************************************************/
if ($messages->count('error') === 0) {
if ($ctx->messages->count('error') === 0) {
$query = "SELECT id, username, email, password, blocked FROM users WHERE username = ? OR email = ?";
$matched = $db->getRow($query, [$username, $username]);
$matched = $ctx->db->getRow($query, [$username, $username]);
if (empty($matched)) {
$messages->addMessage('error', "User or Password incorrect.");
$log->warning("Login Authentication - Login Error, user doesn't exist");
}
$ctx->messages->addMessage('error', "User or Password incorrect.");
$ctx->log->warning("Login Authentication - Login Error, user doesn't exist");
}
}
if ($messages->count('error') === 0) {
if ($ctx->messages->count('error') === 0) {
// Re-apply pepper
$peppered = hash_hmac('sha3-512', $password, $config['secure_key']);
$peppered = hash_hmac('sha3-512', $password, $ctx->config['secure_key']);
// Verify hashed password
if (!password_verify($peppered, $matched['password'])) {
$messages->addMessage('error', "User or Password incorrect.");
$log->warning("Login Authentication - Login Error, password wrong");
$ctx->messages->addMessage('error', "User or Password incorrect.");
$ctx->log->warning("Login Authentication - Login Error, password wrong");
}
}
// Process Login or Redirect
if ($messages->count('error') === 0) {
if ($ctx->messages->count('error') === 0) {
$query = "SELECT groupName FROM user_groups WHERE user_id = ?";
$groups = $db->getRow($query, [$matched['id']]);
$session->set('username', $cleanUsername);
$session->set('group', $groups['groupName']);
$redirect->url($url_success);
$log->info("Login Authentication - Login Success");
$groups = $ctx->db->getRow($query, [$matched['id']]);
$ctx->session->set('username', $cleanUsername);
$ctx->session->set('group', $groups['groupName']);
$ctx->redirect->url($url_success);
$ctx->log->info("Login Authentication - Login Success");
} else {
$redirect->url($url_fail);
$ctx->redirect->url($url_fail);
}
+2 -2
View File
@@ -1,9 +1,9 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Coming Soon',
'heading' => 'Coming Soon',
'countdown' => true,
'launch_date' => '2026-01-01T00:00:00'
]);
view('@novacore/coming-soon', $data);
view('@novacore/coming-soon', $ctx->data);
+7 -7
View File
@@ -6,10 +6,10 @@ use Nickyeoman\Validation;
$validate = new Validation\Validate();
$valid = true;
$p = $post->all();
$p = $ctx->post->all();
// Check secure key
if (empty($p['secure_key']) || $p['secure_key'] !== $config['secure_key']) {
if (empty($p['secure_key']) || $p['secure_key'] !== $ctx->config['secure_key']) {
$valid = false;
}
@@ -31,7 +31,7 @@ if (empty($p['password'])) {
$valid = false;
} else {
// Use pepper + Argon2id
$peppered = hash_hmac('sha3-512', $p['password'], $config['secure_key']);
$peppered = hash_hmac('sha3-512', $p['password'], $ctx->config['secure_key']);
$hashed_password = password_hash($peppered, PASSWORD_ARGON2ID);
}
@@ -45,16 +45,16 @@ if ($valid) {
EOSQL;
$params = [$name, $hashed_password, $p['email']];
$db->query($query, $params);
$userid = $db->lastid();
$ctx->db->query($query, $params);
$userid = $ctx->db->lastid();
// Assign admin group
$groupInsertQuery = <<<EOSQL
INSERT INTO `user_groups` (`user_id`, `groupName`) VALUES (?, ?);
EOSQL;
$db->query($groupInsertQuery, [$userid, 'admin']);
$ctx->db->query($groupInsertQuery, [$userid, 'admin']);
}
// Always redirect at end
$redirect->url('/novaconium');
$ctx->redirect->url('/novaconium');
+5 -5
View File
@@ -1,14 +1,14 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Dashboard Page',
'pageclass' => 'novaconium',
'pageid' => 'controlPanel'
]);
if ( empty($session->get('username'))) {
$redirect->url('/novaconium/login');
$messages->error('You are not loggedin');
if ( empty($ctx->session->get('username'))) {
$ctx->redirect->url('/novaconium/login');
$ctx->messages->error('You are not loggedin');
makeitso();
}
view('@novacore/dashboard', $data);
view('@novacore/dashboard', $ctx->data);
+10 -10
View File
@@ -1,6 +1,6 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Edit Page',
'pageclass' => 'novaconium',
'pageid' => 'controlPanel',
@@ -8,14 +8,14 @@ $data = array_merge($data, [
]);
// Check if logged in
if (empty($session->get('username'))) {
$messages->error('You are not logged in');
$redirect->url('/novaconium/login');
if (empty($ctx->session->get('username'))) {
$ctx->messages->error('You are not logged in');
$ctx->redirect->url('/novaconium/login');
makeitso();
}
// Get page ID from router parameters
$pageid = $router->parameters['id'] ?? null;
$pageid = $ctx->router->parameters['id'] ?? null;
if (!empty($pageid)) {
// Existing page: fetch from database
@@ -51,23 +51,23 @@ WHERE p.id = ?
GROUP BY p.id;
EOSQL;
$data['rows'] = $db->getRow($query, [$pageid]);
$ctx->data['rows'] = $ctx->db->getRow($query, [$pageid]);
// If no row is found, treat as new page
if (!$data['rows']) {
if (!$ctx->data['rows']) {
$pageid = null;
}
}
if (empty($pageid)) {
// New page: set default values for all fields
$data['rows'] = [
$ctx->data['rows'] = [
'id' => 'newpage',
'title' => '',
'heading' => '',
'description' => '',
'keywords' => '',
'author' => $session->get('username') ?? '',
'author' => $ctx->session->get('username') ?? '',
'slug' => '',
'path' => '',
'intro' => '',
@@ -82,4 +82,4 @@ if (empty($pageid)) {
}
// Render the edit page view
view('@novacore/editpage/index', $data);
view('@novacore/editpage/index', $ctx->data);
+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);
+7 -7
View File
@@ -1,15 +1,15 @@
<?php
if ( empty($session->get('username'))) {
$redirect->url('/novaconium/login');
$messages->error('You are not loggedin');
if ( empty($ctx->session->get('username'))) {
$ctx->redirect->url('/novaconium/login');
$ctx->messages->error('You are not loggedin');
makeitso();
}
$messageid = $router->parameters['id'];
$messageid = $ctx->router->parameters['id'];
$query="DELETE FROM contactForm WHERE `contactForm`.`id` = ?";
$db->query($query, [$messageid]);
$ctx->db->query($query, [$messageid]);
$redirect->url('/novaconium/messages');
$messages->notice("Removed Message $messageid");
$ctx->redirect->url('/novaconium/messages');
$ctx->messages->notice("Removed Message $messageid");
makeitso();
+8 -8
View File
@@ -1,19 +1,19 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Message Page',
'pageclass' => 'novaconium'
]);
if ( empty($session->get('username'))) {
$redirect->url('/novaconium/login');
$messages->error('You are not loggedin');
if ( empty($ctx->session->get('username'))) {
$ctx->redirect->url('/novaconium/login');
$ctx->messages->error('You are not loggedin');
makeitso();
}
$messageid = $router->parameters['id'];
$query = "SELECT id, name, email, message, created, unread FROM contactForm WHERE id = '$messageid'";
$messageid = $ctx->router->parameters['id'];
$query = "SELECT id, name, email, message, created, unread FROM contactForm WHERE id = ?";
$data['themessage'] = $db->getRow($query);
$ctx->withData(['themessage' => $ctx->db->getRow($query, [$messageid])]);
view('@novacore/editmessage', $data);
view('@novacore/editmessage', $ctx->data);
+22 -22
View File
@@ -5,53 +5,53 @@ use Nickyeoman\Validation;
$v = new Nickyeoman\Validation\Validate();
$url_success = '/novaconium/messages';
$url_error = '/novaconium/messages/edit/' . $post->get('id'); // Redirect back to the message edit form on error
$url_error = '/novaconium/messages/edit/' . $ctx->post->get('id'); // Redirect back to the message edit form on error
// Check if logged in
if (empty($session->get('username'))) {
$messages->error('You are not logged in');
$redirect->url('/novaconium/login');
if (empty($ctx->session->get('username'))) {
$ctx->messages->error('You are not logged in');
$ctx->redirect->url('/novaconium/login');
makeitso();
}
// Check CSRF token
if ($session->get('token') != $post->get('token')) {
$messages->error('Invalid token');
$redirect->url($url_success);
if ($ctx->session->get('token') != $ctx->post->get('token')) {
$ctx->messages->error('Invalid token');
$ctx->redirect->url($url_success);
makeitso();
}
// Get POST data
$id = $post->get('id');
$name = $post->get('name');
$email = $post->get('email');
$message = $post->get('message');
$unread = !empty($post->get('unread')) ? 1 : 0;
$id = $ctx->post->get('id');
$name = $ctx->post->get('name');
$email = $ctx->post->get('email');
$message = $ctx->post->get('message');
$unread = !empty($ctx->post->get('unread')) ? 1 : 0;
// Validate required fields
if (empty($id) || empty($message) || empty($email)) {
$messages->error('One of the required fields was empty.');
$redirect->url($url_error);
$ctx->messages->error('One of the required fields was empty.');
$ctx->redirect->url($url_error);
makeitso();
}
try {
// Prepare update query
$query = "UPDATE `contactForm`
SET `name` = ?, `email` = ?, `message` = ?, `unread` = ?
$query = "UPDATE `contactForm`
SET `name` = ?, `email` = ?, `message` = ?, `unread` = ?
WHERE `id` = ?";
$params = [$name, $email, $message, $unread, $id];
$db->query($query, $params);
$ctx->db->query($query, $params);
$messages->notice('Message updated successfully');
$ctx->messages->notice('Message updated successfully');
} catch (Exception $e) {
$messages->error('Error updating message: ' . $e->getMessage());
$redirect->url($url_error);
} catch (\Exception $e) {
$ctx->messages->error('Error updating message: ' . $e->getMessage());
$ctx->redirect->url($url_error);
makeitso();
}
// Redirect to success page
$redirect->url($url_success);
$ctx->redirect->url($url_success);
+7 -7
View File
@@ -1,22 +1,22 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Messages',
'pageclass' => 'novaconium',
'pageid' => 'controlPanel'
]);
if ( empty($session->get('username'))) {
$redirect->url('/novaconium/login');
$messages->error('You are not loggedin');
if ( empty($ctx->session->get('username'))) {
$ctx->redirect->url('/novaconium/login');
$ctx->messages->error('You are not loggedin');
makeitso();
}
// Get the pages
$query = "SELECT id, name, email, LEFT(message, 40) AS message, created, unread FROM contactForm";
$matched = $db->getRows($query);
$matched = $ctx->db->getRows($query);
$data['messages'] = $matched;
$ctx->withData(['messages' => $matched]);
view('@novacore/messages', $data);
view('@novacore/messages', $ctx->data);
+7 -7
View File
@@ -1,21 +1,21 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Pages',
'pageclass' => 'novaconium',
'pageid' => 'controlPanel'
]);
if ( empty($session->get('username'))) {
$redirect->url('/novaconium/login');
$messages->error('You are not loggedin');
if ( empty($ctx->session->get('username'))) {
$ctx->redirect->url('/novaconium/login');
$ctx->messages->error('You are not loggedin');
makeitso();
}
// Get the pages
$query = "SELECT id, title, created, updated, draft FROM pages";
$matched = $db->getRows($query);
$matched = $ctx->db->getRows($query);
$data['pages'] = $matched;
$ctx->withData(['pages' => $matched]);
view('@novacore/pages', $data);
view('@novacore/pages', $ctx->data);
+2 -2
View File
@@ -10,7 +10,7 @@ $pt = '@novacore/samples'; //Define the view directory
//$pt = 'samples'; //drop the core for your project
//Grab the slug
$slug = $router->parameters['slug'];
$slug = $ctx->router->parameters['slug'];
//build path
$tmpl = $pt . '/' . $slug;
@@ -26,7 +26,7 @@ if (strpos($pt, '@novacore') !== false) {
$possibleFile = $baseDir . '/' . $slug . '.html.twig'; // add .twig extension if needed
if (is_file($possibleFile) && is_readable($possibleFile)) {
view($tmpl, $data);
view($tmpl, $ctx->data);
} else {
http_response_code('404');
header("Content-Type: text/html");
+34 -34
View File
@@ -5,44 +5,44 @@ use Novaconium\Services\TagManager;
$v = new Nickyeoman\Validation\Validate();
$url_error = '/novaconium/page/edit/' . $post->get('id'); // fallback for errors
$url_error = '/novaconium/page/edit/' . $ctx->post->get('id'); // fallback for errors
// -------------------------
// Check login
// -------------------------
if (empty($session->get('username'))) {
$messages->error('You are not logged in');
$redirect->url('/novaconium/login');
if (empty($ctx->session->get('username'))) {
$ctx->messages->error('You are not logged in');
$ctx->redirect->url('/novaconium/login');
makeitso();
}
// -------------------------
// Check CSRF token
// -------------------------
if ($session->get('token') != $post->get('token')) {
$messages->error('Invalid Token');
$redirect->url('/novaconium/pages');
if ($ctx->session->get('token') != $ctx->post->get('token')) {
$ctx->messages->error('Invalid Token');
$ctx->redirect->url('/novaconium/pages');
makeitso();
}
// -------------------------
// Gather POST data
// -------------------------
$id = $post->get('id');
$title = $_POST['title'] ?? '';
$heading = $_POST['heading'] ?? '';
$description = $_POST['description'] ?? '';
$keywords = $_POST['keywords'] ?? '';
$author = $_POST['author'] ?? '';
$slug = $_POST['slug'] ?? '';
$path = $_POST['path'] ?? null;
$intro = $_POST['intro'] ?? '';
$body = $_POST['body'] ?? '';
$notes = $_POST['notes'] ?? '';
$draft = !empty($post->get('draft')) ? 1 : 0;
$changefreq = $_POST['changefreq'] ?? 'monthly';
$priority = $_POST['priority'] ?? 0.0;
$tags_json = $_POST['tags_json'] ?? '[]';
$id = $ctx->post->get('id');
$title = $ctx->post->get('title', '');
$heading = $ctx->post->get('heading', '');
$description = $ctx->post->get('description', '');
$keywords = $ctx->post->get('keywords', '');
$author = $ctx->post->get('author', '');
$slug = $ctx->post->get('slug', '');
$path = $ctx->post->get('path');
$intro = $ctx->post->get('intro', '');
$body = $ctx->post->get('body', '');
$notes = $ctx->post->get('notes', '');
$draft = !empty($ctx->post->get('draft')) ? 1 : 0;
$changefreq = $ctx->post->get('changefreq', 'monthly');
$priority = $ctx->post->get('priority', 0.0);
$tags_json = $ctx->post->get('tags_json', '[]');
// -------------------------
// Decode & sanitize tags
@@ -57,13 +57,13 @@ $tags = array_unique($tags);
// Validate required fields
// -------------------------
if (empty($title) || empty($slug) || empty($body)) {
$messages->error('Title, Slug, and Body are required.');
$redirect->url($url_error);
$ctx->messages->error('Title, Slug, and Body are required.');
$ctx->redirect->url($url_error);
makeitso();
}
try {
$tagManager = new TagManager();
$tagManager = new TagManager($ctx->db);
if ($id == 'newpage') {
// -------------------------
@@ -79,9 +79,9 @@ try {
$slug, $path, $intro, $body, $notes,
$draft, $changefreq, $priority
];
$db->query($query, $params);
$id = $db->lastid;
$messages->notice('Page Created');
$ctx->db->query($query, $params);
$id = $ctx->db->lastid;
$ctx->messages->notice('Page Created');
} else {
// -------------------------
@@ -97,8 +97,8 @@ try {
$slug, $path, $intro, $body, $notes,
$draft, $changefreq, $priority, $id
];
$db->query($query, $params);
$messages->notice('Page Updated');
$ctx->db->query($query, $params);
$ctx->messages->notice('Page Updated');
}
// -------------------------
@@ -106,11 +106,11 @@ try {
// -------------------------
$tagManager->setTagsForPage($id, $tags);
} catch (Exception $e) {
$messages->error($e->getMessage());
$redirect->url($url_error);
} catch (\Exception $e) {
$ctx->messages->error($e->getMessage());
$ctx->redirect->url($url_error);
makeitso();
}
// Redirect back to edit page
$redirect->url('/novaconium/page/edit/' . $id);
$ctx->redirect->url('/novaconium/page/edit/' . $id);
+5 -5
View File
@@ -1,15 +1,15 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Novaconium Settings',
'pageclass' => 'novaconium',
'pageid' => 'controlPanel'
]);
if ( empty($session->get('username'))) {
$redirect->url('/novaconium/login');
$messages->error('You are not loggedin');
if ( empty($ctx->session->get('username'))) {
$ctx->redirect->url('/novaconium/login');
$ctx->messages->error('You are not loggedin');
makeitso();
}
view('@novacore/settings', $data);
view('@novacore/settings', $ctx->data);
+3 -3
View File
@@ -10,7 +10,7 @@ $query=<<<EOSQL
AND draft = 0
ORDER BY updated DESC;
EOSQL;
$thepages = $db->getRows($query);
$thepages = $ctx->db->getRows($query);
// Start the view
echo '<?xml version="1.0" encoding="UTF-8"?>';
@@ -25,9 +25,9 @@ if ( ! empty($thepages) ) {
echo "<url>";
if ( empty($v['path']) )
echo "<loc>" . $config['base_url'] . '/page/' . $v['slug'] . "</loc>";
echo "<loc>" . $ctx->config['base_url'] . '/page/' . $v['slug'] . "</loc>";
else
echo "<loc>" . $config['base_url'] . $v['path'] . "</loc>";
echo "<loc>" . $ctx->config['base_url'] . $v['path'] . "</loc>";
echo "<lastmod>" . $date . "</lastmod>";
echo "<changefreq>" . $v['changefreq'] . "</changefreq>";
@@ -1,5 +1,5 @@
<?php
$data = array_merge($data, [
$ctx->withData([
'title' => 'Welcome to Novaconium Index Page',
'pageclass' => 'novaconium'
]);
+10 -11
View File
@@ -1,7 +1,7 @@
<?php
$slug = $router->parameters['slug'];
$slug = $ctx->router->parameters['slug'];
$query=<<<EOSQL
SELECT
SELECT
id,
title,
heading,
@@ -11,23 +11,22 @@ $query=<<<EOSQL
body,
created,
updated
FROM pages
WHERE slug = '$slug'
FROM pages
WHERE slug = ?
EOSQL;
//$db->debugGetRow($query);
$data = $db->getRow($query);
if(!$data) {
$page = $ctx->db->getRow($query, [$slug]);
if(!$page) {
http_response_code('404');
header("Content-Type: text/html");
view('404');
exit;
}
$data = array_merge($data, [
$ctx->withData(array_merge($page, [
'menuActive' => 'blog',
'pageid' => 'page',
'permissionsGroup' => $session->get('group')
]);
'permissionsGroup' => $ctx->session->get('group')
]));
view('page', $data);
view('page', $ctx->data);
@@ -6,7 +6,7 @@ header('Content-Type: text/plain; charset=UTF-8');
header('Cache-Control: public, max-age=604800');
// Use $config['base_url'] as-is
$baseUrl = $config['base_url'];
$baseUrl = $ctx->config['base_url'];
echo <<<TXT
# robots.txt for sites powered by Novaconium framework
+4 -3
View File
@@ -2,14 +2,15 @@
namespace Novaconium\Services;
use Novaconium\Database;
class TagManager
{
protected $db;
public function __construct()
public function __construct(?Database $db = null)
{
global $db;
$this->db = $db;
$this->db = $db ?? ($GLOBALS['ctx']->db ?? null) ?? ($GLOBALS['db'] ?? null);
}
/**