[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This is Antispam, a plugin for DotClear. 4 # Copyright (c) 2007 Alain Vagner and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 class dcAntispamURL extends dcUrlHandlers 24 { 25 public static function hamFeed($args) 26 { 27 self::genFeed('ham',$args); 28 } 29 30 public static function spamFeed($args) 31 { 32 self::genFeed('spam',$args); 33 } 34 35 private static function genFeed($type,$args) 36 { 37 global $core; 38 $user_id = dcAntispam::checkUserCode($core,$args); 39 40 if ($user_id === false) { 41 self::p404(); 42 } 43 44 $core->auth->checkUser($user_id,null,null); 45 46 header('Content-Type: application/xml; charset=UTF-8'); 47 48 $title = $core->blog->name.' - '.__('Spam moderation'). ' - '; 49 $params = array(); 50 $end_url = ''; 51 if ($type == 'spam') { 52 $title .= __('Spam'); 53 $params['comment_status'] = -2; 54 $end_url = '?status=-2'; 55 } else { 56 $title .= __('Ham'); 57 $params['sql'] = ' AND comment_status IN (1,-1) '; 58 } 59 60 echo 61 '<?xml version="1.0" encoding="utf-8"?>'."\n". 62 '<rss version="2.0"'."\n". 63 'xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n". 64 'xmlns:content="http://purl.org/rss/1.0/modules/content/">'."\n". 65 '<channel>'."\n". 66 '<title>'.$title.'</title>'."\n". 67 '<link>'.(DC_ADMIN_URL ? DC_ADMIN_URL.'comments.php'.$end_url : 'about:blank').'</link>'."\n". 68 '<description></description>'."\n"; 69 70 $rs = $core->blog->getComments($params); 71 $maxitems = 20; 72 $nbitems = 0; 73 74 while ($rs->fetch() && ($nbitems < $maxitems)) 75 { 76 $nbitems++; 77 $uri = DC_ADMIN_URL ? DC_ADMIN_URL.'comment.php?id='.$rs->comment_id : 'about:blank'; 78 $author = $rs->comment_author; 79 $title = $rs->post_title.' - '.$author; 80 if ($type == 'spam') { 81 $title .= '('.$rs->comment_spam_filter.')'; 82 } 83 $id = $rs->getFeedID(); 84 85 $content = '<p>IP: '.$rs->comment_ip; 86 87 if (trim($rs->comment_site)) { 88 $content .= '<br />URL: <a href="'.$rs->comment_site.'">'.$rs->comment_site.'</a>'; 89 } 90 $content .= "</p><hr />\n"; 91 $content .= $rs->comment_content; 92 93 if (DC_ADMIN_URL) { 94 if ($type == 'spam') { 95 $content .= 96 '<form action="'.DC_ADMIN_URL.'comment.php?id='.$rs->comment_id.'" method="post">'. 97 '<p><input type="submit" value="'.__('Publish').'" />'. 98 '<input type="hidden" name="action" value="status" /></p>'. 99 '</form>'; 100 } else { 101 $content .= 102 '<form action="'.DC_ADMIN_URL.'comment.php?id='.$rs->comment_id.'" method="post">'. 103 '<p><input type="submit" value="'.__('Mark as junk').'" />'. 104 '<input type="hidden" name="action" value="junk" /></p>'. 105 '</form>'; 106 } 107 $content .= '<form action="'.DC_ADMIN_URL.'comment.php?id='.$rs->comment_id.'" method="post">'. 108 '<p><input type="submit" value="'.__('Delete').'" />'. 109 '<input type="hidden" name="action" value="delete" /></p>'. 110 '</form>'; 111 } 112 113 echo 114 '<item>'."\n". 115 ' <title>'.html::escapeHTML($title).'</title>'."\n". 116 ' <link>'.$uri.'</link>'."\n". 117 ' <guid>'.$id.'</guid>'."\n". 118 ' <pubDate>'.$rs->getRFC822Date().'</pubDate>'."\n". 119 ' <dc:creator>'.html::escapeHTML($author).'</dc:creator>'."\n". 120 ' <description>'.html::escapeHTML($content).'</description>'."\n". 121 '</item>'; 122 } 123 124 echo "</channel>\n</rss>"; 125 exit; 126 } 127 } 128 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |