Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davereid/mollomphp
A generic PHP class for Mollom's REST API.
https://github.com/davereid/mollomphp
Last synced: about 1 month ago
JSON representation
A generic PHP class for Mollom's REST API.
- Host: GitHub
- URL: https://github.com/davereid/mollomphp
- Owner: davereid
- License: gpl-2.0
- Created: 2011-12-06T19:14:00.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2011-12-06T18:07:14.000Z (about 13 years ago)
- Last Synced: 2024-10-18T23:30:17.675Z (3 months ago)
- Language: PHP
- Homepage: http://mollom.com
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-GPL.txt
Awesome Lists containing this project
README
A generic Mollom client PHP class.
This base class aims to ease integration of the [Mollom](http://mollom.com) content moderation service into PHP based applications. The class implements essential code logic expected from Mollom clients and provides many helper functions to communicate with Mollom's [REST API](http://mollom.com/api/rest).
To submit bug reports and feature suggestions, or to track changes:
https://github.com/Mollom/MollomPHP/issues## Requirements
* [PHP](http://php.net) 5.2.4 or later
## Usage
* Extend the Mollom class for your platform. At minimum, you need to implement the following methods:
```php
checkContent(array(
'checks' => array('spam'),
'postTitle' => $comment['title'],
'postBody' => $comment['body'],
'authorName' => $comment['name'],
'authorUrl' => $comment['homepage'],
'authorIp' => $_SERVER['REMOTE_ADDR'],
'authorId' => $userid, // If the author is logged in.
));
// You might want to make the fallback case configurable:
if (!is_array($result) || !isset($result['id'])) {
print "The content moderation system is currently unavailable. Please try again later.";
die();
}
// Check the final spam classification.
switch ($result['spamClassification']) {
case 'ham':
// Do nothing. (Accept content.)
break;
case 'spam':
// Discard (block) the form submission.
print "Your submission has triggered the spam filter and will not be accepted.";
die();
break;
case 'unsure':
// Require to solve a CAPTCHA to get the post submitted.
$captcha = $mollom->createCaptcha(array(
'contentId' => $result['id'],
'type' => 'image',
));
if (!is_array($captcha) || !isset($captcha['id'])) {
print "The content moderation system is currently unavailable. Please try again later.";
die();
}
// Output the CAPTCHA.
print '';
print '';
// Re-inject the submitted form values, re-render the form,
// and ask the user to solve the CAPTCHA.
break;
default:
// If we end up here, Mollom responded with a unknown spamClassification.
// Normally, this should not happen.
break;
}
```## Examples
These are examples for implementations of the Mollom class. As visible in the above code snippet, the class only takes over the basic logic to communicate with Mollom. Every implementation still needs application-specific code to handle the results provided by Mollom.
* [MollomDrupal](http://drupalcode.org/project/mollom.git/blob/refs/heads/7.x-2.x:/mollom.drupal.inc)
* [MollomWordpress](https://github.com/netsensei/WP-Mollom/blob/master/includes/mollom.wordpress.inc)## License
You may use this software under the terms of either the MIT License or the
GNU General Public License (GPL), Version 2.See LICENSE-MIT.txt and LICENSE-GPL.txt.