-
Notifications
You must be signed in to change notification settings - Fork 6
/
show_results.php
125 lines (99 loc) · 4.78 KB
/
show_results.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/*
OWASP ASVS Assessment Tool (OWAAT)
Copyright (C) 2014 Mahmoud Ghorbanzadeh <mdgh (a) aut.ac.ir>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
include "settings.php";
include 'function.php';
if(!isset($_SESSION['admin']))
error($PN.'10');
header('Content-Type: text/html; charset=utf-8');
include 'db.php';
if(isset($_GET["assignment_chapters_id"]))
{
$assignment_chapters_id_array = explode(",", $_GET['assignment_chapters_id']);
$assignment_chapters_id = '';
foreach($assignment_chapters_id_array as $chapterID)
{
if($assignment_chapters_id != '')
$assignment_chapters_id .= ',';
$chapterID = trim($chapterID);
$assignment_chapters_id .= (int)$chapterID;
}
}
else
error($PN.'11');
if(isset($_GET["jtSorting"]) && isset($_GET["jtStartIndex"]) && isset($_GET["jtPageSize"]))
{
$Sorting_array_multiple = explode(",", $_GET['jtSorting']);
$sort = '';
foreach($Sorting_array_multiple as $Sorting)
{
$Sorting = trim($Sorting);
$Sorting_array = explode(" ", $Sorting);
if($sort != '')
$sort .= ', ';
if(!isset($Sorting_array[0]) || !isset($Sorting_array[1]))
error($PN.'12');
switch ($Sorting_array[0]) {
case "chapter_id":
$sort .= 'G.chapter_id';
break;
case "rule_number":
$sort .= 'G.rule_number';
break;
case "title":
$sort .= 'G.title';
break;
case "uname":
$sort .= 'G.uname';
break;
case "PassOrFail":
$sort .= 'H.PassOrFail';
break;
case "comment":
$sort .= 'H.comment';
break;
case "last_modified":
$sort .= 'H.last_modified';
break;
default:
error($PN.'13');
}
if($Sorting_array[1] == 'ASC')
$sort .= ' ASC';
else
$sort .= ' DESC';
}
$Sorting = $sort;
$StartIndex = (int)$_GET['jtStartIndex'];
$PageSize = (int)$_GET['jtPageSize'];
}
else
error($PN.'14');
$result = mysql_query("SELECT COUNT(*) AS RecordCount FROM (SELECT E.assignment_id, E.id FROM (SELECT A.assignment_id, B.id, B.chapter_id FROM (SELECT chapter_id, assignment_id FROM assignment_chapter WHERE id IN (".$assignment_chapters_id.")) AS A LEFT JOIN (SELECT rules.id, rules.chapter_id FROM rules) AS B ON A.chapter_id = B.chapter_id) AS E LEFT JOIN (SELECT C.id, D.uname FROM (SELECT id, user_id FROM assignment WHERE id IN (SELECT assignment_id FROM assignment_chapter WHERE id IN (".$assignment_chapters_id."))) AS C LEFT JOIN (SELECT id, uname FROM users) AS D ON C.user_id = D.id) AS F ON E.assignment_id =F.id) AS G INNER JOIN (SELECT assignment_id, rule_id FROM assessment_rules WHERE assignment_id IN (SELECT assignment_id FROM assignment_chapter WHERE id IN (".$assignment_chapters_id."))) AS H ON G.id = H.rule_id and H.assignment_id=G.assignment_id") or error($PN.'15');
$result2 = mysql_query("SELECT G.chapter_id, G.rule_number, G.title, G.uname, H.id, H.PassOrFail, H.comment, H.last_modified FROM (SELECT E.assignment_id, E.id, E.chapter_id, E.rule_number, E.title, F.uname FROM (SELECT A.assignment_id, B.id, B.chapter_id, B.rule_number, B.title FROM (SELECT chapter_id, assignment_id FROM assignment_chapter WHERE id IN (".$assignment_chapters_id.")) AS A LEFT JOIN (SELECT rules.id, rules.chapter_id, rules.rule_number, rules.title FROM rules) AS B ON A.chapter_id = B.chapter_id) AS E LEFT JOIN (SELECT C.id, D.uname FROM (SELECT id, user_id FROM assignment WHERE id IN (SELECT assignment_id FROM assignment_chapter WHERE id IN (".$assignment_chapters_id."))) AS C LEFT JOIN (SELECT id, uname FROM users) AS D ON C.user_id = D.id) AS F ON E.assignment_id =F.id) AS G INNER JOIN (SELECT id, assignment_id, rule_id, PassOrFail, comment, last_modified FROM assessment_rules WHERE assignment_id IN (SELECT assignment_id FROM assignment_chapter WHERE id IN (".$assignment_chapters_id."))) AS H ON G.id = H.rule_id and H.assignment_id=G.assignment_id ORDER BY ".$Sorting." LIMIT ".$StartIndex.",".$PageSize.";") or error($PN.'16');
$row = mysql_fetch_array($result);
$recordCount = $row['RecordCount'];
$rows = array();
while($row = mysql_fetch_array($result2))
{
$rows[] = $row;
}
$response = array();
$response['Result'] = "OK";
$response['TotalRecordCount'] = $recordCount;
$response['Records'] = $rows;
print json_encode($response);
@mysql_close();
?>