From aba35f0fb84d6262f733dc77c55ed158e9708fba Mon Sep 17 00:00:00 2001 From: Pk11 Date: Thu, 31 Mar 2022 02:48:51 -0500 Subject: [PATCH] --- bbs.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/bbs.php b/bbs.php index 9f403db..3a6a98f 100644 --- a/bbs.php +++ b/bbs.php @@ -1,5 +1,5 @@ [bottom]

+ "; echo ''; - if($row['poster_id'] == $_COOKIE['pid'] || $_COOKIE['pid'] == ADMIN_ID) + if((!empty($row['user_id']) && ($row['user_id'] == $_COOKIE['uid'])) || $_COOKIE['uid'] == ADMIN_ID) { echo ' '; + $show_delete = TRUE; + } echo "{$row['name']} {$row['post_time']} "; echo "#{$row['post_id']}"; echo ''; @@ -139,16 +144,18 @@ echo ''; } - echo ''; + + if($show_delete) + echo '

'; echo ''; } function cleanup($id, $force = FALSE) { - $query = "SELECT poster_id, img FROM posts WHERE post_id=$1"; + $query = "SELECT user_id, img FROM posts WHERE post_id=$1"; $result = pg_query_params($query, [$id]) or die('Query failed: ' . pg_last_error()); $row = pg_fetch_array($result); pg_free_result($result); - if($force || $row['poster_id'] == $_COOKIE['pid'] || $_COOKIE['pid'] == ADMIN_ID) { + if($force || $row['user_id'] == $_COOKIE['uid'] || $_COOKIE['uid'] == ADMIN_ID) { unlink(UPLOAD_PATH . $row['img']); $query = "DELETE FROM posts WHERE post_id=$1"; pg_query_params($query, [$id]) or die('Query failed: ' . pg_last_error()); @@ -200,7 +207,7 @@ $save_cookie = isset($_POST['save_cookie']); $err = post($name, $comment, $img, $save_cookie); - } else if($_POST['submit'] == 'Delete' && !empty($_COOKIE['pid'])) { + } else if($_POST['submit'] == 'Delete' && !empty($_COOKIE['uid'])) { foreach($_POST['delete'] as $id) { cleanup($id); } @@ -233,7 +240,7 @@ - /> (Allows deleting your own posts) + /> (Allows deleting your own posts) @@ -256,7 +263,7 @@

Valid XHTML 1.0 Transitional - +