Just updated my generator, now it consist of 3 files:
index.html: only changed request target of the form
simp.php: NEW, responsible for formatting inputs, including ordering
generate.php: still the generator body, takes formatted input from simp.php and generate image
Now, generate.php takes only 1 GET parameter, which contains all information it needs to generate the image.
The parameter pattern: <mark>(<5-character codes>)<format>
<mark> is the full name of the mark. Eg. darkness
<5-character code> consists of a 2-digit number and a 3-character card code, the number is the number of that card. Eg. 164sa, meaning 16 QPs
<format> is png, jpeg, or gif. If this is omitted, png is assumed.
For example: darkness034sa014t3125uk015ul045um035un015uo035up015uq035us0461o0161p0161q0161r0161spng generates png for the starter deck of Darkness
Hope I explained it clearly
simp.php
<?php
$s = $_GET['mark'];
$l = str_split(implode('',explode(' ',$_GET['cards'])),3);
if(sizeof($l)>60) header('Location: generate.php?d=Invalid+deck');
sort($l,SORT_STRING);
foreach(array_count_values($l) as $k => $v) $s .= str_pad($v,2,'0',STR_PAD_LEFT).$k;
$s .= $_GET['format'];
header('Location: generate.php?arg='.$s);
?>
generate.php
<?php
if(array_key_exists('d',$_GET)) die($_GET['d']);
preg_match('/^([^\d]+)(.+)/',$_GET['arg'],$m);
$im = imagecreatefrompng('images/board.png');
$l = str_split($m[2],5);
$u = 0;
for($i = 0; $i < sizeof($l)-1; $i++){
for($j = 0, $t = intval(substr($l[$i],0,2)); $j < $t; $j++, $u++){
$c = @imagecreatefrompng('images/'.substr($l[$i],2).'.png') or die('Invalid card code: '.substr($l[$i],2));
$s = @imagecreatefrompng('images/shadow.png') or die('Can\'t open image');
$x = 15+floor($u/10)*88.9;
$y = 5+($u-floor($u/10)*10)*18.5;
imagecopy($im,$c,$x,$y,0,0,73,73);
imagecopy($im,$s,$x-3,$y-2,0,0,79,75);
}
}
$c = @imagecreatefrompng('images/marks/'.$m[1].'.png') or die('Invalid mark');
imagecopy($im,$c,565,6,0,0,73,73);
header('Content-Type: image/'.$l[sizeof($l)-1]);
eval('image'.$l[sizeof($l)-1].'($im);');
imagedestroy($im);
?>