game/pages/voir_classement.php

92 lines
3.4 KiB
PHP

<?php
session_start();
$id=$_SESSION['id'];
$galaxy=$_SESSION['galaxy'];
$ss=$_SESSION['ss'];
$pos=$_SESSION['pos'];
$race=$_SESSION['race'];
$_SESSION['dernPage'] = '';
include_once('common.php');
require('../connectBDD.php');
require('../template.php');
$template = new Template('../templates/');
$template->set_filenames(array('stat_body' => 'stat_body.tpl','stat_playertable'=>'stat_playertable.tpl', 'stat_playertable_header'=>'stat_playertable_header.tpl' ,'stat_playertable_footer'=>'stat_playertable_footer.tpl'));
// Nombre de joueur affiché par page de classement
$nbppage = 100;
if (isset($_POST['type'])) $type = $_POST['type'];
else $type = 'points';
$parse = $lang;
$who = (isset($_POST["who"]))?$_POST["who"]:$_GET["who"];
$numpage = $start = (isset($_POST["start"]))?(floor($_POST["start"])*$nbppage):0;
echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>Halo battle</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=windows-1252" />
<link rel="stylesheet" media="screen" type="text/css" title="design" href="descriptions/diz/base.css" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="content-type" content="text/html;charset=iso-8869-1" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<style type="text/css">
table {
margin-top: 25px;
}
TD.z {
min-width: 15px;
}
</style>
</head>
<body>';
$parse['who'] = '
<option value="player"'.(($who == "player") ? " selected=\"selected\"" : "").'>Pseudo</option>
<option value="ally"'.(($who == "ally") ? " selected=\"selected\"" : "").'>Alliance</option>';
if (!isset($type)) $type='pts';
$parse['type'] = '
<option value="points"'.(($type == "points") ? " selected=\"selected\"" : "").'>Points</option>
<option value="batiments"'.(($type == "batiments") ? " selected=\"selected\"" : "").'>Batiment</option>
<option value="flottes"'.(($type == "flottes") ? " selected=\"selected\"" : "").'>Flotte</option>
<option value="recherches"'.(($type == "recherches") ? " selected=\"selected\"" : "").'>Recherches</option>';
if (!isset($start)) $start='0';
if($who == "ally"){
}
else {
$test = mysql_query("SELECT * FROM classement");
$nb = mysql_num_rows($test);
$parse['start'] = '';
for ($c=0; $c*$nbppage<$nb ; $c++) {
$parse['start'] .= '<option value="'.$c.'"'.(($numpage/$nbppage == $c) ? " selected=\"selected\"" : "").'>'.($c*$nbppage+1).'-'.(($c+1)*$nbppage).'</option>';
}
$test = mysql_query("SELECT * FROM classement ORDER BY $type DESC LIMIT $numpage, $nbppage");
$i=$numpage+1;
$template->assign_vars( array('who' => $parse['who'],'type' => $parse['type'], 'start' => $parse['start']));
$template->pparse('stat_body');
$template->assign_vars( array('who' => $parse['who'],'type' => $parse['type'], 'start' => $parse['start'], 'body_table' => $parse['body_table']));
$template->pparse('stat_playertable_header');
while ($row = mysql_fetch_assoc($test)){
$table = $template->assign_vars( array('player_rank' => separerNombres($i), 'player_name' => $row['pseudo'], 'player_points' => separerNombres($row[$type]), 'player_mes'=> '<a href="messagerie.php?act=nouv&joueur='.$row['pseudo'].'"><img src="descriptions/diz/m.gif" alt="Envoyer un message privé" /></a>'));
$parse['body_values'] .= $template->pparse('stat_playertable');
$i++;
}
}
$template->pparse('stat_playertable_footer');
echo '</table></body></html>';
?>