-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdelete.php
More file actions
41 lines (33 loc) · 1.09 KB
/
delete.php
File metadata and controls
41 lines (33 loc) · 1.09 KB
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
<?php
require_once 'conn.php';
require_once 'auth.php';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT * FROM tb_files WHERE id = $id";
$rs = $conn->query($query);
if ($rs == true) {
$data = mysqli_fetch_array($rs);
$drive_id = $data['drive_id'];
echo $drive_id;
// delete from google drive
$client = auth();
$client->addScope(Google\Service\Drive::DRIVE);
$service = new Google\Service\Drive($client);
$del = $service->files->delete($drive_id);
if ($del) {
// delete from db
$query = "DELETE FROM tb_files WHERE id = $id";
$rs = $conn->query($query);
if ($rs == true) {
header('Location: index.php');
} else {
echo 'Delete Failed: Database';
}
} else {
echo 'Delete Failed: Drive';
}
} else {
echo 'File Not Found';
}
}
?>