This repository was archived by the owner on Oct 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstats.php
More file actions
90 lines (82 loc) · 3 KB
/
stats.php
File metadata and controls
90 lines (82 loc) · 3 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
<?php
/*
This page is used to look for stats from different users, even more than one user at the same time, so you can compare them.
*/
session_start();
include("includes/header.html");
include('includes/print_messages.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
require ('mysqli_connect.php');
require ('includes/login_functions.inc.php');
$nicks [] = $_POST['nick'];
$i = 0;
while (isset($_POST['nick'.$i])) {
$nicks [] = $_POST['nick'.$i];
$i++;
}
//check if all the nicks exists in our database
foreach ($nicks as $key => $nick) {
$q = "SELECT id_user FROM users WHERE nick='$nick'";
$r = @mysqli_query ($dbc, $q);
$num = mysqli_num_rows($r);
if (0 === $num) {
$error = "The username '$nick' was not found.";
break;
} else {
$row = mysqli_fetch_array($r, MYSQLI_ASSOC);
$uids [] = $row['id_user'];
}
}
// If all of them exists, it redirects the user to user_stats.php with all the users like GET params.
if (!isset($error)) {
$link = "user_stats.php?";
foreach ($uids as $key => $uid) {
if (0 === $key) $link .= "uid=$uid";
else $link .= "&uid$key=$uid";
}
redirect_user($link);
} else echo print_message('danger', "Error: $error"); // If some user does not exist, it prints the error.
}
?>
<div class="row text-center login-title">
<div class="col-sm-12 text-center">
<h1 style="font-size: 4em; text-align: center !important;">See and compare stats</h1>
</div>
</div>
<script>
var i=0;
</script>
<div class="row" style="margin-top: 20px;">
<div class="col-sm-2 offset-5">
<form class="form-horizontal" action="stats.php" method="post">
<div class="form-group row">
<div class="col-sm-12">
<div class="input-group">
<input type="text" class="form-control" name="nick" required id="nick" maxlength="20" placeholder="Username" value="<?php if (isset($_POST['nick'])) echo $_POST['nick']; ?>">
<div class="input-group-btn">
<button class="btn btn-primary" type="button" onclick="addUsers()"><span class="fa fa-plus" style="font-size:1.2em;"></span></button>
</div>
</div>
</div>
<div class="col-sm-2 text-left">
</div>
</div>
<div id="add-users"></div>
<div class="form-group row">
<div class="col-sm-12 text-right">
<button type="submit" class="btn btn-primary btn-block">Submit</button>
</div>
</div>
</form>
</div>
</div>
<script>
// This is used to add all the users you would like to compare. That way it's not static and because it depends on what the user wants to do, if it must be reactive, it must be done with JS.
function addUsers() {
document.getElementById("add-users").innerHTML += '<div class="form-group row"><div class="col-sm-12"><input type="text" class="form-control" name="nick'+i+'" id="nick'+i+'" maxlength="20" placeholder="Username '+(i+2)+'"></div></div>';
i++;
}
</script>
<?php
include("includes/footer.html");
?>