diff --git a/404.php b/404.php
index 2f60934..0c5be3c 100644
--- a/404.php
+++ b/404.php
@@ -1 +1,2 @@
-ERROR 404: Page not found
+
+
ERROR 404: Page not found
diff --git a/config.php b/config.php
new file mode 100644
index 0000000..23d4024
--- /dev/null
+++ b/config.php
@@ -0,0 +1,16 @@
+logout");
+ echo(" - config'");
+}
+else{
+ header("Location: /login"); die();
+}
+?>
+
+
+Config
+
diff --git a/include/header.php b/include/header.php
new file mode 100644
index 0000000..b1228f3
--- /dev/null
+++ b/include/header.php
@@ -0,0 +1,40 @@
+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();
+}
+?>
diff --git a/index.php b/index.php
index 65b000f..fe6e1a2 100644
--- a/index.php
+++ b/index.php
@@ -1,38 +1,5 @@
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($_SESSION["uid"] . " - ");
- echo("logout");
-}
-else{
- echo("Login");
- //header("Location: /login.php"); die();
-}
+include("include/header.php");
?>
diff --git a/user.php b/user.php
index 69d7273..36db50c 100644
--- a/user.php
+++ b/user.php
@@ -1,12 +1,20 @@
query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC);
-if(!$user || !$user["id"]){
+$p_user = $db->query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC);
+if(!$p_user || !$p_user["id"]){
include("404.php");
die();
}
+if(isset($_SESSION["uid"])){
+ if($_SESSION["uid"] == $p_user["id"]){
+ $is_current_user = true;
+ }
+}
+
if($validUser){
header("Location: /"); die();
}
@@ -16,7 +24,7 @@ if(isset($_POST["post-submit"])){
if($_POST["post-text"] == "") $errorMsg = "The question can't be blank.";
else if(strlen($_POST["post-text"]) > 400) $errorMsg = "The question can't bee longer than 400 characters";
else{
- $u = $user["id"];
+ $u = $p_user["id"];
$by = 0;
$question = htmlspecialchars($_POST["post-text"]);
@@ -29,11 +37,13 @@ if(isset($_POST["post-submit"])){
- = $user["username"] ?> | LibreCat
+ = $p_user["username"] ?> | LibreCat
-
- = $user["username"] ?>
- = $user["bio"] ?>
+
+
+ = $p_user["username"] ?>
+ = $p_user["bio"] ?>
+ config"); ?>