Commit f8c7d0ae authored by pixeldesu's avatar pixeldesu
Browse files

whatever

parents 375caf8f 95c4db17
......@@ -72,6 +72,15 @@ if (!isset($notemplate)) {
$res = $sql->query("SELECT `value` FROM `config` WHERE `key` = \"username\";")->fetch_assoc();
$user_name = htmlspecialchars($res['value']);
// show recent?
$res = $sql->query("SELECT `value` FROM `config` WHERE `key` = \"recent_public\";")->fetch_assoc();
$recent_public = $res['value'] === "true" ? true : false;
$recent_count = 0;
if ($recent_public) {
$res = $sql->query("SELECT `value` FROM `config` WHERE `key` = \"recent_count\";")->fetch_assoc();
$recent_count = (int) $res['value'];
}
// the flash
$message = null;
if (isset($_SESSION['flash'])) {
......@@ -84,5 +93,7 @@ if (!isset($notemplate)) {
$tpl->assign("user_name", $user_name);
$tpl->assign("words_total", $words_total_count);
$tpl->assign("inbox_count", $new_words_count);
$tpl->assign("recent_public", $recent_public);
$tpl->assign("recent_count", $recent_count);
$tpl->assign("message", $message);
}
\ No newline at end of file
......@@ -64,4 +64,22 @@ if (isset($_POST['words'])) {
exit();
}
$words = array();
if ($recent_public) {
$sql_str = "SELECT `word1`, `word2`, `word3`, `author`, `new` FROM `words` ORDER BY `id` DESC LIMIT " . $recent_count . ";";
$res = $sql->query($sql_str);
while ($r = $res->fetch_assoc()) {
array_push($words, array(
"word1" => $r['word1'],
"word2" => $r['word2'],
"word3" => $r['word3'],
"author" => $r['author'],
"new" => ($r['new'] == 1 ? true : false)
));
}
}
$tpl->assign("words", $words);
$tpl->draw("index");
\ No newline at end of file
......@@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS `words` (
`word3` VARCHAR(45) NULL,
`author` VARCHAR(45) NULL,
`new` BOOLEAN,
`created_at` TIMESTAMP NULL,
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
{include="layout"}
{include="navbar"}
<div class="container">
{if="$message"}
<div class="alert alert-info">{$message}</div>
{/if}
<h1 class="text-center">{$site_name}!</h1>
<form method="POST">
<p class="text-center">Want to tell them who you are? <input name="author" type="text" class="input-xs" placeholder="Anonymous"></p>
<div class="row">
<div class="col-md-4 rowm">
<input name="word1" type="text" class="form-control" placeholder="First Word">
</div>
<div class="col-md-4 rowm">
<input name="word2" type="text" class="form-control" placeholder="Second Word">
</div>
<div class="col-md-4 rowm">
<input name="word3" type="text" class="form-control" placeholder="Third Word">
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<button type="submit" class="btn btn-primary btn-block btn-lg">Submit</button>
</div>
</div>
<input type="hidden" name="words">
</form>
<<<<<<< HEAD
{if="$recent_answers"}
<div class="row recent-margin">
<div class="col-md-8">
<h4>Recent Answers by others:</h4>
<table class="table table-responsive table-bordered table-condensed">
<tbody>
{loop="$recent"}
<tr>
<td><b>{$value.author}</b> wrote that {$user_name} is <span class="label label-default">{$value.word1}</span>, <span class="label label-default">{$value.word2}</span> and <span class="label label-default">{$value.word3}</span></td>
</tr>
{/loop}
</tbody>
</table>
</div>
</div>
=======
{if="$recent_public"}
<h4>Recent Answers by others:</h4>
<table class="table table-responsive table-bordered table-condensed">
<tbody>
{loop="$words"}
<tr>
<td><b>{$value.author}</b> wrote that {$user_name} is <span class="label label-default">{$value.word1}</span>, <span class="label label-default">{$value.word2}</span> and <span class="label label-default">{$value.word3}</span></td>
</tr>
{/loop}
</tbody>
</table>
>>>>>>> 95c4db170369fc5edd52d9277936175e39c5816c
{/if}
</div>
{include="footer"}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment