[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file handles trackback requests 4 * 5 * This file is part of the evoCore framework - {@link http://evocore.net/} 6 * See also {@link http://sourceforge.net/projects/evocms/}. 7 * 8 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/} 9 * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}. 10 * 11 * {@internal License choice 12 * - If you have received this file as part of a package, please find the license.txt file in 13 * the same folder or the closest folder above for complete license terms. 14 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 15 * then you must choose one of the following licenses before using the file: 16 * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 17 * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 18 * }} 19 * 20 * {@internal Open Source relicensing agreement: 21 * Daniel HAHLER grants Francois PLANQUE the right to license 22 * Daniel HAHLER's contributions to this file and the b2evolution project 23 * under any OSI approved OSS license (http://www.opensource.org/licenses/). 24 * }} 25 * 26 * @package htsrv 27 * 28 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 29 * @author blueyed: Daniel HAHLER 30 * @author fplanque: Francois PLANQUE 31 * 32 * @version $Id: trackback.php,v 1.59 2007/04/26 00:11:14 fplanque Exp $ 33 */ 34 35 36 /** 37 * Initialize everything: 38 */ 39 require_once dirname(__FILE__).'/../conf/_config.php'; 40 41 require_once $inc_path.'_main.inc.php'; 42 43 /** 44 * Send a trackback response and exits. 45 * 46 * @param integer Error code 47 * @param string Error message 48 */ 49 function trackback_response( $error = 0, $error_message = '' ) 50 { // trackback - reply 51 global $io_charset; 52 53 echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.">\n"; 54 echo "<response>\n"; 55 echo "<error>$error</error>\n"; 56 echo "<message>$error_message</message>\n"; 57 echo "</response>"; 58 exit(); 59 } 60 61 // statuses allowed for acting on: 62 $show_statuses = array( 'published', 'protected', 'private' ); 63 64 param( 'tb_id', 'integer' ); 65 param( 'url', 'string' ); 66 param( 'title', 'string' ); 67 param( 'excerpt', 'html' ); 68 param( 'blog_name', 'string' ); 69 70 71 if( empty($tb_id) ) 72 { // No parameter for ID, get if from URL: 73 $path_elements = explode( '/', $ReqPath, 30 ); 74 $tb_id = intval( $path_elements[count($path_elements)-1] ); 75 } 76 77 78 if( ! empty($_GET['__mode']) ) 79 { // some MT extension (AFAIK), that we do not support 80 return; 81 } 82 83 if( empty($tb_id) ) 84 { 85 trackback_response( 1, 'No trackback post ID given.' ); // exits 86 } 87 if( empty($url) ) 88 { 89 trackback_response( 1, 'No url to your permanent entry given.' ); // exits 90 } 91 92 @header('Content-Type: text/xml'); 93 94 $comment_post_ID = $tb_id; 95 $ItemCache = & get_Cache( 'ItemCache' ); 96 $commented_Item = & $ItemCache->get_by_ID( $comment_post_ID ); 97 if( !( $Blog = & $commented_Item->get_Blog() ) ) 98 { 99 trackback_response( 1, 'Sorry, could not get the post\'s weblog.' ); // exits 100 } 101 102 if( ! $Blog->get('allowtrackbacks') ) 103 { 104 trackback_response( 1, 'Sorry, this weblog does not allow you to trackback its posts.' ); // exits 105 } 106 107 // Commented out again, because it's comment specific: if( ! $commented_Item->can_comment( NULL ) ) 108 // "BeforeTrackbackInsert" should be hooked instead! 109 if( $commented_Item->comment_status != 'open' ) 110 { 111 trackback_response( 1, 'Sorry, this item does not accept trackbacks.' ); // exits 112 } 113 114 115 // CHECK content 116 if( $error = validate_url( $url, $comments_allowed_uri_scheme, /* absolute: */ true ) ) 117 { 118 $Messages->add( T_('Supplied URL is invalid: ').$error, 'error' ); 119 } 120 121 if( $Messages->count('error') ) 122 { 123 trackback_response( 1, $Messages->get_string( '', '', 'all', "\n" ) ); // exits 124 } 125 126 127 $title = strip_tags($title); 128 $title = (strlen($title) > 255) ? substr($title, 0, 252).'...' : $title; 129 $excerpt = strip_tags($excerpt); 130 $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252).'...' : $excerpt; 131 $blog_name = htmlspecialchars($blog_name); 132 $blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252).'...' : $blog_name; 133 134 $comment = ''; 135 if( ! empty($title) ) 136 { 137 $comment .= '<strong>'.$title.'</strong>'; 138 139 if( ! empty($excerpt) ) 140 { 141 $comment .= '<br />'; 142 } 143 } 144 $comment .= $excerpt; 145 146 $comment = format_to_post($comment,1,1); 147 if( empty($comment) ) 148 { // comment should not be empty! 149 $Messages->add( T_('Please do not send empty comment'), 'error' ); 150 } 151 elseif( antispam_check( strip_tags($comment) ) ) 152 { 153 $Messages->add( T_('Supplied comment is invalid'), 'error' ); 154 } 155 156 157 /** 158 * @global Comment Trackback object 159 */ 160 $Comment = & new Comment(); 161 $Comment->set( 'type', 'trackback' ); 162 $Comment->set_Item( $commented_Item ); 163 $Comment->set( 'author', $blog_name ); 164 $Comment->set( 'author_url', $url ); 165 $Comment->set( 'author_IP', $Hit->IP ); 166 $Comment->set( 'date', date('Y-m-d H:i:s', $localtimenow ) ); 167 $Comment->set( 'content', $comment ); 168 // Assign default status for new comments: 169 $Comment->set( 'status', $commented_Item->Blog->get_setting('new_feedback_status') ); 170 171 172 // Trigger event, which may add a message of category "error": 173 $Plugins->trigger_event( 'BeforeTrackbackInsert', array( 'Comment' => & $Comment ) ); 174 175 176 // Display errors: 177 if( $errstring = $Messages->get_string( 'Cannot insert trackback, please correct these errors:', '' ) ) 178 { 179 trackback_response(2, $errstring); // TODO: check TRACKBACK SPEC that error code 2 is ok 180 } 181 182 183 // Record trackback into DB: 184 $Comment->dbinsert(); 185 186 187 if( $Comment->ID == 0 ) 188 { 189 // Exit silently! Wz don't want to give an easy tool to try and pass the filters. 190 trackback_response( 0, 'ok' ); 191 } 192 193 194 /* 195 * ---------------------------- 196 * New trackback notification: 197 * ---------------------------- 198 */ 199 // TODO: dh> this should only send published feedback probably and should also use "outbound_notifications_mode" 200 $Comment->send_email_notifications(); 201 202 203 // Trigger event: a Plugin should cleanup any temporary data here.. 204 // fp>> WARNING: won't be called if trackback gets deleted by antispam 205 $Plugins->trigger_event( 'AfterTrackbackInsert', array( 'Comment' => & $Comment ) ); 206 207 208 // fp>TODO: warn about moderation 209 trackback_response( 0, 'ok' ); 210 211 212 /* 213 * $Log: trackback.php,v $ 214 * Revision 1.59 2007/04/26 00:11:14 fplanque 215 * (c) 2007 216 * 217 * Revision 1.58 2007/02/13 01:30:31 blueyed 218 * TODO: do not notify about not published comments / use "outbound_notifications_mode" setting for comments, too 219 * 220 * Revision 1.57 2006/12/22 00:26:41 blueyed 221 * Require absolute URL for trackback source; Correct charset for trackback_response() 222 * 223 * Revision 1.56 2006/11/24 18:27:22 blueyed 224 * Fixed link to b2evo CVS browsing interface in file docblocks 225 * 226 * Revision 1.55 2006/08/19 07:56:29 fplanque 227 * Moved a lot of stuff out of the automatic instanciation in _main.inc 228 * 229 * Revision 1.54 2006/07/03 21:04:48 fplanque 230 * translation cleanup 231 * 232 * Revision 1.53 2006/05/30 00:15:11 blueyed 233 * Do not use Item::can_comment here. 234 * 235 * Revision 1.52 2006/05/29 23:57:13 blueyed 236 * todo 237 * 238 * Revision 1.51 2006/05/29 22:27:46 blueyed 239 * Use NULL instead of false for "no display". 240 * 241 * Revision 1.50 2006/05/29 19:54:45 fplanque 242 * no message 243 * 244 * Revision 1.49 2006/05/20 01:56:07 blueyed 245 * ItemCanComment hook; "disable anonymous feedback" through basic antispam plugin 246 * 247 * Revision 1.48 2006/05/19 18:15:04 blueyed 248 * Merged from v-1-8 branch 249 * 250 * Revision 1.47.2.1 2006/05/19 15:06:23 fplanque 251 * dirty sync 252 * 253 * Revision 1.47 2006/05/02 04:36:24 blueyed 254 * Spam karma changed (-100..100 instead of abs/max); Spam weight for plugins; publish/delete threshold 255 * 256 * Revision 1.46 2006/05/01 05:20:38 blueyed 257 * Check for duplicate content in comments/trackback. 258 * 259 * Revision 1.45 2006/05/01 04:25:04 blueyed 260 * Normalization 261 * 262 * Revision 1.44 2006/04/27 21:03:51 blueyed 263 * Cleanup, fix and add Plugin hook 264 * 265 * Revision 1.43 2006/04/20 16:31:29 fplanque 266 * comment moderation (finished for 1.8) 267 * 268 * Revision 1.42 2006/04/19 20:13:48 fplanque 269 * do not restrict to :// (does not catch subdomains, not even www.) 270 * 271 * Revision 1.41 2006/04/19 15:56:02 blueyed 272 * Renamed T_posts.post_comments to T_posts.post_comment_status (DB column rename!); 273 * and Item::comments to Item::comment_status (Item API change) 274 * 275 * Revision 1.40 2006/04/11 21:22:25 fplanque 276 * partial cleanup 277 * 278 */ 279 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |