"; echo $pepperHex; echo "
"; $passwordFinal = hash("sha512", hash("sha512", $password . $saltHex) . $pepperHex); class Store extends SQLite3 { function __construct() { $this->open('meowboard.db'); } } // This creates the database file on the system automatically. $db = new Store(); // Initialise tables in the database. $db->exec('CREATE TABLE users(username TEXT PRIMARY KEY UNIQUE NOT NULL, password TEXT NOT NULL, pepper TEXT NOT NULL, admin INTEGER DEFAULT 0)'); $db->exec('CREATE TABLE images(id INTEGER PRIMARY KEY AUTOINCREMENT, location TEXT NOT NULL, uploader TEXT NOT NULL, tags TEXT)'); $db->exec('CREATE TABLE settings(key TEXT PRIMARY KEY UNIQUE NOT NULL, value TEXT DEFAULT NULL)'); $db->exec('CREATE TABLE tokens(hash TEXT PRIMARY KEY NOT NULL, username TEXT NOT NULL, expiry INTEGER)'); // Add the admin user to the database. $insert_user_query = $db->prepare('INSERT INTO users (username, password, pepper, admin) VALUES (?, ?, ?, 1)'); $insert_user_query->bindParam(1, $username, SQLITE3_TEXT); $insert_user_query->bindParam(2, $passwordFinal, SQLITE3_TEXT); $insert_user_query->bindParam(3, $pepperHex, SQLITE3_TEXT); $result = $insert_user_query->execute(); // Add the salt into the database otherwise it will be impossible to login. // Also add site name in. $insert_salt_query = $db->prepare('INSERT INTO settings (key, value) VALUES ("salt", ?)'); $insert_salt_query->bindParam(1, $saltHex, SQLITE3_TEXT); $result = $insert_salt_query->execute(); $insert_sitename_query = $db->prepare('INSERT INTO settings (key, value) VALUES ("sitename", ?)'); $insert_sitename_query->bindParam(1, $sitename, SQLITE3_TEXT); $result = $insert_sitename_query->execute(); echo "Meowboard has been installed and is ready to use!"; } else { showHeader(1); echo '

Install meowboard

'; echo '

Admin account credentials

'; echo '


'; echo '

'; echo '

Site settings

'; echo '

'; echo '
'; echo $footer; } ?>