mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +01:00
Try to fix password field, cache ajax_pastes output for awhile.
This commit is contained in:
parent
26d00ce7b6
commit
3d11577eed
4 changed files with 15 additions and 3 deletions
|
@ -4,6 +4,12 @@ require_once('../includes/common.php');
|
|||
|
||||
use PonePaste\Models\Paste;
|
||||
|
||||
if (empty($_GET['q']) && $redis->exists('ajax_pastes')) {
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
echo $redis->get('ajax_pastes');
|
||||
die;
|
||||
}
|
||||
|
||||
$pastes = Paste::with([
|
||||
'user' => function($query) {
|
||||
$query->select('users.id', 'username');
|
||||
|
@ -24,7 +30,7 @@ $pastes = $pastes->get();
|
|||
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
|
||||
echo json_encode(['data' => $pastes->map(function($paste) {
|
||||
$pastes_json = json_encode(['data' => $pastes->map(function($paste) {
|
||||
return [
|
||||
'id' => $paste->id,
|
||||
'title' => $paste->title,
|
||||
|
@ -34,3 +40,7 @@ echo json_encode(['data' => $pastes->map(function($paste) {
|
|||
})
|
||||
];
|
||||
})]);
|
||||
|
||||
$redis->setEx('ajax_pastes', 3600, $pastes_json);
|
||||
|
||||
echo $pastes_json;
|
||||
|
|
|
@ -140,6 +140,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
]);
|
||||
|
||||
$paste->replaceTags(Tag::parseTagInput($tag_input));
|
||||
$redis->del('ajax_pastes'); /* Expire from Redis so the edited paste shows up */
|
||||
} else {
|
||||
$error = 'You must be logged in to do that.';
|
||||
}
|
||||
|
@ -167,6 +168,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
if ($p_visible == '0') {
|
||||
addToSitemap($paste, $priority, $changefreq);
|
||||
}
|
||||
$redis->del('ajax_pastes'); /* Expire from Redis so the new paste shows up */
|
||||
}
|
||||
|
||||
// Redirect to paste on successful entry, or on successful edit redirect back to edited paste
|
||||
|
|
|
@ -269,7 +269,7 @@
|
|||
<div class="columns">
|
||||
<div class="column">
|
||||
<input type="text" class="input" name="pass" id="pass"
|
||||
placeholder="Password" autocomplete="off"
|
||||
placeholder="Password" autocomplete="new-password"
|
||||
value="<?php echo (isset($_POST['pass'])) ? pp_html_escape($_POST['pass']) : ''; ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -341,7 +341,7 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
|
|||
<div class="columns">
|
||||
<div class="column">
|
||||
<input type="text" class="input" name="pass" id="pass" value=""
|
||||
placeholder="Password" autocomplete="off" />
|
||||
placeholder="Password" autocomplete="new-password" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue