-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_download.php
141 lines (128 loc) · 5.11 KB
/
test_download.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
<?php
// do login verification here
error_reporting(E_ALL ^ E_WARNING);
session_start();
include "connect.php";
$username = $_SESSION['username'];
$sql = "SELECT * FROM accounts WHERE user='$username'";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$admin_stat = $row['admin_status'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Liar's Dice </title>
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="stylesheet" type="text/css" href="index.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fascinate+Inline&family=Orbitron&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Kdam+Thmor+Pro&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<link rel = "icon" href = "img/icon.png" type = "image/x-icon">
<!-- JavaScript Bundle with Popper -->
</head>
<style>
<?php
include "css/main.css";
include "css/index.css"
?>
</style>
<body class="d-flex flex-column min-vh-100">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.5/dist/umd/popper.min.js" integrity="sha384-Xe+8cL9oJa6tN/veChSP7q+mnSPaj5Bcu9mPX5F5xIGE0DVittaqT5lorf0EI7Vk" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.min.js" integrity="sha384-kjU+l4N0Yf4ZOJErLsIcvOU2qSb74wXpOhqTvwVx3OElZRweTnQ6d31fXEoRD1Jy" crossorigin=" anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="index.php">{Research Project}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<span class="move-right">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
</li>
<?php
if($username){
echo "<li class='nav-item'><a class='nav-link'> " . $username . "</a></li>";
echo "<li class='nav-item'>
<a class='nav-link' href='profile.php'> profile </a>
</li>";
echo "<li class='nav-item'>
<a class='nav-link' href='logout.php'> logout </a>
</li>";
if($admin_stat == 10){
echo "<li class='nav-item'>
<a class='nav-link' href='admin.php'> admin </a>
</li>";
}
}else{
echo "<li class='nav-item'>
<a class='nav-link' href='login.php'> login </a>
</li>";
echo "<li class='nav-item'>
<a class='nav-link' href='signup.php'> signup </a>
</li>";
}
?>
<li class="nav-item">
<a class="nav-link" href="https://github.com/pawanhk/liars-dice-0.0.2">Version Number: 3.0.0 </a>
</li>
</ul>
</span>
</div>
</nav>
<br><br><br><br>
<!-- Footer -->
<footer class="text-center text-lg-start bg-light text-muted mt-auto">
<div class="text-center p-4">
<span class="move-down">
<a class="text-reset fw-bold" href="privacy.php"><span class="footer-elms">Privacy Policy </span> </a>
<a class="text-reset fw-bold" href="contact.php"><span class="footer-elms">Contact </span> </a>
<a class="text-reset fw-bold" href="about.php"><span class="footer-elms">About </span> </a>
<a class="text-reset fw-bold" href="#"><span class="footer-elms">P23Productions </span> </a>
</span>
</div>
</footer>
</body>
</html>
<?php
$filename = 'users.csv';
$sql = "SELECT * FROM accounts";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0){
$user_arr = array();
while ($row = mysqli_fetch_assoc($result)) {
$username = $row['user'];
$email = $row['email'];
$age = $row['age'];
$gender = $row['gender'];
$user_arr[] = [$username,$email,$age,$gender];
}
}
// file creation
$file = fopen($filename,"w");
foreach ($user_arr as $line){
if($line){
fputcsv($file,$line);
}else{
echo "he";
}
}
if($file){
fclose($file);
}
// download
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".$filename);
header("Content-Type: application/csv; ");
readfile($filename);
?>