-
Notifications
You must be signed in to change notification settings - Fork 0
/
statarcade.php
184 lines (159 loc) · 7.13 KB
/
statarcade.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
<?php
/***************************************************************************
* statarcade.php
* -------------------
* fait le : Dimanche,14 Juin, 2003
* Par : giefca - http://www.gf-phpbb.com
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include( $phpbb_root_path . 'includes/functions_arcade.' . $phpEx);
require( $phpbb_root_path . 'gf_funcs/gen_funcs.' . $phpEx);
$uid = get_var2(array('name'=>'uid', 'intval'=>true, 'default'=>0 ));
if( $uid == 0 )
{
message_die(GENERAL_ERROR, "Utilisateur inconnu", '');
}
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_STATARCADES);
init_userprefs($userdata);
//
// End session management
//
// Start auth check
//
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
if ( !$userdata['session_logged_in'] )
{
header($header_location . append_sid("login.$phpEx?redirect=statarcade.$phpEx", true));
exit;
}
//
// End of auth check
//
//chargement du template
$template->set_filenames(array(
'body' => 'statarcade_body.tpl')
);
$arcade_config = array();
$arcade_config = read_arcade_config();
$sql = "SELECT username FROM " . USERS_TABLE . " WHERE user_id = " . $uid ;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder à la table users", '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$statuser = $row['username'] ;
$nbcol = 2 ;
//récupération de la liste des catégories privées auxquelles l'utilisateur à acces
$liste_cat_auth = get_arcade_categories($userdata['user_id'], $userdata['user_level'],'view');
if( $liste_cat_auth == '' ) $liste_cat_auth = "''";
$sql = "SELECT COUNT(*) as nbtot FROM " . SCORES_TABLE . " s, " . GAMES_TABLE . " g WHERE s.game_id = g.game_id AND g.arcade_catid IN ($liste_cat_auth) AND user_id = " . $uid ;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder à la table des scores", '', __LINE__, __FILE__, $sql);
}
if ($row=$db->sql_fetchrow($result))
{
$total_games = $row['nbtot'];
}
else
{
$total_games = 0;
}
$start = get_var2(array('name'=>'start', 'intval'=>true ));
$limit_sql = ( intval($arcade_config['stat_par_page'])>0 ) ? " LIMIT $start," . intval($arcade_config['stat_par_page']) : '';
$sql = "SELECT s.*, g.* FROM " . SCORES_TABLE . " s LEFT JOIN " . GAMES_TABLE . " g ON g.game_id = s.game_id WHERE g.arcade_catid IN ($liste_cat_auth) AND s.user_id = " . $uid . " ORDER BY g.game_name ASC $limit_sql";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder aux tables users/scores/games", '', __LINE__, __FILE__, $sql);
}
$gamelist = array();
$liste_id = '';
while ($row=$db->sql_fetchrow($result))
{
$gamelist[] = $row ;
$liste_id .= ( $liste_id != '' ) ? ', ' : '';
$liste_id .= "'" . $row['game_id'] . "'" ;
}
$games_par_page = intval($arcade_config['stat_par_page']);
$where_sql = ( $liste_id != '' ) ? " AND s1.game_id IN ( $liste_id )" : '';
$sql = "SET OPTION SQL_BIG_SELECTS=1 ";
$db->sql_query($sql) ;
$sql = "SELECT count(*) as pos, s1.game_id , g.game_highuser, g.game_name FROM " . SCORES_TABLE . " s1 left join " . SCORES_TABLE . " s2 on s1.score_game >= s2.score_game and s1.game_id = s2.game_id
LEFT JOIN " . GAMES_TABLE . " g on g.game_id = s1.game_id WHERE s2.user_id = $uid
and (( s1.score_game > s2.score_game ) or (s1.user_id = $uid )) $where_sql
GROUP BY s1.game_id";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder à la tables des scores", '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$tbpos[ $row['game_id'] ] = $row['pos'] ;
$tbhighuser[ $row['game_id'] ] = $row['game_highuser'] ;
}
$fini = false ;
if (!$row = $db->sql_fetchrow($result) ) $fini=true ;
$template->assign_vars(array(
'PAGINATION' => generate_pagination(append_sid("statarcade.$phpEx?uid=$uid"), $total_games, $games_par_page, $start),
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $games_par_page ) + 1 ), ceil( $total_games / $games_par_page )),
'URL_ARCADE' => '<nobr><a class="cattitle" href="' . append_sid("arcade.$phpEx") . '">' . $lang['lib_arcade'] . '</a></nobr> ',
'URL_BESTSCORES' => '<nobr><a class="cattitle" href="' . append_sid("toparcade.$phpEx") . '">' . $lang['best_scores'] . '</a></nobr> ',
'L_STATS' => $lang['statuser'] . ' ' . $statuser )
);
$nbjeux = count($gamelist);
$i = 0;
$fini = ( $i == $nbjeux ) ? true : false ;
while( !$fini )
{
$template->assign_block_vars('blkligne', array() ) ;
for ( $cg = 1 ; $cg <= $nbcol ; $cg++ )
{
//mise en forme de la colonne
$template->assign_block_vars('blkligne.blkcolonne', array() ) ;
if (!$fini)
{
if ( $gamelist[$i]['score_set'] != 0 )
{
$min = intval( $gamelist[$i]['score_time'] / 60) ;
$sec = $gamelist[$i]['score_time'] - ( $min * 60 ) ;
$scoremoy = round( $gamelist[$i]['score_time'] / $gamelist[$i]['score_set'] ) ;
$minmoy = intval( $scoremoy / 60) ;
$secmoy = $scoremoy - ( $minmoy * 60 ) ;
}
$pos = ( isset($tbpos[ $gamelist[$i]['game_id'] ]) ) ? $tbpos[ $gamelist[$i]['game_id'] ] : 1 ;
$template->assign_block_vars('blkligne.blkcolonne.blkgame', array(
'GAMENAME' => '<nobr><a class="cattitle" href="' . append_sid("games.$phpEx?gid=" . $gamelist[$i]['game_id'] ) . '">' . $gamelist[$i]['game_name'] . '</a></nobr> ',
'L_NBSET' => $lang['statnbset'],
'NBSET' => ( $gamelist[$i]['score_set'] == 0 ) ? "n/a" : $gamelist[$i]['score_set'],
'L_TPSSET' => $lang['stattottime'],
'TPSSET' => ( $gamelist[$i]['score_set'] == 0 ) ? "n/a" : ( ($min >0 ) ? $min . " " . $lang['statminute'] . "," . $sec . " " . $lang['statseconde'] : $sec . " " . $lang['statseconde'] ),
'L_HIGHSCR' => $lang['stathighscore'],
'HIGHSCR' => $gamelist[$i]['score_game'],
'L_DATHIGHSCR' => $lang['statdatehigh'],
'DATHIGHSCR' => create_date( $board_config['default_dateformat'] , $gamelist[$i]['score_date'] , $board_config['board_timezone'] ),
'L_POSGAME' => $lang['statposition'],
'POSGAME' => ( $pos == 1 ) ? $pos . "er" : ( ( $pos == 2 ) ? $pos . "nd" : $pos . "ème" ),
'IMGFIRST' => ( $tbhighuser[ $gamelist[$i]['game_id'] ] == $uid ) ? "<img src='templates/" . $theme['template_name'] . "/images/couronne.gif' align='absmiddle'>" : "" ,
'L_TPSMOY' => $lang['statmedtime'],
'TPSMOY' => ( $gamelist[$i]['score_set'] == 0 ) ? "n/a" : ( ($minmoy >0 ) ? $minmoy . " " . $lang['statminute'] . "," . $secmoy . " " . $lang['statseconde'] : $secmoy . " " . $lang['statseconde'] ) )
);
$i++;
$fini = ( $i == $nbjeux ) ? true : false ;
}// fin if !fini
}
}
//
// Output page header
$page_title = $lang['statarcade_user'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>