Code:
<?php $width = isset($_GET['w']) ? $_GET['w']: '300'; $height = isset($_GET['h']) ? $_GET['h']: '200'; $stroke = isset($_GET['s']) ? $_GET['s']: '222'; $fill = isset($_GET['f']) ? $_GET['f']: 'fafafa'; if (preg_match('([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})', $stroke)) { $stroke = '#'.$stroke; } if (preg_match('([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})', $fill)) { $fill = '#'.$fill; } header('Content-Type: image/svg+xml'); ?> <svg xmlns="http://www.w3.org/2000/svg" width="<?php echo $width; ?>" height="<?php echo $height; ?>"> <g> <rect width="<?php echo $width ?>" height="<?php echo $height; ?>" y="0" x="0" stroke="<?php echo $stroke; ?>" fill="<?php echo $fill; ?>"/> <line x1="0" x2="100%" y1="0" y2="100%" stroke="<?php echo $stroke; ?>"/> <line x1="100%" x2="0" y1="0" y2="100%" stroke="<?php echo $stroke; ?>"/> </g> </svg>