Dotclear

source: plugins/antispam/inc/lib.dc.antispam.url.php @ 0:54703be25dd6

Revision 0:54703be25dd6, 2.7 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

2.3 branch (trunk) first checkin

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Antispam, a plugin for Dotclear 2.
5#
6# Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14class dcAntispamURL extends dcUrlHandlers
15{
16     public static function hamFeed($args)
17     {
18          self::genFeed('ham',$args);
19     }
20     
21     public static function spamFeed($args)
22     {
23          self::genFeed('spam',$args);
24     }
25     
26     private static function genFeed($type,$args)
27     {
28          global $core;
29          $user_id = dcAntispam::checkUserCode($core,$args);
30         
31          if ($user_id === false) {
32               self::p404();
33               return;
34          }
35         
36          $core->auth->checkUser($user_id,null,null);
37         
38          header('Content-Type: application/xml; charset=UTF-8');
39         
40          $title = $core->blog->name.' - '.__('Spam moderation'). ' - ';
41          $params = array();
42          $end_url = '';
43          if ($type == 'spam') {
44               $title .= __('Spam');
45               $params['comment_status'] = -2;
46               $end_url = '?status=-2';
47          } else {
48               $title .= __('Ham');
49               $params['sql'] = ' AND comment_status IN (1,-1) ';
50          }
51         
52          echo
53          '<?xml version="1.0" encoding="utf-8"?>'."\n".
54          '<rss version="2.0"'."\n".
55          'xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n".
56          'xmlns:content="http://purl.org/rss/1.0/modules/content/">'."\n".
57          '<channel>'."\n".
58          '<title>'.html::escapeHTML($title).'</title>'."\n".
59          '<link>'.(DC_ADMIN_URL ? DC_ADMIN_URL.'comments.php'.$end_url : 'about:blank').'</link>'."\n".
60          '<description></description>'."\n";
61         
62          $rs = $core->blog->getComments($params);
63          $maxitems = 20;
64          $nbitems = 0;       
65         
66          while ($rs->fetch() && ($nbitems < $maxitems))
67          {
68               $nbitems++;
69               $uri = DC_ADMIN_URL ? DC_ADMIN_URL.'comment.php?id='.$rs->comment_id : 'about:blank';
70               $author = $rs->comment_author;
71               $title = $rs->post_title.' - '.$author;
72               if ($type == 'spam') {
73                    $title .= '('.$rs->comment_spam_filter.')';
74               }
75               $id = $rs->getFeedID();
76               
77               $content = '<p>IP: '.$rs->comment_ip;
78               
79               if (trim($rs->comment_site)) {
80                    $content .= '<br />URL: <a href="'.$rs->comment_site.'">'.$rs->comment_site.'</a>';
81               }
82               $content .= "</p><hr />\n";
83               $content .= $rs->comment_content;
84               
85               echo
86               '<item>'."\n".
87               '  <title>'.html::escapeHTML($title).'</title>'."\n".                 
88               '  <link>'.$uri.'</link>'."\n".
89               '  <guid>'.$id.'</guid>'."\n".
90               '  <pubDate>'.$rs->getRFC822Date().'</pubDate>'."\n".
91               '  <dc:creator>'.html::escapeHTML($author).'</dc:creator>'."\n".
92               '  <description>'.html::escapeHTML($content).'</description>'."\n".       
93               '</item>';
94          }
95         
96          echo "</channel>\n</rss>";   
97     }
98}
99?>
Note: See TracBrowser for help on using the repository browser.

Sites map