new_year_2020/choix.php

21 lines
496 B
PHP

<?php
if (empty($_GET['element']) || empty($_GET['hash'])) {
die('non');
}
$element_type = $_GET['element'];
$hash = strtolower($_GET['hash']);
$file = hexdec($hash[0]);
$color = substr($hash, 1);
$element = sprintf('elements/%s/%s.svg', $element_type, $file);
while (!file_exists($element)) {
$file--;
$element = sprintf('elements/%s/%s.svg', $element_type, $file);
}
$svg = file_get_contents($element);
$svg = str_replace('class="colored"', 'fill="#'.$color.'"', $svg);
echo $svg;