Remove exit statement - use else instead

This commit is contained in:
raphi 2015-04-17 09:43:34 +00:00
parent 034419f403
commit 4d12ec4f22
1 changed files with 37 additions and 38 deletions

View File

@ -19,43 +19,42 @@ if (!RequestUtils::isPost()) {
$tpl = new Tpl;
$tpl->assign('seconds', $spamPrevention);
$tpl->draw('spam');
exit;
} else {
// Parse request
$pattern = RequestUtils::parsePattern();
$keyboardLayout = RequestUtils::parseKeyboardLayout();
$seed = RequestUtils::parseSeed();
$text = RequestUtils::parseText();
$primary = RequestUtils::parsePrimaryColor();
$secondary = RequestUtils::parseSecondaryColor();
$spaceBarSize = RequestUtils::parseSpacebarSize();
// Setup configuration
$cfg = new Configuration($seed, $pattern, $keyboardLayout, $spaceBarSize, $text, $primary, $secondary);
$creator = new CardCreator($cfg);
// Load SVG templates
$front_template = $creator->getSvgTemplate('simple_back');
$back_template = $creator->getSvgTemplate('simple_front');
// Render SVG into tempfiles
$front = $creator->renderIntoTempfile($front_template);
$back = $creator->renderIntoTempfile($back_template);
// Render the PDF
$doc = PDFRenderer::render($front, $back);
// Prepare response PDF file header
RequestUtils::preparePdfHeader(strlen($doc));
// Ignore user abort to cleanup afterwards
ignore_user_abort(true);
// Strem the PDF
echo $doc;
// Cleanup temporary SVG images
unlink($back);
unlink($front);
}
// Parse request
$pattern = RequestUtils::parsePattern();
$keyboardLayout = RequestUtils::parseKeyboardLayout();
$seed = RequestUtils::parseSeed();
$text = RequestUtils::parseText();
$primary = RequestUtils::parsePrimaryColor();
$secondary = RequestUtils::parseSecondaryColor();
$spaceBarSize = RequestUtils::parseSpacebarSize();
// Setup configuration
$cfg = new Configuration($seed, $pattern, $keyboardLayout, $spaceBarSize, $text, $primary, $secondary);
$creator = new CardCreator($cfg);
// Load SVG templates
$front_template = $creator->getSvgTemplate('simple_back');
$back_template = $creator->getSvgTemplate('simple_front');
// Render SVG into tempfiles
$front = $creator->renderIntoTempfile($front_template);
$back = $creator->renderIntoTempfile($back_template);
// Render the PDF
$doc = PDFRenderer::render($front, $back);
// Prepare response PDF file header
RequestUtils::preparePdfHeader(strlen($doc));
// Ignore user abort to cleanup afterwards
ignore_user_abort(true);
// Strem the PDF
echo $doc;
// Cleanup temporary SVG images
unlink($back);
unlink($front);
}