-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgames.php
executable file
·310 lines (301 loc) · 17.7 KB
/
games.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
303
304
305
306
307
308
309
310
<?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 (is_numeric(get("id"))) {
$game = new Nbhzvn_Game(intval(get("id")));
if (!$game->id) redirect_to_home();
if (!$game->approved && $game->uploader != $user->id && $user->type < 3) redirect_to_home();
$title = $game->name;
$game->add_views();
$comments = $game->comments();
$follows = $game->follows();
$ratings = $game->ratings();
$rated = ($user && $user->id) ? $game->check_rating($user->id) : false;
}
else if (get("category")) {
switch (get("category")) {
case "popular": {
$title = "Game Phổ Biến";
$repo = popular_games();
break;
}
case "recent": {
$title = "Game Mới Tải Lên";
$repo = recent_games();
break;
}
case "mobile": {
$title = "Game Dành Cho Điện Thoại";
$repo = mobile_games();
break;
}
case "recently_updated": {
$title = "Game Mới Cập Nhật Gần Đây";
$repo = recently_updated_games();
break;
}
default: {
$repo = all_games();
break;
}
}
}
else $repo = all_games();
?>
<!DOCTYPE html>
<html lang="zxx">
<head>
<?php
if (!get("category")) $title = $game->name;
require "head.php"
?>
</head>
<body>
<!-- Header Section Begin -->
<header class="header">
<?php require "header.php" ?>
<link rel="stylesheet" href="/css/toastr.css" />
</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>
<span>Thông Tin Game</span>
</div>
</div>
</div>
</div>
</div>
<!-- Breadcrumb End -->
<!-- Anime Section Begin -->
<section class="anime-details spad">
<div class="container">
<?php if ($game && $game->id): ?>
<div class="anime__details__content">
<div class="row">
<div class="col-lg-3">
<div class="anime__details__pic set-bg" data-setbg="/uploads/<?php echo $game->image ?>">
<div class="comment"><i class="fa fa-comments"></i> <?php echo count($comments) ?></div>
<div class="view"><i class="fa fa-eye"></i> <?php echo number_format($game->views, 0, ",", ".") ?></div>
</div>
</div>
<div class="col-lg-9">
<div class="anime__details__text">
<div class="anime__details__title">
<h3><?php echo $game->name ?></h3>
</div>
<div class="anime__details__rating">
<div class="rating" id="rating">
<?php
$average = $ratings->average;
$full = floor($average); $remain = $average - $full; $index = 0; $ostar = 4 - $full;
for ($i = 0; $i < $full; $i++) {
$index++;
echo '<a href="javascript:void(0)" onclick="rate(' . $game->id . ', ' . $index . ')"><i ' . ($rated ? 'data-rated="true"' : '') . ' id="star-' . $index . '" class="fa fa-star"></i></a> ';
}
if ($index < 5) {
$index++;
echo '<a href="javascript:void(0)" onclick="rate(' . $game->id . ', ' . $index . ')"><i ' . ($rated ? 'data-rated="true"' : '') . ' id="star-' . $index . '" class="fa fa-star' . (($remain >= 0.5) ? '-half' : '') . '-o"></i></a> ';
}
for ($i = 0; $i < $ostar; $i++) {
$index++;
echo '<a href="javascript:void(0)" onclick="rate(' . $game->id . ', ' . $index . ')"><i ' . ($rated ? 'data-rated="true"' : '') . ' id="star-' . $index . '" class="fa fa-star-o"></i></a> ';
}
?>
</div>
<span id="ratingText"><?php echo number_format($ratings->total, 0, ",", ".") ?> lượt đánh giá</span>
</div>
<div class="anime__details__widget">
<div class="row">
<div class="col-lg-6 col-md-6">
<ul>
<li><span>Phần mềm làm game:</span> <a href="/search?engine=<?php echo $game->engine ?>"><?php echo $engine_vocab[$game->engine] ?></a></li>
<li><span>Năm ra mắt:</span> <a href="/search?release_year=<?php echo $game->release_year ?>"><?php echo $game->release_year ?></a></li>
<li><span>Nhà phát triển:</span> <?php
$authors = explode(",", $game->author); $elements = [];
foreach ($authors as $author) array_push($elements, '<a href="/search?author=' . $author . '">' . $author . '</a>');
echo implode(", ", $elements);
?></li>
<?php if ($game->translator): ?>
<li><span>Dịch giả:</span> <?php
$translators = explode(",", $game->translator); $elements = [];
foreach ($translators as $translator) array_push($elements, '<a href="/search?translator=' . $translator . '">' . $translator . '</a>');
echo implode(", ", $elements);
?></li>
<?php endif ?>
<li><span>Trạng thái:</span> <a href="/search?status=<?php echo $game->status ?>"><?php echo $status_vocab[$game->status] ?></a></li>
</ul>
</div>
<div class="col-lg-6 col-md-6">
<ul>
<li><span>Người tải lên:</span> <a href="/profile/<?php echo $game->uploader ?>"><?php $uploader = new Nbhzvn_User($game->uploader); echo $uploader->display_name() ?></a></li>
<li><span>Ngôn ngữ:</span> <a href="/search?language=<?php echo $game->language ?>"><?php echo $language_vocab[$game->language] ?></a></li>
<li><span>Hỗ trợ:</span> <?php
$oses = explode(",", $game->supported_os); $elements = [];
foreach ($oses as $os) array_push($elements, '<a href="/search?supported_os=' . $os . '">' . $os_vocab[$os] . '</a>');
echo implode(", ", $elements);
?></li>
<?php if ($game->tags): ?>
<li><span>Thẻ:</span> <?php
$tags = explode(",", $game->tags); $elements = [];
foreach ($tags as $tag) array_push($elements, '<a href="/search?tags=' . $tag . '">' . $tag . '</a>');
echo implode(", ", $elements);
?></li>
<?php endif ?>
<li><span>Lượt tải xuống:</span> <?php echo number_format($game->downloads, 0, ",", ".") ?></li>
</ul>
</div>
</div>
</div>
<div class="anime__details__btn">
<a href="#downloadSection" class="download-btn"><i class="fa fa-download"></i> Tải xuống</a>
<?php if ($game->approved): ?>
<a href="javascript:void(0)" onclick="toggleFollow(<?php echo $game->id ?>)" class="follow-btn"><span id="followText"><?php echo ($user && $user->id && $game->check_follow($user->id)) ? "Bỏ theo dõi" : "Theo dõi" ?></span> <label id="followCount" style="margin-right: 10px"><?php echo number_format($follows, 0, ",", ".") ?></label></a>
<?php if ($user->type == 3): ?>
<a href="/unapprove/<?php echo $game->id ?>" class="download-btn"><i class="fa fa-eye-slash"></i> Ẩn</a>
<?php endif ?>
<?php elseif ($user->type == 3): ?>
<a href="/approve/<?php echo $game->id ?>" class="download-btn"><i class="fa fa-check"></i> Phê duyệt</a>
<?php endif ?>
<?php if ($user->id == $game->uploader): ?>
<a href="/edit_game/<?php echo $game->id ?>" class="download-btn" style="margin-left: 12px"><i class="fa fa-pencil"></i> Chỉnh sửa</a>
<?php endif ?>
<?php if ($user->type == 3): ?>
<a href="/feature/<?php echo $game->id ?>" class="download-btn"><?php if (!$game->is_featured) echo 'Thêm vào'; else echo "Loại bỏ khỏi" ?> mục Tiêu Điểm</a>
<?php endif ?>
<?php if ($user->id == $game->uploader || $user->type == 3): ?>
<a href="/delete_game/<?php echo $game->id ?>" class="download-btn"><i class="fa fa-trash"></i> Xoá</a>
<?php endif ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8">
<div>
<div class="section-title">
<h5>Mô tả game</h5>
</div>
<div class="game_description"><?php echo $parsedown->text($game->description) ?></div>
</div><br>
<div>
<div class="section-title">
<h5>Ảnh chụp màn hình</h5>
</div>
<div class="game_screenshots_container">
<?php
foreach ($game->screenshots as $screenshot) {
$path = "/uploads/" . $screenshot;
echo '<a href="' . $path . '" target="_blank"><img src="' . $path . '" /></a>';
}
?>
</div>
</div><br>
<div id="downloadSection">
<div class="section-title">
<h5>Tải game xuống</h5>
</div>
<p><i><b>Sử dụng WinRAR hoặc 7-Zip để giải nén!</b> Trình giải nén mặc định của Windows có khả năng bị lỗi rất cao và mình không khuyến khích các bạn dùng nó để giải nén.<br>Đối với điện thoại thì bạn nên dùng ứng dụng RAR hoặc ZArchiver để giải nén.</i></p>
<?php
$index = 0;
foreach ($game->links as $link) {
$index++;
$path = "./uploads/" . $link->path;
echo '
<div class="game_file">
<div class="row">
<div class="col-sm-9 game_file_name"><a href="/download/' . $game->id . '/' . $index . '">' . $link->name . '</a></div>
<div class="col-sm-3 game_file_size">' . bytes_to_string(filesize($path)) . '<br>
<small><b>CN lần cuối:</b> ' . timestamp_to_string(filemtime($path)) . '</small>
</div>
</div>
</div>
';
}
?>
</div><br>
<div class="anime__details__review">
<div class="section-title">
<h5>Bình luận (<?php echo count($comments) ?>)</h5>
</div>
<div id="comments">
<?php
$highlighted_comment_id = is_numeric(get("highlighted_comment")) ? intval(get("highlighted_comment")) : 0;
if ($highlighted_comment_id) {
$highlighted_comment = new Nbhzvn_Comment($highlighted_comment_id);
if ($highlighted_comment->id) echo $highlighted_comment->to_html(!!$highlighted_comment->replied_to, $user, false, is_numeric(get("reply_comment")) ? intval(get("reply_comment")) : $highlighted_comment_id);
}
foreach ($comments as $comment) if ($comment->id != $highlighted_comment_id) echo $comment->to_html(!!$comment->replied_to, $user);
?>
</div>
<?php echo pagination(count($comments)); ?>
</div>
<div class="anime__details__form">
<div class="section-title">
<h5>Viết bình luận mới</h5>
</div>
<textarea id="commentContent" placeholder="Nội dung bình luận" required></textarea>
<button id="commentBtn" onclick="comment()"><i class="fa fa-location-arrow"></i> Bình luận</button>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="anime__details__sidebar">
<div class="section-title">
<h5>Các game khác</h5>
</div>
<?php
foreach (random_games($game->id) as $tmp_game) echo echo_tiled_game($tmp_game);
?>
</div>
</div>
</div>
<?php else: ?>
<h3 class="nbhzvn_title"><?php echo $title ? $title : "Danh Sách Game" ?></h3>
<div class="row" id="games">
<?php
$limit = 0;
foreach ($repo as $tmp_game) {
echo echo_search_game($tmp_game, true);
$limit++;
if ($limit == 20) break;
}
?>
</div>
<?php echo pagination(count($repo)) ?>
<?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?v=<?=$res_version?>"></script>
<script src="/js/toastr.js"></script>
<script src="/js/api.js?v=<?=$res_version?>"></script>
<?php if ($game && $game->id): ?>
<script>gameId = <?php echo $game->id ?></script>
<script src="/js/game.js?v=<?=$res_version?>"></script>
<?php else: ?>
<script>repo = "<?php echo addslashes(get("category")) ?>"</script>
<script src="/js/game_list.js?v=<?=$res_version?>"></script>
<?php endif ?>
</body>
</html>