diff options
Diffstat (limited to 'manage_post.php')
-rw-r--r-- | manage_post.php | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/manage_post.php b/manage_post.php index 8c6129b..3f9a9b3 100644 --- a/manage_post.php +++ b/manage_post.php @@ -1,15 +1,7 @@ <?php - -include_once 'includes/db_inc.php'; -include_once 'model/Post.php'; - -function delete_post($dbc, $post) { - $sql = "DELETE FROM posts WHERE post_id = $post->id"; - mysqli_query($dbc, $sql); - - $sql = "UPDATE categories SET `cat_post_count` = `cat_post_count` - '1' WHERE cat_id = " . $post->thread->category->id . ";"; - mysqli_query($dbc, $sql); -} +include('includes/db_inc.php'); +include('includes/functions_post.php'); +include('includes/model/Post.php'); session_start(); @@ -41,7 +33,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') { goto end; } - if ($_SESSION['user_id'] != $post->author->id) { echo "You can't manage another user's post!"; goto end; @@ -50,16 +41,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') { if (strcasecmp($delete, "on") == 0) { delete_post($dbc, $post); } else { - $sql = "UPDATE posts SET post_content = ?, post_date_edited = CONVERT_TZ(NOW(), 'SYSTEM', '+00:00') WHERE post_id = ?;"; - $stmt = mysqli_stmt_init($dbc); - - if (!mysqli_stmt_prepare($stmt, $sql)) { - die('Could not create post due to internal error: ' . mysqli_error($dbc)); - } - - mysqli_stmt_bind_param($stmt, "si", $post_content, $id); - mysqli_stmt_execute($stmt); - mysqli_stmt_close($stmt); + edit_post(); } end: |