Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#397 2023-03-10 13:04:21
Re: com_connect - form and contact mailer
etc wrote #335011:
Many tags need to know whether they are called with content (even empty) or not.
Thought so. That’s fine then.
What we could do rather easily, is not passing null
$thing
at all, but only if the tag has no extra (registered) arguments.
If that would work, great.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#398 2023-03-10 13:09:29
Re: com_connect - form and contact mailer
I patched the plugin anyway in the 4.9.0 codebase. EDIT: and then removed the testing string I forgot about, d’oh.
Last edited by Bloke (2023-03-10 13:11:11)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#399 2023-03-10 13:57:36
Re: com_connect - form and contact mailer
whocarez wrote #334519:
sanitizeForUrl
makes everything lowercase, as far as I understand it. SoREMOTE_ADDR
getsremote_addr
.
This should be fixed now in the 4.9.0 codebase. Sorry for the delay.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#400 2023-03-10 13:58:03
Re: com_connect - form and contact mailer
Bloke wrote #335012:
If that would work, great.
That’s technically easy, but I’m a bit nervous re eventual plugins tags that always expect some content and do not set $thing
:
function abc_careless_tag($atts, $thing) {...}
Maybe it’s more prudent to postpone this to php8 switch.
Offline
#401 2023-03-10 13:59:48
Re: com_connect - form and contact mailer
etc wrote #335016:
Maybe it’s more prudent to postpone this to php8 switch.
Absolutely fine. Easy to workaround for now, and I’ll document it for other plugin authors.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#402 2023-03-13 02:32:44
Re: com_connect - form and contact mailer
Anyone following development of this plugin in preparation for 4.9.0 can try out the new anti-spam features that have been baked into the core plugin. Based on a few ideas cadged from around the internet and from other plugins, the crux of it is:
- An
action
attribute on the main contact form tag. You should not need this, but if you find that bots are hitting your site, you can use this to either:- Supply a different endpoint (URL) to process your form data.
- Supply two different endpoints, the first of which is fake, and the second of which is real. If you omit the second endpoint, the current page is assumed. Through judicial use of the new
delay
attribute the plugin will inject the correct URL (via JavaScript) after the given number of seconds.
- The
delay
attribute can be used either on the main contact form tag, or on the<txp:com_connect_text>
tag. If used globally, it sets the time, or time range, after which any delayed effects take place. Individual tags can then use this value, or specify their own delay. - The
expected
attribute on the<txp:com_connect_text>
tag allows you to specify that certain field values are expected in the result. If they’re not there, or are in any way mangled, the form won’t get through. - The
<txp:com_connect_expect>
tag can be used for special effects or to specify that certain conditions must be met for the form to be passed on.
Using these tools in various combinations will allow you to make it harder for bots and automated form fillers to operate. Examples:
<!-- Add a human test field with one or more expected answers -->
<com::connect_text label="What's 5+3?" name="humancheck" expected="8, eight" />
<!-- Add a hidden field that only gets inserted sometime between
8 and 12 seconds after someone starts interacting with the form.
If the form is submitted before the field is added, it will be rejected -->
<com::connect_text label="" name="nobot" hidden default="1" expected="1" delay="8-12" required="0" />
<!-- Use a fake submission URL that is randomly replaced with the real one
after between 5-15 seconds. Also add a hidden field that rejects the form if it's filled out
(similar to pap_contact_cleaner).
Also add a delayed hidden field that will appear randomly between 5-15 seconds after
a visitor starts interacting with the form -->
<com::connect to="someone@example.org" delay="5-15" action="https://fake.example.org/honeytrap,">
<com::connect_text label="Your name" />
<com::connect_email label="Email address" />
<com::connect_textarea label="Message" />
<com::connect_text hidden label="" name="office_phone" required="0" />
<com::connect_expect name="office_phone" /> <!-- No value means this field is not expected in the payload -->
<com::connect_text label="" name="real_visitor" hidden default="yes" expected="yes" delay required="0" />
</com::connect>
Any of the delay
features require (native) JavaScript.
There’s lots of scope for creating forms now, without additional spam protection plugins, so go nuts and post your examples.
Any issues with this, or ideas to extend it, please throw them here. One thing I’d like to do is offer some way to randomize the form field names from a set, so you can throw some real-sounding field names in the mix, but make them hidden and required with a certain value. Or hidden and not required. Thinking about ways to achieve that in a sane manner.
Last edited by Bloke (2023-03-13 02:40:07)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#403 2023-04-03 10:42:35
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: com_connect - form and contact mailer
to from field started additionally to appear “charset=“UTF-8”
roundcube webmail is a software
com_connect 4.7
Textpattern version: 4.8.8
PHP version: 8.1.16
Offline
#404 2023-04-03 20:39:47
Re: com_connect - form and contact mailer
My 4.7.0 com_connect
form works, but my to_form
doesn’t.
<txp:com_connect to_form="o_select_branch" body_form="o_pa_emailbody">
…
<txp:com_connect_select label="Branch" options="Sydney,Melbourne,Perth,Brisbane" />
…
</txp:com_connect>
with form o_select_branch
:
<txp:php>
global $com_connect_form;
switch($com_connect_form['Branch'])
{
case 'Sydney':
echo 'sydney@domain.com';
break;
case 'Melbourne':
echo 'melbourne@domain.com';
break;
case 'Perth':
echo 'perth@domain.com';
break;
case 'Brisbane':
echo 'brisbane@domain.com';
break;
default:
echo 'default@domain.com';
}
</txp:php>
The form always sends to default@domain.com. Any pointers to where the problem might lie?
Textpattern version: 4.8.8
PHP version: 7.4.33
Offline
#405 2023-04-03 20:54:35
Re: com_connect - form and contact mailer
Try:
switch($com_connect_form['Branch'][0])
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#406 2023-04-04 07:54:26
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: com_connect - form and contact mailer
and my issue
Offline
#407 2023-04-04 08:47:29
Re: com_connect - form and contact mailer
Hi
it s not about the new version it s about the 4.7.0 version, it tooks me 2 days to find why i got a php notice about array converted to string in my plugin code until this mornibg i decided to make a ver_dmp of com_connect_values and found that a select need to be adressed as com_connect_values[‘name’] [0] !
Maybe this information can save time for others.
Cheers.
NB: hard to debug code when fasting
Offline
#408 2023-04-04 19:19:30
Re: com_connect - form and contact mailer
Bloke wrote #335256:
Try:
switch($com_connect_form['Branch'][0])...
Thanks Bloke; that did the trick.
Offline