-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_sheet.php
70 lines (56 loc) · 1.69 KB
/
delete_sheet.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once('settings.php');
require_once('moodle.inc');
if (isloggedin() && $USER->username != 'guest') {
$moodle_id = $USER->id;
} else {
die("Not logged in");
}
if (isloggedin() && $USER->username != 'guest') {
$moodle_id = $USER->id;
} else {
die("Not logged in");
}
$link = mysql_connect($db_server,$db_username,$db_password);
if (! mysql_select_db($db_database)) {
die(mysql_error());
}
if (empty( $sheet_id)) {
if (preg_match('/^\d+$/', $_POST['sheet_id'])) {
$query = sprintf('SELECT sheet_id FROM module_sheets WHERE sheet_id=%s AND moodle_id=%s',
$_POST['sheet_id'],
$moodle_id);
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
if ($row = mysql_fetch_assoc($result)) {
$sheet_id = $row['sheet_id'];
} else {
$message = 'Unknown sheet id ' . $_GET['sheet_id'] . " for user " . $moodle_id;
die($message);
}
} else {
$message = 'Invalid sheet id';
die($message);
return;
}
}
$query = sprintf('DELETE FROM module_sheets WHERE sheet_id=%s',$sheet_id);
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$query = sprintf('DELETE FROM module_data WHERE sheet_id=%s',$sheet_id);
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
header("Location:" . $sqa_www_root . "/admin_audits.php");
?>