-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdelete-user.php
More file actions
executable file
·30 lines (30 loc) · 1.4 KB
/
delete-user.php
File metadata and controls
executable file
·30 lines (30 loc) · 1.4 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
<?php
#!/usr/local/bin/php
chdir(__DIR__);
require '../includes/db.php';
$options = getopt('', array('id:'));
if (array_key_exists('id', $options) && intval($options['id']) > 1) {
$stmt = $db->prepare('SELECT name FROM users WHERE id = ?');
$stmt->execute(array($options['id']));
$name = $stmt->fetchColumn();
$stmt = $db->prepare('DELETE FROM users WHERE id = ?');
$stmt->execute(array($options['id']));
$stmt = $db->prepare('DELETE FROM api WHERE user_id = ?');
$stmt->execute(array($options['id']));
$stmt = $db->prepare('DELETE FROM cwd_bos WHERE user_id = ?');
$stmt->execute(array($options['id']));
$stmt = $db->prepare('DELETE FROM cwd_landscape_components WHERE user_id = ?');
$stmt->execute(array($options['id'])); // In the future we might also want to delete all the images on the server associated with the records being deleted
$stmt = $db->prepare('DELETE FROM cwd_messages WHERE user_id = ?');
$stmt->execute(array($options['id']));
$stmt = $db->prepare('DELETE FROM cwd_states WHERE user_id = ?');
$stmt->execute(array($options['id']));
$stmt = $db->prepare('DELETE FROM time_series WHERE user_id = ?');
$stmt->execute(array($options['id']));
$stmt = $db->prepare('DELETE FROM timing WHERE user_id = ?');
$stmt->execute(array($options['id']));
shell_exec('rm '.escapeshellarg("/var/www/html/{$name}"));
} else {
echo "Example usage: php delete-user.php --id=\"0\"\n";
}
?>