I'm really not sure. I've never tried URL cloaking. Are they two separate installations of zenphoto? If they are, you'd have to do the hack twice -- once for each installation. If not, I think http://www.domain.com/clients may work fine.
No, just one installation. The 'public' URL is a subdomain that redirects to the 'private' URL but in a way that the URL in the title bar only reflects the 'public' version.
Ok, so is there a way to test whether akismet is at work?
I had problems getting it installed though. I swop to use a PHP5 Class for my server but I got a Invalid API Key error. I am using the same API key as for the blog.
Does anyone knows how to get this to work on a PHP5 server?
Now I am stuck at the undefined method Akismet::isError() since the PHP5 class doesn't seem to define it.
Anyway I took the shortcut and commented out the lines with the isError() functions in my class-image.php and changing the isSpam() to isCommentSpam(). Now it seems it mark all comments as spam. Erm I am not an expert with PHP so what mistakes have I made?
I'm sorry kifo, but that php class is written by someone completely different. The two classes have two different architectures and so you can't just swap one for the other. If you want to use that class, you'll have to rewrite how you use it.
Supporting PHP5 is just one of the things I have planned for this hack, I just have to find the time to get around to doing it. Sorry.
I tried this hack and it didn't work. My gallery still works and I can view pictures. When I attempt to add comments, however, nothing happens. I tried the suggested test with the name "viagra-test-123" (without quotes) and the comment was not added and no error was returned. However, I also tried a legitimate comment and again nothing happened.
How is there not a simple "disable comments" option in the admin UI? I'd like to do that just to stem the tide for a bit. My only option to do that is to go hack the source and then unhack it when I want to turn comments on again.
it seems to work for me ok. i even tested it with spam and it stops most of everything i have thrown at it. it does take about a day for new spam to be picked up by akismet, but it is using the api.
you may want to double check the pasted code (i had to do it a couple of times to get it right), and make sure your akismet key and paths are correct. I'll look at my code tonight and verify what needs to be changed, and I may want to take a peek at your modified files, if that's OK by you.
as for turning off the comments entirely, i think that's a planned feature for later versions, but as zenphoto is still in its infancy in terms of comparison with more mature commenting systems like wordpress, there are still a lot of features that need to be included. akismet and comment spam moderation is definitely one of them, it will just take time to get them in the code.
you can remove the commenting from your theme, and that should be sufficient to stop the comment spam if you want to go that route. i can assure you the akismet hack works that gamedudex devised though.
Here's a copy of my code, grabbed right from my class-image.php. Make sure akismet.class.php is in the same directory (/zen). The more I think about it, the more I think you have something misplaced. Commenting should work as well if everything was pasted correctly, and as you described, commenting isn't working.
`
// addComment: assumes data is coming straight from GET or POST
function addComment($name, $email, $website, $comment) {
Comments
http://gallery1.domain.com opens http://www.domain.com/clients/gallery1
http://gallery2.domain.com opens http://www.domain.com/clients/gallery2
and so on. Both versions of the URL work but I make the first version public.
Now what should I specify as my URL in the CONFIGURATION DATA section? I am thinking
http://www.domain.com/clients/ but will it work?
Ok, so is there a way to test whether akismet is at work?
Thanks for all the work by the way.
I wanted to give your akismet hack a shot. Any chance you have the 0.6 zip? The link on your blog (and above) doesn't seem to point to anything.
(I seem to be getting larger amounts of spam lately.)
You can get to it here:
http://www.zenphoto.org/trac/attachment/wiki/ZenphotoHacks/zp_akismet_hack.zip
Craig.
Does anyone knows how to get this to work on a PHP5 server?
Now I am stuck at the undefined method Akismet::isError() since the PHP5 class doesn't seem to define it.
Anyway I took the shortcut and commented out the lines with the isError() functions in my class-image.php and changing the isSpam() to isCommentSpam(). Now it seems it mark all comments as spam. Erm I am not an expert with PHP so what mistakes have I made?
`
// if($akismet->isError()) {
// echo'Couldn't connected to Akismet server!';
// // TODO: Add more precise error handling
// } else {
if($akismet->isCommentSpam()) {
// TODO: Add Spam Moderation Capabilities
echo 'Spam detected';
} else {
// echo 'Not Spam!';
`
I took the PHP5 Akismet Class from Alex here http://www.achingbrain.net/stuff/akismet/
Supporting PHP5 is just one of the things I have planned for this hack, I just have to find the time to get around to doing it. Sorry.
How is there not a simple "disable comments" option in the admin UI? I'd like to do that just to stem the tide for a bit. My only option to do that is to go hack the source and then unhack it when I want to turn comments on again.
it seems to work for me ok. i even tested it with spam and it stops most of everything i have thrown at it. it does take about a day for new spam to be picked up by akismet, but it is using the api.
you may want to double check the pasted code (i had to do it a couple of times to get it right), and make sure your akismet key and paths are correct. I'll look at my code tonight and verify what needs to be changed, and I may want to take a peek at your modified files, if that's OK by you.
as for turning off the comments entirely, i think that's a planned feature for later versions, but as zenphoto is still in its infancy in terms of comparison with more mature commenting systems like wordpress, there are still a lot of features that need to be included. akismet and comment spam moderation is definitely one of them, it will just take time to get them in the code.
you can remove the commenting from your theme, and that should be sufficient to stop the comment spam if you want to go that route. i can assure you the akismet hack works that gamedudex devised though.
`
// addComment: assumes data is coming straight from GET or POST
function addComment($name, $email, $website, $comment) {
############################################################
# CONFIGURATION VARIABLES
############################################################
$zp_gal_url = 'http://www.yoursitehere.com/zenphoto/';
$zp_akismet_key = 'yourakismetkeyhere';
############################################################
# DO NOT EDIT BELOW THIS LINE
############################################################
############################################################
# START: Original Comment Set Up
############################################################
$this->getComments();
$name = trim($name);
$email = trim($email);
$website = trim($website);
// Let the comment have trailing line breaks and space? Nah...
// Also (in)validate HTML here, and in $name.
$comment = trim($comment);
if (empty($email) || !is_valid_email_zp($email) || empty($name) || empty($comment)) {
return false;
}
if (!empty($website) && substr($website, 0, 7) != "http://") {
$website = "http://" . $website;
}
############################################################
# START: Akismet Spam Filter Code
############################################################
require_once 'akismet.class.php';
$commentData = array(
'author' => $name,
'email' => $email,
'website' => $website,
'body' => $comment,
'permalink' => $this->getFullImage()
);
$akismet = new Akismet($zp_gal_url, $zp_akismet_key, $commentData);
if($akismet->isError()) {
echo'Couldn't connected to Akismet server!';
// TODO: Add more precise error handling
} else {
if($akismet->isSpam()) {
// TODO: Add Spam Moderation Capabilities
// echo 'Spam detected';
} else {
// echo 'Not Spam!';
############################################################
# START: Original addComment() Code
############################################################
$newcomment = array();
$newcomment['name'] = $name;
$newcomment['email'] = $email;
$newcomment['website'] = $website;
$newcomment['comment'] = $comment;
$newcomment['date'] = time();
$this->comments[] = $newcomment;
// Update the database entry with the new comment
query("INSERT INTO " . prefix("comments") . " (imageid, name, email, website, comment, date) VALUES " .
" ('" . $this->id .
"', '" . escape($name) .
"', '" . escape($email) .
"', '" . escape($website) .
"', '" . escape($comment) .
"', NOW())");
// Notify the admin user
$message = "A comment has been posted in your album " . $this->getAlbumName() . " about " . $this->getTitle() . "n" .
"n" .
"Author: " . $name . "n" .
"Email: " . $email . "n" .
"Website: " . $website . "n" .
"Comment:n" . $comment . "n" .
"n" .
"You can view all comments about this image here:n" .
"http://" . $_SERVER['SERVER_NAME'] . WEBPATH . "/index.php?album=" . urlencode($this->album->name) . "&image=" . urlencode($this->name) . "n" .
"n" .
"You can edit the comment here:n" .
"http://" . $_SERVER['SERVER_NAME'] . WEBPATH . "/zen/admin.php?page=commentsn";
zp_mail("[" . zp_conf('gallery_title') . "] Comment posted about: " . $this->getTitle(), $message);
############################################################
# END: Original addComment() Code
############################################################
}
}
############################################################
# END: Akismet Spam Filter Code
############################################################
return true;
############################################################
# END: Original Comment Set Up
############################################################
}`