-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
51 lines (39 loc) · 1.02 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
// delete.php
require_once 'assets/config/config.php';
require_once "vendor/autoload.php";
use PhotoTech\ErrorHandler;
use PhotoTech\Database;
use PhotoTech\ImageContentManager;
$errorHandler = new ErrorHandler();
// Register the exception handler method
set_exception_handler([$errorHandler, 'handleException']);
$database = new Database();
$pdo = $database->createPDO();
// New Instance of Login Class
if (!$database->check_login_token()) {
header('location: index.php');
exit();
}
$id = $_GET['id'] ?? null;
if (!empty($id)) {
$args['id'] = $id;
$gallery = new ImageContentManager($pdo, $args);
$data = $gallery->fetch_by_id();
/*
* Delete the images from the directories
*/
unlink($data['image_path']);
unlink($data['thumb_path']);
/*
* Delete the record from the Database Table
*/
$gallery->delete();
/*
* Redirect to the Administrator's Home page
*/
header("Location: dashboard.php");
exit();
}
header("Location: dashboard.php");
exit();