Commentator is an extremely simple PHP comments system that uses a MySQL database.
Requires PHP 5+ and a MySQL database.
» commentator.zip (19KB) - changelog
Latest version: 0.7.5 (added 14 March 2011)
If updating from version 0.5, please see this comment.
You can also fork it on Github.
You need to put some PHP into your own code where you want the comments (and the comment form) to appear. For example, this page contains all comments in a DIV, with an H2 element as a heading, which includes the total number of comments.
<?php
require_once('../commentator.php');
$comments = new Commentator('lemurs', 'My page on lemurs');
?>
<h2 id="comments">Comments (<?php echo $comments->commentcount; ?>)</h2>
<div class="section">
<?php $comments->write() ?>
</div>
require_once argument needs to point to the Commentator PHP file. You only need it once, as the above code should be the only thing that varies from page to page where you want comments.Commentator() should be a name unique to the page, as it is what the MySQL table will be called.new Commentator bit.The script optionally employs the Akismet PHP5 class to avoid spam comments. I really recommend it, as it works really well and spam is pretty ubiquitous. As an example, within two days of putting this page up, there were already comments about viagra being submitted (but they got caught).
The script will also allow you to submit false positives ("Ham") and uncaught Spam to the Akismet service, which helps everyone using it. This is done automatically when you use the "Mark as spam" or "Unmark as spam" buttons (see Managing comments below).
To use it you will need a WordPress API key. It is very easy to get and does not mean you need to get any other WordPress stuff - they'll give it to you for free, which is very nice of them.
When you download the Akismet PHP class, you only need the main PHP file (Akismet.class.php).
You will need to set some variables at the top of commentator.php. None of these are absolutely critical for the operation of the script, but they are important nevertheless. They are quite self-explanatory:
$akismet_file = 'Akismet.class.php'; // Akismet PHP5 class file
$wpAPIkey = 'xxxxxxxxxxx'; // WordPress API key
$commentator_from = 'noreply@example.com'; // email address to appear in "From" field
$email_owner = 'me@example.com'; // Your address. Identifies author in comments
$preview = true; // allows users to preview comments before submitting
$send_email_on_new_comment = true; // Sends $email_owner an email when a new comment is posted
$commentator_password = 'password'; // Password to enable you to delete comments
$gravatars = true; // Use of gravatars. Set to false to disable, true to use default.
$comments_per_page = 20; // Comments to display per page. Set to false to disable pagination
$newest_first = true; // Order comments to display newest comments first.
$mark_as_spam_and_delete = true; // Delete comments automatically when marking as spam
// Allowed HTML tags in comments. Set to '' to disable HTML altogether
$html_comments = '<a><i><b><em><u><s><strong><code><pre><p>';
$htmlfixer_file = 'htmlfixer.class.php'; // HtmlFixer class file to fix bad HTML. Set to false to disable
The other gravatar defaults are supported too by setting $gravatars to one of the default gravatar keywords or to the URL for an image of your own.
If using them, the Akismet and HtmlFixer files must be in the same directory as Commentator.
As you can see in the settings section above, you can set a password. This will make a checkbox appear next to each comment, and these buttons at the bottom:
To use this feature, you must log in by clicking the "Admin" link in the bottom right of the comment-posting form. To log out click it again. The old system of putting ?password=xxxx in the address bar will still work, but its use is discouraged as it is very insecure.
Important: Once logged in, reloading the page will log you out automatically unless you have set up a PHP session in your code using session_start. This needs to be done on the page where you inserted the code in the Usage section above before any HTML is output. This is because sessions work with cookies and PHP cannot set a cookie once stuff has been sent back to the browser.
The buttons are pretty self-explanatory. The number in the last button just tells you how many comments are spam. It appears regardless of whether spam comments are showing or not, so use with caution!
The "Unmark as spam" will submit a "Ham" to Akismet, i.e. it will submit a false positive. Please use it sensibly. The same goes for the "Mark as spam", which tells Akismet about uncaught spam. You can set it to delete the comment as well (see settings above).
BSD-style license. This means you can pretty much do whatever you want as long as you give due credit.
If the steps above didn't help, if you encounter bugs or if you have any other questions, email me:
r [at] this domainNewest first Oldest first Page 1 of 11 Next 20 »
Page 1 of 11 Next 20 »
get gucci aaa and check coupon code available
#206 – 3 February, 2012 at 12:38 am
Very good Tutorial!,
-Admin RodzKieX Forums
RodzKieX Forums
#205 – 1 February, 2012 at 9:38 pm
Việt Nam
#204 – 31 January, 2012 at 7:03 pm
daf
#203 – 31 January, 2012 at 3:11 pm
i just wanted to test this.
i expect this comment box here to be exactly what the whole page is about, right?
:)
#202 – 31 January, 2012 at 4:22 am
Very good project !
It inspired me for my website's comment system (tutntips)
#201 – 31 January, 2012 at 3:54 am
test, it looks good
#200 – 30 January, 2012 at 9:31 am
testing
#199 – 28 January, 2012 at 2:24 pm
testing
#198 – 28 January, 2012 at 2:24 pm
neki komentar
#197 – 26 January, 2012 at 7:09 am
Company Mailing Addres
#196 – 24 January, 2012 at 7:18 am
COol story bro needs more vaginas?
#195 – 23 January, 2012 at 8:51 am
hehhehehehhe
#194 – 19 January, 2012 at 11:06 am
yhjtyju
#193 – 18 January, 2012 at 1:31 am
test
#192 – 17 January, 2012 at 5:14 am
this is a simple test
#191 – 12 January, 2012 at 2:48 pm
this is a simple test
#190 – 12 January, 2012 at 2:48 pm
this is a simple test
#189 – 12 January, 2012 at 2:48 pm
this is a simple test
#188 – 12 January, 2012 at 2:48 pm
this is a simple test
#187 – 12 January, 2012 at 2:47 pm