Fancy URLs settings option

This commit is contained in:
posweg 2020-05-21 17:19:38 +00:00
parent 4d0deabb16
commit c8123de470
4 changed files with 38 additions and 15 deletions

View File

@ -1,16 +1,8 @@
<?php
include("include/header.php");
session_start();
if($_SESSION["login"] === true){
echo($_SESSION["uid"] . " - ");
echo("<a href='/logout'>logout</a>");
echo(" - <a href='/config'>config</a>'");
}
else{
header("Location: /login"); die();
}
?>
<html>
<h1>Config</h1>
</html>

View File

@ -1,4 +1,5 @@
<?php
include("settings.php");
session_start();
$db = new SQLite3('ask.db');
@ -29,12 +30,26 @@ if($_SESSION["login"] === true){
echo("<a href='/'>LibreCat</a>");
echo(" | ");
$user = $db->query("SELECT * FROM users WHERE id = ".$_SESSION["uid"].";")->fetchArray(SQLITE3_ASSOC);
echo("<a href='/user/" . $user["username"] . "'>". $user["username"] . "</a>");
echo(" | ");
echo("<a href='/logout'>logout</a>");
if($fancy_urls){
echo("<a href='/user/" . $user["username"] . "'>". $user["username"] . "</a>");
echo(" | ");
echo("<a href='/logout'>logout</a>");
}
else {
echo("<a href='/user.php?q=" . $user["username"] . "'>" . $user["username"] . "</a>");
echo(" | ");
echo("<a href='/logout.php'>logout</a>");
}
}
else{
echo("<a href='/login'>Login</a>");
echo("<a href='/'>LibreCat</a>");
echo(" | ");
if($fancy_urls){
echo("<a href='/login'>Login</a>");
}
else{
echo("<a href='/login.php'>Login</a>");
}
//header("Location: /login.php"); die();
}
?>

9
include/settings.php Normal file
View File

@ -0,0 +1,9 @@
<?php
// To activate this you have to put
// NGINX's redirect directives. The
// service is perfectly functional
// with this as false
$fancy_urls = false;
?>

View File

@ -43,7 +43,14 @@ if(isset($_POST["post-submit"])){
<?php include("include/header.php"); ?>
<h2><?= $p_user["username"] ?></h2>
<p><?= $p_user["bio"] ?></p>
<?php if($is_current_user) echo("<a href='/config'>config</a>"); ?>
<?php
if($is_current_user){
if($fancy_urls)
echo("<a href='/config'>config</a>");
else
echo("<a href='/config.php'>config</a>");
}
?>
<form name="input" action="" method="post">
<p>Ask me anything</p>