" . $v . "
"; return $v; } else return $s; } function sortMod($a) { // for ($i = 0; $i < count($a); $i++) echo modName($a[$i]).", "; // echo "
"; for ($i = 0; $i < count($a) - 1; $i++) for ($j = $i + 1; $j < count($a); $j++) if (modName($a[$i]) > modName($a[$j])) { $s = $a[$i]; $a[$i] = $a[$j]; $a[$j] = $s; } // for ($i = 0; $i < count($a); $i++) echo modName($a[$i]).", "; // echo "
"; // echo "
"; return $a; } function getDir($pa = '.', $le = 0) { global $ar, $ex; $dh = @opendir($pa); $ad = array(); $af = array(); while (($fi = readdir($dh)) !== false) if (!in_array($fi, array('.', '..'))) if (is_dir($fu = $pa . "/" . $fi)) $ad[count($ad)] = $fu; else $af[count($af)] = $fu; closedir($dh); sort($ad); $af = sortMod($af); // if sortMod, $af = ... $sp = str_repeat(' ', $le * 4); for ($i = 0; $i < count($ad); $i++) { // echo $sp . "" . $ad[$i] . "
"; getDir($ad[$i], $le + 1); } for ($i = 0; $i < count($af); $i++) { // echo $sp . $af[$i] . "
"; if (getExt($af[$i]) == $ex) $ar[count($ar)] = $af[$i]; } } function del($s) { if (file_exists($s)) unlink($s); /* echo $s."
"; */ } function getData() { global $ar, $ex, $ab, $bw, $bh, $rw, $rh; $ar = array(); $ex = "png"; getDir("from"); // result comes to $ar $ab = $ar; $ar = array(); $ex = "tile"; getDir("to"); // result comes to $ar // calculates both w, h $bh = 1; $fi = substr($ab[0], 0, strrpos($ab[0], "_")); while (substr($ab[$bh], 0, strrpos($ab[$bh], "_")) == $fi) $bh++; $bw = count($ab) / $bh; $rh = 1; $fi = substr($ar[0], 0, strrpos($ar[0], "/")); while (substr($ar[$rh], 0, strrpos($ar[$rh], "/")) == $fi) $rh++; $rw = count($ar) / $rh; } foreach ($_GET as $k => $v) $$k = $_GET["$k"]; getData(); if (isset($pmX)) { // remove cutted tile png-s, not tested for ($i = 0; $i < count($ar); $i++) unlink(substr($ar[$i], 0, strlen($ar[$i]) - 5)); if ($pmX == 1) { // echo "del first col
"; for ($i = 0; $i < $bh; $i++) del($ab[$i]); // del first col } // echo "
"; if ($bw - 1 - $pmX == $rw) { // echo "del last col
"; for ($i = 0; $i < $bh; $i++) del($ab[$bh * ($bw - 1) + $i]); // del last col } // echo "---
"; if ($pmY == 1) { // echo "del last row
"; for ($i = 0; $i < $bw; $i++) del($ab[$i * $bh]); // del first row } // echo "
"; if ($bh - 1 - $pmY == $rh) { // echo "del last row
"; for ($i = 0; $i < $bw; $i++) del($ab[$i * $bh + ($bh - 1)]); // del last row } // echo count($ar); getData(); // echo count($ar); } echo "Google: " . count($ar) . " (" . $rw . "x" . $rh . "), Turaterkep: " . count($ab) . " (" . $bw ."x" . $bh. ")

"; if (count($ab) != count($ar)) { // copy cutted .tile from test for ($i = 0; $i < count($ar); $i++) copy($ar[$i], substr($ar[$i], 0, strlen($ar[$i]) - 5)); ?>

     

" . substr($ab[$i], 0, strlen($ab[$i]) - 4) . "to.png
"; } // copy for ($i = 0; $i < count($ab); $i++) { copy($ab[$i], $ar[$i]); // remove cutted .tile // if (file_exists($fn = substr($ar[$i], 0, strlen($ar[$i]) - 5) . ".png")) unlink($fn); // not tested } ?>
" */ ?> " */ ?>