query("CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
username TEXT,
shadow TEXT,
name TEXT,
bio TEXT
)");
$db->exec("CREATE TABLE IF NOT EXISTS questions(
id INTEGER PRIMARY KEY,
user INTEGER,
by INTEGER,
question TEXT,
date INTEGER,
answered INTEGER
);");
if(!$db->querySingle("SELECT EXISTS(SELECT * FROM users where id = 0);")){
echo "NOTICE: anonymous user created.";
$db->exec("INSERT INTO users(id, username, name) VALUES('0','anonymous','Anonymous');");
}
if($_SESSION["login"] === true){
echo("LibreCat");
echo(" | ");
$user = $db->query("SELECT * FROM users WHERE id = ".$_SESSION["uid"].";")->fetchArray(SQLITE3_ASSOC);
echo("". $user["username"] . "");
echo(" | ");
echo("logout");
}
else{
echo("Login");
//header("Location: /login.php"); die();
}
?>