Changeset 13799


Ignore:
Timestamp:
Mar 29, 2012, 8:48:09 PM (9 years ago)
Author:
rvelices
Message:

rv_akismet - added a technique to detect robots (as of today my tests show 100% spams caught) :)

Location:
extensions/rv_akismet
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_akismet/check.inc.php

    r7610 r13799  
    2121    'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
    2222  );
     23  if (isset($_POST['url']) && strlen($_POST['url']))
     24    $aki_comm['comment_author_url'] = $_POST['url'];
    2325
    2426  $akismet = new Akismet(get_absolute_root_url(), $conf['akismet_api_key'], $aki_comm);
     
    3234      if ('reject'!=$action) set_status_header(403);
    3335      $counters[0]++;
     36      $_POST['cr'][] = 'aki';
    3437    }
     38    else
     39      $_POST['cr'][] = 'aki-ok';
    3540    $counters[1]++;
    3641    $conf['akismet_counters'] = implode('/', $counters);
     
    3843    pwg_query($query);
    3944  }
    40   elseif (is_admin())
    41     var_export( $akismet->getErrors() );
     45  else {
     46    $_POST['cr'][] = 'aki-FAIL';
     47    if (is_admin())
     48      var_export( $akismet->getErrors() );
     49  }
    4250
    4351  return $action;
  • extensions/rv_akismet/main.inc.php

    r12365 r13799  
    11<?php /*
    22Plugin Name: RV Akismet
    3 Version: 2.3.a
     3Version: 2.4.a
    44Description: Uses Akismet online service to check comments agains spam
    55Plugin URI: http://piwigo.org/ext/extension_view.php?eid=192
     
    1212
    1313add_event_handler('user_comment_check', 'akismet_user_comment_check_wrapper', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2);
     14add_event_handler('loc_begin_page_tail', 'akismet_page_tail' );
     15
    1416
    1517add_event_handler('get_admin_plugin_menu_links', 'akismet_plugin_admin_menu' );
     18add_event_handler('init', 'akismet_init' );
     19
    1620
    1721function akismet_plugin_admin_menu($menu)
     
    3741{
    3842        include_once( dirname(__FILE__).'/check.inc.php' );
    39         return akismet_user_comment_check($action, $comment);
     43        $action = akismet_user_comment_check($action, $comment);
     44        if (!isset($_SESSION['csi']) && isset($_POST['url']) && strlen($_POST['url']) )
     45        {
     46                $action = 'reject';
     47                $_POST['cr'][] = 'csi url';
     48        }
     49        return $action;
    4050}
     51
     52function akismet_init()
     53{
     54        global $template;
     55        $template->smarty->register_prefilter('akismet_prefilter_comment_form');
     56}
     57
     58function akismet_prefilter_comment_form($source, $smarty)
     59{
     60        if ( ($pos=strpos($source, '<textarea'))!==false
     61                && ($pos2=strpos($source, 'comment', $pos))!==false
     62                && $pos2-$pos <300)
     63        {
     64                $source= substr_replace($source, '{html_style}#urlid{ldelim}display:none}{/html_style}<input type="text" name="url" id="urlid">', $pos,0);
     65        }
     66        return $source;
     67}
     68
     69function akismet_page_tail()
     70{
     71        global $template, $conf;
     72        if (!isset($_SESSION['csi']) && strpos($_SERVER['HTTP_USER_AGENT'],'bot')===false)
     73        {
     74                $src = get_root_url().'plugins/'.AKIS_DIR.'/csi.php';
     75                $template->append( 'footer_elements', '<img src="'.$src.'" width=0 height=0>');
     76        }
     77}
     78
    4179?>
Note: See TracChangeset for help on using the changeset viewer.