Redirect to page with key when private asking and fixes

This commit is contained in:
posweg 2020-09-01 15:30:26 +00:00
parent b2c13d22d0
commit 9af445c433
2 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,7 @@
<?php
session_start();
include("../include/settings.php");
include("../include/functions.php");
$db = new SQLite3('../ask.db');
@ -19,15 +20,24 @@ if(isset($_POST["post-submit"])){
$by = 0;
$question = htmlspecialchars($_POST["post-text"], ENT_QUOTES);
$priv = 0;
$time = strtotime('now');
if(isset($_SESSION["uid"]) && !$_POST["anon"]) $by = $_SESSION["uid"];
if($_POST["priv"]) $priv = 1;
// Insert user into DB
$db->exec("INSERT INTO questions(user,by,question,q_date,private) VALUES ('$u','$by','$question',". strtotime('now') .",$priv);");
$db->exec("INSERT INTO questions(user,by,question,q_date,private) VALUES ('$u','$by','$question',". $time .",$priv);");
unset($_POST["post-text"]);
if($fancy_urls) header("Location: /user/" . $p_user["username"]);
else header("Location: /user.php?q=" . $p_user["username"]);
$q_new = $db->query("SELECT * FROM questions WHERE q_date = '" . $time . "';")->fetchArray(SQLITE3_ASSOC);
$new_get["q"] = $p_user["username"];
if($priv){
$new_get["p"] = $q_new["id"];
$new_get["key"] = md5($question);
}
header("Location: " . redirect("user", $new_get));
}
}
?>

View File

@ -205,7 +205,7 @@ if(isset($_GET["p"])){
$time->settimestamp($current["q_date"]);
echo("\t\t\t\t\t");
$tmp_get["p"] = $current["id"];
$tmp_get["key"] = md5($current["question"]);
if($current["private"] == 1) $tmp_get["key"] = md5($current["question"]);
echo('<a href="' . redirect("user", $tmp_get) . '">');
echo("<p class='question-date'>" . $time->format("Y-m-d h:i:s") . "</p>");
echo("</a>\n");