par
djblagues » 10 juin 2007, 10:11
J'ai réussi à trouver un échappatoire grace à toi 'Sékiltoyai', voici mon code ::
<?php
$autotiles_rep = 'Autotiles'; // Répertoire regroupant les autotiles
$autotiles_replus = 'Zototiles'; // Répertoire regroupant les autotiles
// Seulement si le nombre fait trois chiffres
if (strlen($_GET['num']) == 3) {
$autotiles_open = opendir($autotiles_rep);
// Scan du répertoire des autotiles
unset($nbr, $passe);
while ($autotiles_scan = readdir($autotiles_open)) {
if ($autotiles_scan != '.' && $autotiles_scan != '..') {
$autotiles_ext = substr($autotiles_scan, strrpos($autotiles_scan, '.') + 1);
if ($autotiles_ext == 'png') {
$nbr++;
$autotiles_nom[substr($autotiles_scan, 0, 3)] = $autotiles_scan;
if ($_GET['num'] == substr($autotiles_scan, 0, 3)) {$passe = 1;}
}
}
}
closedir($autotiles_open);
clearstatcache();
// Si le passage est confirmé et si le répertoire de sauvegarde n'existe pas!
if ($passe == 1 && !file_exists($autotiles_replus.'/'.$_GET['num'])) {
// On créer le répertoire de sauvegarde
mkdir($autotiles_replus.'/'.$_GET['num'], 0700);
// Repérage de l'autotile choisi
$autotiles = imagecreatefrompng($autotiles_rep.'/'.$autotiles_nom[$_GET['num']]);
// Indexation de l'Autotiles
unset($k, $l);
for ($j = 0; $j <= 11; $j++) {
$autotiles_[$j] = imagecreate(32, 32);
imagecopy($autotiles_[$j], $autotiles, 0, 0, $k * 32, $l * 32, 32, 32);
imagepng($autotiles_[$j], $autotiles_replus.'/'.$_GET['num'].'/zoto_'.($j + 1).'.png');
imagedestroy($autotiles_[$j]);
$k++;
if ($k > 2) {$k = 0; $l++;}
}
imagedestroy($autotiles);
$zototiles = imagecreatefrompng($autotiles_replus.'/'.$_GET['num'].'/zoto_1.png');
$coin = imagecreate(128, 32);
$zototilesplus = imagecreatefrompng($autotiles_replus.'/'.$_GET['num'].'/zoto_2.png');
imagecopy($coin, $zototilesplus, 0, 0, 0, 0, 32, 32);
imagecopy($coin, $zototilesplus, 32, 0, 0, 0, 32, 32);
imagecopy($coin, $zototilesplus, 64, 0, 0, 0, 32, 32);
imagecopy($coin, $zototilesplus, 96, 0, 0, 0, 32, 32);
imagecopy($coin, $zototiles, 16, 16, 0, 0, 16, 16);
imagecopy($coin, $zototiles, 0 + 32, 16, 16, 0, 16, 16);
imagecopy($coin, $zototiles, 16 + 64, 0, 0, 16, 16, 16);
imagecopy($coin, $zototiles, 0 + 96, 0, 16, 16, 16, 16);
$coinplus = imagecreate(32, 32);
imagecopy($coinplus, $coin, 0, 0, 0, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/bd.png');
imagecopy($coinplus, $coin, 0, 0, 32, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/bg.png');
imagecopy($coinplus, $coin, 0, 0, 64, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/hd.png');
imagecopy($coinplus, $coin, 0, 0, 96, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/hg.png');
imagedestroy($coin);
imagedestroy($coinplus);
}
}
?>
J'ai réussi à trouver un échappatoire grace à toi 'Sékiltoyai', voici mon code ::
[php]
<?php
$autotiles_rep = 'Autotiles'; // Répertoire regroupant les autotiles
$autotiles_replus = 'Zototiles'; // Répertoire regroupant les autotiles
// Seulement si le nombre fait trois chiffres
if (strlen($_GET['num']) == 3) {
$autotiles_open = opendir($autotiles_rep);
// Scan du répertoire des autotiles
unset($nbr, $passe);
while ($autotiles_scan = readdir($autotiles_open)) {
if ($autotiles_scan != '.' && $autotiles_scan != '..') {
$autotiles_ext = substr($autotiles_scan, strrpos($autotiles_scan, '.') + 1);
if ($autotiles_ext == 'png') {
$nbr++;
$autotiles_nom[substr($autotiles_scan, 0, 3)] = $autotiles_scan;
if ($_GET['num'] == substr($autotiles_scan, 0, 3)) {$passe = 1;}
}
}
}
closedir($autotiles_open);
clearstatcache();
// Si le passage est confirmé et si le répertoire de sauvegarde n'existe pas!
if ($passe == 1 && !file_exists($autotiles_replus.'/'.$_GET['num'])) {
// On créer le répertoire de sauvegarde
mkdir($autotiles_replus.'/'.$_GET['num'], 0700);
// Repérage de l'autotile choisi
$autotiles = imagecreatefrompng($autotiles_rep.'/'.$autotiles_nom[$_GET['num']]);
// Indexation de l'Autotiles
unset($k, $l);
for ($j = 0; $j <= 11; $j++) {
$autotiles_[$j] = imagecreate(32, 32);
imagecopy($autotiles_[$j], $autotiles, 0, 0, $k * 32, $l * 32, 32, 32);
imagepng($autotiles_[$j], $autotiles_replus.'/'.$_GET['num'].'/zoto_'.($j + 1).'.png');
imagedestroy($autotiles_[$j]);
$k++;
if ($k > 2) {$k = 0; $l++;}
}
imagedestroy($autotiles);
$zototiles = imagecreatefrompng($autotiles_replus.'/'.$_GET['num'].'/zoto_1.png');
$coin = imagecreate(128, 32);
$zototilesplus = imagecreatefrompng($autotiles_replus.'/'.$_GET['num'].'/zoto_2.png');
imagecopy($coin, $zototilesplus, 0, 0, 0, 0, 32, 32);
imagecopy($coin, $zototilesplus, 32, 0, 0, 0, 32, 32);
imagecopy($coin, $zototilesplus, 64, 0, 0, 0, 32, 32);
imagecopy($coin, $zototilesplus, 96, 0, 0, 0, 32, 32);
imagecopy($coin, $zototiles, 16, 16, 0, 0, 16, 16);
imagecopy($coin, $zototiles, 0 + 32, 16, 16, 0, 16, 16);
imagecopy($coin, $zototiles, 16 + 64, 0, 0, 16, 16, 16);
imagecopy($coin, $zototiles, 0 + 96, 0, 16, 16, 16, 16);
$coinplus = imagecreate(32, 32);
imagecopy($coinplus, $coin, 0, 0, 0, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/bd.png');
imagecopy($coinplus, $coin, 0, 0, 32, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/bg.png');
imagecopy($coinplus, $coin, 0, 0, 64, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/hd.png');
imagecopy($coinplus, $coin, 0, 0, 96, 0, 32, 32);
imagepng($coinplus, $autotiles_replus.'/'.$_GET['num'].'/hg.png');
imagedestroy($coin);
imagedestroy($coinplus);
}
}
?>
[/php]