Browse Source

Fix post() for category deleting

Prinsipnya kan categori yang memiliki post baik itu publik atau draf harusnya tidak bisa dihapus. pada template view sudah dibatasi demikian, namun ketika saya mencoba secara langsung melalui link `/category/nama_category/delete` bisa terhapus meski category tersebut memiliki postingan.
Dengan fix ini maka hal itu tidak akan terjadi.
pull/475/head
Yaya Laressa 4 years ago
committed by GitHub
parent
commit
4f442b9855
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 3 deletions
  1. +26
    -3
      system/htmly.php

+ 26
- 3
system/htmly.php View File

@ -1903,12 +1903,35 @@ get('/category/:category/delete', function ($category) {
}); });
// Get deleted category data // Get deleted category data
post('/category/:category/delete', function () {
post('/category/:category/delete', function ($category)
{
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if ($proper && login()) {
if ($proper && login())
{
$desc = get_category_info($category);
if (strtolower($category) !== 'uncategorized')
{
$desc = $desc[0];
}
$file = from($_REQUEST, 'file'); $file = from($_REQUEST, 'file');
$destination = from($_GET, 'destination'); $destination = from($_GET, 'destination');
delete_page($file, $destination);
if (get_categorycount($desc->md) == 0 && get_draftcount($desc->md) == 0)
{
delete_page($file, $destination);
}
else
{
if ($destination == 'post')
{
$redirect = site_url();
header("Location: $redirect");
}
else
{
$redirect = site_url() . $destination;
header("Location: $redirect");
}
}
} }
}); });


Loading…
Cancel
Save