Skip to content

Instantly share code, notes, and snippets.

Created June 11, 2014 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/e2726b63dc5247ead60a to your computer and use it in GitHub Desktop.
Save anonymous/e2726b63dc5247ead60a to your computer and use it in GitHub Desktop.
Kirby Submission Plugin with Honeypot Spam Detection. This is just @dweidner's template for using the Honeypot. See: https://github.com/bastianallgeier/kirbycms-extensions/pull/61#issuecomment-29104650
<?php
$form = new contactform(array(
'to' => 'Daniel Weidner <hallo@danielweidner.de>',
'from' => 'Contact Form <kontakt@danielweidner.de>',
'subject' => 'Neue Nachricht',
'goto' => null,
'honeypot' => 'email-repeat-142'
));
?>
<?php if($form->isSubmitted() && !$form->isError()): ?>
<div class="contact-form is-sent">
<div class="message message--success">
<i class="icon icon--ok" aria-hidden="true"></i>
<strong>Vielen Dank für Ihre Anfrage!</strong> Ihre Nachricht wurde erfolgreich verschickt. Ich werde mich so bald wie möglich bei Ihnen melden. Im Folgenden finden Sie zur Übersicht noch einmal die von ihnen verschickten Daten.
</div>
<pre class="contact-form__summary">
<strong>An:</strong> Daniel Weidner &lt;<?= str::email($site->email()); ?>&gt;
<strong>Von:</strong> <?= $form->htmlValue('name'); ?> &lt;<?= str::email($form->htmlValue('email')); ?>&gt;
<?= $form->htmlValue('text'); ?>
</pre>
</div>
<?php else: ?>
<form action="#form" method="POST" class="contact-form">
<?php if($form->isError('send')): ?>
<div class="message message--error">
<i class="icon icon--cancel icon--inline" aria-hidden="true"></i>
Es gab technische Schwierigkeiten beim Versenden ihrer Nachricht. Ihre Nachricht konnte nicht verschickt werden. Bitte versuchen Sie es später erneut oder nutzen Sie einen der anderen Kommunikationswege.
</div>
<?php elseif($form->isError()): ?>
<div class="message message--error">
<i class="icon icon--cancel icon--inline" aria-hidden="true"></i>
Ihre Nachricht wurde nicht verschickt. Um ihre Nachricht erfolgreich abschicken zu können müssen Sie alle als Pflichtfeld markierten Textfelder (*) ausfüllen. Folgende Textfelder enthalten bisher keinen oder fehlerhaften Inhalt: <?= ucwords(implode(', ', $form->errors())); ?>
</div>
<?php endif; ?>
<ul class="fields">
<li class="field-group">
<label for="cf-name">
Name <?= $form->isRequired('name') ? '<span class="required">*</span>' : ''; ?>
</label>
<input type="text" name="name" value="<?= $form->htmlValue('name'); ?>" id="cf-name" class="text-input text-input--full" />
<?php if($form->isError('name')): ?>
<small class="text-input-help">
<i class="icon icon--info" aria-hidden="true"></i>
Bitte geben Sie einen Namen an mit dem ich Sie in meiner Antwort ansprechen kann.
</small>
<?php endif; ?>
</li>
<li class="field-group">
<label for="cf-email">
Email <?= $form->isRequired('email') ? '<span class="required">*</span>' : ''; ?>
</label>
<input type="email" name="email" value="<?= $form->htmlValue('email'); ?>" id="cf-email" class="text-input text-input--full" />
<?php if($form->isError('email')): ?>
<small class="text-input-help">
<i class="icon icon--info" aria-hidden="true"></i>
Bitte geben Sie in diesem Feld ihre Email Adresse an. Eine gültige Email Adresse wird benötigt, damit ich ggf. eine Antwort auf ihre Nachricht verschicken kann. Ihre Angaben werden vertraulich behandelt und nicht an etwaige Dritte weitergegeben.
</small>
<?php endif; ?>
</li>
<li class="field-group field-group--alternate">
<label for="cf-email-repeat-142">
Bitte das folgende Feld freilassen. Es dient lediglich dem Schutz gegen automatisierte Nachrichten.
</label>
<input type="email" name="email-repeat-142" value="" id="cf-email-repeat-142" class="text-input text-input--full" />
</li>
<li class="field-group">
<label for="cf-text">
Nachricht <?= $form->isRequired('text') ? '<span class="required">*</span>' : ''; ?>
</label>
<textarea id="cf-text" name="text" cols="70" rows="15" class="text-input text-input--full"><?= $form->htmlValue('text'); ?></textarea>
<?php if($form->isError('text')): ?>
<small class="text-input-help">
<i class="icon icon--info" aria-hidden="true"></i>
Sie haben noch keine Nachricht in das Textfeld eingegeben.
</small>
<?php endif; ?>
</li>
</ul>
<button type="submit" class="btn btn--large btn--full" title="Nachricht abschicken">
Abschicken
</button>
<script>
document.getElementById('cf-email-repeat-142').setAttribute('autocomplete', 'off');
</script>
</form>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment