Line | |
---|
1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: No Stats For Robots |
---|
4 | Version: auto |
---|
5 | Description: Do not log visits from search engine robots (history and hits) |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid= |
---|
7 | Author: plg |
---|
8 | Author URI: http://le-gall.net/pierrick |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) |
---|
12 | { |
---|
13 | die('Hacking attempt!'); |
---|
14 | } |
---|
15 | |
---|
16 | $bots = array( |
---|
17 | 'Googlebot', |
---|
18 | 'bingbot', |
---|
19 | 'Baiduspider', |
---|
20 | 'yandex', |
---|
21 | 'AhrefsBot', |
---|
22 | 'msnbot', |
---|
23 | 'Slurp', |
---|
24 | 'BLEXBot', |
---|
25 | 'VoilaBot', |
---|
26 | ); |
---|
27 | |
---|
28 | if (isset($_SERVER["HTTP_USER_AGENT"]) |
---|
29 | and preg_match('/('.implode('|', $bots).')/', $_SERVER['HTTP_USER_AGENT'])) |
---|
30 | { |
---|
31 | add_event_handler('pwg_log_allowed', create_function('', 'return false;')); |
---|
32 | add_event_handler('allow_increment_element_hit_count', create_function('$b', 'return false;')); |
---|
33 | } |
---|
34 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.