changed some things for better spam protection #49

Open
andibraeu wants to merge 5 commits from andibraeu/antispam into master
4 changed files with 50 additions and 14 deletions
Showing only changes of commit 3d4500b846 - Show all commits

View file

@ -156,17 +156,18 @@ class EventController extends Controller
{ {
$entity = new Event(); $entity = new Event();
if (! $request->get('origin')) {
$em = $this->saveEvent($request, $entity); $em = $this->saveEvent($request, $entity);
$errors = $entity->isValid(); $errors = $entity->isValid();
if ( $errors === true ) { if ( $errors === true ) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($entity); $em->persist($entity);
$em->flush(); $em->flush();
return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug))); return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug)));
} }
} else {
return $this->redirect($this->generateUrl(''));
}
return array( return array(
'entity' => $entity, 'entity' => $entity,
@ -284,16 +285,18 @@ class EventController extends Controller
throw $this->createNotFoundException('Unable to find Event entity.'); throw $this->createNotFoundException('Unable to find Event entity.');
} }
$em = $this->saveEvent($request, $entity);
$errors = $entity->isValid(); $errors = $entity->isValid();
if ($errors === true) { if ($errors === true && (! $request->get('origin'))) {
$em = $this->saveEvent($request, $entity);
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($entity); $em->persist($entity);
$em->flush(); $em->flush();
return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug))); return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug)));
} else {
return $this->redirect($this->generateUrl(''));
} }
return array( return array(

View file

@ -178,6 +178,9 @@ class RepeatingEventController extends Controller
private function saveRepeatingEvent(Request $request, RepeatingEvent $entity) private function saveRepeatingEvent(Request $request, RepeatingEvent $entity)
{ {
if ( $request->get('origin')) {
return false;
}
$location = $request->get('location'); $location = $request->get('location');
$location_lat = $request->get('location_lat'); $location_lat = $request->get('location_lat');
$location_lon = $request->get('location_lon'); $location_lon = $request->get('location_lon');

View file

@ -147,6 +147,21 @@
</div> </div>
</div> </div>
</div> </div>
<div class="field oos">
<label class="control-label required" for="event_origin">Origin</label>
<div class="ui icon input" title="Origin URL (Screenreader: bitte leer lassen)">
<input type="text"
name="origin"
id="event_origin"
maxlength="255"
value="{{ entity.origin|default('') }}"
class="form-control">
<i class="icon globe"></i>
<div class="ui corner label">
<i class="icon asterisk"></i>
</div>
</div>
</div>
</div> </div>
<input type="submit" class="ui button green" value="Speichern"/> <input type="submit" class="ui button green" value="Speichern"/>

View file

@ -157,6 +157,21 @@
<div class="ui label">Du kannst hier kommasepariert <a <div class="ui label">Du kannst hier kommasepariert <a
href="https://en.wikipedia.org/wiki/Tag_%28metadata%29">Tags</a> angeben. href="https://en.wikipedia.org/wiki/Tag_%28metadata%29">Tags</a> angeben.
</div> </div>
<div class="field oos">
<label class="control-label required" for="event_origin">Origin</label>
<div class="ui icon input" title="Origin URL (Screenreader: bitte leer lassen)">
<input type="text"
name="origin"
id="event_origin"
maxlength="255"
value="{{ entity.origin|default('') }}"
class="form-control">
<i class="icon globe"></i>
<div class="ui corner label">
<i class="icon asterisk"></i>
</div>
</div>
</div>
</div> </div>
<input type="submit" class="ui green button" value="Speichern"/> <input type="submit" class="ui green button" value="Speichern"/>