forked from ernestbuffington/platinum.86it.us
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proarcade.php
251 lines (251 loc) · 14.1 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
<?php
/************************************************************************/
/* Platinum Nuke Pro: 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.nukeplanet.com */
/* Loki / Teknerd - Scott Partee (loki@nukeplanet.com) */
/* */
/* Copyright (c) 2007 - 2017 by http://www.platinumnukepro.com */
/* */
/* Refer to platinumnukepro.com for detailed information on this CMS */
/*******************************************************************************/
/* This file is part of the PlatinumNukePro CMS - http://platinumnukepro.com */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
if ( !defined('MODULE_FILE') )
{
die("You can't access this file directly...");
}
if (!isset($popup)) {
$module_name = basename(dirname(__FILE__));
require("modules/".$module_name."/nukebb.php");
} else {
$phpbb_root_path = 'modules/Forums/';
}
define('IN_PHPBB', true);
include_once($phpbb_root_path . 'extension.inc');
include_once($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'gf_funcs/gen_funcs.' . $phpEx);
$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, $nukeuser);
init_userprefs($userdata);
//
// End session management
//
include_once('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 = $_POST['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 . append_sid("login.$phpEx?redirect=arcade.$phpEx", true));
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 . append_sid("arcade.$phpEx", true));
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 . append_sid("arcade.$phpEx", true));
exit;
}
}
//
// End of 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) {
$sql = "UPDATE " . USERS_TABLE . " SET user_new_privmsg = '1', user_last_privmsg = '9999999999' WHERE user_id = $user_id";
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not update users table', '', __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')";
$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']))) . "', '5', " . $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 . append_sid("commentspopup_new.$phpEx?gid=$gid", true));
exit;
}
else
{
header($header_location . append_sid("comments_new.$phpEx?gid=$gid", true));
exit;
}
}
else
{
if ($_COOKIE['arcadepopup']=='1')
{
header($header_location . append_sid("gamespopup.$phpEx?gid=$gid&mode=done", true));
exit;
}
else
{
header($header_location . append_sid("games.$phpEx?gid=$gid", true));
exit;
}
}
?>