Skip to content

Commit

Permalink
order spam comments by date
Browse files Browse the repository at this point in the history
  • Loading branch information
twanvl committed Aug 31, 2012
1 parent 7e9df50 commit ce3b26b
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions delete-spam.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,41 @@

// Build HTML table of all comments
$num_new_spam = 0;

$p->body .= '<table class="spam">';
$coms = array();
foreach (Resolver::find_all_pages('blog') as $page) {
$comments = Comments::get_all($page->url,true);
$com_body = array();
///$com_body = array();
foreach ($comments as $comment) {
$is_spam = ($comment->visible ? 'visible' : 'hidden') . ' ' .
($comment->is_spam() ? 'spam' : 'nonspam');
if ($comment->visible || !$comment->is_spam()) {
$com_body [] =
"<td class='$is_spam summary'>" . htmlspecialchars($comment->author_name) . ', ' . htmlspecialchars($comment->author_email) . ', ' . htmlspecialchars($comment->author_url) . ', ' . htmlspecialchars($comment->author_ip) .
"<td class='$is_spam summary'>" . htmlspecialchars(substr($comment->body,0,100));
//"<td class='$is_spam summary'>" . $comment->body_html();
$coms []= (object)array(
'date' => $comment->date,
'html' =>
"<tr>" .
"<td><a href='".htmlspecialchars($page->url)."'>" . $page->title . '</a>' .
"<td class='$is_spam summary'>" . htmlspecialchars($comment->author_name) .
', ' . htmlspecialchars($comment->author_email) .
', ' . htmlspecialchars($comment->author_url) .
', ' . htmlspecialchars($comment->author_ip) .
"<td class='$is_spam summary'>" . htmlspecialchars(substr($comment->body,0,100)) .
"<td class='$is_spam summary'>" . $comment->date,
);
}
if ($comment->visible && $comment->is_spam()) {
$num_new_spam++;
}
}
if ($com_body) {
$p->body .= "<tr class='first'><td rowspan='".count($com_body)."'><a href='".htmlspecialchars($page->url)."'>" . $page->title . '</a>';
$p->body .= implode('<tr>',$com_body);
}
}

function compare_date($a,$b) {
return $a->date == $b->date ? 0 : $a->date < $b->date ? 1 : -1;
}
usort($coms,'compare_date');

$p->body .= '<table class="spam">';
foreach ($coms as $com) {
$p->body .= $com->html;
}
$p->body .= '</table>';

Expand Down

0 comments on commit ce3b26b

Please sign in to comment.