-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuid.php
executable file
·302 lines (266 loc) · 11.8 KB
/
uid.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
include("include/superHead.php");
include("include/mysql_connect.php");
?>
<!DOCTYPE html>
<html>
<head>
<?php include("include/leaderBoardHeader.php"); ?>
<script>
$(document).ready(function(){
$( ".show_func" ).click(function() {
var splits = this.id.split('<===>');
$.get("./getFunc.php", { uid: splits[0], fid: splits[1] })
.done(function(data) {
//alert(data);
$(".modal-title").html("Show Function");
$("#modal_content").html("<p><strong>User:"+splits[2]+"  Function:"+splits[3]+"</strong></p><pre class=\"sh_cpp\">"+data+"</pre>");
sh_highlightDocument();
});
});
$( ".show_incomplete" ).click(function() {
var splits = this.id.split('<===>');
var show = "*Please note that the following functions have not been evaluated for collection "
+splits[0]+". Try to evaluate them (clicking on functions) and see whether your can be the best! <br><br>";
show += "<ul>";
for (var i = 1; i < splits.length; i++){
if (splits[i].length > 0){
var _id = splits[i];
var func_name = _id.split(':::')[0];
var groupID = _id.split(':::')[1];
show += "<li><form action=\"evaFun.php\" method=\"post\">" + "<input type=\"hidden\" name=\"groupID\" value=\"" + groupID + "\" />" + "<button type=\"submit\" class=\"btn btn-default btn-sm\">"+func_name+"</button>" + "</form></li>";//"<li><a id=\""+_id+"\" style=\"cursor:pointer;\" onClick=\"eval_func(this.id);\">"+splits[i]+"</a></li>";
}
}
show += "</ul>";
$(".modal-title").html("Incomplete Evaluation");
$("#modal_content").html(show);
});
function eval_func(_id) {
alert("hehe");
var url = 'evaFun.php';
var form = $('<form action="' + url + '" method="post">' + '<input type="text" name="groupID" value="' + _id + '" />' + '</form>');
$('body').append(form);
$(form).submit();
}
});
</script>
</head>
<body onload="sh_highlightDocument();">
<?php //session_start();
if(!isset($_SESSION['user'])){
echo "This toolkit is only for register users, please <a href=\"login.php\">Login</a><br/>\n";
header('Location: login.php');
}
?>
<?php
function getThisUser() {
$sql_user = mysqli_connect('p:'.MysqlHost,MysqlUser,MysqlPassword,'users2',MysqlPort);
$query="select * from user where userID = " . $_GET['uid'];
$result = mysqli_query($sql_user,$query);
if(!$result) echo "Could not get index list.<br/>\n";
else
{
while($row = mysqli_fetch_row($result))
{
$userID = $row[0];
$loginName = $row[1];
$firstName = $row[4];
$lastName = $row[5];
$this_user = array($userID, $loginName, $firstName, $lastName);
}
}
mysqli_close($sql_user);
return $this_user;
}
?>
<div class="container">
<a href="allUsers.php">Users List</a>
<div>
<table class="table table-bordered table-hover" style="text-align:center;">
<thead>
<tr>
<th>userID</th>
<th>loginID</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$this_user = getThisUser();
foreach ($this_user as $v) {
echo "<td>$v</td>";
}
?>
</tr>
</tbody>
</table>
<?php
$username=$_SESSION['user'];
$uid=$_SESSION['userID'];
$getuid=$_GET['uid'];
//echo "uid uid uid:".$uid."<br>";
//echo "username username username:".$username."<br>";
$sql_collection = mysqli_connect('p:'.MysqlHost,MysqlUser,MysqlPassword,'collections2',MysqlPort);
if(!$sql_collection) echo "Could not connect to databases.<br/>\n";
$sql_eval = mysqli_connect('p:'.MysqlHost,MysqlUser,MysqlPassword,'evaluations2',MysqlPort);
$sql_user = mysqli_connect('p:'.MysqlHost,MysqlUser,MysqlPassword,'users2',MysqlPort);
if(!$sql_user) echo "Could not connect to databases.<br/>\n";
$LeaderBoard=array();
$query_index="select collectionID,collectionName from collection order by collectionName";
$result_index = mysqli_query($sql_collection,$query_index);
if(!$result_index) echo "Could not get index list.<br/>\n";
else
{
while($row_index = mysqli_fetch_row($result_index))
{
$function_array = array();
$leaderBoard_cnt = 0;
$index=$row_index[0];
$collectionName=$row_index[1];
if (!array_key_exists($collectionName, $LeaderBoard)){
$LeaderBoard[$collectionName] = array();
}
//echo "<em>$index</em><br>";
$query_eval="select * from evaluation where collectionID=$index and userID=$getuid order by map desc, p30 desc";
//echo "$query_eval<br>";
$result_eval = mysqli_query($sql_eval,$query_eval);
if(!$result_eval) {
echo "Could not get evaluation results list.<br/>\n";
} else {
while($row_eval = mysqli_fetch_row($result_eval)){
$evaluationID=$row_eval[0];
$uid=$row_eval[1];
$collectionID=$row_eval[2];
$functionID=$row_eval[3];
$MAP=$row_eval[4];
$P30=$row_eval[5];
if($uid == 0){
// super user, do not have user name.
continue;
}
if (in_array($functionID, $function_array)) {
continue;
}
//echo $evaluationID."===>".$uid."===>".$collectionID."===>".$functionID."===>".$MAP."===>".$P30."<br>";
$query_user="select userID,loginName,userType,userGroup from user where userID=$uid";
$results_user=mysqli_query($sql_user,$query_user);
$row_user=mysqli_fetch_row($results_user);
$userID=$row_user[0];
$user=$row_user[1];
$userType=$row_user[2];
$userGroup=$row_user[3];
//echo $user;
mysqli_free_result($results_user);
if ($userType >= 1 && $userGroup == MyUserGroupID){
$query_func="select * from function where userID=$uid and functionID=$functionID and onlyFlag=1";
$results_func=mysqli_query($sql_user,$query_func);
//var_dump($results_func);
if (mysqli_num_rows($results_func) != 0) {
//echo $evaluationID."===>".$uid."===>".$collectionID."===>".$functionID."===>".$MAP."===>".$P30."<br>";
$row_func=mysqli_fetch_row($results_func);
//var_dump($row_func);
$funtion_path=$row_func[4];
//echo "onlyFlag:".$row_func[3]."<br>";
$func_path_split=explode('/', $funtion_path);
$ret_func=substr($func_path_split[sizeof($func_path_split)-1], 0, sizeof($func_path_split[sizeof($func_path_split)-1])-5);
//echo $user."--->".$ret_func."--->".$collectionName."--->".$MAP."--->".$P30."<br>";
//echo $evaluationID."===>".$uid."===>".$collectionID."===>".$functionID."===>".$MAP."===>".$P30."<br>";
$LeaderBoard[$collectionName][] = array("userID" => $userID, "user" => $user, "funcID" => $functionID, "fPath" => $funtion_path, "ret_func" => $ret_func, "collectionID" => $index, "collection" => $collectionName, "MAP" => $MAP, "P30" => $P30);
$leaderBoard_cnt++;
$function_array[] = $functionID;
if ($leaderBoard_cnt >= 100) {
break;
}
}
mysqli_free_result($results_func);
}
}
}
mysqli_free_result($result_eval);
}
mysqli_free_result($result_index);
}
mysqli_close($sql_user);
mysqli_close($sql_collection);
mysqli_close($sql_eval);
//var_dump($LeaderBoard);
echo "<ul class=\"nav nav-tabs\">";
$outer_i=0;
foreach($LeaderBoard as $index => $ranks){
if ($outer_i == 0){
echo "<li class=\"active\"><a href=\"#$index\" data-toggle=\"tab\">$index</a></li>";
} else {
echo "<li><a href=\"#$index\" data-toggle=\"tab\">$index</a></li>";
}
$outer_i++;
}
echo "</ul>";
echo "<div class=\"tab-content\">";
$outer_i=0;
foreach($LeaderBoard as $index => $ranks){
if ($outer_i == 0){
echo "<div class=\"tab-pane active\" id=\"$index\">";
} else {
echo "<div class=\"tab-pane\" id=\"$index\">";
}
echo "<table class=\"table table-bordered table-hover\" style=\"text-align:center;\">";
echo "<thead>
<tr>
<th>Rank</th>
<th>Retrieval Function</th>
<th>Function Path</th>
<th>MAP</th>
<th>P@30</th>
</tr>
</thead>
<tbody>";
$keys = array_keys($ranks);
if (sizeof($keys) > 0){
for ($i=0;$i<sizeof($keys);$i++){
$user = $ranks[$keys[$i]]["user"];
$userID = $ranks[$keys[$i]]["userID"];
$funcID = $ranks[$keys[$i]]["funcID"];
$funPath = $ranks[$keys[$i]]["fPath"];
$func = $ranks[$keys[$i]]["ret_func"];
$collectionID = $ranks[$keys[$i]]["collectionID"];
echo "<tr>";
echo "<td>".($i+1)."</td>";
echo "<td><button data-toggle=\"modal\" href=\"#show_modal\" class=\"btn btn-info btn-sm show_func\" id=\"$userID<===>$funcID<===>$user<===>$func\">$func</button></td>";
echo "<td>$funPath</td>";
echo "<td>".$ranks[$keys[$i]]["MAP"]."</td>";
echo "<td>".$ranks[$keys[$i]]["P30"]."</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan=\"5\">There is NO evaluation for this collection yet.</td></tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
$outer_i++;
}
echo "</div>";
?>
</div>
<!-- Modal -->
<div class="modal fade" id="show_modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Show Function</h4>
</div>
<div class="modal-body">
<div class="accordion" id="modal_content">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</body>
</html>