Beispiel #1
0
function antispamDashboardFavsIcon($core, $name, $icon)
{
    // Check if it is comments favs
    if ($name == 'comments') {
        // Hack comments title if there is at least one spam
        $str = dcAntispam::dashboardIconTitle($core);
        if ($str != '') {
            $icon[0] .= $str;
        }
    }
}
 private static function genFeed($type, $args)
 {
     global $core;
     $user_id = dcAntispam::checkUserCode($core, $args);
     if ($user_id === false) {
         self::p404();
         return;
     }
     $core->auth->checkUser($user_id, null, null);
     header('Content-Type: application/xml; charset=UTF-8');
     $title = $core->blog->name . ' - ' . __('Spam moderation') . ' - ';
     $params = array();
     $end_url = '';
     if ($type == 'spam') {
         $title .= __('Spam');
         $params['comment_status'] = -2;
         $end_url = '?status=-2';
     } else {
         $title .= __('Ham');
         $params['sql'] = ' AND comment_status IN (1,-1) ';
     }
     echo '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<rss version="2.0"' . "\n" . 'xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . 'xmlns:content="http://purl.org/rss/1.0/modules/content/">' . "\n" . '<channel>' . "\n" . '<title>' . html::escapeHTML($title) . '</title>' . "\n" . '<link>' . (DC_ADMIN_URL ? DC_ADMIN_URL . 'comments.php' . $end_url : 'about:blank') . '</link>' . "\n" . '<description></description>' . "\n";
     $rs = $core->blog->getComments($params);
     $maxitems = 20;
     $nbitems = 0;
     while ($rs->fetch() && $nbitems < $maxitems) {
         $nbitems++;
         $uri = DC_ADMIN_URL ? DC_ADMIN_URL . 'comment.php?id=' . $rs->comment_id : 'about:blank';
         $author = $rs->comment_author;
         $title = $rs->post_title . ' - ' . $author;
         if ($type == 'spam') {
             $title .= '(' . $rs->comment_spam_filter . ')';
         }
         $id = $rs->getFeedID();
         $content = '<p>IP: ' . $rs->comment_ip;
         if (trim($rs->comment_site)) {
             $content .= '<br />URL: <a href="' . $rs->comment_site . '">' . $rs->comment_site . '</a>';
         }
         $content .= "</p><hr />\n";
         $content .= $rs->comment_content;
         echo '<item>' . "\n" . '  <title>' . html::escapeHTML($title) . '</title>' . "\n" . '  <link>' . $uri . '</link>' . "\n" . '  <guid>' . $id . '</guid>' . "\n" . '  <pubDate>' . $rs->getRFC822Date() . '</pubDate>' . "\n" . '  <dc:creator>' . html::escapeHTML($author) . '</dc:creator>' . "\n" . '  <description>' . html::escapeHTML($content) . '</description>' . "\n" . '</item>';
     }
     echo "</channel>\n</rss>";
 }
Beispiel #3
0
 public static function purgeOldSpam(&$core)
 {
     $defaultDateLastPurge = time();
     $defaultModerationTTL = '7';
     $init = false;
     // settings
     $core->blog->settings->setNameSpace('antispam');
     $dateLastPurge = $core->blog->settings->antispam_date_last_purge;
     if ($dateLastPurge === null) {
         $init = true;
         $core->blog->settings->put('antispam_date_last_purge', $defaultDateLastPurge, 'integer', 'Antispam Date Last Purge (unix timestamp)', true, false);
         $dateLastPurge = $defaultDateLastPurge;
     }
     $moderationTTL = $core->blog->settings->antispam_moderation_ttl;
     if ($moderationTTL === null) {
         $core->blog->settings->put('antispam_moderation_ttl', $defaultModerationTTL, 'integer', 'Antispam Moderation TTL (days)', true, false);
         $moderationTTL = $defaultModerationTTL;
     }
     if ($moderationTTL < 0) {
         // disabled
         return;
     }
     // we call the purge every day
     if (time() - $dateLastPurge > 86400) {
         // update dateLastPurge
         if (!$init) {
             $core->blog->settings->put('antispam_date_last_purge', time(), null, null, true, false);
         }
         $date = date('Y-m-d H:i:s', time() - $moderationTTL * 86400);
         dcAntispam::delAllSpam($core, $date);
     }
 }
Beispiel #4
0
 public static function getCommentById($core, $get)
 {
     if (empty($get['id'])) {
         throw new Exception('No comment ID');
     }
     $rs = $core->blog->getComments(array('comment_id' => (int) $get['id']));
     if ($rs->isEmpty()) {
         throw new Exception('No comment for this ID');
     }
     $rsp = new xmlTag('post');
     $rsp->id = $rs->comment_id;
     $rsp->comment_dt($rs->comment_dt);
     $rsp->comment_upddt($rs->comment_upddt);
     $rsp->comment_author($rs->comment_author);
     $rsp->comment_site($rs->comment_site);
     $rsp->comment_content($rs->comment_content);
     $rsp->comment_trackback($rs->comment_trackback);
     $rsp->comment_status($rs->comment_status);
     $rsp->post_title($rs->post_title);
     $rsp->post_url($rs->post_url);
     $rsp->post_id($rs->post_id);
     $rsp->post_dt($rs->post_dt);
     $rsp->user_id($rs->user_id);
     $rsp->comment_display_content($rs->getContent(true));
     if ($core->auth->userID()) {
         $rsp->comment_ip($rs->comment_ip);
         $rsp->comment_email($rs->comment_email);
         $rsp->comment_spam_disp(dcAntispam::statusMessage($rs));
     }
     return $rsp;
 }
Beispiel #5
0
    }
    echo '</form>';
    # Filters
    echo '<form action="' . $p_url . '" method="post" id="filters-list-form">';
    if (!empty($_GET['upd'])) {
        dcPage::success(__('Filters configuration has been successfully saved.'));
    }
    echo '<div class="table-outer">' . '<table class="dragable">' . '<caption class="as_h3">' . __('Available spam filters') . '</caption>' . '<thead><tr>' . '<th>' . __('Order') . '</th>' . '<th>' . __('Active') . '</th>' . '<th>' . __('Auto Del.') . '</th>' . '<th class="nowrap">' . __('Filter name') . '</th>' . '<th colspan="2">' . __('Description') . '</th>' . '</tr></thead>' . '<tbody id="filters-list" >';
    $i = 0;
    foreach ($filters as $fid => $f) {
        $gui_link = '&nbsp;';
        if ($f->hasGUI()) {
            $gui_link = '<a href="' . html::escapeHTML($f->guiURL()) . '">' . '<img src="images/edit-mini.png" alt="' . __('Filter configuration') . '" ' . 'title="' . __('Filter configuration') . '" /></a>';
        }
        echo '<tr class="line' . ($f->active ? '' : ' offline') . '" id="f_' . $fid . '">' . '<td class="handle">' . form::field(array('f_order[' . $fid . ']'), 2, 5, (string) $i, 'position', '', false, 'title="' . __('position') . '"') . '</td>' . '<td class="nowrap">' . form::checkbox(array('filters_active[]'), $fid, $f->active, '', '', false, 'title="' . __('Active') . '"') . '</td>' . '<td class="nowrap">' . form::checkbox(array('filters_auto_del[]'), $fid, $f->auto_delete, '', '', false, 'title="' . __('Auto Del.') . '"') . '</td>' . '<td class="nowrap" scope="row">' . $f->name . '</td>' . '<td class="maximal">' . $f->description . '</td>' . '<td class="status">' . $gui_link . '</td>' . '</tr>';
        $i++;
    }
    echo '</tbody></table></div>' . '<p>' . form::hidden('filters_order', '') . $core->formNonce() . '<input type="submit" name="filters_upd" value="' . __('Save') . '" /></p>' . '</form>';
    # Syndication
    if (DC_ADMIN_URL) {
        $ham_feed = $core->blog->url . $core->url->getURLFor('hamfeed', $code = dcAntispam::getUserCode($core));
        $spam_feed = $core->blog->url . $core->url->getURLFor('spamfeed', $code = dcAntispam::getUserCode($core));
        echo '<h3>' . __('Syndication') . '</h3>' . '<ul class="spaminfo">' . '<li class="feed"><a href="' . $spam_feed . '">' . __('Junk comments RSS feed') . '</a></li>' . '<li class="feed"><a href="' . $ham_feed . '">' . __('Published comments RSS feed') . '</a></li>' . '</ul>';
    }
    dcPage::helpBlock('antispam', 'antispam-filters');
}
?>

</body>
</html>
Beispiel #6
0
 public function display($page, $nb_per_page, $enclose_block = '', $filter = false, $spam = false)
 {
     if ($this->rs->isEmpty()) {
         if ($filter) {
             echo '<p><strong>' . __('No comments or trackbacks matches the filter') . '</strong></p>';
         } else {
             echo '<p><strong>' . __('No comments') . '</strong></p>';
         }
     } else {
         // Get antispam filters' name
         $filters = array();
         if ($spam) {
             if (class_exists('dcAntispam')) {
                 dcAntispam::initFilters();
                 $fs = dcAntispam::$filters->getFilters();
                 foreach ($fs as $fid => $f) {
                     $filters[$fid] = $f->name;
                 }
             }
         }
         $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
         $comments = array();
         if (isset($_REQUEST['comments'])) {
             foreach ($_REQUEST['comments'] as $v) {
                 $comments[(int) $v] = true;
             }
         }
         $html_block = '<div class="table-outer">' . '<table>';
         if ($filter) {
             $html_block .= '<caption>' . sprintf(__('Comment or trackback matching the filter.', 'List of %s comments or trackbacks matching the filter.', $this->rs_count), $this->rs_count) . '</caption>';
         } else {
             $html_block .= '<caption class="hidden">' . __('Comments and trackbacks list') . '</caption>';
         }
         $cols = array('type' => '<th colspan="2" scope="col" abbr="comm" class="first">' . __('Type') . '</th>', 'author' => '<th scope="col">' . __('Author') . '</th>', 'date' => '<th scope="col">' . __('Date') . '</th>', 'status' => '<th scope="col" class="txt-center">' . __('Status') . '</th>');
         if ($spam) {
             $cols['ip'] = '<th scope="col">' . __('IP') . '</th>';
             $cols['spam_filter'] = '<th scope="col">' . __('Spam filter') . '</th>';
         }
         $cols['entry'] = '<th scope="col" abbr="entry">' . __('Entry') . '</th>';
         $cols = new ArrayObject($cols);
         $this->core->callBehavior('adminCommentListHeader', $this->core, $this->rs, $cols);
         $html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>';
         if ($enclose_block) {
             $html_block = sprintf($enclose_block, $html_block);
         }
         echo $pager->getLinks();
         $blocks = explode('%s', $html_block);
         echo $blocks[0];
         while ($this->rs->fetch()) {
             echo $this->commentLine(isset($comments[$this->rs->comment_id]), $spam, $filters);
         }
         echo $blocks[1];
         echo $pager->getLinks();
     }
 }
Beispiel #7
0
    if ($moderationTTL != null && $moderationTTL >= 0) {
        echo '<p>' . sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $moderationTTL) . '</p>';
    }
    echo '</fieldset></form>';
    # Filters
    echo '<form action="' . $p_url . '" method="post">' . '<fieldset><legend>' . __('Available spam filters') . '</legend>';
    if (!empty($_GET['upd'])) {
        echo '<p class="message">' . __('Filters configuration has been successfully saved.') . '</p>';
    }
    echo '<table class="dragable">' . '<thead><tr>' . '<th>' . __('Order') . '</th>' . '<th>' . __('Active') . '</th>' . '<th>' . __('Auto Del.') . '</th>' . '<th class="nowrap">' . __('Filter name') . '</th>' . '<th colspan="2">' . __('Description') . '</th>' . '</tr></thead>' . '<tbody id="filters-list" >';
    $i = 0;
    foreach ($filters as $fid => $f) {
        $gui_link = '&nbsp;';
        if ($f->hasGUI()) {
            $gui_link = '<a href="' . html::escapeHTML($f->guiURL()) . '">' . '<img src="images/edit-mini.png" alt="' . __('Filter configuration') . '" ' . 'title="' . __('Filter configuration') . '" /></a>';
        }
        echo '<tr class="line' . ($f->active ? '' : ' offline') . '" id="f_' . $fid . '">' . '<td class="handle">' . form::field(array('f_order[' . $fid . ']'), 2, 5, (string) $i) . '</td>' . '<td class="nowrap">' . form::checkbox(array('filters_active[]'), $fid, $f->active) . '</td>' . '<td class="nowrap">' . form::checkbox(array('filters_auto_del[]'), $fid, $f->auto_delete) . '</td>' . '<td class="nowrap">' . $f->name . '</td>' . '<td class="maximal">' . $f->description . '</td>' . '<td class="status">' . $gui_link . '</td>' . '</tr>';
        $i++;
    }
    echo '</tbody></table>' . '<p>' . form::hidden('filters_order', '') . $core->formNonce() . '<input type="submit" name="filters_upd" value="' . __('Save') . '" /></p>' . '</fieldset></form>';
    # Syndication
    if (DC_ADMIN_URL) {
        $ham_feed = $core->blog->url . $core->url->getBase('hamfeed') . '/' . ($code = dcAntispam::getUserCode($core));
        $spam_feed = $core->blog->url . $core->url->getBase('spamfeed') . '/' . ($code = dcAntispam::getUserCode($core));
        echo '<fieldset><legend>' . __('Syndication') . '</legend>' . '<ul class="spaminfo">' . '<li class="feed"><a href="' . $spam_feed . '">' . __('Junk comments RSS feed') . '</a></li>' . '<li class="feed"><a href="' . $ham_feed . '">' . __('Published comments RSS feed') . '</a></li>' . '</ul>' . '</fieldset>';
    }
}
?>

</body>
</html>