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