-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
445 lines (386 loc) · 18 KB
/
index.php
File metadata and controls
445 lines (386 loc) · 18 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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<?php ?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Git Challenge</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#337ab7">
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="assets/components/jquery.scrollex/jquery.scrollex.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/skel/3.0.1/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!--[if lte IE 8]><script src="assets/components/html5shiv/dist/html5shiv.min.js"></script><![endif]-->
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
<!-- Stylesheets -->
<link rel="stylesheet" href="assets/css/main.css"/>
<link rel="stylesheet" href="assets/css/git-challenge.css"/>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css"/><![endif]-->
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css"/><![endif]-->
<link rel="manifest" href="manifest.json">
</head>
<?php
if (file_exists("include/configuration.php")) {
$configs = include("include/configuration.php");
} else {
$configs = include("include/configuration-template.php");
}
require("connection.php");
$connection = new Connection;
$conn = $connection->initialize();
$alert = new Alert;
$call_count = 0;
?>
<body>
<!-- Wrapper -->
<div id="wrapper">
<!-- Header -->
<header id="header" class="alt">
<h1 class="fa fa-git-square">Challenge</h1>
<table class="alt">
<thead>
<tr>
<th>Rank</th>
<th>Name</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT * FROM Users ORDER BY score DESC";
$result = $conn->query($query);
for ($row = 0; $row < $result->num_rows; $row++) {
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
$challengeScore = 0;
$ChallengeQuery = "SELECT * FROM Challenges ORDER BY points DESC";
$challengeResult = $conn->query($ChallengeQuery);
for ($challengeRow = 0; $challengeRow < $challengeResult->num_rows; $challengeRow++) {
$challenge = $challengeResult->fetch_assoc();
if (strpos($challenge["users"], $user["username"]) !== false) {
$challengeScore += $challenge["points"];
}
}
$sql = "UPDATE Users SET challenge=" . $challengeScore . " WHERE id='" . $user["id"] . "'";
$conn->query($sql);
}
}
$query = "SELECT * FROM Users ORDER BY score DESC";
$result = $conn->query($query);
for ($row = 0; $row < 5; $row++) {
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
$score = ($user["added"] * $configs->points->additions) + ($user["removed"] * $configs->points->deletions) + ($user["challenge"] * $configs->points->challenges) + ($user["commits"] * $configs->points->commits) + ($user["issues"] * $configs->points->issues) + ($user["pullRequests"] * $configs->points->pullRequests);
$sql = "UPDATE Users SET score=" . $score . " WHERE id='" . $user["id"] . "'";
$conn->query($sql);
echo "<tr>";
echo "<td>" . ($row + 1) . "</td>";
echo "<td>" . $user["name"] . "</td>";
echo "<td>" . $score . "</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
</header>
<!-- Nav -->
<nav id="nav">
<ul>
<?php
if ($configs->options->info == true) {
echo "<li><a href=\"#intro\" class=\"active\">Introduction</a></li>";
}
?>
<li><a href="#breakdown">Point Breakdown</a></li>
<?php
if ($configs->options->event == true) {
echo "<li><a href=\"#event\">Event</a></li>";
}
?>
<?php
if ($configs->options->challenges == true) {
echo "<li><a href=\"#challenges\">Challenges</a></li>";
}
?>
<li><a href="#second">Statistics</a></li>
<?php
if ($configs->options->debug == true) {
echo "<li><a href=\"#debug\">Debug</a></li>";
}
?>
</ul>
</nav>
<!-- Main -->
<div id="main">
<?php
if ($configs->options->info == true) {
?>
<!-- Introduction -->
<section id="intro" class="main">
<div class="spotlight">
<div class="content">
<header class="major">
<h2>Idea</h2>
</header>
<p>Git Challenge was a project I had an idea for when I looked over a GitHub Organisation I was
a
part of. It is for my old High School Technology Team, the organisation that taught me most
of
what I knew about programming before I came to RIT. The projects in the GitHub hadn't been
touched
by anyone except myself and a few other Team Alumni. So I thought I should come up with a
way to
encourage contributing to these projects, and to teach people git. So I came up with
Git-Challenge. A app made to gamify contributing to projects, for any Organisation. Not just
this Tech Team. It could be used for CSH, or really any other git organisation with multiple
contributors.</p>
<ul class="actions">
<li><a href="https://github.com/devinmatte/Git-Challenge" class="button">Learn More</a></li>
<li><a href="howTogit.php" class="button">Learn Git</a></li>
</ul>
</div>
</div>
</section>
<?php
}
?>
<!-- Breakdown Section -->
<section id="breakdown" class="main special">
<header class="major">
<h2>Point Breakdown</h2>
</header>
<div class="alert alert-success"><h3>Point Scaling</h3><h4>
Additions: <?php echo $configs->points->additions; ?> |
Deletions: <?php echo $configs->points->deletions; ?> |
Commits: <?php echo $configs->points->commits; ?> | Issues: <?php echo $configs->points->issues; ?>
| Merged Pull Requests: <?php echo $configs->points->pullRequests; ?></h4></div>
<table class="alt">
<thead>
<tr>
<th>Rank</th>
<th></th>
<th>Name</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT * FROM Users ORDER BY score DESC";
$result = $conn->query($query);
for ($row = 0; $row < $result->num_rows; $row++) {
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
$score = ($user["added"] * $configs->points->additions) + ($user["removed"] * $configs->points->deletions) + ($user["challenge"] * $configs->points->challenges) + ($user["commits"] * $configs->points->commits) + ($user["issues"] * $configs->points->issues) + ($user["pullRequests"] * $configs->points->pullRequests);
$sql = "UPDATE Users SET score=" . $score . " WHERE id='" . $user["id"] . "'";
$conn->query($sql);
echo "<tr>";
echo "<td align=\"center\" width=\"10%\">" . ($row + 1) . "</td>";
echo "<td align=\"center\" width=\"10%\">" . "<a href=\"https://github.com/" . $user["username"] . "\"><img src=\"https://avatars1.githubusercontent.com/u/" . $user["id"] . "\" width=\"100%\" alt=\"\" /></a>" . "</td>";
echo "<td align=\"center\" width=\"45%\">" . $user["name"] . "</td>";
echo "<td align=\"center\" width=\"45%\">" . $score . "</td>";
echo "</tr><tr>";
echo "<td colspan=\"4\" nowrap=\"nowrap\" align=\"center\"><div class=\"progress\">
<div class=\"progress-bar progress-bar-success active fa fa-plus-circle\" title=\"Additions: " . $user["added"] . "\" role=\"progressbar\" style=\"width:" . ((float)((float)$user["added"] / (float)$score)) * (100.0 * $configs->points->additions) . "%\">
</div>
<div class=\"progress-bar progress-bar-danger active fa fa-minus-circle\" title=\"Deletions: " . $user["removed"] . "\" role=\"progressbar\" style=\"width:" . ((float)((float)$user["removed"] / (float)$score)) * (100.0 * $configs->points->deletions) . "%\">
</div>
<div class=\"progress-bar progress-bar-info active fa fa-upload\" title=\"Commits: " . $user["commits"] . "\" role=\"progressbar\" style=\"width:" . ((float)(((float)$user["commits"] / (float)$score)) * (100.0 * $configs->points->commits)) . "%\">
</div>
<div class=\"progress-bar progress-bar-issue active fa fa-exclamation-circle\" title=\"Issues: " . $user["issues"] . "\" role=\"progressbar\" style=\"width:" . ((float)(((float)$user["issues"] / (float)$score)) * (100.0 * $configs->points->issues)) . "%\">
</div>
<div class=\"progress-bar progress-bar-pr-merged active fa fa-code-fork\" title=\"Pull Requests (Merged): " . $user["pullRequests"] . "\" role=\"progressbar\" style=\"width:" . ((float)(((float)$user["pullRequests"] / (float)$score)) * (100.0 * $configs->points->pullRequests)) . "%\">
</div>
<div class=\"progress-bar progress-bar-warning active fa fa-trophy\" title=\"Challenge Points: " . $user["challenge"] . "\" role=\"progressbar\" style=\"width:" . ((float)((float)$user["challenge"] / (float)$score)) * (100.0 * $configs->points->challenges) . "%\">
</div>
</div>" . "</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
<footer class="major">
<a class="button special fit"
title="<?php echo $configs->options->maxcalls; ?> API Calls | Will take time, please be patient"
href='index.php?load=true'>Load New Data</a>
</footer>
</section>
<?php
if ($configs->options->event == true) {
?>
<section id="event" class="main special">
<header class="major">
<h2>Event</h2>
</header>
<p>
<?php
echo "Work in Progress. Cool prizes coming soon!";
?>
</p>
<footer class="major">
</footer>
</section>
<?php
}
?>
<?php
if ($configs->options->challenges == true) {
?>
<section id="challenges" class="main special">
<header class="major">
<h2>Challenges</h2>
</header>
<?php
$query = "SELECT * FROM Challenges ORDER BY name";
$result = $conn->query($query);
$styles = [
"style5",
"style1",
"style2",
"style3",
"style4"
];
$stylePointer = 0;
for ($row = 0; $row < $result->num_rows; $row++) {
$challenge = $result->fetch_assoc();
?>
<div id="testmodal<?php echo $challenge['id'] ?>" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?php echo $challenge['name'] ?></h4>
<h5 class="modal-title"><?php echo $challenge['points'] ?> Points</h5>
</div>
<div class="modal-body">
<?php echo $challenge['description'] ?>
<form action="<?php echo $challenge['hint'] ?>">
<input type="submit" class="button special small fit" value="Hint"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="button fit" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
}
$query = "SELECT * FROM Challenges ORDER BY name";
$result = $conn->query($query);
echo "<ul class=\"statistics\">";
$styles = [
"style5",
"style1",
"style2",
"style3",
"style4"
];
$stylePointer = 0;
for ($row = 0; $row < $result->num_rows; $row++) {
$challenge = $result->fetch_assoc();
?>
<?php if ($stylePointer >= 5) {
echo "</ul><ul class=\"statistics\">";
} ?>
<li data-toggle="modal" data-target="#testmodal<?php echo $challenge['id'] ?>"
class="<?php if ($stylePointer < 5) {
echo $styles[$stylePointer++];
} else {
$stylePointer = 0;
echo $styles[$stylePointer++];
} ?> ">
<span class="icon fa-trophy"></span>
<p><?php echo $challenge['name'] ?></p>
</li>
<?php
}
?>
</ul>
<footer class="major">
</footer>
</section>
<?php
}
?>
<!-- Second Section -->
<section id="second" class="main special">
<header class="major">
<h2>Statistics</h2>
</header>
<ul class="statistics">
<li class="style2">
<span class="icon fa-folder-open-o"></span>
<?php
$query = "SELECT * FROM Stats ORDER BY commits DESC";
$result = $conn->query($query);
?>
<strong><?php echo $result->num_rows; ?></strong> Total Repositories
</li>
<li class="style3">
<span class="icon fa-signal"></span>
<?php
$query = "SELECT * FROM Stats ORDER BY commits DESC";
$result = $conn->query($query);
$total = 0;
for ($i = 0; $i < $result->num_rows; $i++) {
$commit = $result->fetch_assoc();
$total += $commit["commits"];
}
?>
<strong><?php echo $total; ?></strong> Total Commits
</li>
<li class="style4">
<span class="icon fa-users"></span>
<?php
$query = "SELECT * FROM Users ORDER BY score DESC";
$result = $conn->query($query);
?>
<strong><?php echo $result->num_rows; ?></strong> Total Contributors
</li>
</ul>
<footer class="major">
</footer>
</section>
<?php
if ($configs->options->debug == true) {
?>
<section id="debug" class="main special">
<header class="major">
<h2>Debugging</h2>
</header>
<?php
if (isset($_GET['load'])) {
require("main.php");
$main = new main($conn, $configs, $alert);
}
?>
<footer class="major">
</footer>
</section>
<?php
}
?>
</div>
<!-- Footer -->
<footer id="footer">
<p class="copyright">
<a href="https://github.com/devinmatte/Git-Challenge" class="icon fa-github"><span
class="label">GitHub</span></a>
</br>
© <?php echo date("Y") ?> <a href="https://github.com/devinmatte">Devin Matte</a> | Design: <a
href="https://html5up.net">HTML5 UP</a>.</p>
</footer>
</div>
</body>
</html>
<?php
mysqli_close($conn);
?>