Comment Spam Sucks

One of the biggest problems with allows people to post comments is that all this crap spam comes along with it. Now I moderate all my comments so none of this spam goes onto my site, but removing the spam from the approval queue is very time consuming, esp when you have 12+ pages.

I know what I could install the spam module, or the bad behaviour module, but I have not gotten to it.

Now with the forms api, you can re-theme any form, so I did a small amount of coding and added to the command page a toggle all link which switches checks all the check boxes. This is just a quick hack that speeds this up a lot for me.

<?php
function phptemplate_comment_admin_overview($form) {
  $js = <<<EOL
<script type="text/javascript" language="javascript">
function toggle_checkboxes() {
  var inputs = document.getElementsByTagName('input');
  for (i = 0; input = inputs[i]; i++) {
    if (input && input.type == 'checkbox') {
      input.checked = (input.checked ? false : true);
    }
  }
  return false;
}
</script>
EOL;
  drupal_set_html_head($js);
  $form['options']['select all'] = array(
    '#value' => '<a href="#" onClick="return toggle_checkboxes()">Toggle Checkboxes</a>',
    '#weight' => 1,
  );
  // Call the real theme so if there are changes I don't need to worry about coping them over.
  return theme_comment_admin_overview($form);
}
?>

Now I have a little link which allows me to just click and check all the spams and then away they go.
 

my projects: