query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC); if(!$p_user || $p_user["id"] == 0){ // Test if user exists or if it is the id 0, anonymous include("404.php"); die(); } if(isset($_SESSION["uid"])){ if($_SESSION["uid"] == $p_user["id"]){ $is_current_user = true; } } ?> <?= $p_user["username"] ?> | LibreCat

"); if($fancy_urls){ echo("config"); echo(" - "); echo('share on twitter'); } else{ echo("config"); } } ?>
query("SELECT * FROM questions WHERE id = " . $_GET["p"] . ";")->fetchArray(SQLITE3_ASSOC); $h_user = $db->query("SELECT * FROM users WHERE id = " . $h_question["by"] . ";")->fetchArray(SQLITE3_ASSOC); $q_key = md5($h_question["question"]); if($p_user["id"] == $h_question["user"] and ($h_question["private"] != 1 or $q_md5 != $_GET["key"] or $is_current_user)){ // Only show question that are for this user echo('
'); echo('
'); $time = new DateTime("@0"); // Title echo("

"); if($h_user["id"] == 0){ // no link if anonymous echo($h_user["name"]); } else{ $new_get["q"] = $h_user["name"]; echo("" . $h_user["name"] ."\n"); } echo(" asked:

"); // Actual question text echo("\t

". $h_question["question"] ."

\n"); // Footer if($is_current_user){ echo("\treply "); echo("\tdelete "); echo("fav ignore "); } // Time $time->settimestamp($h_question["q_date"]); echo('

'); echo('' . $time->format('Y-m-d h:i:s') . ''); echo('

'); echo('
'); // question-body /* Answer */ if($h_question["answer"]){ echo("
"); echo('

' . $p_user["name"] . ' answered:'); echo("

" . $h_question["answer"] . "

"); $time->settimestamp($h_question["a_date"]); echo("

" . $time->format("Y-m-d h:i:s") . "

"); echo("
"); } echo('
'); // highlighted-post } } ?>

"/>

name="anon"/> Post anonymously

Private

$errorMsg

\n"; ?>
query('SELECT COUNT(*) FROM questions WHERE user = "' . $p_user["id"] . '";')->fetchArray(SQLITE3_ASSOC)['COUNT(*)']; $u_prep = $db->prepare("SELECT * FROM users WHERE id = :id"); $qs = $db->query("SELECT * FROM questions WHERE user = '". $p_user["id"] . "' " . $private_filter . " ORDER BY id DESC LIMIT ". $p_limit ." OFFSET ". $p_offset .";"); /** QUESTIONS MAIN LOOP **/ $time = new DateTime("@0"); $tmp_get = $_GET; while($current = $qs->fetchArray(SQLITE3_ASSOC)){ // Execute prepared statement $u_prep->bindValue(":id", $current["by"], SQLITE3_INTEGER); $q_user = $u_prep->execute()->fetchArray(SQLITE3_ASSOC); echo("\t\t\t"); echo("
\n"); // Question username echo("\t\t\t\t"); echo("

" ); if($q_user["id"] == 0){ // no link if anonymous echo($q_user["name"]); } else{ $new_get["q"] = $q_user["name"]; echo("" . $q_user["name"] .""); } if($current["private"] == 1){ echo(" "); echo("(private)"); } echo("

\n"); // Actual text body echo("\t\t\t\t"); echo("

". $current["question"] ."

\n"); /* Question footer */ echo("\t\t\t\t"); echo('\n"); // Footer /* Answer */ if($current["answer"]){ echo("\t\t\t\t"); echo("
\n"); echo("\t\t\t\t\t"); echo(nl2br("

" . $current["answer"] . "

\n")); $time->settimestamp($current["a_date"]); echo("\t\t\t\t\t"); echo("

" . $time->format("Y-m-d h:i:s") . "

\n"); echo("\t\t\t\t"); echo("
\n"); } echo("\t\t\t"); echo("
\n"); // Question echo("\n"); } /* PAGE SELECTOR */ // ps_* means Page Selector $p_total = ceil($q_count / $p_limit); $ps_margin = 2; // Amount of page numbers to show after and before the actual one // Limit displayed numbers to the existing ones (bound logic) if($_GET["page"] - $ps_margin <= 1) $ps_init = 1; else if($_GET["page"] + $ps_margin > $p_total) $ps_init = $p_total - $ps_margin * 2; else $ps_init = $_GET["page"] - $ps_margin; $ps = ""; $ps .= "
\n"; function ps_item($label, $link){ $ps_item = ""; if($link){ $tmp_get = $_GET; $tmp_get["page"] = $link; $link_init = ""; $label = $link_init . $label . ""; } $ps_item = "\t
" . $label . "
\n"; return $ps_item; } // "|<" and "<" if($ps_init > 1) $ps .= ps_item("|<", 1); if($_GET["page"] > 1) $ps .= ps_item("<", $_GET["page"] - 1); // Numbers for($i = $ps_init; $i <= $ps_init + $ps_margin * 2 && $i <= $p_total && $p_total != 1; $i++){ if($i == $_GET["page"]) $ps .= ps_item($i, ""); else $ps .= ps_item($i, $i); } // ">" and ">|" if($_GET["page"] < $p_total) $ps .= ps_item(">", $_GET["page"] + 1); if($ps_init + $ps_margin * 2 < $p_total) $ps .= ps_item(">|",$p_total); $ps .= "
\n"; echo $ps; ?>