-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
plugin.php
250 lines (241 loc) · 6.12 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
/**
Plugin Name: Don't Log Bots
Plugin URI: https://github.com/YOURLS/dont-log-bots
Description: Do not log some bots in stats
Version: 1.3
Author: Ozh, Leo Colomb, Suguru Hirahara
Author URI: http://yourls.org
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
// Check current user-agent against a list of bots, return boolean
function yp_dlb_is_bot() {
// Get current User-Agent
$current = strtolower( $_SERVER['HTTP_USER_AGENT'] );
// Array of known bot lowercase strings
// Example: 'googlebot' will match 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)'
$bots = array(
// List of Active crawlers & bots since October 2013 (imcomplete)
// picked up from: http://user-agent-string.info/list-of-ua/bots
// also: http://myip.ms/browse/web_bots/Known_Web_Bots_Web_Bots_2014_Web_Spider_List.html
'200please.com/bot',
'360spider',
'80legs.com/webcrawler',
'a6-indexer',
'aboundex',
'aboutusbot',
'addsearchbot',
'addthis.com',
'adressendeutschland.de',
'adsbot-google',
'ahrefsbot',
'aihitbot',
'alexa site audit',
'amznkassocbot',
'analyticsseo.com',
'antbot',
'arabot',
'archive.org_bot',
'archive.orgbot',
'askpeterbot',
'backlinkcrawler',
'baidu.com/search/spider.html',
'baiduspider',
'begunadvertising',
'bingbot',
'bingpreview',
'bitlybot',
'bixocrawler',
'blekkobot',
'blexbot',
'brainbrubot',
'browsershots',
'bubing',
'butterfly',
'bufferbot',
'careerbot',
'catchbot',
'ccbot',
'cert figleafbot',
'changedetection.com/bot.html',
'chilkat',
'claritybot',
'classbot',
'cliqzbot',
'cms crawler',
'coccoc',
'compspybot',
'crawler4j',
'crowsnest',
'crystalsemanticsbot',
'dataminr.com',
'daumoa',
'easouspider',
'exabot',
'exb language crawler',
'ezooms',
'facebookexternalhit',
'facebookplatform',
'fairshare',
'feedfetcher',
'feedly.com/fetcher.html',
'feedlybot',
'fetch',
'flipboardproxy',
'fyberspider',
'genieo',
'gigabot',
'google page speed insights',
'googlebot',
'grapeshot',
'hatena-useragent',
'hubspot connect',
'hubspot links crawler',
'hosttracker.com',
'ia_archiver',
'icc-crawler',
'ichiro',
'immediatenet.com',
'iltrovatore-setaccio',
'infohelfer',
'instapaper',
'ixebot',
'jabse.com crawler',
'james bot',
'jikespider',
'jyxobot',
'linkdex',
'linkfluence',
'loadimpactpageanalyzer',
'luminate.com',
'lycosa',
'magpie-crawler',
'mail.ru_bot',
'meanpathbot',
'mediapartners-google',
'metageneratorcrawler',
'metajobbot',
'mj12bot',
'mojeekbot',
'msai.in',
'msnbot-media',
'musobot',
'najdi.si',
'nalezenczbot',
'nekstbot',
'netcraftsurveyagent',
'netestate ne crawler',
'netseer crawler',
'nuhk',
'obot',
'omgilibot',
'openwebspider',
'panscient.com',
'parsijoo',
'plukkie',
'proximic',
'psbot',
'qirina hurdler',
'qualidator.com',
'queryseekerspider',
'readability',
'rogerbot',
'sbsearch',
'scrapy',
'search.kumkie.com',
'searchbot',
'searchmetricsbot',
'semrushbot',
'seocheckbot',
'seoengworldbot',
'seokicks-robot',
'seznambot',
'shareaholic.com/bot',
'shopwiki.com/wiki/help:bot',
'showyoubot',
'sistrix',
'sitechecker',
'siteexplorer',
'speedy spider',
'socialbm_bot',
'sogou web spider',
'sogou',
'sosospider',
'spbot',
'special_archiver',
'spiderling',
'spinn3r',
'spreadtrum',
'steeler',
'suma spider',
'surveybot',
'suggybot',
'svenska-webbsido',
'teoma',
'thumbshots',
'tineye.com',
'trendiction.com',
'trendiction.de/bot',
'turnitinbot',
'tweetedtimes bot',
'tweetmeme',
'twitterbot',
'uaslinkchecker',
'umbot',
'undrip bot',
'unisterbot',
'unwindfetchor',
'urlappendbot',
'vedma',
'vkshare',
'voilabot',
'wbsearchbot',
'wch web spider',
'webcookies',
'webcrawler at wise-guys dot nl',
'webthumbnail',
'wesee:search',
'woko',
'woobot',
'woriobot',
'wotbox',
'y!j-bri',
'y!j-bro',
'y!j-brw',
'y!j-bsc',
'yacybot',
'yahoo! slurp',
'yahooysmcm',
'yandexbot',
'yats',
'yeti',
'yioopbot',
'yodaobot',
'youdaobot',
'zb-1',
'zeerch.com/bot.php',
'zing-bottabot',
'zumbot',
// accessed when tweeted
'ning/1.0',
'yahoo:linkexpander:slingstone',
'google-http-java-client/1.17.0-rc (gzip)',
'js-kit url resolver',
'htmlparser',
'paperlibot',
// xenu
'xenu link sleuth',
);
// Check if the current UA string contains a know bot string
$is_bot = ( str_replace( $bots, '', $current ) != $current );
return $is_bot;
}
// Hook stuff in
yourls_add_filter( 'shunt_update_clicks', 'yp_dlb_skip_if_bot' );
yourls_add_filter( 'shunt_log_redirect', 'yp_dlb_skip_if_bot' );
// Skip if it's a bot
function yp_dlb_skip_if_bot() {
return yp_dlb_is_bot();
// if anything but false is returned, functions using the two shunt_* filters will be short-circuited
}