09-01-2007, 10:16 PM
Code PHP :
<?
include('zone-page/haut.php');
include('zone-page/menu-gauche.php');
include('zone-page/droit.php');
include('bdd.php');
$page=@$_GET['page'];
switch($page)
{
/////Affichage map et insertion////
case '0' :
if(empty($_SESSION['connection'])) session_start();
{
$requete=0;
$perso=$_SESSION['perso'];
$id=$_SESSION['id'];
if($_SESSION['connection'])
{
// on regardesi le perso est inseré dans la table perso
$query=mysql_fetch_array(mysql_query("SELECT * FROM membres WHERE id='$id'"));
$activation=$query['activation'];
//faut que je revois ça
if($activation=='0')
{
echo'IL faut activer votre compte.';
}
else
{
/////////
//affichage de la map
/////////
//debut definition bord map
$minmap=-10;
$maxmap=9;
//fin definition bord map
?>
<TABLE border="0" cellpadding=0 cellspacing=0 bgcolor="#000000" style="font-family:Verdana, Arial, Helvetica, sans-serif; color:#FFFFFF; font-size:11px;">
<?php
$whereperso=mysql_fetch_array(mysql_query("SELECT m.X,m.Y,p.vision FROM map as m LEFT OUTER JOIN membres as p ON p.id=m.perso WHERE m.perso='$id'"));
$requete++;
$minXvue=$whereperso['X']-$whereperso['vision'];
$minYvue=$whereperso['Y']-$whereperso['vision'];
$maxXvue=$whereperso['X']+$whereperso['vision'];
$maxYvue=$whereperso['Y']+$whereperso['vision'];
$resultall=mysql_query("SELECT c.perso,c.X,c.Y,c.terrain,c.bat,p.joueur_pseudo,t.fichier,t.tnom FROM map as c LEFT OUTER JOIN membres as p ON c.perso=p.id LEFT OUTER JOIN terrain as t ON t.id=c.terrain WHERE X>='$minXvue' and X<='$maxXvue' and Y>='$minYvue' and Y<='$maxYvue' ORDER BY Y DESC,X ASC");
$requete++;
$nbcase=0;
for ($y=$maxYvue;$y>=$minYvue;$y--)
{for($x=$minXvue;$x<=$maxXvue;$x++)
{if($x<=$maxmap AND $y<=$maxmap AND $x>=$minmap AND $y>=$minmap)
{$result1[$x][$y]=mysql_fetch_assoc($resultall);
}
$nbcase++;
}
}
$x=$minXvue-1;
$y=$maxYvue+1;
for ($case=0;$case<=$nbcase;$case++)
{if($x==($minXvue-1) AND $y==($maxYvue+1))
{?><tr><td valign="middle" align="center" style="padding:2px;">Y\X</td><?php
}
elseif ($y==$maxYvue+1)
{?><td valign="middle" align="center" style="padding:2px;"><?php echo $x; ?></td><?php
$case--;
}
elseif ($x==$minXvue-1)
{?><td valign="middle" align="center"><?php echo $y; ?></td><?php
$case--;
}
elseif(!isset($result1[$x][$y]['terrain']))
{?><td valign="middle" align="center" bgcolor="#111111"> </td><?php
}
else
{if(isset($result1[$x][$y]['joueur_pseudo']))
{?><td onclick="windows.open('http://adresse.com/fiche?mat=<?php echo $joueur['mat']; ?>'); valign="middle" background="image/<?php echo $result1[$x][$y]['fichier']; ?>" align="center" bgcolor="#111111" width="50px" height="50px"><?php echo $result1[$x][$y]['joueur_pseudo']; ?>
</td><?php
}
elseif ($result1[$x][$y]['bat']!=0)
{?><td valign="middle" align="center" bgcolor="#111111" width="50px" height="50px">base</td><?php
}
else
{?><td align="center" background="image/<?php echo $result1[$x][$y]['fichier']; ?>" width="50px" height="50px"> </td><?php
}
}
$x++;
if ($x>$maxXvue)
{?></tr><?php
$x=$minXvue-1;
$y--;
if ($y>=$minYvue)
{?><tr><?php
}
}
}
?>
</table>
<?php
echo $requete;
//fin
if (isset($_SESSION['message'])) echo'<br><br><fieldset><legend><font color="gray">Attaque</font></legend><br>'.$_SESSION['message'].'</fieldset>';
echo'<br><br><fieldset><legend><font color="gray">Navigation</font></legend><br>';
include('tour.php');
echo'<br><br><a href="carte.php">Carte</a> <a href="messagerie.php">Messagerie</a> <a href="profilrp.php">Modifier votre profil Rp</a>';
}
}
else
{
echo'<center>Il faut se connecter pour accéder à cette partie.</center>';
}
break;
}
}
include('zone-page/droit2.php');
?>
Voili voilou