-
Notifications
You must be signed in to change notification settings - Fork 0
/
proarcade.php
365 lines (280 loc) · 13.2 KB
/
proarcade.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
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
<?php
/***************************************************************************
* proarcade.php
* -------------------
*
* PHPNuke Ported Arcade - http://arcade.portedmods.com
* Original Arcade Mod phpBB by giefca - http://www.gf-phpbb.com
*
***************************************************************************/
/***************************************************************************
* PHP-Nuke Platinum: Expect to be impressed COPYRIGHT
*
* Copyright (c) 2004 - 2006 by http://www.techgfx.com
* Techgfx - Graeme Allan (goose@techgfx.com)
*
* Copyright (c) 2004 - 2006 by http://www.conrads-berlin.de
* MrFluffy - Axel Conrads (axel@conrads-berlin.de)
*
* Refer to TechGFX.com for detailed information on PHP-Nuke Platinum
*
* TechGFX: Your dreams, our imagination
***************************************************************************/
define('IN_PHPBB', true);
include(dirname(__FILE__).'/mainfile.php');
$phpbb_root_path = NUKE_FORUMS_DIR;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
require( $phpbb_root_path . 'gf_funcs/gen_funcs.' . $phpEx );
include('includes/constants.php');
global $userinfo;
$gid = get_var_gf(array('name'=>'gid', 'intval'=>true, 'default'=>0));
$header_location = (@preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE"))) ? "Refresh: 0; URL=" : "Location: ";
/***************************
*
* Start session management
*
**************************/
$userdata = session_pagestart($user_ip, PAGE_GAME);
init_userprefs($userdata);
/***************************
*
* End session management
*
**************************/
include('includes/functions_arcade.' . $phpEx);
/***************************
*
* Start auth check
*
**************************/
$header_location = (@preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE"))) ? "Refresh: 0; URL=" : "Location: ";
$sql = "SELECT * FROM " . GAMES_TABLE . " WHERE game_id = '$gid'";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Could not read from the games table", '', __LINE__, __FILE__, $sql);
}
if (!($row = $db->sql_fetchrow($result))) {
message_die(GENERAL_ERROR, "Game does not exist.");
}
$hashoffset = get_var_gf(array('name'=>'hashoffset', 'default'=>''));
$gamehash = get_var_gf(array('name'=>'gamehash', 'default'=>''));
$vpaver = get_var_gf(array('name'=>'vpaver', 'default'=>''));
$newhash = get_var_gf(array('name'=>'newhash', 'default'=>''));
$gpaver = get_var_gf(array('name'=>'gpaver', 'default'=>''));
$settime = get_var_gf(array('name'=>'settime', 'intval'=>true, 'default'=>''));
$sid = get_var_gf(array('name'=>'sid', 'default'=>''));
$valid = get_var_gf(array('name'=>'valid', 'default'=>''));
if ($row['game_type'] == 0) {
message_die(GENERAL_ERROR, "Game Type no longer supported, please contact the admin and have him/her delete it.");
}
if ($row['game_type'] == 1) {
message_die(GENERAL_ERROR, "Game Type no longer supported, please contact the admin and have him/her delete it.");
}
if ($row['game_type'] == 2) {
message_die(GENERAL_ERROR, "Game Type no longer supported, please contact the admin and have him/her delete it.");
}
if ($row['game_type'] == 3) {
$gamehash_id = substr($newhash , $hashoffset , 32) . substr($newhash , 0 , $hashoffset);
$vpaver = ($gpaver == "GFARV2") ? '100B2' : '';
$vscore = $row['game_scorevar'];
$score = get_var_gf(array('name'=>$vscore, 'intval'=>true, 'default'=>''));
}
if ($row['game_type'] == 4 or $row['game_type'] == 5) {
$gamehash_id = md5($user_ip);
$vpaver = ($gpaver == "GFARV2") ? '100B2' : '';
$score = $HTTP_POST_VARS['vscore'];
$settime = $_COOKIE['timestarted'];
}
$vscore = $score;
if (!$userdata['session_logged_in'] && ($valid=='')) {
header($header_location . "modules.php?name=Forums&file=proarcade&$vscore=$score&gid=$gid&valid=X&newhash=$newhash&gamehash_id=$gamehash_id&gamehash=$gamehash&hashoffset=$hashoffset&settime=$settime&sid=$sid&vpaver=$vpaver");
exit;
}
if (!$userdata['session_logged_in']) {
header($header_location . "modules.php?name=Your_Account");
exit;
}
if ($row['game_type'] != 4 or $row['game_type'] != 5) {
$sql = "SELECT * FROM " . GAMEHASH_TABLE . " WHERE gamehash_id = '$gamehash_id' and game_id = '$gid' and user_id = '" . $userdata['user_id'] . "'";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Could not read the hashtable", '', __LINE__, __FILE__, $sql);
}
if (!($row = $db->sql_fetchrow($result)) or ($vpaver != "100B2") or (!isset($vscore))) {
$sql = "INSERT INTO " . HACKGAME_TABLE . " (user_id , game_id , date_hack) VALUES ('" . $userdata['user_id'] . "' , '$gid' , '" . time() . "')" ;
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not insert hack game data', '', __LINE__, __FILE__, $sql);
}
header($header_location . "modules.php?name=Forums&file=arcade");
exit;
}
}
$sql = "DELETE FROM " . GAMEHASH_TABLE . " WHERE gamehash_id = '$gamehash_id' and game_id = $gid and user_id = " . $userdata['user_id'] ;
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not delete hash data from the games table', '', __LINE__, __FILE__, $sql);
}
if ($row['game_type'] == 4 or $row['game_type'] ==5) {
if ($_COOKIE['gidstarted'] != $gid || !isset($_COOKIE['gidstarted'])) {
$sql = "INSERT INTO " . HACKGAME_TABLE . " (user_id , game_id , date_hack) VALUES ('" . $userdata['user_id'] . "' , '$gid' , '" . time() . "')";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not insert hack data from the games table', '', __LINE__, __FILE__, $sql);
}
header($header_location . "modules.php?name=Forums&file=arcade");
exit;
}
}
/***************************
*
* End auth check
*
**************************/
$sql = "SELECT * FROM " . SCORES_TABLE . " WHERE game_id = $gid and user_id = " . $userdata['user_id'] ;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Unable to insert data into scores table", '', __LINE__, __FILE__, $sql);
}
$datenow = time();
$ecart = $datenow - $settime ;
if (!($row = $db->sql_fetchrow($result))) {
$sql = "INSERT INTO " . SCORES_TABLE . " (game_id , user_id , score_game , score_date , score_time , score_set) VALUES ($gid , " . $userdata['user_id'] . " , $score , $datenow , $ecart , 1) ";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Unable to insert data into scores table", '', __LINE__, __FILE__, $sql);
}
}
else
{
if ($row['score_game'] < $score)
{
$sql = "UPDATE " . SCORES_TABLE . " set score_game = $score , score_set = score_set + 1 , score_date = $datenow , score_time = score_time + $ecart WHERE game_id = $gid and user_id = " . $userdata['user_id'] ;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Unable to insert data into scores table", '', __LINE__, __FILE__, $sql);
}
}
else
{
$sql = "UPDATE " . SCORES_TABLE . " set score_set = score_set + 1 , score_time = score_time + $ecart WHERE game_id = $gid and user_id = " . $userdata['user_id'] ;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Unable to insert data into scores table", '', __LINE__, __FILE__, $sql);
}
}
}
$sql = "SELECT * FROM " . GAMES_TABLE . " WHERE game_id = " . $gid;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Could not read the games table", '', __LINE__, __FILE__, $sql);
}
if (($row = $db->sql_fetchrow($result)) && ($row['game_highscore']< $score)) {
$sql = "UPDATE " . GAMES_TABLE . " SET game_highscore = $score, game_highuser = " . $userdata['user_id'] . ", game_highdate = " . time() . ", game_set = game_set+1 WHERE game_id = $gid" ;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Error accessing games table", '', __LINE__, __FILE__, $sql);
}
if ($row['game_highuser'] != $userdata['user_id']) {
$sql = "UPDATE " . COMMENTS_TABLE . " SET comments_value = '' WHERE game_id = $gid";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Error accessing comments table", '', __LINE__, __FILE__, $sql);
}
$flag = 1;
$sql = "SELECT * FROM " . SCORES_TABLE . " WHERE game_id = $gid ORDER BY score_game DESC LIMIT 1,1";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Error accessing scores table", '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)) {
$sql= "SELECT s.score_game, s.game_id, g.game_name, u.user_id, u.username
FROM " . SCORES_TABLE . " s
LEFT JOIN " . USERS_TABLE . " u
ON s.user_id = u.user_id
LEFT JOIN " . GAMES_TABLE . " g
ON s.game_id = g.game_id WHERE s.game_id = " . $gid . "
ORDER BY score_game DESC LIMIT 0,1";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Error accessing scores and users table", '', __LINE__, __FILE__, $sql);
}
$row[0] = $db->sql_fetchrow($result);
$sql= "SELECT s.score_game, s.game_id, g.game_name, u.user_id, u.username
FROM " . SCORES_TABLE . " s
LEFT JOIN " . USERS_TABLE . " u
ON s.user_id = u.user_id LEFT JOIN " . GAMES_TABLE . " g
ON s.game_id = g.game_id WHERE s.game_id = " . $gid . "
ORDER BY score_game DESC LIMIT 1,1";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Error accessing scores and users table", '', __LINE__, __FILE__, $sql);
}
$row[1] = $db->sql_fetchrow($result);
$user_id = $row[1]['user_id'];
$sql = "SELECT user_allow_arcadepm FROM " . USERS_TABLE . " WHERE user_id = $user_id";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Error retrieving user arcade pm preference", '', __LINE__, __FILE__, $sql);
}
$row_check = $db->sql_fetchrow($result);
if ($row_check['user_allow_arcadepm'] == 1) {
# Add to the users new pm counter
$sql = "UPDATE " . USERS_TABLE . "
SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "
WHERE user_id = " . $user_id;
if ( !$status = $db->sql_query($sql) ) {
message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
}
$link = "<a href=modules.php?name=Forums&file=games&gid=" . $row[0]['game_id'] . ">here</a>";
$privmsgs_date = date("U");
$sql = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type,
privmsgs_subject,
privmsgs_from_userid,
privmsgs_to_userid,
privmsgs_date,
privmsgs_enable_html,
privmsgs_enable_bbcode,
privmsgs_enable_smilies,
privmsgs_attach_sig)
VALUES (".PRIVMSGS_NEW_MAIL.",
'" . str_replace("\'",
"''",addslashes(sprintf($lang['register_pm_subject'],$row[0]['game_name'])))."',
'2',
".$user_id .",
".$privmsgs_date .",
'0',
'1',
'1',
'0')";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not insert private message sent info', '', __LINE__, __FILE__, $sql);
}
$privmsg_sent_id = $db->sql_nextid();
$sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_text)
VALUES ($privmsg_sent_id, '" . str_replace("\'", "''", addslashes(sprintf($lang['register_pm'],$row[1]['score_game'],$row[0]['game_name'],$row[0]['username'],$row[0]['score_game'],$link))) . "')";
if (!$db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Could not insert private message sent text', '', __LINE__, __FILE__, $sql);
}
}
}
}
}
else
{
$sql = "UPDATE " . GAMES_TABLE . " SET game_set = game_set+1 WHERE game_id = $gid";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update games table', '', __LINE__, __FILE__, $sql);
}
}
if ($flag == 1) {
if ($_COOKIE['arcadepopup']=='1') {
header($header_location . "modules.php?name=Forums&file=commentspopup_new&gid=$gid");
exit;
}
else
{
header($header_location . "modules.php?name=Forums&file=comments_new&gid=$gid");
exit;
}
}
else
{
if ($_COOKIE['arcadepopup']=='1')
{
header($header_location . "modules.php?name=Forums&file=gamespopup&gid=$gid&mode=done");
exit;
}
else
{
header($header_location . "modules.php?name=Forums&file=games&gid=$gid");
exit;
}
}
?>