Pages (2):    1 2
Member
Member
thinkdreams   2007-08-28, 12:01
#21

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) {

############################################################

# 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

############################################################

}`

Pages (2):    1 2
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.