-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
executable file
·287 lines (279 loc) · 13.7 KB
/
profile.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
<?php
require "api/functions.php";
require "api/users/functions.php";
require "api/users/cookies.php";
require "api/games/functions.php";
$parsedown = new Parsedown();
$parsedown->setSafeMode(true);
$parsedown->setMarkupEscaped(true);
if (!$user && !get("id")) redirect_to_home();
$profile_user = $user;
if (get("id") && is_numeric(get("id"))) $profile_user = new Nbhzvn_User(intval(get("id")));
if (!$profile_user->id) redirect_to_home();
if (!get("repo")) {
$followed_games = $profile_user->followed_games();
$comments = $profile_user->comments();
if ($profile_user->type >= 2) {
$uploaded_games = $profile_user->uploaded_games();
$total_views = 0; $total_downloads = 0;
foreach ($uploaded_games as $tmp_game) {
$total_views += $tmp_game->views;
$total_downloads += $tmp_game->downloads;
}
}
if ($profile_user->id == $user->id) {
$email_end_pos = strpos($user->email, "@");
$censored_email = substr($user->email, 0, 2) . "••••••" . substr($user->email, $email_end_pos - 2, strlen($user->email) - $email_end_pos + 2);
}
else $overwrite_title = $profile_user->display_name();
}
else {
switch (get("repo")) {
case "uploads": {
if ($profile_user->type < 2) redirect_to_home();
$repo = $profile_user->uploaded_games();
$overwrite_title = "Game Đã Tải Lên";
break;
}
case "follows": {
$repo = $profile_user->followed_games();
$overwrite_title = "Danh Sách Theo Dõi";
break;
}
case "unapproved": {
if ($user->type < 2) redirect_to_home();
$repo = unapproved_games($user);
$overwrite_title = "Game Đang Chờ Duyệt";
break;
}
default: {
redirect_to_home();
break;
}
}
}
?>
<!DOCTYPE html>
<html lang="zxx">
<head>
<?php
$title = $overwrite_title ? $overwrite_title : "Thông Tin Tài Khoản";
require __DIR__ . "/head.php";
?>
</head>
<body>
<!-- Header Section Begin -->
<header class="header">
<?php require "header.php"; ?>
</header>
<!-- Header End -->
<!-- Breadcrumb Begin -->
<div class="breadcrumb-option">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb__links">
<a href="/"><i class="fa fa-home"></i> Trang Chủ</a>
<?php if ($overwrite_title): ?>
<a href="/profile/<?php echo $profile_user->id ?>">Thông Tin Tài Khoản</a>
<span><?php echo $overwrite_title ?></span>
<?php else: ?>
<span>Thông Tin Tài Khoản</span>
<?php endif ?>
</div>
</div>
</div>
</div>
</div>
<!-- Breadcrumb End -->
<!-- Anime Section Begin -->
<section class="anime-details spad">
<div class="container">
<?php if ($repo): ?>
<h3 class="nbhzvn_title"><b><?php echo $overwrite_title ?> <?php if (get("repo") != "unapproved") echo ' Của ' . $profile_user->display_name() ?></b></h3>
<div class="row" id="games">
<?php
$limit = 0;
foreach ($repo as $game) {
echo echo_search_game($game, true);
$limit++;
if ($limit == 20) break;
}
?>
</div>
<?php echo pagination(count($repo)) ?>
<?php else: ?>
<?php if ($user->id == $profile_user->id): ?>
<div style="text-align: right">
<a href="/logout" class="nbhzvn_btn"><span>Đăng Xuất</span></a>
</div>
<?php endif ?>
<div class="anime__details__content">
<div class="anime__details__text">
<div class="anime__details__title">
<h3><?php echo $profile_user->display_name() ?></h3>
<span><?php echo $profile_user->username ?> (ID: <?php echo $profile_user->id ?>)</span>
</div>
<div class="anime__details__widget">
<div class="row">
<div class="col-lg-6 col-md-6">
<ul>
<li><span>Chức vụ:</span> <?php
$account_type = array(
1 => "Tài khoản thường",
2 => "Uploader",
3 => "Quản trị viên"
);
echo $account_type[$profile_user->type]
?></li>
<?php if ($profile_user->type >= 2): ?>
<li><span>Game đã tải lên:</span> <?php echo count($uploaded_games ? $uploaded_games : []) ?></li>
<?php else: ?>
<li><span>Game đã theo dõi:</span> <?php echo count($followed_games ? $followed_games : []) ?></li>
<?php endif ?>
<?php if ($profile_user->type >= 2): ?>
<li><span>Tổng lượt xem:</span> <?php echo number_format($total_views, 0, ",", ".") ?></li>
<?php endif ?>
<?php if ($profile_user->id == $user->id): ?>
<li><span>Email:</span> <?php echo $censored_email ?></li>
<?php endif ?>
</ul>
</div>
<div class="col-lg-6 col-md-6">
<ul>
<li><span>Ngày tạo tài khoản:</span> <?php echo timestamp_to_string($profile_user->timestamp) ?></li>
<li><span>Số bình luận đã gửi:</span> <?php echo count($comments ? $comments : []) ?></li>
<?php if ($profile_user->type >= 2): ?>
<li><span>Tổng lượt tải xuống:</span> <?php echo number_format($total_downloads, 0, ",", ".") ?></li>
<?php endif ?>
<?php if ($profile_user->id == $user->id): ?>
<li><span>ID Discord:</span> <?php echo $user->discord_id ? $user->discord_id : "Chưa liên kết" ?></li>
<?php endif ?>
</ul>
</div>
</div>
</div>
<?php if ($profile_user->description) echo $parsedown->text($profile_user->description); else echo '<p><i>Tài khoản này chưa đặt mô tả.</i></p>' ?><br>
<div class="anime__details__btn"><p>
<?php if ($profile_user->id == $user->id): ?>
<a href="/change_info" class="nbhzvn_btn"><span><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Thay đổi thông tin</span></a>
<?php else: ?>
<?php if ($user->type == 3 && $profile_user->type < 3): ?>
<a href="/assign/<?php echo $profile_user->id ?>" class="nbhzvn_btn"><span>Thay đổi chức vụ</span></a>
<?php if ($profile_user->ban_information): ?>
<a href="/unban/<?php echo $profile_user->id ?>" class="nbhzvn_btn"><span>Bỏ cấm thành viên này</span></a>
<?php else: ?>
<a href="/ban/<?php echo $profile_user->id ?>" class="nbhzvn_btn"><span>Cấm thành viên này</span></a>
<?php endif ?>
<?php endif ?>
<?php endif ?>
</p></div><br>
</div>
<div class="row">
<div class="col-lg-8 col-md-8">
<?php $unapproved_games = unapproved_games($user) ?>
<?php if ($user->id == $profile_user->id && $user->type >= 2 && count($unapproved_games)): ?>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="section-title">
<h4>Game Đang Chờ Duyệt</h4>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="btn__all">
<a href="/unapproved/<?php echo $profile_user->id ?>" class="primary-btn">Xem tất cả <span class="arrow_right"></span></a>
</div>
</div>
</div>
<div class="row">
<?php
foreach ($unapproved_games as $tmp_game) echo echo_search_game($tmp_game, true);
?>
</div><br>
<?php endif ?>
<?php if ($profile_user->type >= 2): ?>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="section-title">
<h4>Game Đã Tải Lên</h4>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="btn__all">
<a href="/uploads/<?php echo $profile_user->id ?>" class="primary-btn">Xem tất cả <span class="arrow_right"></span></a>
</div>
</div>
</div>
<div class="row">
<?php
$limit = 0;
foreach ($uploaded_games as $tmp_game) {
echo echo_search_game($tmp_game, true);
$limit++;
if ($limit == 6) break;
}
?>
</div><br>
<?php endif ?>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="section-title">
<h4>Danh Sách Theo Dõi</h4>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="btn__all">
<a href="/follows/<?php echo $profile_user->id ?>" class="primary-btn">Xem tất cả <span class="arrow_right"></span></a>
</div>
</div>
</div>
<div class="row">
<?php
$limit = 0;
foreach ($followed_games as $tmp_game) {
echo echo_search_game($tmp_game, true);
$limit++;
if ($limit == 6) break;
}
?>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="anime__details__sidebar">
<div class="section-title">
<h5>Bình luận gần đây</h5>
</div>
<?php
$limit = 0;
foreach ($comments as $comment) {
echo $comment->to_html(false, $user, true);
$limit++;
if ($limit == 6) break;
}
?>
</div>
</div>
</div>
<?php endif ?>
</div>
</section>
<!-- Anime Section End -->
<!-- Footer Section Begin -->
<footer class="footer">
<?php require "footer.php" ?>
</footer>
<!-- Footer Section End -->
<!-- Js Plugins -->
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/mixitup.min.js"></script>
<script src="/js/jquery.slicknav.js"></script>
<script src="/js/owl.carousel.min.js"></script>
<script src="/js/main.js"></script>
<?php if ($repo): ?>
<script>var userId = <?php echo $profile_user->id ?>, repo = "<?php if (get("repo") != "unapproved") echo "users"; else echo "games" ?>/<?php echo addslashes(get("repo")) ?>";</script>
<script src="/js/api.js"></script>
<script src="/js/profile.js"></script>
<?php endif ?>
</body>
</html>