| 4 | | //returns string action to perform on a new comment: validate, moderate, reject |
| 5 | | function user_comment_check_albums($action, $comment) |
| 6 | | { |
| 7 | | global $conf,$user; |
| 8 | | |
| 9 | | if ($action=='reject') |
| 10 | | return $action; |
| 11 | | |
| 12 | | $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate'; |
| 13 | | |
| 14 | | if ($action==$my_action) |
| 15 | | return $action; |
| 16 | | |
| 17 | | // we do here only BASIC spam check (plugins can do more) |
| 18 | | if ( !is_a_guest() ) |
| 19 | | return $action; |
| 20 | | |
| 21 | | $link_count = preg_match_all( '/https?:\/\//', |
| 22 | | $comment['content'], $matches); |
| 23 | | |
| 24 | | if ( strpos($comment['author'], 'http://')!==false ) |
| 25 | | { |
| 26 | | $link_count++; |
| 27 | | } |
| 28 | | |
| 29 | | if ( $link_count>$conf['comment_spam_max_links'] ) |
| 30 | | return $my_action; |
| 31 | | |
| 32 | | return $action; |
| 33 | | } |
| 34 | | |
| 35 | | add_event_handler('user_comment_check_albums', 'user_comment_check_albums', |
| | 4 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
| | 5 | add_event_handler('user_comment_check_albums', 'user_comment_check', |
| 325 | | if (!function_exists('email_admin')) |
| 326 | | { |
| 327 | | function email_admin($action, $comment) |
| 328 | | { |
| 329 | | global $conf; |
| 330 | | |
| 331 | | if (!in_array($action, array('edit', 'delete')) |
| 332 | | or (($action=='edit') and !$conf['email_admin_on_comment_edition']) |
| 333 | | or (($action=='delete') and !$conf['email_admin_on_comment_deletion'])) |
| 334 | | { |
| 335 | | return; |
| 336 | | } |
| 337 | | |
| 338 | | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
| 339 | | |
| 340 | | $keyargs_content = array(); |
| 341 | | $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']); |
| 342 | | if ($action=='delete') |
| 343 | | { |
| 344 | | $keyargs_content[] = get_l10n_args('This author removed the comment with id %d', |
| 345 | | $comment['comment_id'] |
| 346 | | ); |
| 347 | | } |
| 348 | | else |
| 349 | | { |
| 350 | | $keyargs_content[] = get_l10n_args('This author modified following comment:', ''); |
| 351 | | $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']); |
| 352 | | } |
| 353 | | |
| 354 | | pwg_mail_notification_admins(get_l10n_args('Comment by %s', |
| 355 | | $comment['author']), |
| 356 | | $keyargs_content |
| 357 | | ); |
| 358 | | } |
| 359 | | } |
| 360 | | |