Repository navigation
Expand file tree
/
Copy pathcomments.php
More file actions
276 lines (236 loc) · 11.1 KB
/
Copy pathcomments.php
File metadata and controls
276 lines (236 loc) · 11.1 KB
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
<?php
/***************************************************************************
* comments.php
* -------------------
* begin : 2006/02/25
* copyright : (C) Oyo - http://u-web.org
* email : oyo@u-web.org
*
* $Id: comments.php,v 1.0.0 25/02/2006 Oyo Exp $
*
* 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
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path .'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
// Start session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
// End session management
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
if ( $userdata['session_logged_in'] != 1 )
{
header($header_location . append_sid('login.' . $phpEx . '?redirect=comments.'.$phpEx.'', true));
exit;
}
if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
$mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
}
$start = (isset($HTTP_GET_VARS['start'])) ? intval($HTTP_GET_VARS['start']) : 0;
$submit = (isset($HTTP_POST_VARS['submit'])) ? intval($HTTP_POST_VARS['submit']) : '';
generate_smilies('inline', PAGE_INDEX);
$template->set_filenames(array(
'body' => 'comments_body.tpl'
));
if($mode == 'update')
{
$game_id = intval($HTTP_POST_VARS['comment_id']);
$message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : '';
$user_id = $userdata['user_id'];
$sql = 'SELECT game_highuser FROM ' . GAMES_TABLE. ' WHERE game_id = '.$game_id;
if( !($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, "Error Authenticating User", '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
if( $user_id != $row['game_highuser'] )
{
message_die(GENERAL_ERROR, 'Error Authenticating User - Possible hack attempt!', '');
}
$sql = 'SELECT * FROM ' . COMMENTS_TABLE . ' WHERE game_id = '.$game_id;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Couldnot obtain data', '', __LINE__, __FILE__, $sql);
}
$avs_info = $db->sql_fetchrow($result);
$avs_txt = $message;
$avs_txt = str_replace('<', '<', $avs_txt); // >> supression des balise pour evité les script
$avs_txt = str_replace('>', '>', $avs_txt); // >> supression des balise pour evité les script
$sql = "UPDATE " . COMMENTS_TABLE . " SET message = '" . str_replace("\'", "''", $avs_txt) . "' WHERE game_id = $game_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not insert row in comments table', '', __LINE__, __FILE__, $sql);
}
$message = sprintf($lang['Comment_updated'],'<a href="' . append_sid("arcade.$phpEx") . '">','</a>');
$message .= "<META HTTP-EQUIV=\"refresh\" content=\"5;URL=comments.$phpEx\">";
message_die(GENERAL_MESSAGE, $message);
}
if($mode == 'submit')
{
$game_id = (isset($HTTP_POST_VARS['comment_id'])) ? intval($HTTP_POST_VARS['comment_id']) : 0;
$sql = 'SELECT g.game_id AS gid, g.game_name, c.* FROM ' . GAMES_TABLE. ' g LEFT JOIN '. COMMENTS_TABLE . ' c ON g.game_id = c.game_id WHERE g.game_id = '.$game_id;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error retrieving comment list', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$template->assign_vars(array(
'ARCADE_COMMENT' => $lang['Arcade_Comments'],
'ADD_EDIT_COMMENTS' => $lang['AddEdit_comment'],
'QUICK_STATS' => $lang['Quick_stats'],
'L_SUBMIT' => $lang['Submit'],
'ENTER_ARCADE_COMMENT' => $lang['Enter_arcade_comment'],
'L_GAME_NAME' => $lang['Game_name'],
'L_BBCODE_B_HELP' => $lang['bbcode_b_help'],
'L_BBCODE_I_HELP' => $lang['bbcode_i_help'],
'L_BBCODE_U_HELP' => $lang['bbcode_u_help'],
'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'],
'L_BBCODE_C_HELP' => $lang['bbcode_c_help'],
'L_BBCODE_L_HELP' => $lang['bbcode_l_help'],
'L_BBCODE_O_HELP' => $lang['bbcode_o_help'],
'L_BBCODE_P_HELP' => $lang['bbcode_p_help'],
'L_BBCODE_W_HELP' => $lang['bbcode_w_help'],
'L_BBCODE_A_HELP' => $lang['bbcode_a_help'],
'L_BBCODE_S_HELP' => $lang['bbcode_s_help'],
'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
'L_EMPTY_MESSAGE' => $lang['Empty_message'],
'L_FONT_COLOR' => $lang['Font_color'],
'L_COLOR_DEFAULT' => $lang['color_default'],
'L_COLOR_DARK_RED' => $lang['color_dark_red'],
'L_COLOR_RED' => $lang['color_red'],
'L_COLOR_ORANGE' => $lang['color_orange'],
'L_COLOR_BROWN' => $lang['color_brown'],
'L_COLOR_YELLOW' => $lang['color_yellow'],
'L_COLOR_GREEN' => $lang['color_green'],
'L_COLOR_OLIVE' => $lang['color_olive'],
'L_COLOR_CYAN' => $lang['color_cyan'],
'L_COLOR_BLUE' => $lang['color_blue'],
'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'],
'L_COLOR_INDIGO' => $lang['color_indigo'],
'L_COLOR_VIOLET' => $lang['color_violet'],
'L_COLOR_WHITE' => $lang['color_white'],
'L_COLOR_BLACK' => $lang['color_black'],
'L_FONT_SIZE' => $lang['Font_size'],
'L_FONT_TINY' => $lang['font_tiny'],
'L_FONT_SMALL' => $lang['font_small'],
'L_FONT_NORMAL' => $lang['font_normal'],
'L_FONT_LARGE' => $lang['font_large'],
'L_FONT_HUGE' => $lang['font_huge'],
'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'],
'L_STYLES_TIP' => $lang['Styles_tip'],
'NAV_DESC' => '<a class="nav" href="' . append_sid("arcade.$phpEx") . '">' . $lang['arcade'] . '</a> ' ,
'GAME_NAME' => '<a href="' . append_sid("games.$phpEx?gid=" . $row['game_id']) . '">' . $row['game_name'] . '</a>',
'GAME_ID' => $row['game_id'],
'MESSAGE' => $row['message'],
'S_ACTION' => append_sid("comments.$phpEx?mode=update"),
));
//Gets Avatar based on user settings and other user stats
$sql = 'SELECT username, user_avatar_type, user_allowavatar, user_avatar FROM ' . USERS_TABLE . ' WHERE user_id = ' . $userdata['user_id'] ;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Cannot access the users table', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$user_id = $userdata['user_id'];
$user = $row['username'];
$user_avatar_type = $row['user_avatar_type'];
$user_allowavatar = $row['user_allowavatar'];
$user_avatar = $row['user_avatar'];
$avatar_img = '';
if ( $user_avatar_type && $user_allowavatar )
{
switch( $user_avatar_type )
{
case USER_AVATAR_UPLOAD:
$avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $user_avatar . '" alt="" border="0" hspace="20" align="center" valign="center"/>' : '';
break;
case USER_AVATAR_REMOTE:
$avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $user_avatar . '" alt="" border="0" hspace="20" align="center" valign="center" />' : '';
break;
case USER_AVATAR_GALLERY:
$avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $user_avatar . '" alt="" border="0" hspace="20" align="center" valign="center" />' : '';
break;
}
}
$template->assign_vars(array(
'USER_AVATAR' => '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=" . $userdata['user_id'] ) . '">' . $avatar_img . '</a>',
'USERNAME' => '<a href="' . append_sid("statarcade.$phpEx?uid=" . $user_id ) . '" class="genmed">' . $user . '</a> ',
));
//Gets some user stats to display on the comment submission page
$sql ="SELECT s.score_set, s.game_id, g.game_name 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.user_id = " . $userdata['user_id'] . " ORDER BY score_set DESC LIMIT 1";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Cannot access user stats to display', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$times_played = $row['score_set'];
$favgame = '<a href="' . append_sid("games.$phpEx?gid=" . $row['game_id']) . '">' . $row['game_name'] . '</a>';
$sql="SELECT * FROM " .GAMES_TABLE ." WHERE game_highuser = " . $userdata['user_id'] . " ORDER BY game_highdate DESC";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Cannot access last high score data", '', __LINE__, __FILE__, $sql);
}
$score_count = $db->sql_numrows( $result ); //Gets the number of highscores for the current user
$row = $db->sql_fetchrow($result);
$lasthigh_date = create_date( $board_config['default_dateformat'] , $row['game_highdate'] , $board_config['board_timezone'] );
$lasthigh_game = '<a href="' . append_sid("games.$phpEx?gid=" . $row['game_id']) . '">' . $row['game_name'] . '</a>';
$template->assign_vars(array(
'YOURS_QUICK_STATS' => sprintf($lang['Yours_quick_stats'],$score_count,$favgame,$times_played,$lasthigh_date,$lasthigh_game)
));
// Generate the page end
$page_title = $lang['Arcade_Comments'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
$template->set_filenames(array(
'body' => 'comments_select_body.tpl'
));
$link = 'comments.'.$phpEx;
$uid = intval($userdata['user_id']);
$submit = append_sid($link."?mode=submit");
$sql = 'SELECT g.*, c.* FROM ' . GAMES_TABLE. ' g LEFT JOIN ' . COMMENTS_TABLE . ' c ON g.game_id = c.game_id WHERE game_highuser = '.$uid.' ORDER BY game_name ASC';
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error retrieving high score list', '', __LINE__, __FILE__, $sql);
}
$score_count = $db->sql_numrows( $result );
if ($score_count != 0)
{
$select_highscore = "<select name='comment_id' class='post'>";
while ( $row = $db->sql_fetchrow($result))
{
$select_highscore .= "<option value='" . $row['game_id'] . "' >" . $row['game_name'] . "</option>";
}
$select_highscore .= '</select>';
$template->assign_vars(array(
'ARCADE_COMMENT' => $lang['Arcade_Comments'],
'L_SELECT_GAME' => $lang['Select_game'],
'SELECT_GAME_EXPLAIN' => $lang['Select_game_explain'],
'NAV_DESC' => '<a class="nav" href="' . append_sid("arcade.$phpEx") . '">' . $lang['arcade'] . '</a> ' ,
'HOLD_HIGHSCORE_COUNT' => sprintf($lang['hold_highscore_count'],$score_count),
'HIGHSCORE_SELECT' => $select_highscore,
'L_SUBMIT' => $lang['Submit'],
'S_ACTION' => $submit,
));
// Generate the page end
$page_title = $lang['Arcade_Comments'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->pparse('body');
include("includes/page_tail.php");
}
else
{
$message = sprintf($lang['Hold_no_highscore'],'<a href="' . append_sid("arcade.$phpEx") . '">','</a>');
$message .= "<META HTTP-EQUIV=\"refresh\" content=\"8;URL=arcade.$phpEx\">";
message_die(GENERAL_MESSAGE, $message);
}
?>