<?php

include 'ImageGenerator.php';
include 'SongProvider.php';
include 'Song.php';

$person = $_GET['name'] ? $_GET['name'] : 'Ошибка';
$key = $_GET['key'] ? $_GET['key'] : 1;
$time = $_GET['time'] ? $_GET['time'] : time();
$download = isset($_GET['download']);

$songProvider = new SongProvider();

$song = $songProvider->provide($key);

$generator = new ImageGenerator($person, $song->text, $song->name, $time);

if ($download) {
    header("Content-Disposition: attachment; filename=\"Напутствие.png\";" );
} else {
    header("Content-type: image/png");
}

$generator->expose();