2020-05-17 00:02:20 +00:00
|
|
|
<?php
|
2020-05-17 20:06:22 +00:00
|
|
|
session_start();
|
|
|
|
|
2020-05-21 11:57:27 +00:00
|
|
|
$db = new SQLite3('ask.db');
|
|
|
|
|
|
|
|
$users_table = $db->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');");
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:06:22 +00:00
|
|
|
if($_SESSION["login"] === true){
|
|
|
|
echo($_SESSION["uid"] . " - ");
|
|
|
|
echo("<a href='/logout'>logout</a>");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
echo("<a href='/login'>Login</a>");
|
|
|
|
//header("Location: /login.php"); die();
|
|
|
|
}
|
2020-05-17 00:02:20 +00:00
|
|
|
?>
|
2020-05-17 20:06:22 +00:00
|
|
|
|
|
|
|
<html>
|
|
|
|
<h1>LibreCat</h1>
|
|
|
|
</html>
|