diff --git a/action/delete-question.php b/action/delete-question.php new file mode 100644 index 0000000..99693b1 --- /dev/null +++ b/action/delete-question.php @@ -0,0 +1,32 @@ +query("SELECT * FROM questions WHERE id = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC); + if(!$question || !$question["id"]){ + echo("Question not found."); + } + else if($question["user"] != $_SESSION["uid"]){ + echo("You're not allowed to perform that task."); + } + else{ + $db->exec("DELETE FROM questions WHERE id = " . $question["id"] . ";"); + if($pretty_urls){ + header("Location: /user/" . $db->querySingle("SELECT username FROM users WHERE id = " . $question["user"] . ";")); + die(); + } + else{ + header("Location: /user.php?q=" . $db->querySingle("SELECT username FROM users WHERE id = " . $question["user"] . ";")); + die(); + } + } +} diff --git a/user.php b/user.php index de64203..97eaef6 100644 --- a/user.php +++ b/user.php @@ -27,9 +27,9 @@ if(isset($_SESSION["uid"])){ config"); + echo("config"); else - echo("config"); + echo("config"); } ?> @@ -52,12 +52,18 @@ if(isset($_SESSION["uid"])){ $u_prep->bindValue(":id", $current["by"], SQLITE3_INTEGER); $q_user = $u_prep->execute()->fetchArray(SQLITE3_ASSOC); - echo("
". $current["question"] ."
\n"); + + if($is_current_user){ + echo("\tdelete "); + echo("fav ignore "); + } + // Time $time->setTimestamp($current["date"]); echo($time->format("Y-m-d H:i:s")); - echo("
". $current["question"] ."
"); + echo("\n\n"); } ?>