YouTube Google Code Twitter

ListMaps PHP pour TrackMania

Version en cours
Version 0.3
Téléchargez la dernière version

Pré-requis

PHP 5.x
Librairie GD

Comment ça marche ?

Décompressez les fichiers et placez les sur votre site.
Important : laissez les fichiers les uns à côté des autres.
Placez les images dans votre dossier image.
Pour que le tout fonctionne, éditez le fichier listmaps.php et adaptez le chemin vers le fichier config.php à la ligne n°3.
Ouvrez ensuite le fichier config.php et renseignez les champs indiqués.

  • $language qui permet de choisir la langue d’affichage
  • $root pour indiquer le nom du dossier contenant le fichier listmaps.php. Ce nom est relatif à votre page d’inclusion.
  • $img_root pour indiquer le nom du dossier contenant vos images. Ce nom est relatif à votre page d’inclusion.

Une fois fait, placez les dossiers contenant vos maps au même endroit que le fichier listmaps.php.
Chaque dossier devra contenir un fichier title.txt pour être listé. Ce fichier contiendra le nom du pack de map. Il sera affiché avant la liste des maps.
Si vous souhaitez permettre le téléchargement de l’ensemble des maps via un pack, placez un fichier *.zip ou *.rar dans le dossier, l’affichage du lien sera automatique.

Le code source

<?
// Change the path to the config file
include(« listmaps/config.php »);
// Change the path to the config file
if(isset($_GET[‘listmap’]))
{
$folder=$root.$listing[$_GET[‘listmap’]].‘/’;
?>
<h1><? echo file_get_contents($folder.‘title.txt’); ?></h1>
<?
$pack
=glob($folder.‘*.rar’);
if(
count($pack)==0) $pack=glob($folder.‘*.zip’);
if(
count($pack)>0){
?>
<p class= »img_milieu »><img src= »<? echo $img_root; ?>filesave.png » alt= »Téléchargement » width= »32″ height= »32″ />
<span><a href= »<? echo $pack[0]; ?>« ><? echo $lang_dlpack; ?></a></span></p>
<?
}
// We’re only parsing the maps
$maps=glob($folder.‘*.Challenge.Gbx’);
// Parsing the map Array
foreach($maps as $map){
// Name cleaning for the class
$map=basename($map,‘.Challenge.Gbx’);
// Class creation
$ObjMap=new MapInfos();
$ObjMap->name($map,$folder);
$ObjMap->infos();
?>
<h2><? echo $ObjMap->ingame_name.‘ ‘.$lang_by.‘ ‘.$ObjMap->author; ?></h2>
<img src= »<? echo $root;?>image.php?map=<? echo $map; ?>&folder=<? echo $_GET[‘listmap’]; ?> »
alt= »* » class= »img_gauche » width= »256″ height= »256″ />
<img src= »<? echo $img_root; ?>
<?
echo $ObjMap->environment; ?>.jpg » alt= »image <? echo $ObjMap->environment; ?> » />
<div class= »infos »><strong><? echo $lang_infos; ?></strong><br />
Mood: <? echo $ObjMap->mood; ?><br />
<p class= »img_milieu »>
<img src= »<? echo $img_root; ?>gold.png » alt= »Médaille d’or » width= »32″ height= »32″ />
<span><? echo $ObjMap->gold; ?></span></p>
<p class= »img_milieu »>
<img src= »<? echo $img_root; ?>silver.png » alt= »Médaille d’argent » width= »32″ height= »32″ />
<span><? echo $ObjMap->silver; ?></span></p>
<p class= »img_milieu »>
<img src= »<? echo $img_root; ?>copper.png » alt= »Médaille de bronze » width= »32″ height= »32″ />
<span><? echo $ObjMap->bronze; ?></span></p>
<p class= »img_milieu »>
<img src= »<? echo $img_root; ?>filesave.png » alt= »Téléchargement » width= »32″ height= »32″ /> <
span><a href= »<? echo $folder.$map; ?>.Challenge.Gbx »><? echo $map; ?></a></span></p>
</div>
<?
}
} else {
?>
<p>
<ul>
<?
// Parsing the listing array
foreach($listing as $key=>$folder){
// If we have a folder…
if(is_dir($root.$folder)===true){
// then we check if the title.txt file is here
$title=@file_get_contents($root.$folder.‘/title.txt’);
// If so, print the menu
if($title!==false) {
?>
<li><a href= »?<? echo $_SERVER[‘QUERY_STRING’]; ?>&listmap=<? echo $key; ?>« ><? echo $title; ?></a></li>
<?
}
}
}
?>
</ul>
</p>
<?
}
?>