-
Notifications
You must be signed in to change notification settings - Fork 0
/
toparcade.php
138 lines (115 loc) · 4.31 KB
/
toparcade.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
<?php
/***************************************************************************
* proarcade.php
* -------------------
* fait le : Mercredi,19 Mai, 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);
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_TOPARCADES);
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=toparcade.$phpEx", true));
exit;
}
//
// End of auth check
//
//chargement du template
$template->set_filenames(array(
'body' => 'toparcade_body.tpl')
);
$template->assign_vars(array(
'L_ARCADE' => 'Le TOP 5 des jeux')
);
$nbcol = 3 ;
$games_par_page = 12 ;
//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 " . GAMES_TABLE . " WHERE arcade_catid IN ($liste_cat_auth)";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder à la tables des jeux", '', __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 = " LIMIT $start," . $games_par_page;
$sql = "SELECT distinct game_id , game_name FROM " . GAMES_TABLE . " WHERE arcade_catid IN ($liste_cat_auth) ORDER BY game_name ASC $limit_sql";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder à la tables des jeux", '', __LINE__, __FILE__, $sql);
}
$fini = false ;
if (!$row = $db->sql_fetchrow($result) ) $fini=true ;
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)
{
$template->assign_block_vars('blkligne.blkcolonne.blkgame', array(
'GAMENAME' => '<nobr><a class="cattitle" href="' . append_sid("games.$phpEx?gid=" . $row['game_id'] ) . '">' . $row['game_name'] . '</a></nobr> '));
$pos = 0 ;
$posreelle = 0 ;
$lastscore = 0 ;
$sql2 = "SELECT s.* , u.username FROM " . SCORES_TABLE . " s left join " . USERS_TABLE . " u on u.user_id = s.user_id WHERE s.game_id = " . $row['game_id'] . " order by s.score_game DESC, s.score_date ASC LIMIT 0,5 " ;
if( !($result2 = $db->sql_query($sql2)) )
{
message_die(GENERAL_ERROR, "Impossible d'acceder à la tables des jeux", '', __LINE__, __FILE__, $sql);
}
while( $row2 = $db->sql_fetchrow($result2) )
{
$posreelle++ ;
if ( $lastscore != $row2['score_game'] )
{
$pos = $posreelle ;
}
$lastscore = $row2['score_game'] ;
$template->assign_block_vars('blkligne.blkcolonne.blkgame.blkscore', array(
'SCORE' => $row2['score_game'],
'USERNAME' => $row2['username'],
'POS' => $pos ));
}
if (!($row = $db->sql_fetchrow($result)) ) $fini = true ;
}// fin if !fini
}
}
$template->assign_vars( array(
'PAGINATION' => generate_pagination(append_sid("toparcade.$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 ))
));
//
// Output page header
$page_title = $lang['toparcade'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>