We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I’ve been looking at Mollom, which purports to "Kill comment, contact form and registration form spam."

    Basically, you send the content and the user’s ISP to Mollom’s server. They reply back whether the content is spam, ham (legitimate content), or unsure. With "unsure" they optionally present a captcha image (audio or image) which they claim often changes and is not de-codable (and they detect whether it’s been compromised and then change it).

    I’m thinking about a Mollom class file based on their API, but I’d also like to see a plugin that could be routinely used by jot, eForm, SPForm, NewsPublisher, etc. (if it’s installed) that would use the Mollom class to test content. It’s tricky because of the back and forth communication between the snippet, plugin, and Molllom server, i.e. (just from the MODx side):

      • Get me the server list (maybe)
      • Connect to the server
      • Evaluate this content
      • Give me a captcha image
      • Give me another captcha image (maybe)
      • Give me an audio captcha (maybe)
      • Was the response correct?

    Drupal and several other CMS platforms have a Mollom plugin so it would be nice if we could be on that list.

    Assuming that it’s even possible, I’m wondering what system event (or events) would be appropriate for this. We have OnUserFormSave and OnWUserFormSave, but I’m wondering if a more generic OnEvaluateContent or something similar might be in order. It could be used by other validating plugins as well (e.g. Akismet).

    The plugin could use custom system event(s) (a la WLPE), but then every client would have to check for them and optionally create them on every access.

    I’d appreciate hearing thoughts on this and on how best to approach the plugin.

      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 22303 MODX Staff
      • 10,725 Posts
      It should be a reusable class that has functions to call the Mollum XMP-RPC services and process the responses. Then any snippet or plugin can make use of it. It can use the XML-RPC client code already available in the MODx Revolution code base.
        • 22303 MODX Staff
        • 10,725 Posts
        Further, in 0.9.6 it can be loaded as an "extension" like DBAPI, and in Revolution as a "service" class, like modRegistry and modSmarty (see modX::getService()).
          • 3749
          • 24,544 Posts
          Great. The class should be straightforward (hopefully) -- the API is pretty well documented. It might be nice to have a plugin as a wrapper for it, since every client will want pretty much the same thing. What do you think about a new System Event for it?

          I can see it being used in a lot of places for logins and content evaluation. With the plugin, the client would just invoke the event with some optional parameters and get a yes/no result with the plugin handling the communication and user interaction (hypothetically, of course). That would make it easy to integrate into other components.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: BobRay at Feb 05, 2009, 05:29 PM

            It might be nice to have a plugin as a wrapper for it, since every client will want pretty much the same thing. What do you think about a new System Event for it?

            I can see it being used in a lot of places for logins and content evaluation. With the plugin, the client would just invoke the event with some optional parameters and get a yes/no result with the plugin handling the communication and user interaction (hypothetically, of course). That would make it easy to integrate into other components.
            I’m not understanding the new event question; at what point in the core would this event be executed? I think we have all the events we need. You’ll just get the service in your snippet or plugin registered to the event of your choice, or even in an external script that is instantiating the modX class, and call the appropriate function( s ).
              • 3749
              • 24,544 Posts
              I’m thinking of it as just a System Event name that would be invoked by any component that wants to evaluate content for spam potential. I believe there are current System Events that are not executed anywhere in the core -- maybe I’m wrong.

              That way, someone could write a plugin that worked through Akismet, Mollom, or whatever to evaluate content for spam and have it listen for that event and component developers could just invoke that event properly when content is submitted for things like jot, SPForm, etc. rather than having each developer have to learn the Mollom or Akismet API and write a lot of custom code for their component.

              I hope this makes sense. tongue
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 22303 MODX Staff
                • 10,725 Posts
                It seems to me the primary use of this service class would already be in a plugin triggered on the form events, at least on the backend, and for the front-end adding it to the form processing will be as simple as using it in a plugin. Here’s a Revo code example that might be used in a plugin or snippet.
                <?php
                /* add the package */
                $modx->addPackage('mollum', MODX_ASSETS_PATH . 'components/mollum/model/');
                /* get the service using the run-time properties from the snippet/plugin */
                if ($modx->getService('mollum', 'mollum.modMollum', '', $scriptProperties)) {
                    /* evaluate your chosen contentVariable for spam */
                    if (!$modx->mollum->evaluate($contentVariable)) {
                        /* it's spam, take some action */
                    } else {
                        /* it's not spam, do something else */
                    }
                }
                ?>


                For the captcha stuff, I’m not sure how exactly you would handle that processing, but it shouldn’t be too difficult. And anyway, the real point IMO is why create an event to execute within an existing system event which is triggering a plugin that uses the Mollum web service? I don’t see any purpose in invoking events in code that may itself be invoked by an event itself.
                  • 30223
                  • 1,010 Posts
                  Quote from: OpenGeek at Feb 05, 2009, 02:06 PM

                  Further, in 0.9.6 it can be loaded as an "extension" like DBAPI, and in Revolution as a "service" class, like modRegistry and modSmarty (see modX::getService()).

                  Jason, how would you load this as an extension in 0.9.6? The DocumentParser does have a loadExtension() method but it can only load DBAPI and managerAPI.

                  I can imagine using a plugin triggered by the onWebPageInit to  load the mollum class (and provide a global instance if necessary), but beyond that I don’t see how to make it an extension of the modx object. Or am I misunderstanding?
                    • 3749
                    • 24,544 Posts
                    Quote from: OpenGeek at Feb 06, 2009, 01:02 AM

                    It seems to me the primary use of this service class would already be in a plugin triggered on the form events, at least on the backend, and for the front-end adding it to the form processing will be as simple as using it in a plugin. Here’s a Revo code example that might be used in a plugin or snippet.
                    <?php
                    /* add the package */
                    $modx->addPackage('mollum', MODX_ASSETS_PATH . 'components/mollum/model/');
                    /* get the service using the run-time properties from the snippet/plugin */
                    if ($modx->getService('mollum', 'mollum.modMollum', '', $scriptProperties)) {
                        /* evaluate your chosen contentVariable for spam */
                        if (!$modx->mollum->evaluate($contentVariable)) {
                            /* it's spam, take some action */
                        } else {
                            /* it's not spam, do something else */
                        }
                    }
                    ?>


                    I was thinking that this would be simpler:

                    $eventInfo= $modx->invokeEvent('OnEvaluateContent');


                    It would also allow multiple plugins of various kinds to evaluate the content with less extra code in the components.


                    And anyway, the real point IMO is why create an event to execute within an existing system event which is triggering a plugin that uses the Mollum web service? I don’t see any purpose in invoking events in code that may itself be invoked by an event itself.

                    Maybe I’m confused, but I don’t see this ever happening. As I see it, the event would never be triggered by the core and would only be used in the front end. In the back end, as you say, there are already events the plugin could listen to. In the front end, though, there’s really no common event that occurs before saving or emailing user content, but it would be easy for developers to invoke one when processing user input if it existed.

                    As for making it a service, it seems to me that if there’s no available system event, maybe it should be a snippet since more people already know how to interact with a snippet and it would port better to 0.9.6. BTW, does 0.9.6 have the xml-rpc stuff?
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 30223
                      • 1,010 Posts
                      In the front end, though, there’s really no common event that occurs before saving or emailing user content, but it would be easy for developers to invoke one when processing user input if it existed.

                      Now you are getting me confused smiley The front end does not save anything and does not email anything and when in the core does it process front-end user input? So where would you have that event triggered? Isn’t it the snippets or plugins that do most of the processing, saving and emailing?

                      I’m trying to get my head around this. You basically want to make a third party service add-on that is then easily made available to other add-ons am I correct? I don’t see what the difficulty is for developers of those other add-ons to simply check if the particular add-on exists, include it , create an instance of it and use it in the same way you would for instance use PHPmailer or any other third party product.