1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Capture IP Address

Discussion in 'Subscriber Support' started by jjpedersen, Aug 26, 2008.

  1. jjpedersen

    jjpedersen New Member

    Level: Standard
    Has anyone figured out a way to capture the IP address of the users that are using the fabrik forms?

    This would be a huge help to me and my business and I would be very grateful for any help.

    Jason
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    You should be able to run a PHP form submit script to grab it.

    Add a hidden element on your form, simple text, call it ipaddress.

    Then create a form submit script, "before form is processed, simple eval", which does this:
    PHP:

    $aData['table_name___ipaddress'] = mosGetParam( $_SERVER, 'REMOTE_ADDR', 0 );
    Substitute your table name for table_name.

    -- hugh
     
  3. jjpedersen

    jjpedersen New Member

    Level: Standard
    Thanks for your help cheesegrits,
    I think Ive almost got it. I might be using a older version of Fabrikar (v1.0.5.1) so I wanted to make sure that Ive followed the instructions correctly.

    Ive created an element that is a hidden text box that is labled "ipaddress". Then on my form that Ive created, at the bottom I add the following code:

    PHP:

    $aData['jos_fabrik_elements._ipaddress'] = mosGetParam( $_SERVER, 'REMOTE_ADDR', 0 );
     
    With "process PHP script" set to "As soon as form submitted (simple eval). The table name is jos_fabrik_elements. Did I format the table and field name correctly?

    Again, thanks for your help, the reason I am doing this is that multiple times a day, someone fills out the form on my site like this:

    I have no idea why or what this junk is but I want to be able to block their IP address.

    Jason
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    NOOOOO! The table is not called jos_fabrik_elements. That's one of Fabrik's built in, 'metadata' tables. In this case, the one that stores all the information about all of your elements. Even tho it's harmless in this case, there are no situations in fabrik where you ever need to access any of the built in tables, and in the wrong place it could have potentially disasterous consequences!

    Tables created by fabrik for you for your data are always called jos_fabrik_formdata_X, where X is the table id (as shown on the Tables tab in Fabrik admin). Or the form ID. Jeez, now I'm confusing myself.

    Anyway, the easiest way to work out what your full element name should be is to look at the source of the page in your browser. You are looking for the actual HTML element ID. Search for the element name (ipaddress) and you'll find it in various places, looking like jos_fabrik_formdata_X___ipaddress.

    Or better yet, use FireBug with FireFox, then you can just point at the element on the form and it'll show you the ID.

    Also, it's ___ (as per my example), not ,_ as you used. Sometimes full element names use . inside our PHP code, but we've been phasing that out. So always use table_name___element_name. This applies pretty much anywhere, in either Javascript or PHP. And CSS, come to think of it. And templates.

    -- hugh
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    PS.

    We have an experimental anti-spam feature which uses www.akismet.com to identify spam. I'm still looking for willing volunteers. It takes about five minutes to set up.

    You have to get a (free) key at http://akismet.com/personal/ by creating a WordPress blog, but that's a quick and easy process.

    Once you have a key, you enter it in the Fabrik Setting tab. Or edit your configuration.php if you have an earlier version and have no Settings tab on the menubar. There's an obviously named setting.

    Then create a new validation rule called "akismet" (all lower case, don't include the quotes!). No need to set anything else, just create the rule.

    Now, any form elements you want checked against Akismet, assign the new "akismet" rule to them.

    In this case I'd say the most likely way to get a hit would be the "Specialty type" field, as this is probably trying to get people to hit infected sites, and Akismet check for known malware sites.

    If you try this, let me know if it helps. Or if it blows up and reduces your site to a sad looking pile of rubble. Only joking. But if suddenly nobody can submit any forms, you know where to look. :)

    -- hugh
     

Share This Page