1
0
mirror of https://github.com/glmdev/eecs448-lab10 synced 2024-10-27 19:14:00 +00:00
eecs448-lab10/DeletePost.php
2020-12-06 13:58:02 -06:00

25 lines
636 B
PHP

<?php
require './configuration.php';
$request = common\Request::capture();
$page = new common\Page;
$posts = new app\PostRepository;
$post_ids = [];
foreach ( $request->input() as $post_key => $value ) {
if ( $value !== 'yes' ) continue;
$post_id = explode('-', $post_key)[1];
$post_ids[] = $post_id;
$posts->delete(['post_id' => $post_id]);
}
$page->title('EECS 448 Lab 10 - Exercise 7')
->header('Posts Deleted')
->writes('<p>Posts with the following IDs were deleted: ' . implode(', ', $post_ids) . '</p>')
->writes('<a href="' . system_url('AdminHome.html') . '">Admin Home</a>');
$page->write();