source: extensions/rv_akismet/admin.php @ 6650

Last change on this file since 6650 was 6506, checked in by rvelices, 14 years ago

added rv_akismet extension to svn

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function test_akismet()
5{
6  global $page, $conf;
7  include_once( dirname(__FILE__).'/akismet.class.php' );
8  $akismet = new Akismet(get_absolute_root_url(), $conf['akismet_api_key'], array('referrer'=>'') );
9  if( $akismet->errorsExist() )
10    $page['errors'] = array_merge($page['errors'], array_values($akismet->getErrors()) );
11  else
12    $page['infos'][] = 'Akismet is OK';
13}
14
15if ( isset($_POST['submit']) and !is_adviser() )
16{
17  $query = '
18UPDATE '.CONFIG_TABLE.'
19  SET value="'.$_POST['akismet_api_key'].'"
20  WHERE param="akismet_api_key"
21  LIMIT 1';
22  pwg_query($query);
23
24  $query = '
25UPDATE '.CONFIG_TABLE.'
26  SET value="'.$_POST['akismet_spam_action'].'"
27  WHERE param="akismet_spam_action"
28  LIMIT 1';
29  pwg_query($query);
30
31  list($conf['akismet_api_key']) = array_from_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param="akismet_api_key"', 'value');
32  list($conf['akismet_spam_action']) = array_from_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param="akismet_spam_action"', 'value');
33  test_akismet();
34}
35
36if ( isset($_GET['test']) )
37  test_akismet();
38if ( isset($_GET['reset-stats']) )
39{
40  $conf['akismet_counters']='0/0';
41  $query = 'UPDATE '.CONFIG_TABLE.' SET value="'.$conf['akismet_counters'].'" WHERE param="akismet_counters" LIMIT 1';
42  pwg_query($query);
43}
44
45$template->set_filename('plugin_admin_content', dirname(__FILE__).'/admin.tpl');
46
47$counters = explode('/', $conf['akismet_counters']);
48$template->assign(
49    array(
50      'AKISMET_API_KEY' => $conf['akismet_api_key'],
51      'AKISMET_BLOG_URL' => get_absolute_root_url(),
52      'AKISMET_TEST_URL' => add_url_params( get_admin_plugin_menu_link(dirname(__FILE__).'/admin.php'), array('test'=>1) ),
53      'AKISMET_RESET_STATS_URL' => add_url_params( get_admin_plugin_menu_link(dirname(__FILE__).'/admin.php'), array('reset-stats'=>1) ),
54      'AKISMET_SPAM_COMMENTS' => $counters[0],
55      'AKISMET_CHECKED_COMMENTS' => $counters[1],
56      'AKISMET_SPAM_ACTION' => $conf['akismet_spam_action'],
57    )
58  );
59
60
61$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
62
63?>
Note: See TracBrowser for help on using the repository browser.