CodeIgniter Forums
[SOLVED] - Honeypot - How to capture an exception - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: [SOLVED] - Honeypot - How to capture an exception (/showthread.php?tid=75339)



[SOLVED] - Honeypot - How to capture an exception - reszko - 01-28-2020

Hi,

I am following the userguide instructions to use the honeypot class and almost everithing worked well.
But, I don't know how to capture a HoneyPotException when it is triggered when a bot fills the hidden field in the form.
I would like to capture that exception before it will be showed to user but I can't do that.
Even if I try to use a try/catch block, like so:

PHP Code:
try {
 
print_r($this->request->getPost());
}
catch (
Honeypotexception $e) {
echo 
$e->getMessage();


the print_r portion of my code is never reached.

So. How can I capture that exception to treat it before it is showed to user.


thank.
Ps. My english is a working in progress.


[SOLVED] - RE: Honeypot - How to capture an exception - reszko - 01-28-2020

Hi everyone

To make it work I decided to create my own filter, and put it inside app/filters.
The content is about the same that exists in system/filters/honeypot.
So, after do that, I went to app/Filter and I set the configuration to call my own HoneyPot filter instead of the native one.
Then, I could do anything I want there, including throw an Honeypotexception or not.

I hope I it helped someone.

Thankyou

(01-28-2020, 05:39 AM)reszko Wrote: Hi,

I am following the userguide instructions to use the honeypot class and almost everithing worked well.
But, I don't know how to capture a HoneyPotException when it is triggered when a bot fills the hidden field in the form.
I would like to capture that exception before it will be showed to user but I can't do that.
Even if I try to use a try/catch block, like so:

PHP Code:
try {
 
print_r($this->request->getPost());
}
catch (
Honeypotexception $e) {
echo 
$e->getMessage();


the print_r portion of my code is never reached.

So. How can I capture that exception to treat it before it is showed to user.


thank.
Ps. My english is a working in progress.



RE: [SOLVED] - RE: Honeypot - How to capture an exception - swsupport - 11-26-2020

(01-28-2020, 03:14 PM)Hello,Can you please post the code changes in the app/filters/honeypot and app/filter file to call your own honeypot filter?I have tried several combinations but keep getting errors.Thanksreszko Wrote: Hi everyone

To make it work I decided to create my own filter, and put it inside app/filters.
The content is about the same that exists in system/filters/honeypot.
So, after do that, I went to app/Filter and I set the configuration to call my own HoneyPot filter instead of the native one.
Then, I could do anything I want there, including throw an Honeypotexception or not.

I hope I it helped someone.

Thankyou

(01-28-2020, 05:39 AM)reszko Wrote: Hi,

I am following the userguide instructions to use the honeypot class and almost everithing worked well.
But, I don't know how to capture a HoneyPotException when it is triggered when a bot fills the hidden field in the form.
I would like to capture that exception before it will be showed to user but I can't do that.
Even if I try to use a try/catch block, like so:

PHP Code:
try {
 
print_r($this->request->getPost());
}
catch (
Honeypotexception $e) {
echo 
$e->getMessage();


the print_r portion of my code is never reached.

So. How can I capture that exception to treat it before it is showed to user.


thank.
Ps. My english is a working in progress.



RE: [SOLVED] - RE: Honeypot - How to capture an exception - murugappan - 11-08-2021

(11-26-2020, 01:47 PM)Just like any other forum, people close the post  as "solved" when it is not. Worse, people giving suggestions to questions do not actually provide a sample code and they leave the post "hanging". Its shame a good product has hopeless users. swsupport Wrote:
(01-28-2020, 03:14 PM)Hello,Can you please post the code changes in the app/filters/honeypot and app/filter file to call your own honeypot filter?I have tried several combinations but keep getting errors.Thanksreszko Wrote: Hi everyone

To make it work I decided to create my own filter, and put it inside app/filters.
The content is about the same that exists in system/filters/honeypot.
So, after do that, I went to app/Filter and I set the configuration to call my own HoneyPot filter instead of the native one.
Then, I could do anything I want there, including throw an Honeypotexception or not.

I hope I it helped someone.

Thankyou

(01-28-2020, 05:39 AM)reszko Wrote: Hi,

I am following the userguide instructions to use the honeypot class and almost everithing worked well.
But, I don't know how to capture a HoneyPotException when it is triggered when a bot fills the hidden field in the form.
I would like to capture that exception before it will be showed to user but I can't do that.
Even if I try to use a try/catch block, like so:

PHP Code:
try {
 
print_r($this->request->getPost());
}
catch (
Honeypotexception $e) {
echo 
$e->getMessage();


the print_r portion of my code is never reached.

So. How can I capture that exception to treat it before it is showed to user.


thank.
Ps. My english is a working in progress.