<?php
session_start();
if(!isset($_SESSION["uid"])){
	header("Location: /login");
	die();
}

include("include/header.php");
include("include/settings.php");

$db = new SQLite3('ask.db');

$p_user = $db->query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC);
//var_dump($p_user);

?>
<!DOCTYPE html>
<html>
<head>

<title>Config | LibreCat</title>
<?php include("themes/$theme_name/config.php"); ?>

</head>
<body>
	<div class="main-container">
		<h1 class="title">Config</h1>

		<div class="section">
		<h2>Posting to social networks</h2>
		<p>Work in progress, but it works.</p>

<?php // Login with twitter button
if(!$db->querySingle("SELECT tw_oauth_verify FROM users where id = " . $_SESSION["uid"] . ";")){

	echo "<p><a href='/action/tw-login.php'>Login with Twitter</a></p>";
}
else{
	echo "<p><a href='/action/tw-post-sample'>Post test tweet</a></p>";
	echo "<br/>";
	echo "</p><a href='/action/tw-unlink.php'>Unlink account</a></p>";
}
?>

<?php //Login with mastodon pleroma
	  if(!$db->querySingle("SELECT tw_oauth_verify FROM users where id = " . $_SESSION["uid"] . ";")){

	  echo "<p><a href='/action/tw-login.php'>Login with Mastodon</a></p>";
	  }
	  else{
	  echo "<p><a href='/action/tw-post-sample'>Post test tweet</a></p>";
	  echo "<br/>";
	  echo "</p><a href='/action/tw-unlink.php'>Unlink account</a></p>";
	  }
?>
	<!--
		<div class="section" style="opacity:0.25;">
		<h2>Account settings (WIP, doesn&apos;t work)</h2>
		<form>
			<p>Username</p>
			<input label="name" type="text"/>
			<p>Name</p>
			<input label="username" type="text"/>
			<p>Profile photo</p>
			<input type="file"/>
		</form>
	</div>
	-->
</body>
</html>
