Post by supak111 » Sat Feb 22, 2025 3:12 am

I made this ocmod to add a few extra fields to the contact form. Ocmod works fine but once in a while I end up getting an error in my storage logs. I really don't understand why this error happens... Can someone take a look and see if you can spot why my OCmod would causing this error ONLY once in a while?

Error:

Code: Select all

PHP Notice:  Undefined index: enquiry in /home/xxx/storage/modification/catalog/controller/information/contact.php on line 196
line 196 on that file is:

Code: Select all

if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
		$this->error['enquiry'] = $this->language->get('error_enquiry');
		}
part of my OCmod dealing with controller file:

Code: Select all

    <file path="catalog/controller/information/contact.php">
        
        
        <operation error="skip">
            <search>
                <![CDATA[$mail->setText($this->request->post['enquiry']);]]>
            </search>
            <add position="replace">
                <![CDATA[

                    $mail->setText(
                        "Make and Model: \n" . $this->request->post['vehicle'] . "\n\n" .
                        "How did you hear about us: \n" . $this->request->post['hearaboutus'] . "\n\n" .
                        "Enquiry: \n" . $this->request->post['enquiry']
                    );

]]>
            </add>
        </operation>
        
        
        <operation error="skip">
            <search>
                <![CDATA[$data['button_submit'] = $this->language->get('button_submit');]]>
            </search>
            <add position="before">
                <![CDATA[

                    if (isset($this->error['vehicle'])) {
                        $data['error_vehicle'] = $this->error['vehicle'];
                    } else {
                        $data['error_vehicle'] = '';
                    }


                    if (isset($this->error['hearaboutus'])) {
                        $data['error_hearaboutus'] = $this->error['hearaboutus'];
                    } else {
                        $data['error_hearaboutus'] = '';
                    }

]]>
            </add>
        </operation>


        <operation error="skip">
            <search>
                <![CDATA[protected function validate() {]]>
            </search>
            <add position="after">
                <![CDATA[

                    if ((utf8_strlen($this->request->post['vehicle']) < 3) || (utf8_strlen($this->request->post['vehicle']) > 300)) {
                        $this->error['vehicle'] = $this->language->get('error_vehicle');
                    }


                    if ((utf8_strlen($this->request->post['hearaboutus']) < 3) || (utf8_strlen($this->request->post['hearaboutus']) > 300)) {
                        $this->error['hearaboutus'] = $this->language->get('error_hearaboutus');
                    }

]]>
            </add>
        </operation>
    </file>
Last edited by supak111 on Sun Feb 23, 2025 6:45 am, edited 1 time in total.

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by ADD Creative » Sat Feb 22, 2025 5:27 am

Most likely a POST without enquiry set. Maybe a bot, unless there is something causing the field to disappear from your HTML form.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Sat Feb 22, 2025 6:37 am

You know I was thinking it could be a spam bot doing this because when I fill out the contact form, even when I fill it out incorrectly, I still don't get the error in my logs.

Error only shows up in logs sometimes, could be a few days in between, and sometimes 2 times in an hour but I can't personally replicate it no matter what I try. I tried replicating it using different browser with no luck

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by supak111 » Sun Feb 23, 2025 6:46 am

After more digging into the issue and looking at the raw log file from my server I have realized this error is 100% happening becuase of a spam BOT visiting my contact page. Issue solved.

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm
Who is online

Users browsing this forum: Google [Bot] and 14 guests