source: extensions/rv_akismet/main.inc.php @ 31815

Last change on this file since 31815 was 29452, checked in by rvelices, 10 years ago

akismet no csi for robots

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
RevLine 
[6506]1<?php /*
2Plugin Name: RV Akismet
[29452]3Version: 2.7.a
[6506]4Description: Uses Akismet online service to check comments agains spam
5Plugin URI: http://piwigo.org/ext/extension_view.php?eid=192
6Author: rvelices
7Author URI: http://www.modusoptimus.com
8*/
9
[6672]10define('AKIS_DIR' , basename(dirname(__FILE__)));
11define('AKIS_PATH' , PHPWG_PLUGINS_PATH . AKIS_DIR . '/');
12
[26859]13add_event_handler('user_comment_check', 'akismet_user_comment_check_wrapper', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 3);
[29452]14if (!isset($_SESSION['csi']))
15        add_event_handler('loc_begin_page_tail', 'akismet_page_tail' );
[6506]16
[13799]17
[6506]18add_event_handler('get_admin_plugin_menu_links', 'akismet_plugin_admin_menu' );
19
20function akismet_plugin_admin_menu($menu)
21{
22        global $page,$conf;
23        if ( empty($conf['akismet_api_key']) and in_array($page['page'], array('intro','plugins_list')) )
24        {
[6672]25                load_language('plugin.lang', AKIS_PATH);
26                $page['errors'][] = l10n('You need to define the Akismet api key');
[6506]27        }
28        $admin_url = get_admin_plugin_menu_link(dirname(__FILE__).'/admin.php');
[18945]29        $menu[] = array(
[6506]30                                'NAME' => 'Akismet',
31                                'URL' => $admin_url
[18945]32                        );
[6506]33        return $menu;
34}
35
36
[26859]37function akismet_user_comment_check_wrapper($action, $comment, $where=null)
[6506]38{
39        include_once( dirname(__FILE__).'/check.inc.php' );
[26859]40        $action = akismet_user_comment_check($action, $comment, $where);
[13799]41        return $action;
[6506]42}
[13799]43
[18945]44/*add_event_handler('init', 'akismet_init' );
45
[13799]46function akismet_init()
47{
48        global $template;
49        $template->smarty->register_prefilter('akismet_prefilter_comment_form');
50}
51
52function akismet_prefilter_comment_form($source, $smarty)
53{
54        if ( ($pos=strpos($source, '<textarea'))!==false
55                && ($pos2=strpos($source, 'comment', $pos))!==false
56                && $pos2-$pos <300)
57        {
58                $source= substr_replace($source, '{html_style}#urlid{ldelim}display:none}{/html_style}<input type="text" name="url" id="urlid">', $pos,0);
59        }
60        return $source;
[18945]61}*/
[13799]62
63function akismet_page_tail()
64{
[29452]65        global $template;
66
67        $ua = @$_SERVER['HTTP_USER_AGENT'];
68        foreach(array('bot','crawl','spider','slurp') as $needle)
69                if (stripos($ua, $needle)!==false)
70                                return;
71
72        $src = get_root_url().'plugins/'.AKIS_DIR.'/csi.php';
73        $template->append( 'footer_elements', '<img src="'.$src.'" width=0 height=0>');
[13799]74}
75
[6506]76?>
Note: See TracBrowser for help on using the repository browser.