Ejemplo n.º 1
0
    $options['fonts'] = isset($_GET['fonts']) ? strtolower(htmlspecialchars(urldecode($_GET['fonts']))) : 'freeserif';
    if (filter_var($options['fonts'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === false) {
        $options['fonts'] = '';
    }
}
try {
    if (isset($_GET['refresh'])) {
        $refresh = new Refresh($api);
        $refresh->refresh();
        $success = 'The cache is updated for ' . $api->lang . ' language.';
        include 'templates/book.php';
    }
    if ($title === '') {
        include 'templates/book.php';
    } else {
        $creator = BookCreator::forApi($api, $format, $options);
        try {
            list($book, $file) = $creator->create($title);
        } catch (WSExportInvalidArgumentException $exception) {
            throw new HttpException('Unsupported Media Type', 415);
        }
        header('X-Robots-Tag: none');
        header('Content-Description: File Transfer');
        header('Content-Type: ' . $creator->getMimeType());
        header('Content-Disposition: attachment; filename="' . $title . '.' . $creator->getExtension() . '"');
        header('Content-length: ' . filesize($file));
        readfile($file);
        unlink($file);
        flush();
        CreationLog::singleton()->add($book, $format);
    }