Skip to content

Commit

Permalink
Merge pull request #121 from CollegiumAcademicum/test
Browse files Browse the repository at this point in the history
Add spam protection to aula mieten and fix CI
  • Loading branch information
han16nah authored Aug 4, 2024
2 parents e8d500e + 2fd5273 commit 911c8b4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: bash build_prod.sh
- name: Upload to FTP
run: lftp -c "set sftp:auto-confirm yes ; open -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} -p ${{ secrets.FTP_PORT }} sftp://${{ secrets.FTP_HOST }} ; mirror -Rn --ignore-time -P 12 upload/ /web/website ; quit"
if: ${{ github.event.inputs.REUPLOAD_ALL == 'false'}}
# if: ${{ github.event_name == 'push' || github.event.inputs.REUPLOAD_ALL == 'false'}}
- name: Upload to FTP (all files)
run: lftp -c "set sftp:auto-confirm yes ; open -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} -p ${{ secrets.FTP_PORT }} sftp://${{ secrets.FTP_HOST }} ; mirror -R -P 12 upload/ /web/website ; quit"
if: ${{ github.event.inputs.REUPLOAD_ALL == 'true'}}
2 changes: 1 addition & 1 deletion .github/workflows/deploy_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: bash build_test.sh
- name: Upload to FTP (only changed files)
run: lftp -c "set sftp:auto-confirm yes ; open -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} -p ${{ secrets.FTP_PORT }} sftp://${{ secrets.FTP_HOST }} ; mirror -Rn --ignore-time -P 12 upload/ /web/website_tmp ; quit"
if: ${{ github.event.inputs.REUPLOAD_ALL == 'false'}}
# if: ${{ github.event_name == 'push' || github.event.inputs.REUPLOAD_ALL == 'false'}}
- name: Upload to FTP (all files)
run: lftp -c "set sftp:auto-confirm yes ; open -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} -p ${{ secrets.FTP_PORT }} sftp://${{ secrets.FTP_HOST }} ; mirror -R -P 12 upload/ /web/website_tmp ; quit"
if: ${{ github.event.inputs.REUPLOAD_ALL == 'true'}}
8 changes: 8 additions & 0 deletions content/pages/events/mieten/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ Schreibt uns an <a href="mailto:aula@collegiumacademicum.de">aula@collegiumacade
<textarea class="input" type="textarea" placeholder="Optional" maxlength="1000" name="freetext"></textarea>
</div>
</div>
<div class="field">
<label class="label" for="spam_protection">Um sicherzustellen, dass du kein
Computer bist, bitten wir dich folgende Frage zu beantworten: Wie viel ist
9 - 3? </label>
<div class="spam_protection">
<input class="input" type="text" placeholder="" maxlength="10" name="spam_protection">
</div>
</div>
<div class="field">
<div class="control">
<label class="sr-only" for="submit"></label>
Expand Down
8 changes: 5 additions & 3 deletions content/pages/events/mieten/send.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
file_put_contents($log_file, $initial_content);
}

// NOTE:The field mail is a fake field for spam protection
$fields = ['full_name', 'email', 'phone', 'event', 'date',
'number_guests', 'freetext'];
'number_guests', 'freetext', 'mail', 'spam_protection'];

$i18n = [
"de" => [
Expand Down Expand Up @@ -105,8 +106,9 @@ function check_for_spam($logs, $ip_address) {

// spam protection
$spam = check_for_spam($logs, $ip_address);

if (! $spam ) {
$spam_protection = $form->post("spam_protection");
$fake_mail_field = $form->post("mail");
if ($spam_protection == 6 and $fake_mail_field == "" and ! $spam ) {
$data = ["email" => $form->post('email','Email','valid_email')];
foreach ($fields as $field) {
$_dat = $form->post($field);
Expand Down

0 comments on commit 911c8b4

Please sign in to comment.