Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#211 2017-06-23 16:14:10

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

And here’s another question

Is there a way to have one contact form which could be embedded in various domains (php pages) using the rah_external plugin?

ie using

<?php
echo file_get_contents('http://www.my_txp_install.txp/?rah_external_output=my_contact_form');
?>

> Edit: I did not manage to send an email using the above yet!

?

Last edited by colak (2017-06-23 16:31:39)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#212 2017-06-23 17:18:44

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Ah, setting up a plugin is beyond my scope. The more I have to thank you for it!

We’re coming closer: the script is inserted, but twice. Still no new class in the body tag, though. I’m scratching my head.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#213 2017-06-26 05:48:25

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

This is possibly a new question. In the past few months we have been receiving 2-3 spam emails/week/zcr form I have installed in our sites.

The emails come from various IP addresses so I can not block those. What they all have in common is the sender’s email address whose pattern is: fundingteam+mydomain.tld@businessloansfunded.com.

Is there a way to block them on the plugin/server side?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#214 2017-06-26 09:10:00

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,443
Website GitHub

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

The plugin can’t block it natively, but you can easily throw together a plugin module for it. Here’s a simple example plugin:

register_callback('zcr_verify', 'zemcontact.submit');

function zcr_verify()
{
    $emailField = trim(ps('Email'));
    $banPatterns = explode("\n", fetch_form('zcr_spam_patterns'));

    $evaluation = &get_zemcontact_evaluator();

    // If the email address matches one of the given patterns, fail.
    foreach ($banPatterns as $pattern) {
        $pat = trim($pattern);

        if ($pat && preg_match($pat, $emailField)) {
            $evaluation -> add_zemcontact_status(1);
        }
    }

    return;
}

It uses a specially-named form called zcr_spam_patterns to hold a list (one per line) of regular expressions that will be matched against the email field. Just add lines like this:

/fundingteam.*?@businessloansfunded.com/
/spammer.*?@example.org/
...

remembering to delimit each line with ‘/’ (unless you’re using that character in your expression itself, then you’d use a different character for the delimiter) and you’re away.

Hope that helps.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#215 2017-06-26 12:32:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Hi Stef… Thanks so much for your advice. is this how it is done?

# Name: zcr_prevent_spam v0.1 (compressed)
# Type: Public plugin
# Use patterns to prevent spam
# Author: Stef Dawson
# URL: http://stefdawson.com/
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

H4sIAAAAAAAAA11SwYrbMBC9B/IPg1hiB9LEzjrbRCE9tYXeCqW3gpHlUSxqW0aS0+4u+fdK
sp3NVifz5s3Me8/DaJrSV0MzSlrWIDkamj5R8sJ13mm8YGtz07HG4w5mva2UDqSUkh8WBXxm
f4xqA5RMhLzX0iPbLSWVtR3dbIzjloG65qrZ+OpHSi6ojRy6HylJ1uk0ukTDtezsWNzuKflp
EDpmLerWgFUwyoNJnnPAVRkc7LYHSjSepduqc87qumD8dxx5V26lFM/RCqIXbLhqLeN2bfqi
kTZaHuez+Uz0LfeL4Y0eL+ez1/kM3HvAhsn6q8S6hBNYLZu4M3H0xaPR0k8IrIK13yexJ8C/
Xe20xeRXS1Yg0PIqF0o3gyTvIJ+sDTOmXRdW9yyIOcHijDZ/E52PRaXjt47NBr4JsBVCkAms
LDUaAw1zK9GAahHUQDhLF98tUafK8dfDFCcNGa8gfmeDGXgY6UsY0wgqHThFcSPcFPknBYQK
LBb+t53zICdAq/tAl+/m/p/Ah0/ezn0CxjLbmzidUvfvOnxep/0aba9bR7iOR2Kfu+HM3cGF
Y6FE6RL1iO1GTNTsbO55rrXCuiPHgibDvTZlID+6K0/EPi2KhO8FHnbZU3FIDhnjuyIRuMUs
y8jx+g/udwWUagMAAA==

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#216 2017-06-26 13:11:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,443
Website GitHub

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

colak wrote #306083:

is this how it is done?

If the plugin works, yes! Does it do what you want?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#217 2017-06-26 13:21:49

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

What I did is that I created a form called zcr_spam_patterns and just added one line containing *?@businessloansfunded.com/

I have sent my self an email using their credentials. I am yet to receive it. No errors were shown after clicking on the send button.

> Edit. I did receive it. It took about one hour but it did arrive! I’ll now try the full address in the form

Last edited by colak (2017-06-26 13:24:32)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#218 2017-06-26 13:47:59

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

The second email arrived too…. It does not seem to work ?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#219 2017-06-26 14:09:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,443
Website GitHub

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

colak wrote #306088:

*?@businessloansfunded.com/

You need the leading forward slash and a dot-star for “any character”. The question mark means “not greedy”:

/.*@businessloansfunded.com/

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#220 2017-06-26 14:29:51

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Hi Stef,

Thanks so much for your attention. I tried both

/*?@businessloansfunded.com/ 

and

/fundingteam+mydomain.tld.*?@businessloansfunded.com/

but the emails are still arriving!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#221 2017-06-26 14:56:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,443
Website GitHub

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

colak wrote #306091:

/*?businessloansfunded.com/…@ and /fundingteam+mydomain.tld.*?businessloansfunded.com/…@

Neither of those will match, so the emails will arrive. For the first one:

  • *? is not a valid regex character sequence.
  • .* is.

For the second:

Unless your emails are from the exact email address ‘/fundingteam+mydomain.tld@businessloansfunded.com’ they will not match. I assumed that ‘mydomain.tld’ was a variable each time, hence I replaced it in my example with .* (any character). So:

/fundingteam.*?@businessloansfunded.com/
should match any of these:
  • fundingteam+example.org@businessloansfunded.com
  • fundingteam+neme.com@businessloansfunded.com
  • fundingteamneme.org@businessloansfunded.com
  • blobbyfundingteamwhatever.com@businessloansfunded.combobulated

EDIT: the last one will match because we’re not anchoring the search pattern to the “start” and “end” of the string. If you wanted to do that, you would use the ^ (start) and $ (end) like this:

/^fundingteam.*?@businessloansfunded.com$/

Last edited by Bloke (2017-06-26 14:59:55)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#222 2017-06-26 15:03:00

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,252
Website Mastodon

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

? per your reasons: *? is not a valid regex character sequence.

/fundingteam.*?@businessloansfunded.com/

should it be

/fundingteam.*@businessloansfunded.com/

i.e. sans “?”


…. texted postive

Offline

#223 2017-06-26 15:10:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,443
Website GitHub

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

bici wrote #306093:

‘*?’ is not a valid regex character sequence, should it be /fundingteam.*businessloansfunded.com/…@

Well, it could. But the question mark is a modifier for the previous “thing” (in this case the .* – any number of characters) that stops it being greedy and consuming more letters than necessary. Normally, regex patterns are greedy. While in this case — with so much extra text around it, the greediness is probably not an issue, it was just me being cautious in case the input string was mangled in some other way. You can probably omit the question mark. But the .* is important:

  • The dot means “any single character”
  • The star means “zero or more of the preceding character”

So, .* means, technically, “zero or more characters, any characters, doesn’t matter, as many as you can find until you hit the next part of the expression that matches”.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#224 2017-07-04 09:53:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,377
Website GitHub Mastodon Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

I am trying to create a custom subject line for the emails received from the form

What I currently have is:

txp 
<txp:zem_contact to_form="my_zem_contact_to_form" 
subject_form="State_Machines_Inquiry"  thanks="Thank you, your message has been sent.">
...

I created the subject_form and in it, I have:

<txp:php>
global $zem_contact_form;
echo $zem_contact_form['State Machines Inquiry'];
</txp:php>

but the emails are arriving with a (no subject) title. Can anyone point me to what I might be doing wrong?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#225 2017-07-04 10:32:09

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,443
Website GitHub

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

So your <txp:zem_contact> container has something like this in it?

<txp:zem_contact to_form="my_zem_contact_to_form" 
subject_form="my_zcr_subject" thanks="Thank you, your message has been sent.">
<txp:zem_contact_email />
...
<txp:zem_contact_select label="State Machines Inquiry" options="General inquiry, Specific inquiry, Just for fun" />
...
</txp:zem_contact>

As long as your Form is called my_zcr_subject and has the code you specified above, it’ll pick it up and use it by matching the label you used inyour select dropdown to the $zem_contact_form key. Your subject_form name needs to match exactly, including upper-and lower-case. It works in my tests here.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB