function mark($as = 'spam', $type = 'comments') { global $IN, $LANG, $DSP, $FNS, $DB; // if no comments are posted, go home if ($as == 'spam' && !$IN->GBL('comment_ids', 'POST') or $as == 'ham' && !$IN->GBL('toggle', 'POST')) { return $this->home(); } $comments = array(); $type = $IN->GBL('T'); // turn comments into array if ($as == 'spam') { $comments = explode('|', $IN->GBL('comment_ids', 'POST')); } else { foreach ($IN->GBL('toggle', 'POST') as $key => $comment_id) { $comments[] = $comment_id; // needed to play nice with the Publish class $_POST['toggle_' . $key] = 'c' . $comment_id; } } // Get the Low_nospam class if (!class_exists('Low_nospam')) { require PATH_MOD . 'low_nospam/mod.low_nospam' . EXT; } // init nospam class $NSPM = new Low_nospam(); if ($NSPM->is_available and $NSPM->is_valid) { $method = 'mark_as_' . $as; foreach ($this->get_comments($comments, $type) as $row) { // marks the comments as spam/ham $NSPM->{$method}($row); } if ($type == 'gallery') { // Handle gallery comments if ($as == 'spam') { // Just delete 'em; they're closed, so no stats are affected $DB->query("DELETE FROM exp_gallery_comments WHERE comment_id IN ('" . implode("','", $comments) . "')"); } else { // Gallery module doesn't support batch opening of closed comments, // and I'll be damned if I'm gonna write all that stuff myself. // I'll just show a message saying 'open them using the Gallery module'... $FNS->redirect(BASE . AMP . 'C=modules' . AMP . 'M=' . $this->name . AMP . 'msg=open_gallery_comments_not_supported'); } } else { // Get the Publish class, to delete the comments if (!class_exists('Publish')) { require PATH_CP . 'cp.publish' . EXT; } $PUB = new Publish(); // init publish class // Delete or Open $as == 'spam' ? $PUB->delete_comment() : $PUB->change_comment_status('open'); } // go back home, using redirect $FNS->redirect(BASE . AMP . 'C=modules' . AMP . 'M=' . $this->name . AMP . 'msg=comments_' . ($as == 'spam' ? 'deleted' : 'opened')); exit; } else { // Service not available or invalid key... } }