[18369] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Comments Blacklist |
---|
| 4 | Version: auto |
---|
| 5 | Description: Define a list of words which are not authorized in a comment. |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=637 |
---|
| 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | defined('COMM_BLACKLIST_ID') or define('COMM_BLACKLIST_ID', basename(dirname(__FILE__))); |
---|
| 14 | define('COMM_BLACKLIST_PATH' , PHPWG_PLUGINS_PATH . COMM_BLACKLIST_ID . '/'); |
---|
| 15 | define('COMM_BLACKLIST_ADMIN', get_root_url() . 'admin.php?page=plugin-' . COMM_BLACKLIST_ID); |
---|
| 16 | define('COMM_BLACKLIST_FILE', PWG_LOCAL_DIR . 'comments_blacklist.txt'); |
---|
| 17 | define('COMM_BLACKLIST_VERSION', 'auto'); |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | add_event_handler('init', 'comm_blacklist_init'); |
---|
| 21 | |
---|
| 22 | if (defined('IN_ADMIN')) |
---|
| 23 | { |
---|
| 24 | add_event_handler('get_admin_plugin_menu_links', 'comm_blacklist_admin_plugin_menu_links'); |
---|
| 25 | |
---|
| 26 | function comm_blacklist_admin_plugin_menu_links($menu) |
---|
| 27 | { |
---|
| 28 | array_push($menu, array( |
---|
| 29 | 'NAME' => 'Comments Blacklist', |
---|
| 30 | 'URL' => COMM_BLACKLIST_ADMIN, |
---|
| 31 | )); |
---|
| 32 | return $menu; |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | else |
---|
| 36 | { |
---|
| 37 | add_event_handler('user_comment_check', 'comm_blacklist_user_comment_check', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 38 | include_once(COMM_BLACKLIST_PATH . 'include/functions.inc.php'); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * plugin initialization |
---|
| 44 | */ |
---|
| 45 | function comm_blacklist_init() |
---|
| 46 | { |
---|
| 47 | global $conf, $pwg_loaded_plugins; |
---|
| 48 | |
---|
| 49 | // apply upgrade if needed |
---|
| 50 | if ( |
---|
| 51 | $pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'] == 'auto' or |
---|
| 52 | version_compare($pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'], COMM_BLACKLIST_VERSION, '<') |
---|
| 53 | ) |
---|
| 54 | { |
---|
| 55 | include_once(COMM_BLACKLIST_PATH . 'include/install.inc.php'); |
---|
| 56 | comm_blacklist_install(); |
---|
| 57 | |
---|
| 58 | if ($pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'] != 'auto') |
---|
| 59 | { |
---|
| 60 | $query = ' |
---|
| 61 | UPDATE '. PLUGINS_TABLE .' |
---|
| 62 | SET version = "'. COMM_BLACKLIST_VERSION .'" |
---|
| 63 | WHERE id = "'. COMM_BLACKLIST_ID .'"'; |
---|
| 64 | pwg_query($query); |
---|
| 65 | |
---|
| 66 | $pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'] = COMM_BLACKLIST_VERSION; |
---|
| 67 | |
---|
| 68 | if (defined('IN_ADMIN')) |
---|
| 69 | { |
---|
| 70 | $_SESSION['page_infos'][] = 'Comments Blacklist updated to version '. COMM_BLACKLIST_VERSION; |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | // load plugin language file |
---|
| 76 | load_language('plugin.lang', COMM_BLACKLIST_PATH); |
---|
| 77 | |
---|
| 78 | // prepare plugin configuration |
---|
| 79 | $conf['comments_blacklist'] = unserialize($conf['comments_blacklist']); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | ?> |
---|