Version Description
Download this release
Release Info
Developer | tellyworth |
Plugin | Akismet Anti-Spam |
Version | 3.0.0-RC1 |
Comparing to | |
See all releases |
Code changes from version 2.6.0 to 3.0.0-RC1
- .htaccess +11 -0
- _inc/akismet.css +361 -0
- akismet.js → _inc/akismet.js +88 -89
- _inc/form.js +17 -0
- _inc/img/logo-full-2x.png +0 -0
- admin.php +0 -943
- akismet.css +0 -1
- akismet.gif +0 -0
- akismet.php +17 -658
- class.akismet-admin.php +952 -0
- widget.php → class.akismet-widget.php +12 -10
- class.akismet.php +764 -0
- img/logo.png +0 -0
- img/logo@2x.png +0 -0
- index.php +1 -1
- legacy.php +0 -396
- readme.txt +14 -1
- views/config.php +163 -0
- views/get.php +5 -0
- views/notice.php +91 -0
- views/start.php +101 -0
- views/stats.php +4 -0
- views/strict.php +7 -0
- wrapper.php +293 -0
.htaccess
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Order Deny,Allow
|
2 |
+
Deny from all
|
3 |
+
|
4 |
+
<FilesMatch "^(form|akismet)\.(css|js)$">
|
5 |
+
Allow from all
|
6 |
+
</FilesMatch>
|
7 |
+
|
8 |
+
#allow access to any image
|
9 |
+
<FilesMatch "^(.+)\.(png|gif)$">
|
10 |
+
Allow from all
|
11 |
+
</FilesMatch>
|
_inc/akismet.css
ADDED
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#submitted-on {
|
3 |
+
position: relative;
|
4 |
+
}
|
5 |
+
#the-comment-list .author .akismet-user-comment-count {
|
6 |
+
display: inline;
|
7 |
+
}
|
8 |
+
#the-comment-list .author a span {
|
9 |
+
text-decoration: none;
|
10 |
+
color: #999;
|
11 |
+
}
|
12 |
+
#the-comment-list .author a span.akismet-span-link {
|
13 |
+
text-decoration: inherit;
|
14 |
+
color: inherit;
|
15 |
+
}
|
16 |
+
#the-comment-list .remove_url {
|
17 |
+
margin-left: 3px;
|
18 |
+
color: #999;
|
19 |
+
padding: 2px 3px 2px 0;
|
20 |
+
}
|
21 |
+
#the-comment-list .remove_url:hover {
|
22 |
+
color: #A7301F;
|
23 |
+
font-weight: bold;
|
24 |
+
padding: 2px 2px 2px 0;
|
25 |
+
}
|
26 |
+
#dashboard_recent_comments .akismet-status {
|
27 |
+
display: none;
|
28 |
+
}
|
29 |
+
.akismet-status {
|
30 |
+
float: right;
|
31 |
+
}
|
32 |
+
.akismet-status a {
|
33 |
+
color: #AAA;
|
34 |
+
font-style: italic;
|
35 |
+
}
|
36 |
+
span.comment-link a {
|
37 |
+
text-decoration: underline;
|
38 |
+
}
|
39 |
+
span.comment-link:after {
|
40 |
+
content: " "attr(title) " ";
|
41 |
+
color: #aaa;
|
42 |
+
text-decoration: none;
|
43 |
+
}
|
44 |
+
.mshot-arrow {
|
45 |
+
width: 0;
|
46 |
+
height: 0;
|
47 |
+
border-top: 10px solid transparent;
|
48 |
+
border-bottom: 10px solid transparent;
|
49 |
+
border-right: 10px solid #5C5C5C;
|
50 |
+
position: absolute;
|
51 |
+
left: -6px;
|
52 |
+
top: 91px;
|
53 |
+
}
|
54 |
+
.mshot-container {
|
55 |
+
background: #5C5C5C;
|
56 |
+
position: absolute;
|
57 |
+
top: -94px;
|
58 |
+
padding: 7px;
|
59 |
+
width: 450px;
|
60 |
+
height: 338px;
|
61 |
+
z-index: 20000;
|
62 |
+
-moz-border-radius: 6px;
|
63 |
+
border-radius: 6px;
|
64 |
+
-webkit-border-radius: 6px;
|
65 |
+
}
|
66 |
+
h2.ak-header {
|
67 |
+
padding: 30px;
|
68 |
+
background: #7c9936 url('img/logo-full-2x.png') no-repeat 20px center;
|
69 |
+
background-size: 185px 33px;
|
70 |
+
height: 33px;
|
71 |
+
text-indent: -9999em;
|
72 |
+
margin-right: 10px;
|
73 |
+
}
|
74 |
+
.checkforspam {
|
75 |
+
display: inline-block !important;
|
76 |
+
}
|
77 |
+
.checkforspam-spinner {
|
78 |
+
display: none;
|
79 |
+
margin-top: 10px;
|
80 |
+
}
|
81 |
+
|
82 |
+
.config-wrap {
|
83 |
+
margin-top: 2em;
|
84 |
+
max-width: 700px;
|
85 |
+
}
|
86 |
+
|
87 |
+
.activate-option {
|
88 |
+
background: #e3e3e3;
|
89 |
+
border-radius: 3px;
|
90 |
+
margin-bottom: 30px;
|
91 |
+
overflow: hidden;
|
92 |
+
padding: 20px;
|
93 |
+
}
|
94 |
+
.activate-option.clicked {
|
95 |
+
background: #7c9936;
|
96 |
+
color: #fff;
|
97 |
+
}
|
98 |
+
.activate-option.clicked:hover {
|
99 |
+
background: #68802E;
|
100 |
+
color: #fff;
|
101 |
+
}
|
102 |
+
|
103 |
+
.activate-option .button.button-secondary {
|
104 |
+
margin: 15px 0;
|
105 |
+
}
|
106 |
+
|
107 |
+
.activate-option p {
|
108 |
+
margin: 10px 0 10px;
|
109 |
+
}
|
110 |
+
|
111 |
+
.activate-highlight {
|
112 |
+
background: #fff;
|
113 |
+
padding: 30px;
|
114 |
+
margin-right: 10px;
|
115 |
+
}
|
116 |
+
|
117 |
+
.activate-highlight.secondary {
|
118 |
+
background: #ddd;
|
119 |
+
padding: 20px 30px;
|
120 |
+
}
|
121 |
+
|
122 |
+
.activate-highlight h3 {
|
123 |
+
margin: 0 0 0.3em;
|
124 |
+
}
|
125 |
+
.activate-highlight p {
|
126 |
+
color: #777;
|
127 |
+
}
|
128 |
+
.activate-highlight .button-primary {
|
129 |
+
margin-top: 15px;
|
130 |
+
}
|
131 |
+
|
132 |
+
#akismet-enter-api-key .regular-text {
|
133 |
+
width: 18em;
|
134 |
+
margin-top: 15px;
|
135 |
+
}
|
136 |
+
|
137 |
+
.right {
|
138 |
+
float: right;
|
139 |
+
}
|
140 |
+
|
141 |
+
.alert-text {
|
142 |
+
color: #dd3d36;
|
143 |
+
}
|
144 |
+
.success {
|
145 |
+
color: #7c9936;
|
146 |
+
}
|
147 |
+
.option-description {
|
148 |
+
float: left;
|
149 |
+
font-size: 16px;
|
150 |
+
}
|
151 |
+
.option-description span {
|
152 |
+
color: #666;
|
153 |
+
display: block;
|
154 |
+
font-size: 14px;
|
155 |
+
margin-top: 5px;
|
156 |
+
}
|
157 |
+
.option-action {
|
158 |
+
float: right;
|
159 |
+
}
|
160 |
+
.key-config-link {
|
161 |
+
font-size: 14px;
|
162 |
+
margin-left: 20px;
|
163 |
+
}
|
164 |
+
.jetpack-account {
|
165 |
+
float: left;
|
166 |
+
font-size: 18px;
|
167 |
+
margin-right: 40px;
|
168 |
+
}
|
169 |
+
.small-heading {
|
170 |
+
color: #777;
|
171 |
+
display: block;
|
172 |
+
font-size: 12px;
|
173 |
+
font-weight: bold;
|
174 |
+
margin-bottom: 5px;
|
175 |
+
text-transform: uppercase;
|
176 |
+
}
|
177 |
+
.inline-label {
|
178 |
+
background: #ddd;
|
179 |
+
border-radius: 3px;
|
180 |
+
font-size: 11px;
|
181 |
+
padding: 3px 8px;
|
182 |
+
text-transform: uppercase;
|
183 |
+
}
|
184 |
+
.inline-label.alert {
|
185 |
+
background: #e54747;
|
186 |
+
color: #fff;
|
187 |
+
}
|
188 |
+
.jetpack-account .inline-label {
|
189 |
+
margin-left: 5px;
|
190 |
+
}
|
191 |
+
.option-action .manual-key {
|
192 |
+
margin-top: 7px;
|
193 |
+
}
|
194 |
+
|
195 |
+
.alert {
|
196 |
+
border: 1px solid #e5e5e5;
|
197 |
+
padding: 0.4em 1em 1.4em 1em;
|
198 |
+
border-radius: 3px;
|
199 |
+
-webkit-border-radius: 3px;
|
200 |
+
border-width: 1px;
|
201 |
+
border-style: solid;
|
202 |
+
}
|
203 |
+
|
204 |
+
.alert h3.key-status {
|
205 |
+
color: #fff;
|
206 |
+
margin: 1em 0 0.5em 0;
|
207 |
+
}
|
208 |
+
|
209 |
+
.alert.critical {
|
210 |
+
background-color: #993300;
|
211 |
+
}
|
212 |
+
|
213 |
+
.alert.active {
|
214 |
+
background-color: #3db238;
|
215 |
+
}
|
216 |
+
|
217 |
+
.alert p.key-status {
|
218 |
+
font-size: 24px;
|
219 |
+
}
|
220 |
+
|
221 |
+
.alert p.description {
|
222 |
+
color:#fff;
|
223 |
+
font-size: 14px;
|
224 |
+
margin: 0 0;
|
225 |
+
font-style: normal;
|
226 |
+
}
|
227 |
+
|
228 |
+
.alert p.description a,
|
229 |
+
.alert p.description a,
|
230 |
+
.alert p.description a,
|
231 |
+
.alert p.description a {
|
232 |
+
color: #fff;
|
233 |
+
}
|
234 |
+
|
235 |
+
.new-snapshot {
|
236 |
+
margin-top: 1em;
|
237 |
+
padding: 1em;
|
238 |
+
text-align: center;
|
239 |
+
}
|
240 |
+
|
241 |
+
.new-snapshot.stats {
|
242 |
+
background: #fff;
|
243 |
+
border: 1px solid #e5e5e5;
|
244 |
+
}
|
245 |
+
|
246 |
+
.new-snapshot h3 {
|
247 |
+
background: #f5f5f5;
|
248 |
+
color: #888;
|
249 |
+
font-size: 11px;
|
250 |
+
margin: 0;
|
251 |
+
padding: 3px;
|
252 |
+
}
|
253 |
+
|
254 |
+
.new-snapspot ul {
|
255 |
+
font-size: 12px;
|
256 |
+
width: 100%;
|
257 |
+
}
|
258 |
+
|
259 |
+
.new-snapshot ul li {
|
260 |
+
color: #999;
|
261 |
+
float: left;
|
262 |
+
font-size: 11px;
|
263 |
+
padding: 0 20px;
|
264 |
+
text-transform: uppercase;
|
265 |
+
width: 33%;
|
266 |
+
box-sizing: border-box;
|
267 |
+
-moz-box-sizing: border-box;
|
268 |
+
-webkit-box-sizing: border-box;
|
269 |
+
-ms-box-sizing: border-box;
|
270 |
+
}
|
271 |
+
|
272 |
+
.new-snapshot.stats ul li:first-child,
|
273 |
+
.new-snapshot.stats ul li:nth-child(2) {
|
274 |
+
border-right:1px dotted #ccc;
|
275 |
+
}
|
276 |
+
|
277 |
+
.new-snapshot.account ul li:nth-child(2) {
|
278 |
+
border-right: none;
|
279 |
+
}
|
280 |
+
|
281 |
+
.new-snapshot ul li span {
|
282 |
+
color: #52accc;
|
283 |
+
display: block;
|
284 |
+
font-size: 32px;
|
285 |
+
font-weight: lighter;
|
286 |
+
line-height: 1.5em;
|
287 |
+
}
|
288 |
+
|
289 |
+
.new-snapshot.stats {
|
290 |
+
}
|
291 |
+
|
292 |
+
.new-snapshot.account,
|
293 |
+
.new-snapshot.settings {
|
294 |
+
float: left;
|
295 |
+
padding: 0;
|
296 |
+
text-align: left;
|
297 |
+
width: 50%;
|
298 |
+
box-sizing: border-box;
|
299 |
+
-moz-box-sizing: border-box;
|
300 |
+
-webkit-box-sizing: border-box;
|
301 |
+
-ms-box-sizing: border-box;
|
302 |
+
}
|
303 |
+
|
304 |
+
.account-container {
|
305 |
+
background: #fff;
|
306 |
+
border: 1px solid #e5e5e5;
|
307 |
+
margin-right: 0.5em;
|
308 |
+
}
|
309 |
+
|
310 |
+
.settings-container {
|
311 |
+
background: #fff;
|
312 |
+
border: 1px solid #e5e5e5;
|
313 |
+
margin-left: 0.5em;
|
314 |
+
}
|
315 |
+
|
316 |
+
.new-snapshot.account ul li {
|
317 |
+
width:100%
|
318 |
+
}
|
319 |
+
|
320 |
+
.new-snapshot.account ul li span {
|
321 |
+
font-size: 14px;
|
322 |
+
font-weight: normal;
|
323 |
+
}
|
324 |
+
|
325 |
+
|
326 |
+
.new-snapshot.settings ul li {
|
327 |
+
border: none;
|
328 |
+
display: block;
|
329 |
+
width:100%
|
330 |
+
}
|
331 |
+
|
332 |
+
.new-snapshot.settings ul li span {
|
333 |
+
display: block;
|
334 |
+
font-size: 14px;
|
335 |
+
font-weight: normal;
|
336 |
+
}
|
337 |
+
|
338 |
+
.new-snapshot.settings p.submit {
|
339 |
+
margin: 0;
|
340 |
+
text-align: center;
|
341 |
+
}
|
342 |
+
|
343 |
+
.akismet-settings th.strictness {
|
344 |
+
vertical-align: top;
|
345 |
+
padding-top: 15px;
|
346 |
+
}
|
347 |
+
|
348 |
+
.akismet-settings input[type=text] {
|
349 |
+
width: 75%;
|
350 |
+
}
|
351 |
+
|
352 |
+
.akismet-settings span.note{
|
353 |
+
float: left;
|
354 |
+
padding-left: 23px;
|
355 |
+
font-size: 75%;
|
356 |
+
margin-top: -10px;
|
357 |
+
}
|
358 |
+
|
359 |
+
.clearfix {
|
360 |
+
clear:both;
|
361 |
+
}
|
akismet.js → _inc/akismet.js
RENAMED
@@ -1,59 +1,58 @@
|
|
1 |
jQuery( function ( $ ) {
|
2 |
-
$( '.
|
3 |
-
var
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
return false;
|
10 |
});
|
11 |
-
$( 'p.need-key a' ).click( function(){
|
12 |
-
document.akismet_activate.submit();
|
13 |
-
});
|
14 |
$('.akismet-status').each(function () {
|
15 |
var thisId = $(this).attr('commentid');
|
16 |
-
$(this).prependTo('#comment-' + thisId + ' .column-comment
|
17 |
});
|
18 |
$('.akismet-user-comment-count').each(function () {
|
19 |
var thisId = $(this).attr('commentid');
|
20 |
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
|
21 |
});
|
22 |
$('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title ^= "http://"]').each(function () {
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
$( '<a href="#" class="remove_url">x</a>' )
|
31 |
.attr( 'commentid', thisCommentId[1] )
|
32 |
.attr( 'title', WPAkismet.strings['Remove this URL'] )
|
33 |
);
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
_wpnonce: WPAkismet.comment_author_url_nonce,
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
.attr('cid', thisId)
|
58 |
.addClass('akismet_undo_link_removal')
|
59 |
.html(
|
@@ -66,40 +65,40 @@ jQuery( function ( $ ) {
|
|
66 |
.addClass( 'akismet-span-link' )
|
67 |
);
|
68 |
}
|
69 |
-
|
70 |
});
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
var thisUrl = $(this).attr('href').replace("http://www.", "").replace("http://", "");
|
77 |
-
|
78 |
-
|
79 |
_wpnonce: WPAkismet.comment_author_url_nonce,
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
$.ajax({
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
$("a[commentid='"+ thisId +"']").show();
|
95 |
// Show link
|
96 |
$("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
|
97 |
-
|
98 |
-
|
99 |
});
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
$('a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type').mouseover(function () {
|
104 |
var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
|
105 |
// Need to determine size of author column
|
@@ -124,30 +123,30 @@ jQuery( function ( $ ) {
|
|
124 |
}).mouseout(function () {
|
125 |
$(this).find('.mShot').hide();
|
126 |
});
|
127 |
-
$('.checkforspam:not(.button-disabled)').click( function(e) {
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
function akismet_check_for_spam(offset, limit) {
|
135 |
-
$.post(
|
136 |
-
ajaxurl,
|
137 |
-
{
|
138 |
-
'action': 'akismet_recheck_queue',
|
139 |
-
'offset': offset,
|
140 |
-
'limit': limit
|
141 |
-
},
|
142 |
-
function(result) {
|
143 |
-
if (result.processed < limit) {
|
144 |
-
window.location.reload();
|
145 |
-
}
|
146 |
-
else {
|
147 |
-
akismet_check_for_spam(offset + limit, limit);
|
148 |
-
}
|
149 |
-
}
|
150 |
-
);
|
151 |
}
|
152 |
});
|
153 |
// URL encode plugin
|
1 |
jQuery( function ( $ ) {
|
2 |
+
$( 'a.activate-option' ).click( function(){
|
3 |
+
var link = $( this );
|
4 |
+
if ( link.hasClass( 'clicked' ) ) {
|
5 |
+
link.removeClass( 'clicked' );
|
6 |
+
}
|
7 |
+
else {
|
8 |
+
link.addClass( 'clicked' );
|
9 |
+
}
|
10 |
+
$( '.toggle-have-key' ).slideToggle( 'slow', function() {});
|
11 |
return false;
|
12 |
});
|
|
|
|
|
|
|
13 |
$('.akismet-status').each(function () {
|
14 |
var thisId = $(this).attr('commentid');
|
15 |
+
$(this).prependTo('#comment-' + thisId + ' .column-comment');
|
16 |
});
|
17 |
$('.akismet-user-comment-count').each(function () {
|
18 |
var thisId = $(this).attr('commentid');
|
19 |
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
|
20 |
});
|
21 |
$('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title ^= "http://"]').each(function () {
|
22 |
+
var thisTitle = $(this).attr('title');
|
23 |
+
thisCommentId = $(this).parents('tr:first').attr('id').split("-");
|
24 |
+
|
25 |
+
$(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
|
26 |
+
|
27 |
+
if (thisTitle) {
|
28 |
+
$(this).after(
|
29 |
$( '<a href="#" class="remove_url">x</a>' )
|
30 |
.attr( 'commentid', thisCommentId[1] )
|
31 |
.attr( 'title', WPAkismet.strings['Remove this URL'] )
|
32 |
);
|
33 |
+
}
|
34 |
+
});
|
35 |
+
$('.remove_url').live('click', function () {
|
36 |
+
var thisId = $(this).attr('commentid');
|
37 |
+
var data = {
|
38 |
+
action: 'comment_author_deurl',
|
39 |
_wpnonce: WPAkismet.comment_author_url_nonce,
|
40 |
+
id: thisId
|
41 |
+
};
|
42 |
+
$.ajax({
|
43 |
+
url: ajaxurl,
|
44 |
+
type: 'POST',
|
45 |
+
data: data,
|
46 |
+
beforeSend: function () {
|
47 |
+
// Removes "x" link
|
48 |
+
$("a[commentid='"+ thisId +"']").hide();
|
49 |
+
// Show temp status
|
50 |
+
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
|
51 |
+
},
|
52 |
+
success: function (response) {
|
53 |
+
if (response) {
|
54 |
+
// Show status/undo link
|
55 |
+
$("#author_comment_url_"+ thisId)
|
56 |
.attr('cid', thisId)
|
57 |
.addClass('akismet_undo_link_removal')
|
58 |
.html(
|
65 |
.addClass( 'akismet-span-link' )
|
66 |
);
|
67 |
}
|
68 |
+
}
|
69 |
});
|
70 |
|
71 |
+
return false;
|
72 |
+
});
|
73 |
+
$('.akismet_undo_link_removal').live('click', function () {
|
74 |
+
var thisId = $(this).attr('cid');
|
75 |
var thisUrl = $(this).attr('href').replace("http://www.", "").replace("http://", "");
|
76 |
+
var data = {
|
77 |
+
action: 'comment_author_reurl',
|
78 |
_wpnonce: WPAkismet.comment_author_url_nonce,
|
79 |
+
id: thisId,
|
80 |
+
url: thisUrl
|
81 |
+
};
|
82 |
$.ajax({
|
83 |
+
url: ajaxurl,
|
84 |
+
type: 'POST',
|
85 |
+
data: data,
|
86 |
+
beforeSend: function () {
|
87 |
+
// Show temp status
|
88 |
+
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
|
89 |
+
},
|
90 |
+
success: function (response) {
|
91 |
+
if (response) {
|
92 |
+
// Add "x" link
|
93 |
$("a[commentid='"+ thisId +"']").show();
|
94 |
// Show link
|
95 |
$("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
|
96 |
+
}
|
97 |
+
}
|
98 |
});
|
99 |
+
|
100 |
+
return false;
|
101 |
+
});
|
102 |
$('a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type').mouseover(function () {
|
103 |
var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
|
104 |
// Need to determine size of author column
|
123 |
}).mouseout(function () {
|
124 |
$(this).find('.mShot').hide();
|
125 |
});
|
126 |
+
$('.checkforspam:not(.button-disabled)').click( function(e) {
|
127 |
+
$('.checkforspam:not(.button-disabled)').addClass('button-disabled');
|
128 |
+
$('.checkforspam-spinner').show();
|
129 |
+
akismet_check_for_spam(0, 100);
|
130 |
+
e.preventDefault();
|
131 |
+
});
|
132 |
+
|
133 |
+
function akismet_check_for_spam(offset, limit) {
|
134 |
+
$.post(
|
135 |
+
ajaxurl,
|
136 |
+
{
|
137 |
+
'action': 'akismet_recheck_queue',
|
138 |
+
'offset': offset,
|
139 |
+
'limit': limit
|
140 |
+
},
|
141 |
+
function(result) {
|
142 |
+
if (result.processed < limit) {
|
143 |
+
window.location.reload();
|
144 |
+
}
|
145 |
+
else {
|
146 |
+
akismet_check_for_spam(offset + limit, limit);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
);
|
150 |
}
|
151 |
});
|
152 |
// URL encode plugin
|
_inc/form.js
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function ( $ ) {
|
2 |
+
var ak_js = $( '#ak_js' );
|
3 |
+
|
4 |
+
// If the form field already exists just use that
|
5 |
+
if ( ak_js.length == 0 ) {
|
6 |
+
ak_js = $( '<input type="hidden" id="ak_js" name="ak_js" />' );
|
7 |
+
}
|
8 |
+
else {
|
9 |
+
ak_js.remove();
|
10 |
+
}
|
11 |
+
|
12 |
+
ak_js.val( ( new Date() ).getTime() );
|
13 |
+
|
14 |
+
// single page, front-end comment form
|
15 |
+
// inline comment reply, wp-admin
|
16 |
+
$( '#commentform, #replyrow td:first' ).append( ak_js );
|
17 |
+
} );
|
_inc/img/logo-full-2x.png
ADDED
Binary file
|
admin.php
DELETED
@@ -1,943 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
add_action( 'admin_menu', 'akismet_admin_menu' );
|
3 |
-
|
4 |
-
akismet_admin_warnings();
|
5 |
-
|
6 |
-
function akismet_admin_init() {
|
7 |
-
global $wp_version;
|
8 |
-
|
9 |
-
// all admin functions are disabled in old versions
|
10 |
-
if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) {
|
11 |
-
|
12 |
-
function akismet_version_warning() {
|
13 |
-
echo '
|
14 |
-
<div id="akismet-warning" class="updated fade"><p><strong>'.sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) .'</strong> '.sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). '</p></div>
|
15 |
-
';
|
16 |
-
}
|
17 |
-
add_action('admin_notices', 'akismet_version_warning');
|
18 |
-
|
19 |
-
return;
|
20 |
-
}
|
21 |
-
|
22 |
-
if ( function_exists( 'get_plugin_page_hook' ) )
|
23 |
-
$hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
|
24 |
-
else
|
25 |
-
$hook = 'dashboard_page_akismet-stats-display';
|
26 |
-
add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
|
27 |
-
}
|
28 |
-
add_action('admin_init', 'akismet_admin_init');
|
29 |
-
|
30 |
-
add_action( 'admin_enqueue_scripts', 'akismet_load_js_and_css' );
|
31 |
-
function akismet_load_js_and_css() {
|
32 |
-
global $hook_suffix;
|
33 |
-
|
34 |
-
if ( in_array( $hook_suffix, array(
|
35 |
-
'index.php', # dashboard
|
36 |
-
'edit-comments.php',
|
37 |
-
'comment.php',
|
38 |
-
'post.php',
|
39 |
-
'plugins_page_akismet-key-config',
|
40 |
-
'jetpack_page_akismet-key-config',
|
41 |
-
) ) ) {
|
42 |
-
wp_register_style( 'akismet.css', AKISMET_PLUGIN_URL . 'akismet.css', array(), AKISMET_VERSION );
|
43 |
-
wp_enqueue_style( 'akismet.css');
|
44 |
-
|
45 |
-
wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'), AKISMET_VERSION );
|
46 |
-
wp_enqueue_script( 'akismet.js' );
|
47 |
-
wp_localize_script( 'akismet.js', 'WPAkismet', array(
|
48 |
-
'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
|
49 |
-
'strings' => array(
|
50 |
-
'Remove this URL' => __( 'Remove this URL' ),
|
51 |
-
'Removing...' => __( 'Removing...' ),
|
52 |
-
'URL removed' => __( 'URL removed' ),
|
53 |
-
'(undo)' => __( '(undo)' ),
|
54 |
-
'Re-adding...' => __( 'Re-adding...' ),
|
55 |
-
)
|
56 |
-
) );
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
|
62 |
-
$akismet_nonce = 'akismet-update-key';
|
63 |
-
|
64 |
-
function akismet_plugin_action_links( $links, $file ) {
|
65 |
-
if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
|
66 |
-
$links[] = '<a href="' . admin_url( 'admin.php?page=akismet-key-config' ) . '">'.__( 'Settings' ).'</a>';
|
67 |
-
}
|
68 |
-
|
69 |
-
return $links;
|
70 |
-
}
|
71 |
-
|
72 |
-
add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 );
|
73 |
-
|
74 |
-
function akismet_conf() {
|
75 |
-
global $akismet_nonce, $current_user;
|
76 |
-
|
77 |
-
$new_key_link = 'https://akismet.com/get/';
|
78 |
-
$config_link = esc_url( add_query_arg( array( 'page' => 'akismet-key-config', 'show' => 'enter-api-key' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'plugins.php' ) ) );
|
79 |
-
$stats_link = esc_url( add_query_arg( array( 'page' => 'akismet-stats-display' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'index.php' ) ) );
|
80 |
-
$api_key = akismet_get_key();
|
81 |
-
$show_key_form = $api_key;
|
82 |
-
$key_status = 'empty';
|
83 |
-
$saved_ok = false;
|
84 |
-
$key_status_text = '';
|
85 |
-
|
86 |
-
$ms = array();
|
87 |
-
|
88 |
-
if ( isset( $_POST['submit'] ) ) {
|
89 |
-
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
|
90 |
-
die(__('Cheatin’ uh?'));
|
91 |
-
|
92 |
-
$show_key_form = true;
|
93 |
-
|
94 |
-
check_admin_referer( $akismet_nonce );
|
95 |
-
$key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
|
96 |
-
$home_url = parse_url( get_bloginfo('url') );
|
97 |
-
|
98 |
-
if ( empty( $home_url['host'] ) )
|
99 |
-
$ms[] = 'bad_home_url';
|
100 |
-
|
101 |
-
if ( empty( $key ) ) {
|
102 |
-
if ( $api_key ) {
|
103 |
-
delete_option('wordpress_api_key');
|
104 |
-
$saved_ok = true;
|
105 |
-
$ms[] = 'new_key_empty';
|
106 |
-
}
|
107 |
-
else
|
108 |
-
$ms[] = 'key_empty';
|
109 |
-
}
|
110 |
-
else
|
111 |
-
$key_status = akismet_verify_key( $key );
|
112 |
-
|
113 |
-
if ( $key != $api_key && $key_status == 'valid' ) {
|
114 |
-
$ms[] = 'new_key_valid';
|
115 |
-
update_option('wordpress_api_key', $key);
|
116 |
-
}
|
117 |
-
elseif ( $key_status == 'invalid' )
|
118 |
-
$ms[] = 'new_key_invalid';
|
119 |
-
elseif ( $key_status == 'failed' )
|
120 |
-
$ms[] = 'new_key_failed';
|
121 |
-
|
122 |
-
$api_key = $key_status == 'valid' ? $key : false;
|
123 |
-
|
124 |
-
if ( isset( $_POST['akismet_discard_month'] ) )
|
125 |
-
update_option( 'akismet_discard_month', 'true' );
|
126 |
-
else
|
127 |
-
update_option( 'akismet_discard_month', 'false' );
|
128 |
-
|
129 |
-
if ( isset( $_POST['akismet_show_user_comments_approved'] ) )
|
130 |
-
update_option( 'akismet_show_user_comments_approved', 'true' );
|
131 |
-
else
|
132 |
-
update_option( 'akismet_show_user_comments_approved', 'false' );
|
133 |
-
|
134 |
-
if ( empty( $ms ) )
|
135 |
-
$saved_ok = true;
|
136 |
-
|
137 |
-
}
|
138 |
-
elseif ( isset( $_POST['check'] ) ) {
|
139 |
-
$show_key_form = true;
|
140 |
-
check_admin_referer( $akismet_nonce );
|
141 |
-
akismet_get_server_connectivity(0);
|
142 |
-
}
|
143 |
-
elseif ( isset( $_GET['show'] ) && $_GET['show'] == 'enter-api-key' ) {
|
144 |
-
$show_key_form = true;
|
145 |
-
}
|
146 |
-
|
147 |
-
if ( $show_key_form ) {
|
148 |
-
//check current key status
|
149 |
-
//only get this if showing the key form otherwise takes longer for page to load for new user
|
150 |
-
//no need to get it if we already know it and its valid
|
151 |
-
if ( in_array( $key_status, array( 'invalid', 'failed', 'empty' ) ) ) {
|
152 |
-
$key = get_option('wordpress_api_key');
|
153 |
-
if ( empty( $key ) ) {
|
154 |
-
//no key saved yet - maybe connection to Akismet down?
|
155 |
-
if ( in_array( $key_status, array( 'invalid', 'empty' ) ) ) {
|
156 |
-
if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
|
157 |
-
$ms[] = 'no_connection';
|
158 |
-
}
|
159 |
-
}
|
160 |
-
else
|
161 |
-
$key_status = akismet_verify_key( $key );
|
162 |
-
}
|
163 |
-
|
164 |
-
if ( !isset( $_POST['submit'] ) ) {
|
165 |
-
if ( $key_status == 'invalid' )
|
166 |
-
$ms[] = 'key_invalid';
|
167 |
-
elseif ( !empty( $key ) && $key_status == 'failed' )
|
168 |
-
$ms[] = 'key_failed';
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
$key_status_strings = array(
|
173 |
-
'empty' => __( 'Empty' ),
|
174 |
-
'valid' => __( 'Valid' ),
|
175 |
-
'invalid' => __( 'Invalid' ),
|
176 |
-
'failed' => __( 'Failed' ),
|
177 |
-
);
|
178 |
-
|
179 |
-
$messages = array(
|
180 |
-
'new_key_empty' => array( 'class' => 'updated fade', 'text' => __('Your key has been cleared.' ) ),
|
181 |
-
'new_key_valid' => array( 'class' => 'updated fade', 'text' => __('Your Akismet account has been successfully set up and activated. Happy blogging!' ) ),
|
182 |
-
'new_key_invalid' => array( 'class' => 'error', 'text' => __('The key you entered is invalid. Please double-check it.' ) ),
|
183 |
-
'new_key_failed' => array( 'class' => 'error', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.' ) ),
|
184 |
-
'no_connection' => array( 'class' => 'error', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.' ) ),
|
185 |
-
'key_empty' => array( 'class' => 'updated fade', 'text' => __('Please enter an API key' ) ),
|
186 |
-
'key_invalid' => array( 'class' => 'error', 'text' => __('This key is invalid.' ) ),
|
187 |
-
'key_failed' => array( 'class' => 'error', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.' ) ),
|
188 |
-
'bad_home_url' => array( 'class' => 'error', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) )
|
189 |
-
);
|
190 |
-
?>
|
191 |
-
|
192 |
-
|
193 |
-
<div class="wrap">
|
194 |
-
<?php if ( !$api_key ) : ?>
|
195 |
-
<h2 class="ak-header"><?php _e('Akismet'); ?></h2>
|
196 |
-
<?php else: ?>
|
197 |
-
<h2 class="ak-header"><?php printf( __( 'Akismet <a href="%s" class="add-new-h2">Stats</a>' ), $stats_link ); ?></h2>
|
198 |
-
<?php endif; ?>
|
199 |
-
<div class="no-key <?php echo $show_key_form ? 'hidden' : '';?>">
|
200 |
-
<p><?php _e('Akismet eliminates the comment and trackback spam you get on your site. To use Akismet you may need to sign up for an API key. Click the button below to get started.'); ?></p>
|
201 |
-
<form name="akismet_activate" action="https://akismet.com/get/" method="POST">
|
202 |
-
<input type="hidden" name="return" value="1"/>
|
203 |
-
<input type="hidden" name="jetpack" value="<?php echo (string) class_exists( 'Jetpack' );?>"/>
|
204 |
-
<input type="hidden" name="user" value="<?php echo esc_attr( $current_user->user_login );?>"/>
|
205 |
-
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Create a new Akismet Key' ); ?>"/>
|
206 |
-
</form>
|
207 |
-
<br/>
|
208 |
-
<a href="<?php echo $config_link;?>"><?php _e('I already have a key'); ?></a>
|
209 |
-
</div>
|
210 |
-
<div class="have-key <?php echo $show_key_form ? '' : 'hidden';?>">
|
211 |
-
<?php if ( !empty($_POST['submit'] ) && $saved_ok ) : ?>
|
212 |
-
<div id="message" class="updated fade"><p><strong><?php _e('Settings saved.') ?></strong></p></div>
|
213 |
-
<?php endif; ?>
|
214 |
-
<?php if ( isset($_GET['message']) && $_GET['message'] == 'success' ) : ?>
|
215 |
-
<div id="message" class="updated fade"><p><?php _e('<strong>Sign up success!</strong> Please check your email for your Akismet API Key and enter it below.') ?></p></div>
|
216 |
-
<?php endif; ?>
|
217 |
-
<?php foreach( $ms as $m ) : ?>
|
218 |
-
<div class="<?php echo $messages[$m]['class']; ?>"><p><strong><?php echo $messages[$m]['text']; ?></strong></p></div>
|
219 |
-
<?php endforeach; ?>
|
220 |
-
<form action="" method="post" id="akismet-conf">
|
221 |
-
<table class="form-table">
|
222 |
-
<tbody>
|
223 |
-
<tr>
|
224 |
-
<th><label for="key"><?php _e('Akismet API Key');?></label></th>
|
225 |
-
<td>
|
226 |
-
<input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="regular-text code <?php echo $key_status;?>"><div class="under-input key-status <?php echo $key_status;?>"><?php echo isset( $key_status_strings[ $key_status ] ) ? $key_status_strings[ $key_status ] : '';?></div>
|
227 |
-
<p class="need-key description"><?php printf( __('You must enter a valid Akismet API key here. If you need an API key, you can <a href="%s">create one here</a>'), '#' );?></p>
|
228 |
-
</td>
|
229 |
-
</tr>
|
230 |
-
<?php if ( $api_key ):?>
|
231 |
-
<tr valign="top">
|
232 |
-
<th scope="row"><?php _e('Settings');?></th>
|
233 |
-
<td>
|
234 |
-
<fieldset><legend class="screen-reader-text"><span><?php _e('Settings');?></span></legend>
|
235 |
-
<label for="akismet_discard_month" title="<?php esc_attr_e( 'Auto-detete old spam' ); ?>"><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php echo get_option('akismet_discard_month') == 'true' ? 'checked="checked"':''; ?>> <span><?php _e('Auto-delete spam submitted on posts more than a month old.'); ?></span></label><br>
|
236 |
-
<label for="akismet_show_user_comments_approved" title="<?php esc_attr_e( 'Show approved comments' ); ?>"><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="true" type="checkbox" <?php echo get_option('akismet_show_user_comments_approved') == 'true' ? 'checked="checked"':''; ?>> <span><?php _e('Show the number of comments you\'ve approved beside each comment author.'); ?></span></label>
|
237 |
-
</fieldset>
|
238 |
-
</td>
|
239 |
-
</tr>
|
240 |
-
<?php endif; ?>
|
241 |
-
</tbody>
|
242 |
-
</table>
|
243 |
-
<?php akismet_nonce_field($akismet_nonce) ?>
|
244 |
-
<p class="submit">
|
245 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save Changes');?>">
|
246 |
-
</p>
|
247 |
-
</form>
|
248 |
-
|
249 |
-
<?php if ( $api_key ) : ?>
|
250 |
-
<h3><?php _e('Server Connectivity'); ?></h3>
|
251 |
-
<form action="" method="post" id="akismet-connectivity">
|
252 |
-
<table class="form-table">
|
253 |
-
<tbody>
|
254 |
-
<tr>
|
255 |
-
<th><label for="key"><?php _e('Server Status');?></label></th>
|
256 |
-
<td>
|
257 |
-
<?php if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) : ?>
|
258 |
-
<p class="key-status failed"><?php _e('Network functions are disabled.'); ?></p>
|
259 |
-
<p class="description"><?php echo sprintf( __('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet\'s system requirements</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
260 |
-
<?php else :
|
261 |
-
$servers = akismet_get_server_connectivity();
|
262 |
-
$fail_count = count( $servers ) - count( array_filter( $servers ) );
|
263 |
-
if ( is_array( $servers ) && count( $servers ) > 0 ) {
|
264 |
-
if ( $fail_count > 0 && $fail_count < count( $servers ) ) { // some connections work, some fail ?>
|
265 |
-
<p class="key-status some"><?php _e('Unable to reach some Akismet servers.'); ?></p>
|
266 |
-
<p class="description"><?php echo sprintf( __('A network problem or firewall is blocking some connections from your web server to Akismet.com. Akismet is working but this may cause problems during times of network congestion. Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
267 |
-
<?php } elseif ( $fail_count > 0 ) { // all connections fail ?>
|
268 |
-
<p class="key-status failed"><?php _e('Unable to reach any Akismet servers.'); ?></p>
|
269 |
-
<p class="description"><?php echo sprintf( __('A network problem or firewall is blocking all connections from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
270 |
-
<?php } else { // all connections work ?>
|
271 |
-
<p class="key-status valid"><?php _e('All Akismet servers are available.'); ?></p>
|
272 |
-
<p class="description"><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
|
273 |
-
<?php }
|
274 |
-
} else { //can't connect to any server ?>
|
275 |
-
<p class="key-status failed"><?php _e('Unable to find Akismet servers.'); ?></p>
|
276 |
-
<p class="description"><?php echo sprintf( __('A DNS problem or firewall is preventing all access from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
277 |
-
<?php }
|
278 |
-
endif; ?>
|
279 |
-
</td>
|
280 |
-
</tr>
|
281 |
-
<?php if ( !empty( $servers ) ) : ?>
|
282 |
-
<tr valign="top">
|
283 |
-
<th scope="row"><?php _e('Network Status');?></th>
|
284 |
-
<td>
|
285 |
-
<table class="network-status">
|
286 |
-
<thead>
|
287 |
-
<th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th>
|
288 |
-
</thead>
|
289 |
-
<tbody>
|
290 |
-
<?php
|
291 |
-
asort($servers);
|
292 |
-
foreach ( $servers as $ip => $status ) : ?>
|
293 |
-
<tr>
|
294 |
-
<td align="center"><?php echo esc_html( $ip ); ?></td>
|
295 |
-
<td class="key-status <?php echo $status ? 'valid' : 'failed'; ?>"><?php echo $status ? __('Accessible') : __('Re-trying'); ?></td>
|
296 |
-
</tr>
|
297 |
-
<?php endforeach; ?>
|
298 |
-
</tbody>
|
299 |
-
</table>
|
300 |
-
<br/>
|
301 |
-
<input type="submit" name="check" id="submit" class="button" style="margin-left: 13.3em;" value="<?php _e('Check Network Status');?>">
|
302 |
-
</td>
|
303 |
-
</tr>
|
304 |
-
<?php endif; ?>
|
305 |
-
<tr valign="top">
|
306 |
-
<th scope="row"><?php _e('Last Checked');?></th>
|
307 |
-
<td>
|
308 |
-
<p><strong><?php echo get_option('akismet_connectivity_time') ? sprintf( __('%s Ago'), ucwords( human_time_diff( get_option('akismet_connectivity_time') ) ) ) : __( 'Not yet' ); ?></strong></p>
|
309 |
-
<p class="description"><?php printf( __('You can confirm that Akismet.com is up by <a href="%s" target="_blank">clicking here</a>.'), 'http://status.automattic.com/9931/136079/Akismet-API' ); ?></p>
|
310 |
-
</td>
|
311 |
-
</tbody>
|
312 |
-
</table>
|
313 |
-
<?php akismet_nonce_field($akismet_nonce) ?>
|
314 |
-
</form>
|
315 |
-
<?php endif;?>
|
316 |
-
</div>
|
317 |
-
</div>
|
318 |
-
<?php
|
319 |
-
}
|
320 |
-
|
321 |
-
function akismet_stats_display() {
|
322 |
-
global $akismet_api_host, $akismet_api_port;
|
323 |
-
|
324 |
-
$blog = urlencode( get_bloginfo('url') );
|
325 |
-
$api_key = akismet_get_key();
|
326 |
-
$config_link = esc_url( add_query_arg( array( 'page' => 'akismet-key-config' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'plugins.php' ) ) );?>
|
327 |
-
|
328 |
-
<div class="wrap"><?php
|
329 |
-
if ( !$api_key ) :?>
|
330 |
-
<div id="akismet-warning" class="updated fade"><p><strong><?php _e('Akismet is almost ready.');?></strong> <?php printf( __( 'You must <a href="%1$s">enter your Akismet API key</a> for it to work.' ), $config_link );?></p></div><?php
|
331 |
-
else :?>
|
332 |
-
<iframe src="<?php echo esc_url( sprintf( '%s://akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s', is_ssl()?'https':'http', $blog, $api_key ) ); ?>" width="100%" height="2500px" frameborder="0" id="akismet-stats-frame"></iframe><?php
|
333 |
-
endif;?>
|
334 |
-
</div><?php
|
335 |
-
}
|
336 |
-
|
337 |
-
function akismet_stats() {
|
338 |
-
if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
|
339 |
-
return;
|
340 |
-
if ( !$count = get_option('akismet_spam_count') )
|
341 |
-
return;
|
342 |
-
$path = plugin_basename(__FILE__);
|
343 |
-
echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
|
344 |
-
global $submenu;
|
345 |
-
echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/?return=true', esc_url( add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( isset( $submenu['edit-comments.php'] ) ? 'edit-comments.php' : 'edit.php' ) ) ), number_format_i18n($count) ).'</p>';
|
346 |
-
}
|
347 |
-
add_action('activity_box_end', 'akismet_stats');
|
348 |
-
|
349 |
-
function akismet_admin_warnings() {
|
350 |
-
global $wpcom_api_key, $pagenow;
|
351 |
-
|
352 |
-
if (
|
353 |
-
$pagenow == 'edit-comments.php'
|
354 |
-
|| ( !empty( $_GET['page'] ) && $_GET['page'] == 'akismet-key-config' )
|
355 |
-
|| ( !empty( $_GET['page'] ) && $_GET['page'] == 'akismet-stats-display' )
|
356 |
-
) {
|
357 |
-
if ( get_option( 'akismet_alert_code' ) ) {
|
358 |
-
function akismet_alert() {
|
359 |
-
$alert = array(
|
360 |
-
'code' => (int) get_option( 'akismet_alert_code' ),
|
361 |
-
'msg' => get_option( 'akismet_alert_msg' )
|
362 |
-
);
|
363 |
-
?>
|
364 |
-
<div class='error'>
|
365 |
-
<p><strong><?php _e( 'Akismet Error Code');?>: <?php echo $alert['code']; ?></strong></p>
|
366 |
-
<p><?php esc_html_e( $alert['msg'] ); ?></p>
|
367 |
-
<p><?php //FIXME: need to revert this to using __() in next version
|
368 |
-
printf( translate( 'For more information:' ) . ' <a href="%s">%s</a>' , 'https://akismet.com/errors/'.$alert['code'], 'https://akismet.com/errors/'.$alert['code'] );?>
|
369 |
-
</p>
|
370 |
-
</div>
|
371 |
-
<?php
|
372 |
-
}
|
373 |
-
|
374 |
-
add_action( 'admin_notices', 'akismet_alert' );
|
375 |
-
}
|
376 |
-
}
|
377 |
-
|
378 |
-
if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
|
379 |
-
function akismet_warning() {
|
380 |
-
global $hook_suffix, $current_user;
|
381 |
-
|
382 |
-
if ( $hook_suffix == 'plugins.php' ) {
|
383 |
-
echo '
|
384 |
-
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
|
385 |
-
<style type="text/css">
|
386 |
-
.akismet_activate{min-width:825px;border:1px solid #4F800D;padding:5px;margin:15px 0;background:#83AF24;background-image:-webkit-gradient(linear,0% 0,80% 100%,from(#83AF24),to(#4F800D));background-image:-moz-linear-gradient(80% 100% 120deg,#4F800D,#83AF24);-moz-border-radius:3px;border-radius:3px;-webkit-border-radius:3px;position:relative;overflow:hidden}.akismet_activate .aa_a{position:absolute;top:-5px;right:10px;font-size:140px;color:#769F33;font-family:Georgia, "Times New Roman", Times, serif;z-index:1}.akismet_activate .aa_button{font-weight:bold;border:1px solid #029DD6;border-top:1px solid #06B9FD;font-size:15px;text-align:center;padding:9px 0 8px 0;color:#FFF;background:#029DD6;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#029DD6),to(#0079B1));background-image:-moz-linear-gradient(0% 100% 90deg,#0079B1,#029DD6);-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px}.akismet_activate .aa_button:hover{text-decoration:none !important;border:1px solid #029DD6;border-bottom:1px solid #00A8EF;font-size:15px;text-align:center;padding:9px 0 8px 0;color:#F0F8FB;background:#0079B1;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#0079B1),to(#0092BF));background-image:-moz-linear-gradient(0% 100% 90deg,#0092BF,#0079B1);-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px}.akismet_activate .aa_button_border{border:1px solid #006699;-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px;background:#029DD6;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#029DD6),to(#0079B1));background-image:-moz-linear-gradient(0% 100% 90deg,#0079B1,#029DD6)}.akismet_activate .aa_button_container{cursor:pointer;display:inline-block;background:#DEF1B8;padding:5px;-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px;width:266px}.akismet_activate .aa_description{position:absolute;top:22px;left:285px;margin-left:25px;color:#E5F2B1;font-size:15px;z-index:1000}.akismet_activate .aa_description strong{color:#FFF;font-weight:normal}
|
387 |
-
</style>
|
388 |
-
<form name="akismet_activate" action="'.esc_url( add_query_arg( array( 'page' => 'akismet-key-config' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'plugins.php' ) ) ).'" method="POST">
|
389 |
-
<input type="hidden" name="return" value="1"/>
|
390 |
-
<input type="hidden" name="jetpack" value="'.(string) class_exists( 'Jetpack' ).'"/>
|
391 |
-
<input type="hidden" name="user" value="'.esc_attr( $current_user->user_login ).'"/>
|
392 |
-
<div class="akismet_activate">
|
393 |
-
<div class="aa_a">A</div>
|
394 |
-
<div class="aa_button_container" onclick="document.akismet_activate.submit();">
|
395 |
-
<div class="aa_button_border">
|
396 |
-
<div class="aa_button">'.__('Activate your Akismet account').'</div>
|
397 |
-
</div>
|
398 |
-
</div>
|
399 |
-
<div class="aa_description">'.__('<strong>Almost done</strong> - activate your account and say goodbye to comment spam').'</div>
|
400 |
-
</div>
|
401 |
-
</form>
|
402 |
-
</div>
|
403 |
-
';
|
404 |
-
}
|
405 |
-
}
|
406 |
-
|
407 |
-
add_action('admin_notices', 'akismet_warning');
|
408 |
-
return;
|
409 |
-
} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) && wp_next_scheduled('akismet_schedule_cron_recheck') ) {
|
410 |
-
function akismet_warning() {
|
411 |
-
global $wpdb;
|
412 |
-
akismet_fix_scheduled_recheck();
|
413 |
-
$waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" );
|
414 |
-
$next_check = wp_next_scheduled('akismet_schedule_cron_recheck');
|
415 |
-
if ( $waiting > 0 && $next_check > time() )
|
416 |
-
echo '
|
417 |
-
<div id="akismet-warning" class="updated fade"><p><strong>'.__('Akismet has detected a problem.').'</strong> '.sprintf(__('Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation. Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.'), 'admin.php?page=akismet-key-config').'</p></div>
|
418 |
-
';
|
419 |
-
}
|
420 |
-
add_action('admin_notices', 'akismet_warning');
|
421 |
-
return;
|
422 |
-
}
|
423 |
-
}
|
424 |
-
|
425 |
-
// FIXME placeholder
|
426 |
-
|
427 |
-
function akismet_comment_row_action( $a, $comment ) {
|
428 |
-
|
429 |
-
// failsafe for old WP versions
|
430 |
-
if ( !function_exists('add_comment_meta') )
|
431 |
-
return $a;
|
432 |
-
|
433 |
-
$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
|
434 |
-
$akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
|
435 |
-
$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
|
436 |
-
$comment_status = wp_get_comment_status( $comment->comment_ID );
|
437 |
-
$desc = null;
|
438 |
-
if ( $akismet_error ) {
|
439 |
-
$desc = __( 'Awaiting spam check' );
|
440 |
-
} elseif ( !$user_result || $user_result == $akismet_result ) {
|
441 |
-
// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
|
442 |
-
if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
|
443 |
-
$desc = __( 'Flagged as spam by Akismet' );
|
444 |
-
elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
|
445 |
-
$desc = __( 'Cleared by Akismet' );
|
446 |
-
} else {
|
447 |
-
$who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
|
448 |
-
if ( $user_result == 'true' )
|
449 |
-
$desc = sprintf( __('Flagged as spam by %s'), $who );
|
450 |
-
else
|
451 |
-
$desc = sprintf( __('Un-spammed by %s'), $who );
|
452 |
-
}
|
453 |
-
|
454 |
-
// add a History item to the hover links, just after Edit
|
455 |
-
if ( $akismet_result ) {
|
456 |
-
$b = array();
|
457 |
-
foreach ( $a as $k => $item ) {
|
458 |
-
$b[ $k ] = $item;
|
459 |
-
if (
|
460 |
-
$k == 'edit'
|
461 |
-
|| ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
|
462 |
-
) {
|
463 |
-
$b['history'] = '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
$a = $b;
|
468 |
-
}
|
469 |
-
|
470 |
-
if ( $desc )
|
471 |
-
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.esc_html( $desc ).'</a></span>';
|
472 |
-
|
473 |
-
if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
|
474 |
-
$comment_count = akismet_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
|
475 |
-
$comment_count = intval( $comment_count );
|
476 |
-
echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( _n( '%s approved', '%s approved', $comment_count ), number_format_i18n( $comment_count ) ) . '</span></span>';
|
477 |
-
}
|
478 |
-
|
479 |
-
return $a;
|
480 |
-
}
|
481 |
-
|
482 |
-
add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );
|
483 |
-
|
484 |
-
function akismet_comment_status_meta_box($comment) {
|
485 |
-
$history = akismet_get_comment_history( $comment->comment_ID );
|
486 |
-
|
487 |
-
if ( $history ) {
|
488 |
-
echo '<div class="akismet-history" style="margin: 13px;">';
|
489 |
-
foreach ( $history as $row ) {
|
490 |
-
$time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
|
491 |
-
echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';
|
492 |
-
echo esc_html( $row['message'] ) . '</div>';
|
493 |
-
}
|
494 |
-
|
495 |
-
echo '</div>';
|
496 |
-
|
497 |
-
}
|
498 |
-
}
|
499 |
-
|
500 |
-
|
501 |
-
// add an extra column header to the comments screen
|
502 |
-
function akismet_comments_columns( $columns ) {
|
503 |
-
$columns[ 'akismet' ] = __( 'Akismet' );
|
504 |
-
return $columns;
|
505 |
-
}
|
506 |
-
|
507 |
-
#add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );
|
508 |
-
|
509 |
-
// Show stuff in the extra column
|
510 |
-
function akismet_comment_column_row( $column, $comment_id ) {
|
511 |
-
if ( $column != 'akismet' )
|
512 |
-
return;
|
513 |
-
|
514 |
-
$history = akismet_get_comment_history( $comment_id );
|
515 |
-
|
516 |
-
if ( $history ) {
|
517 |
-
echo '<dl class="akismet-history">';
|
518 |
-
foreach ( $history as $row ) {
|
519 |
-
echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';
|
520 |
-
echo '<dd>' . esc_html( $row['message'] ) . '</dd>';
|
521 |
-
}
|
522 |
-
|
523 |
-
echo '</dl>';
|
524 |
-
}
|
525 |
-
}
|
526 |
-
|
527 |
-
#add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );
|
528 |
-
|
529 |
-
// END FIXME
|
530 |
-
|
531 |
-
// call out URLS in comments
|
532 |
-
function akismet_text_add_link_callback( $m ) {
|
533 |
-
// bare link?
|
534 |
-
if ( $m[4] == $m[2] )
|
535 |
-
return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';
|
536 |
-
else
|
537 |
-
return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';
|
538 |
-
}
|
539 |
-
|
540 |
-
function akismet_text_add_link_class( $comment_text ) {
|
541 |
-
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', 'akismet_text_add_link_callback', $comment_text );
|
542 |
-
}
|
543 |
-
|
544 |
-
add_filter('comment_text', 'akismet_text_add_link_class');
|
545 |
-
|
546 |
-
|
547 |
-
// WP 2.5+
|
548 |
-
function akismet_rightnow() {
|
549 |
-
global $submenu, $wp_db_version;
|
550 |
-
|
551 |
-
if ( 8645 < $wp_db_version ) // 2.7
|
552 |
-
$link = add_query_arg( array( 'comment_status' => 'spam' ), admin_url( 'edit-comments.php' ) );
|
553 |
-
elseif ( isset( $submenu['edit-comments.php'] ) )
|
554 |
-
$link = add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( 'edit-comments.php' ) );
|
555 |
-
else
|
556 |
-
$link = add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( 'edit.php' ) );
|
557 |
-
|
558 |
-
if ( $count = get_option('akismet_spam_count') ) {
|
559 |
-
$intro = sprintf( _n(
|
560 |
-
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
|
561 |
-
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
|
562 |
-
$count
|
563 |
-
), 'http://akismet.com/?return=true', number_format_i18n( $count ) );
|
564 |
-
} else {
|
565 |
-
$intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/?return=true' );
|
566 |
-
}
|
567 |
-
|
568 |
-
$link = function_exists( 'esc_url' ) ? esc_url( $link ) : clean_url( $link );
|
569 |
-
if ( $queue_count = akismet_spam_count() ) {
|
570 |
-
$queue_text = sprintf( _n(
|
571 |
-
'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
|
572 |
-
'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
|
573 |
-
$queue_count
|
574 |
-
), number_format_i18n( $queue_count ), $link );
|
575 |
-
} else {
|
576 |
-
$queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $link );
|
577 |
-
}
|
578 |
-
|
579 |
-
$text = $intro . '<br />' . $queue_text;
|
580 |
-
echo "<p class='akismet-right-now'>$text</p>\n";
|
581 |
-
}
|
582 |
-
|
583 |
-
add_action('rightnow_end', 'akismet_rightnow');
|
584 |
-
|
585 |
-
|
586 |
-
// For WP >= 2.5
|
587 |
-
function akismet_check_for_spam_button( $comment_status ) {
|
588 |
-
if ( 'approved' == $comment_status )
|
589 |
-
return;
|
590 |
-
|
591 |
-
if ( function_exists('plugins_url') )
|
592 |
-
$link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
|
593 |
-
else
|
594 |
-
$link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
|
595 |
-
|
596 |
-
echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . $link . '">' . esc_html__('Check for Spam') . '</a>';
|
597 |
-
echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="checkforspam-spinner" />';
|
598 |
-
}
|
599 |
-
add_action('manage_comments_nav', 'akismet_check_for_spam_button');
|
600 |
-
|
601 |
-
function akismet_submit_nonspam_comment ( $comment_id ) {
|
602 |
-
global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
|
603 |
-
$comment_id = (int) $comment_id;
|
604 |
-
|
605 |
-
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
|
606 |
-
if ( !$comment ) // it was deleted
|
607 |
-
return;
|
608 |
-
|
609 |
-
// use the original version stored in comment_meta if available
|
610 |
-
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
611 |
-
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
|
612 |
-
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
613 |
-
}
|
614 |
-
|
615 |
-
$comment->blog = get_bloginfo('url');
|
616 |
-
$comment->blog_lang = get_locale();
|
617 |
-
$comment->blog_charset = get_option('blog_charset');
|
618 |
-
$comment->permalink = get_permalink($comment->comment_post_ID);
|
619 |
-
if ( is_object($current_user) ) {
|
620 |
-
$comment->reporter = $current_user->user_login;
|
621 |
-
}
|
622 |
-
if ( is_object($current_site) ) {
|
623 |
-
$comment->site_domain = $current_site->domain;
|
624 |
-
}
|
625 |
-
|
626 |
-
$comment->user_role = '';
|
627 |
-
if ( isset( $comment->user_ID ) )
|
628 |
-
$comment->user_role = akismet_get_user_roles($comment->user_ID);
|
629 |
-
|
630 |
-
if ( akismet_test_mode() )
|
631 |
-
$comment->is_test = 'true';
|
632 |
-
|
633 |
-
$post = get_post( $comment->comment_post_ID );
|
634 |
-
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
635 |
-
|
636 |
-
$query_string = '';
|
637 |
-
foreach ( $comment as $key => $data )
|
638 |
-
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
639 |
-
|
640 |
-
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
|
641 |
-
if ( $comment->reporter ) {
|
642 |
-
akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam'), $comment->reporter ), 'report-ham' );
|
643 |
-
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
|
644 |
-
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
645 |
-
}
|
646 |
-
|
647 |
-
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
|
648 |
-
}
|
649 |
-
|
650 |
-
function akismet_submit_spam_comment ( $comment_id ) {
|
651 |
-
global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
|
652 |
-
$comment_id = (int) $comment_id;
|
653 |
-
|
654 |
-
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
|
655 |
-
if ( !$comment ) // it was deleted
|
656 |
-
return;
|
657 |
-
if ( 'spam' != $comment->comment_approved )
|
658 |
-
return;
|
659 |
-
|
660 |
-
// use the original version stored in comment_meta if available
|
661 |
-
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
662 |
-
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
|
663 |
-
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
664 |
-
}
|
665 |
-
|
666 |
-
$comment->blog = get_bloginfo('url');
|
667 |
-
$comment->blog_lang = get_locale();
|
668 |
-
$comment->blog_charset = get_option('blog_charset');
|
669 |
-
$comment->permalink = get_permalink($comment->comment_post_ID);
|
670 |
-
if ( is_object($current_user) ) {
|
671 |
-
$comment->reporter = $current_user->user_login;
|
672 |
-
}
|
673 |
-
if ( is_object($current_site) ) {
|
674 |
-
$comment->site_domain = $current_site->domain;
|
675 |
-
}
|
676 |
-
|
677 |
-
$comment->user_role = '';
|
678 |
-
if ( isset( $comment->user_ID ) )
|
679 |
-
$comment->user_role = akismet_get_user_roles($comment->user_ID);
|
680 |
-
|
681 |
-
if ( akismet_test_mode() )
|
682 |
-
$comment->is_test = 'true';
|
683 |
-
|
684 |
-
$post = get_post( $comment->comment_post_ID );
|
685 |
-
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
686 |
-
|
687 |
-
$query_string = '';
|
688 |
-
foreach ( $comment as $key => $data )
|
689 |
-
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
690 |
-
|
691 |
-
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
|
692 |
-
if ( $comment->reporter ) {
|
693 |
-
akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam'), $comment->reporter ), 'report-spam' );
|
694 |
-
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
|
695 |
-
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
696 |
-
}
|
697 |
-
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
|
698 |
-
}
|
699 |
-
|
700 |
-
// For WP 2.7+
|
701 |
-
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
|
702 |
-
if ( $new_status == $old_status )
|
703 |
-
return;
|
704 |
-
|
705 |
-
# we don't need to record a history item for deleted comments
|
706 |
-
if ( $new_status == 'delete' )
|
707 |
-
return;
|
708 |
-
|
709 |
-
if ( !is_admin() )
|
710 |
-
return;
|
711 |
-
|
712 |
-
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
|
713 |
-
return;
|
714 |
-
|
715 |
-
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
|
716 |
-
return;
|
717 |
-
|
718 |
-
// if this is present, it means the status has been changed by a re-check, not an explicit user action
|
719 |
-
if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
|
720 |
-
return;
|
721 |
-
|
722 |
-
global $current_user;
|
723 |
-
$reporter = '';
|
724 |
-
if ( is_object( $current_user ) )
|
725 |
-
$reporter = $current_user->user_login;
|
726 |
-
|
727 |
-
// Assumption alert:
|
728 |
-
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
|
729 |
-
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
|
730 |
-
// determine why the transition_comment_status action was triggered. And there are several different ways by which
|
731 |
-
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
|
732 |
-
// We'll assume that this is an explicit user action if POST or GET has an 'action' key.
|
733 |
-
if ( isset($_POST['action']) || isset($_GET['action']) ) {
|
734 |
-
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
|
735 |
-
return akismet_submit_spam_comment( $comment->comment_ID );
|
736 |
-
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
|
737 |
-
return akismet_submit_nonspam_comment( $comment->comment_ID );
|
738 |
-
}
|
739 |
-
}
|
740 |
-
|
741 |
-
akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
|
742 |
-
}
|
743 |
-
|
744 |
-
add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
|
745 |
-
|
746 |
-
// Total spam in queue
|
747 |
-
// get_option( 'akismet_spam_count' ) is the total caught ever
|
748 |
-
function akismet_spam_count( $type = false ) {
|
749 |
-
global $wpdb;
|
750 |
-
|
751 |
-
if ( !$type ) { // total
|
752 |
-
$count = wp_cache_get( 'akismet_spam_count', 'widget' );
|
753 |
-
if ( false === $count ) {
|
754 |
-
if ( function_exists('wp_count_comments') ) {
|
755 |
-
$count = wp_count_comments();
|
756 |
-
$count = $count->spam;
|
757 |
-
} else {
|
758 |
-
$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
|
759 |
-
}
|
760 |
-
wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
|
761 |
-
}
|
762 |
-
return $count;
|
763 |
-
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
|
764 |
-
$type = '';
|
765 |
-
} else { // pingback, trackback, ...
|
766 |
-
$type = $wpdb->escape( $type );
|
767 |
-
}
|
768 |
-
|
769 |
-
return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
|
770 |
-
}
|
771 |
-
|
772 |
-
|
773 |
-
function akismet_recheck_queue() {
|
774 |
-
global $wpdb, $akismet_api_host, $akismet_api_port;
|
775 |
-
|
776 |
-
akismet_fix_scheduled_recheck();
|
777 |
-
|
778 |
-
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
|
779 |
-
return;
|
780 |
-
|
781 |
-
$paginate = '';
|
782 |
-
if ( isset( $_POST['limit'] ) && isset( $_POST['offset'] ) ) {
|
783 |
-
$paginate = $wpdb->prepare( " LIMIT %d OFFSET %d", array( $_POST['limit'], $_POST['offset'] ) );
|
784 |
-
}
|
785 |
-
$moderation = $wpdb->get_results( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A );
|
786 |
-
foreach ( (array) $moderation as $c ) {
|
787 |
-
$c['user_ip'] = $c['comment_author_IP'];
|
788 |
-
$c['user_agent'] = $c['comment_agent'];
|
789 |
-
$c['referrer'] = '';
|
790 |
-
$c['blog'] = get_bloginfo('url');
|
791 |
-
$c['blog_lang'] = get_locale();
|
792 |
-
$c['blog_charset'] = get_option('blog_charset');
|
793 |
-
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
794 |
-
|
795 |
-
$c['user_role'] = '';
|
796 |
-
if ( isset( $c['user_ID'] ) )
|
797 |
-
$c['user_role'] = akismet_get_user_roles($c['user_ID']);
|
798 |
-
|
799 |
-
if ( akismet_test_mode() )
|
800 |
-
$c['is_test'] = 'true';
|
801 |
-
|
802 |
-
$id = (int) $c['comment_ID'];
|
803 |
-
|
804 |
-
$query_string = '';
|
805 |
-
foreach ( $c as $key => $data )
|
806 |
-
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
807 |
-
|
808 |
-
add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
|
809 |
-
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
|
810 |
-
if ( 'true' == $response[1] ) {
|
811 |
-
wp_set_comment_status($c['comment_ID'], 'spam');
|
812 |
-
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
|
813 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_error' );
|
814 |
-
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
|
815 |
-
|
816 |
-
} elseif ( 'false' == $response[1] ) {
|
817 |
-
update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
|
818 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_error' );
|
819 |
-
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
|
820 |
-
// abnormal result: error
|
821 |
-
} else {
|
822 |
-
update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
|
823 |
-
akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), substr($response[1], 0, 50)), 'check-error' );
|
824 |
-
}
|
825 |
-
|
826 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
|
827 |
-
}
|
828 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
829 |
-
wp_send_json( array(
|
830 |
-
'processed' => count((array) $moderation),
|
831 |
-
));
|
832 |
-
}
|
833 |
-
else {
|
834 |
-
$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
|
835 |
-
wp_safe_redirect( $redirect_to );
|
836 |
-
exit;
|
837 |
-
}
|
838 |
-
}
|
839 |
-
|
840 |
-
add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
|
841 |
-
add_action('wp_ajax_akismet_recheck_queue', 'akismet_recheck_queue');
|
842 |
-
|
843 |
-
// Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
|
844 |
-
function akismet_remove_comment_author_url() {
|
845 |
-
if ( !empty($_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
|
846 |
-
global $wpdb;
|
847 |
-
$comment = get_comment( intval($_POST['id']), ARRAY_A );
|
848 |
-
if (current_user_can('edit_comment', $comment['comment_ID'])) {
|
849 |
-
$comment['comment_author_url'] = '';
|
850 |
-
do_action( 'comment_remove_author_url' );
|
851 |
-
print(wp_update_comment( $comment ));
|
852 |
-
die();
|
853 |
-
}
|
854 |
-
}
|
855 |
-
}
|
856 |
-
|
857 |
-
add_action('wp_ajax_comment_author_deurl', 'akismet_remove_comment_author_url');
|
858 |
-
|
859 |
-
function akismet_add_comment_author_url() {
|
860 |
-
if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
|
861 |
-
global $wpdb;
|
862 |
-
$comment = get_comment( intval($_POST['id']), ARRAY_A );
|
863 |
-
if (current_user_can('edit_comment', $comment['comment_ID'])) {
|
864 |
-
$comment['comment_author_url'] = esc_url($_POST['url']);
|
865 |
-
do_action( 'comment_add_author_url' );
|
866 |
-
print(wp_update_comment( $comment ));
|
867 |
-
die();
|
868 |
-
}
|
869 |
-
}
|
870 |
-
}
|
871 |
-
|
872 |
-
add_action('wp_ajax_comment_author_reurl', 'akismet_add_comment_author_url');
|
873 |
-
|
874 |
-
// Check connectivity between the WordPress blog and Akismet's servers.
|
875 |
-
// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
|
876 |
-
function akismet_check_server_connectivity() {
|
877 |
-
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
|
878 |
-
|
879 |
-
$test_host = 'rest.akismet.com';
|
880 |
-
|
881 |
-
// Some web hosts may disable one or both functions
|
882 |
-
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
|
883 |
-
return array();
|
884 |
-
|
885 |
-
$ips = gethostbynamel($test_host);
|
886 |
-
if ( !$ips || !is_array($ips) || !count($ips) )
|
887 |
-
return array();
|
888 |
-
|
889 |
-
$servers = array();
|
890 |
-
foreach ( $ips as $ip ) {
|
891 |
-
$response = akismet_verify_key( akismet_get_key(), $ip );
|
892 |
-
// even if the key is invalid, at least we know we have connectivity
|
893 |
-
if ( $response == 'valid' || $response == 'invalid' )
|
894 |
-
$servers[$ip] = true;
|
895 |
-
else
|
896 |
-
$servers[$ip] = false;
|
897 |
-
}
|
898 |
-
|
899 |
-
return $servers;
|
900 |
-
}
|
901 |
-
|
902 |
-
// Check the server connectivity and store the results in an option.
|
903 |
-
// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
|
904 |
-
// Returns the same associative array as akismet_check_server_connectivity()
|
905 |
-
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
|
906 |
-
$servers = get_option('akismet_available_servers');
|
907 |
-
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
|
908 |
-
return $servers;
|
909 |
-
|
910 |
-
// There's a race condition here but the effect is harmless.
|
911 |
-
$servers = akismet_check_server_connectivity();
|
912 |
-
update_option('akismet_available_servers', $servers);
|
913 |
-
update_option('akismet_connectivity_time', time());
|
914 |
-
return $servers;
|
915 |
-
}
|
916 |
-
|
917 |
-
// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
|
918 |
-
function akismet_server_connectivity_ok() {
|
919 |
-
// skip the check on WPMU because the status page is hidden
|
920 |
-
global $wpcom_api_key;
|
921 |
-
if ( $wpcom_api_key )
|
922 |
-
return true;
|
923 |
-
$servers = akismet_get_server_connectivity();
|
924 |
-
return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
|
925 |
-
}
|
926 |
-
|
927 |
-
function akismet_admin_menu() {
|
928 |
-
if ( class_exists( 'Jetpack' ) ) {
|
929 |
-
add_action( 'jetpack_admin_menu', 'akismet_load_menu' );
|
930 |
-
} else {
|
931 |
-
akismet_load_menu();
|
932 |
-
}
|
933 |
-
}
|
934 |
-
|
935 |
-
function akismet_load_menu() {
|
936 |
-
if ( class_exists( 'Jetpack' ) ) {
|
937 |
-
add_submenu_page( 'jetpack', __( 'Akismet' ), __( 'Akismet' ), 'manage_options', 'akismet-key-config', 'akismet_conf' );
|
938 |
-
add_submenu_page( 'jetpack', __( 'Akismet Stats' ), __( 'Akismet Stats' ), 'manage_options', 'akismet-stats-display', 'akismet_stats_display' );
|
939 |
-
} else {
|
940 |
-
add_submenu_page('plugins.php', __('Akismet'), __('Akismet'), 'manage_options', 'akismet-key-config', 'akismet_conf');
|
941 |
-
add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
|
942 |
-
}
|
943 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
akismet.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
#submitted-on{position:relative}#the-comment-list .author .akismet-user-comment-count{display:inline}#the-comment-list .author a span{text-decoration:none;color:#999}#the-comment-list .remove_url{margin-left:3px;color:#999;padding:2px 3px 2px 0}#the-comment-list .remove_url:hover{color:#A7301F;font-weight:bold;padding:2px 2px 2px 0}#dashboard_recent_comments .akismet-status{display:none}.akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}span.comment-link a{text-decoration:underline}span.comment-link:after{content:" "attr(title) " ";color:#aaa;text-decoration:none}.mshot-arrow{width:0;height:0;border-top:10px solid transparent;border-bottom:10px solid transparent;border-right:10px solid #5C5C5C;position:absolute;left:-6px;top:91px}.mshot-container{background:#5C5C5C;position:absolute;top:-94px;padding:7px;width:450px;height:338px;z-index:20000;-moz-border-radius:6px;border-radius:6px;-webkit-border-radius:6px}h2.ak-header{padding-left:38px;background:url('img/logo.png') no-repeat 0 9px;margin-bottom:14px;line-height:32px}.key-status{padding:0.4em 1em;color:#fff;font-weight:bold;text-align:center;-webkit-border-radius:3px;border-radius:3px;border-width:1px;border-style:solid;max-width:23.3em}input#key{width:25.3em !important}input#key.valid{border-color:#4F800D}input#key.invalid,input#key.failed{border-color:#888}.key-status.under-input{margin-top:-5px;padding-bottom:0px}.key-status.invalid,.key-status.failed{background-color:#888}.key-status.valid{background-color:#4F800D}.key-status.some{background-color:#993300}.key-status.empty{display:none}table.network-status th,table.network-status td{padding:0.4em;margin:0;text-align:center}table.network-status{border-color:#dfdfdf;border-width:0 0 1px 1px;border-style:solid;border-spacing:0;width:25.6em}table.network-status th,table.network-status td{border-color:#dfdfdf;border-width:1px 1px 0 0;border-style:solid;margin:0;border-spacing:0}table.network-status td.key-status{border-radius:0px;-webkit-border-radius:0px}.checkforspam{display:inline-block !important;}.checkforspam-spinner{display:none;margin-top:10px;}
|
|
akismet.gif
DELETED
Binary file
|
akismet.php
CHANGED
@@ -6,10 +6,11 @@
|
|
6 |
Plugin Name: Akismet
|
7 |
Plugin URI: http://akismet.com/?return=true
|
8 |
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
|
9 |
-
Version:
|
10 |
Author: Automattic
|
11 |
Author URI: http://automattic.com/wordpress-plugins/
|
12 |
License: GPLv2 or later
|
|
|
13 |
*/
|
14 |
|
15 |
/*
|
@@ -34,667 +35,25 @@ if ( !function_exists( 'add_action' ) ) {
|
|
34 |
exit;
|
35 |
}
|
36 |
|
37 |
-
define('AKISMET_VERSION', '
|
38 |
-
define('
|
39 |
-
define('
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
$wpcom_api_key = constant('WPCOM_API_KEY');
|
44 |
-
else
|
45 |
-
$wpcom_api_key = '';
|
46 |
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
if ( is_admin() )
|
53 |
-
require_once
|
54 |
-
|
55 |
-
function akismet_init() {
|
56 |
-
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
|
57 |
-
|
58 |
-
if ( $wpcom_api_key )
|
59 |
-
$akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
|
60 |
-
else
|
61 |
-
$akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
|
62 |
-
|
63 |
-
$akismet_api_port = 80;
|
64 |
-
}
|
65 |
-
add_action('init', 'akismet_init');
|
66 |
-
|
67 |
-
function akismet_get_key() {
|
68 |
-
global $wpcom_api_key;
|
69 |
-
if ( !empty($wpcom_api_key) )
|
70 |
-
return $wpcom_api_key;
|
71 |
-
return get_option('wordpress_api_key');
|
72 |
-
}
|
73 |
-
|
74 |
-
function akismet_check_key_status( $key, $ip = null ) {
|
75 |
-
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
|
76 |
-
$blog = urlencode( get_option('home') );
|
77 |
-
if ( $wpcom_api_key )
|
78 |
-
$key = $wpcom_api_key;
|
79 |
-
$response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);
|
80 |
-
return $response;
|
81 |
-
}
|
82 |
-
|
83 |
-
// given a response from an API call like akismet_check_key_status(), update the alert code options if an alert is present.
|
84 |
-
function akismet_update_alert( $response ) {
|
85 |
-
$code = $msg = null;
|
86 |
-
if ( isset($response[0]['x-akismet-alert-code']) ) {
|
87 |
-
$code = $response[0]['x-akismet-alert-code'];
|
88 |
-
$msg = $response[0]['x-akismet-alert-msg'];
|
89 |
-
}
|
90 |
-
|
91 |
-
// only call update_option() if the value has changed
|
92 |
-
if ( $code != get_option( 'akismet_alert_code' ) ) {
|
93 |
-
update_option( 'akismet_alert_code', $code );
|
94 |
-
update_option( 'akismet_alert_msg', $msg );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
function akismet_verify_key( $key, $ip = null ) {
|
99 |
-
$response = akismet_check_key_status( $key, $ip );
|
100 |
-
akismet_update_alert( $response );
|
101 |
-
if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )
|
102 |
-
return 'failed';
|
103 |
-
return $response[1];
|
104 |
-
}
|
105 |
-
|
106 |
-
// if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
|
107 |
-
function akismet_test_mode() {
|
108 |
-
if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
|
109 |
-
return true;
|
110 |
-
return false;
|
111 |
-
}
|
112 |
-
|
113 |
-
// return a comma-separated list of role names for the given user
|
114 |
-
function akismet_get_user_roles( $user_id ) {
|
115 |
-
$roles = false;
|
116 |
-
|
117 |
-
if ( !class_exists('WP_User') )
|
118 |
-
return false;
|
119 |
-
|
120 |
-
if ( $user_id > 0 ) {
|
121 |
-
$comment_user = new WP_User($user_id);
|
122 |
-
if ( isset($comment_user->roles) )
|
123 |
-
$roles = join(',', $comment_user->roles);
|
124 |
-
}
|
125 |
-
|
126 |
-
if ( is_multisite() && is_super_admin( $user_id ) ) {
|
127 |
-
if ( empty( $roles ) ) {
|
128 |
-
$roles = 'super_admin';
|
129 |
-
} else {
|
130 |
-
$comment_user->roles[] = 'super_admin';
|
131 |
-
$roles = join( ',', $comment_user->roles );
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
return $roles;
|
136 |
-
}
|
137 |
-
|
138 |
-
// Returns array with headers in $response[0] and body in $response[1]
|
139 |
-
function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
|
140 |
-
global $wp_version;
|
141 |
-
|
142 |
-
$akismet_ua = "WordPress/{$wp_version} | ";
|
143 |
-
$akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
|
144 |
-
|
145 |
-
$akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
|
146 |
-
|
147 |
-
$content_length = strlen( $request );
|
148 |
-
|
149 |
-
$http_host = $host;
|
150 |
-
// use a specific IP if provided
|
151 |
-
// needed by akismet_check_server_connectivity()
|
152 |
-
if ( $ip && long2ip( ip2long( $ip ) ) ) {
|
153 |
-
$http_host = $ip;
|
154 |
-
} else {
|
155 |
-
$http_host = $host;
|
156 |
-
}
|
157 |
-
|
158 |
-
// use the WP HTTP class if it is available
|
159 |
-
if ( function_exists( 'wp_remote_post' ) ) {
|
160 |
-
$http_args = array(
|
161 |
-
'body' => $request,
|
162 |
-
'headers' => array(
|
163 |
-
'Content-Type' => 'application/x-www-form-urlencoded; ' .
|
164 |
-
'charset=' . get_option( 'blog_charset' ),
|
165 |
-
'Host' => $host,
|
166 |
-
'User-Agent' => $akismet_ua
|
167 |
-
),
|
168 |
-
'httpversion' => '1.0',
|
169 |
-
'timeout' => 15
|
170 |
-
);
|
171 |
-
$akismet_url = "http://{$http_host}{$path}";
|
172 |
-
$response = wp_remote_post( $akismet_url, $http_args );
|
173 |
-
if ( is_wp_error( $response ) )
|
174 |
-
return '';
|
175 |
-
|
176 |
-
return array( $response['headers'], $response['body'] );
|
177 |
-
} else {
|
178 |
-
$http_request = "POST $path HTTP/1.0\r\n";
|
179 |
-
$http_request .= "Host: $host\r\n";
|
180 |
-
$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
|
181 |
-
$http_request .= "Content-Length: {$content_length}\r\n";
|
182 |
-
$http_request .= "User-Agent: {$akismet_ua}\r\n";
|
183 |
-
$http_request .= "\r\n";
|
184 |
-
$http_request .= $request;
|
185 |
-
|
186 |
-
$response = '';
|
187 |
-
if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
|
188 |
-
fwrite( $fs, $http_request );
|
189 |
-
|
190 |
-
while ( !feof( $fs ) )
|
191 |
-
$response .= fgets( $fs, 1160 ); // One TCP-IP packet
|
192 |
-
fclose( $fs );
|
193 |
-
$response = explode( "\r\n\r\n", $response, 2 );
|
194 |
-
}
|
195 |
-
return $response;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
// filter handler used to return a spam result to pre_comment_approved
|
200 |
-
function akismet_result_spam( $approved ) {
|
201 |
-
static $just_once = false;
|
202 |
-
if ( $just_once )
|
203 |
-
return $approved;
|
204 |
-
|
205 |
-
// bump the counter here instead of when the filter is added to reduce the possibility of overcounting
|
206 |
-
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
207 |
-
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
208 |
-
|
209 |
-
// this is a one-shot deal
|
210 |
-
$just_once = true;
|
211 |
-
return 'spam';
|
212 |
-
}
|
213 |
-
|
214 |
-
function akismet_result_hold( $approved ) {
|
215 |
-
static $just_once = false;
|
216 |
-
if ( $just_once )
|
217 |
-
return $approved;
|
218 |
-
|
219 |
-
// once only
|
220 |
-
$just_once = true;
|
221 |
-
return '0';
|
222 |
-
}
|
223 |
-
|
224 |
-
// how many approved comments does this author have?
|
225 |
-
function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
226 |
-
global $wpdb;
|
227 |
-
|
228 |
-
if ( !empty($user_id) )
|
229 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
|
230 |
-
|
231 |
-
if ( !empty($comment_author_email) )
|
232 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
|
233 |
-
|
234 |
-
return 0;
|
235 |
-
}
|
236 |
-
|
237 |
-
function akismet_microtime() {
|
238 |
-
$mtime = explode( ' ', microtime() );
|
239 |
-
return $mtime[1] + $mtime[0];
|
240 |
-
}
|
241 |
-
|
242 |
-
// log an event for a given comment, storing it in comment_meta
|
243 |
-
function akismet_update_comment_history( $comment_id, $message, $event=null ) {
|
244 |
-
global $current_user;
|
245 |
-
|
246 |
-
// failsafe for old WP versions
|
247 |
-
if ( !function_exists('add_comment_meta') )
|
248 |
-
return false;
|
249 |
-
|
250 |
-
$user = '';
|
251 |
-
if ( is_object($current_user) && isset($current_user->user_login) )
|
252 |
-
$user = $current_user->user_login;
|
253 |
-
|
254 |
-
$event = array(
|
255 |
-
'time' => akismet_microtime(),
|
256 |
-
'message' => $message,
|
257 |
-
'event' => $event,
|
258 |
-
'user' => $user,
|
259 |
-
);
|
260 |
-
|
261 |
-
// $unique = false so as to allow multiple values per comment
|
262 |
-
$r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
|
263 |
-
}
|
264 |
-
|
265 |
-
// get the full comment history for a given comment, as an array in reverse chronological order
|
266 |
-
function akismet_get_comment_history( $comment_id ) {
|
267 |
-
|
268 |
-
// failsafe for old WP versions
|
269 |
-
if ( !function_exists('add_comment_meta') )
|
270 |
-
return false;
|
271 |
-
|
272 |
-
$history = get_comment_meta( $comment_id, 'akismet_history', false );
|
273 |
-
usort( $history, 'akismet_cmp_time' );
|
274 |
-
return $history;
|
275 |
-
}
|
276 |
-
|
277 |
-
function akismet_cmp_time( $a, $b ) {
|
278 |
-
return $a['time'] > $b['time'] ? -1 : 1;
|
279 |
-
}
|
280 |
-
|
281 |
-
// this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
|
282 |
-
// because we don't know the comment ID at that point.
|
283 |
-
function akismet_auto_check_update_meta( $id, $comment ) {
|
284 |
-
global $akismet_last_comment;
|
285 |
-
|
286 |
-
// failsafe for old WP versions
|
287 |
-
if ( !function_exists('add_comment_meta') )
|
288 |
-
return false;
|
289 |
-
|
290 |
-
if ( !isset( $akismet_last_comment['comment_author_email'] ) )
|
291 |
-
$akismet_last_comment['comment_author_email'] = '';
|
292 |
-
|
293 |
-
// wp_insert_comment() might be called in other contexts, so make sure this is the same comment
|
294 |
-
// as was checked by akismet_auto_check_comment
|
295 |
-
if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
|
296 |
-
if ( isset($akismet_last_comment['comment_post_ID']) && intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
|
297 |
-
&& $akismet_last_comment['comment_author'] == $comment->comment_author
|
298 |
-
&& $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
|
299 |
-
// normal result: true or false
|
300 |
-
if ( $akismet_last_comment['akismet_result'] == 'true' ) {
|
301 |
-
update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
|
302 |
-
akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
|
303 |
-
if ( $comment->comment_approved != 'spam' )
|
304 |
-
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
|
305 |
-
} elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
|
306 |
-
update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
|
307 |
-
akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
|
308 |
-
if ( $comment->comment_approved == 'spam' ) {
|
309 |
-
if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
|
310 |
-
akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
|
311 |
-
else
|
312 |
-
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
|
313 |
-
}
|
314 |
-
// abnormal result: error
|
315 |
-
} else {
|
316 |
-
update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
|
317 |
-
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), substr($akismet_last_comment['akismet_result'], 0, 50)), 'check-error' );
|
318 |
-
}
|
319 |
-
|
320 |
-
// record the complete original data as submitted for checking
|
321 |
-
if ( isset($akismet_last_comment['comment_as_submitted']) )
|
322 |
-
update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
|
323 |
-
}
|
324 |
-
}
|
325 |
-
}
|
326 |
-
|
327 |
-
add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
|
328 |
-
|
329 |
-
|
330 |
-
function akismet_auto_check_comment( $commentdata ) {
|
331 |
-
global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
|
332 |
-
|
333 |
-
$comment = $commentdata;
|
334 |
-
$comment['user_ip'] = akismet_get_ip_address();
|
335 |
-
$comment['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
336 |
-
$comment['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
|
337 |
-
$comment['blog'] = get_option('home');
|
338 |
-
$comment['blog_lang'] = get_locale();
|
339 |
-
$comment['blog_charset'] = get_option('blog_charset');
|
340 |
-
$comment['permalink'] = get_permalink($comment['comment_post_ID']);
|
341 |
-
|
342 |
-
if ( !empty( $comment['user_ID'] ) ) {
|
343 |
-
$comment['user_role'] = akismet_get_user_roles( $comment['user_ID'] );
|
344 |
-
}
|
345 |
-
|
346 |
-
$akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
347 |
-
$comment['akismet_comment_nonce'] = 'inactive';
|
348 |
-
if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
|
349 |
-
$comment['akismet_comment_nonce'] = 'failed';
|
350 |
-
if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
|
351 |
-
$comment['akismet_comment_nonce'] = 'passed';
|
352 |
-
|
353 |
-
// comment reply in wp-admin
|
354 |
-
if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
|
355 |
-
$comment['akismet_comment_nonce'] = 'passed';
|
356 |
-
|
357 |
-
}
|
358 |
-
|
359 |
-
if ( akismet_test_mode() )
|
360 |
-
$comment['is_test'] = 'true';
|
361 |
-
|
362 |
-
foreach ($_POST as $key => $value ) {
|
363 |
-
if ( is_string($value) )
|
364 |
-
$comment["POST_{$key}"] = $value;
|
365 |
-
}
|
366 |
-
|
367 |
-
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
|
368 |
-
|
369 |
-
foreach ( $_SERVER as $key => $value ) {
|
370 |
-
if ( !in_array( $key, $ignore ) && is_string($value) )
|
371 |
-
$comment["$key"] = $value;
|
372 |
-
else
|
373 |
-
$comment["$key"] = '';
|
374 |
-
}
|
375 |
-
|
376 |
-
$post = get_post( $comment['comment_post_ID'] );
|
377 |
-
$comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
|
378 |
-
|
379 |
-
$query_string = '';
|
380 |
-
foreach ( $comment as $key => $data )
|
381 |
-
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
382 |
-
|
383 |
-
$commentdata['comment_as_submitted'] = $comment;
|
384 |
-
|
385 |
-
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
|
386 |
-
do_action( 'akismet_comment_check_response', $response );
|
387 |
-
akismet_update_alert( $response );
|
388 |
-
$commentdata['akismet_result'] = $response[1];
|
389 |
-
if ( 'true' == $response[1] ) {
|
390 |
-
// akismet_spam_count will be incremented later by akismet_result_spam()
|
391 |
-
add_filter('pre_comment_approved', 'akismet_result_spam');
|
392 |
-
|
393 |
-
do_action( 'akismet_spam_caught' );
|
394 |
-
|
395 |
-
$last_updated = strtotime( $post->post_modified_gmt );
|
396 |
-
$diff = time() - $last_updated;
|
397 |
-
$diff = $diff / 86400;
|
398 |
-
|
399 |
-
if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' && empty($comment['user_ID']) ) {
|
400 |
-
// akismet_result_spam() won't be called so bump the counter here
|
401 |
-
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
402 |
-
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
403 |
-
$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
|
404 |
-
wp_safe_redirect( $redirect_to );
|
405 |
-
die();
|
406 |
-
}
|
407 |
-
}
|
408 |
-
|
409 |
-
// if the response is neither true nor false, hold the comment for moderation and schedule a recheck
|
410 |
-
if ( 'true' != $response[1] && 'false' != $response[1] ) {
|
411 |
-
if ( !current_user_can('moderate_comments') ) {
|
412 |
-
add_filter('pre_comment_approved', 'akismet_result_hold');
|
413 |
-
}
|
414 |
-
if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
|
415 |
-
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
|
420 |
-
// WP 2.1+: delete old comments daily
|
421 |
-
if ( !wp_next_scheduled('akismet_scheduled_delete') )
|
422 |
-
wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete');
|
423 |
-
} elseif ( (mt_rand(1, 10) == 3) ) {
|
424 |
-
// WP 2.0: run this one time in ten
|
425 |
-
akismet_delete_old();
|
426 |
-
}
|
427 |
-
$akismet_last_comment = $commentdata;
|
428 |
-
|
429 |
-
akismet_fix_scheduled_recheck();
|
430 |
-
return $commentdata;
|
431 |
-
}
|
432 |
-
|
433 |
-
add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
|
434 |
-
|
435 |
-
function akismet_get_ip_address() {
|
436 |
-
foreach( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
|
437 |
-
if ( array_key_exists( $key, $_SERVER ) === true ) {
|
438 |
-
foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
|
439 |
-
$ip = trim($ip);
|
440 |
-
|
441 |
-
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
|
442 |
-
return $ip;
|
443 |
-
}
|
444 |
-
}
|
445 |
-
}
|
446 |
-
}
|
447 |
-
return null;
|
448 |
-
}
|
449 |
-
|
450 |
-
function akismet_delete_old() {
|
451 |
-
global $wpdb;
|
452 |
-
|
453 |
-
while( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", defined( 'AKISMET_DELETE_LIMIT' ) ? AKISMET_DELETE_LIMIT : 10000 ) ) ) {
|
454 |
-
if ( empty( $comment_ids ) )
|
455 |
-
return;
|
456 |
-
|
457 |
-
$wpdb->queries = array();
|
458 |
-
|
459 |
-
do_action( 'delete_comment', $comment_ids );
|
460 |
-
|
461 |
-
$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
|
462 |
-
|
463 |
-
$wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( $comma_comment_ids )");
|
464 |
-
$wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( $comma_comment_ids )");
|
465 |
-
|
466 |
-
clean_comment_cache( $comment_ids );
|
467 |
-
}
|
468 |
-
|
469 |
-
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11) ) ) // lucky number
|
470 |
-
$wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
|
471 |
-
}
|
472 |
-
|
473 |
-
function akismet_delete_old_metadata() {
|
474 |
-
global $wpdb;
|
475 |
-
|
476 |
-
$interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
|
477 |
-
|
478 |
-
# enfore a minimum of 1 day
|
479 |
-
$interval = absint( $interval );
|
480 |
-
if ( $interval < 1 )
|
481 |
-
$interval = 1;
|
482 |
-
|
483 |
-
// akismet_as_submitted meta values are large, so expire them
|
484 |
-
// after $interval days regardless of the comment status
|
485 |
-
while ( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT m.comment_id FROM {$wpdb->commentmeta} as m INNER JOIN {$wpdb->comments} as c USING(comment_id) WHERE m.meta_key = 'akismet_as_submitted' AND DATE_SUB(NOW(), INTERVAL %d DAY) > c.comment_date_gmt LIMIT 10000", $interval ) ) ) {
|
486 |
-
if ( empty( $comment_ids ) )
|
487 |
-
return;
|
488 |
-
|
489 |
-
$wpdb->queries = array();
|
490 |
-
|
491 |
-
foreach ( $comment_ids as $comment_id ) {
|
492 |
-
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
|
493 |
-
}
|
494 |
-
}
|
495 |
-
|
496 |
-
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11) ) ) // lucky number
|
497 |
-
$wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
|
498 |
}
|
499 |
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
|
504 |
-
global $wpdb, $akismet_api_host, $akismet_api_port;
|
505 |
-
|
506 |
-
$id = (int) $id;
|
507 |
-
$c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
|
508 |
-
if ( !$c )
|
509 |
-
return;
|
510 |
-
|
511 |
-
$c['user_ip'] = $c['comment_author_IP'];
|
512 |
-
$c['user_agent'] = $c['comment_agent'];
|
513 |
-
$c['referrer'] = '';
|
514 |
-
$c['blog'] = get_option('home');
|
515 |
-
$c['blog_lang'] = get_locale();
|
516 |
-
$c['blog_charset'] = get_option('blog_charset');
|
517 |
-
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
518 |
-
$id = $c['comment_ID'];
|
519 |
-
if ( akismet_test_mode() )
|
520 |
-
$c['is_test'] = 'true';
|
521 |
-
$c['recheck_reason'] = $recheck_reason;
|
522 |
-
|
523 |
-
$query_string = '';
|
524 |
-
foreach ( $c as $key => $data )
|
525 |
-
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
526 |
-
|
527 |
-
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
|
528 |
-
return ( is_array( $response ) && isset( $response[1] ) ) ? $response[1] : false;
|
529 |
-
}
|
530 |
|
531 |
-
function akismet_cron_recheck() {
|
532 |
-
global $wpdb;
|
533 |
-
|
534 |
-
$status = akismet_verify_key( akismet_get_key() );
|
535 |
-
if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
|
536 |
-
// since there is currently a problem with the key, reschedule a check for 6 hours hence
|
537 |
-
wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
|
538 |
-
return false;
|
539 |
-
}
|
540 |
-
|
541 |
-
delete_option('akismet_available_servers');
|
542 |
-
|
543 |
-
$comment_errors = $wpdb->get_col( "
|
544 |
-
SELECT comment_id
|
545 |
-
FROM {$wpdb->prefix}commentmeta
|
546 |
-
WHERE meta_key = 'akismet_error'
|
547 |
-
LIMIT 100
|
548 |
-
" );
|
549 |
-
|
550 |
-
foreach ( (array) $comment_errors as $comment_id ) {
|
551 |
-
// if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
|
552 |
-
$comment = get_comment( $comment_id );
|
553 |
-
if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
|
554 |
-
delete_comment_meta( $comment_id, 'akismet_error' );
|
555 |
-
continue;
|
556 |
-
}
|
557 |
-
|
558 |
-
add_comment_meta( $comment_id, 'akismet_rechecking', true );
|
559 |
-
$status = akismet_check_db_comment( $comment_id, 'retry' );
|
560 |
-
|
561 |
-
$msg = '';
|
562 |
-
if ( $status == 'true' ) {
|
563 |
-
$msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
|
564 |
-
} elseif ( $status == 'false' ) {
|
565 |
-
$msg = __( 'Akismet cleared this comment during an automatic retry.' );
|
566 |
-
}
|
567 |
-
|
568 |
-
// If we got back a legit response then update the comment history
|
569 |
-
// other wise just bail now and try again later. No point in
|
570 |
-
// re-trying all the comments once we hit one failure.
|
571 |
-
if ( !empty( $msg ) ) {
|
572 |
-
delete_comment_meta( $comment_id, 'akismet_error' );
|
573 |
-
akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
|
574 |
-
update_comment_meta( $comment_id, 'akismet_result', $status );
|
575 |
-
// make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
|
576 |
-
$comment = get_comment( $comment_id );
|
577 |
-
if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
|
578 |
-
if ( $status == 'true' ) {
|
579 |
-
wp_spam_comment( $comment_id );
|
580 |
-
} elseif ( $status == 'false' ) {
|
581 |
-
// comment is good, but it's still in the pending queue. depending on the moderation settings
|
582 |
-
// we may need to change it to approved.
|
583 |
-
if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
|
584 |
-
wp_set_comment_status( $comment_id, 1 );
|
585 |
-
}
|
586 |
-
}
|
587 |
-
} else {
|
588 |
-
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
589 |
-
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
590 |
-
return;
|
591 |
-
}
|
592 |
-
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
593 |
-
}
|
594 |
-
|
595 |
-
$remaining = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" );
|
596 |
-
if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
|
597 |
-
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
598 |
-
}
|
599 |
-
}
|
600 |
-
add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
|
601 |
-
|
602 |
-
function akismet_add_comment_nonce( $post_id ) {
|
603 |
-
echo '<p style="display: none;">';
|
604 |
-
wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
|
605 |
-
echo '</p>';
|
606 |
-
}
|
607 |
-
|
608 |
-
$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
609 |
-
|
610 |
-
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
|
611 |
-
add_action( 'comment_form', 'akismet_add_comment_nonce' );
|
612 |
-
|
613 |
-
function akismet_pingback_forwarded_for( $r, $url ) {
|
614 |
-
static $urls = array();
|
615 |
-
|
616 |
-
// Call this with $r == null to prime the callback to add headers on a specific URL
|
617 |
-
if ( is_null( $r ) && !in_array( $url, $urls ) ) {
|
618 |
-
$urls[] = $url;
|
619 |
-
}
|
620 |
-
|
621 |
-
// Add X-Pingback-Forwarded-For header, but only for requests to a specific URL (the apparent pingback source)
|
622 |
-
if ( is_array( $r ) && is_array( $r['headers'] ) && !isset( $r['headers']['X-Pingback-Forwarded-For'] ) && in_array( $url, $urls ) ) {
|
623 |
-
$remote_ip = preg_replace( '/[^a-fx0-9:.,]/i', '', $_SERVER['REMOTE_ADDR'] );
|
624 |
-
|
625 |
-
// Note: this assumes REMOTE_ADDR is correct, and it may not be if a reverse proxy or CDN is in use
|
626 |
-
$r['headers']['X-Pingback-Forwarded-For'] = $remote_ip;
|
627 |
-
|
628 |
-
// Also identify the request as a pingback verification in the UA string so it appears in logs
|
629 |
-
$r['user-agent'] .= '; verifying pingback from ' . $remote_ip;
|
630 |
-
}
|
631 |
-
|
632 |
-
return $r;
|
633 |
-
}
|
634 |
-
|
635 |
-
function akismet_pre_check_pingback( $method ) {
|
636 |
-
|
637 |
-
if ( $method !== 'pingback.ping' )
|
638 |
-
return;
|
639 |
-
|
640 |
-
global $wp_xmlrpc_server;
|
641 |
-
|
642 |
-
if ( !is_object( $wp_xmlrpc_server ) )
|
643 |
-
return false;
|
644 |
-
|
645 |
-
// Lame: tightly coupled with the IXR class.
|
646 |
-
$args = $wp_xmlrpc_server->message->params;
|
647 |
-
|
648 |
-
if ( !empty( $args[1] ) ) {
|
649 |
-
$post_id = url_to_postid( $args[1] );
|
650 |
-
|
651 |
-
// If this gets through the pre-check, make sure we properly identify the outbound request as a pingback verification
|
652 |
-
akismet_pingback_forwarded_for( null, $args[0] );
|
653 |
-
add_filter( 'http_request_args', 'akismet_pingback_forwarded_for', 10, 2 );
|
654 |
-
|
655 |
-
$comment = array(
|
656 |
-
'comment_author_url' => $args[0],
|
657 |
-
'comment_post_ID' => $post_id,
|
658 |
-
'comment_author' => '',
|
659 |
-
'comment_author_email' => '',
|
660 |
-
'comment_content' => '',
|
661 |
-
'comment_type' => 'pingback',
|
662 |
-
'akismet_pre_check' => '1',
|
663 |
-
'comment_pingback_target' => $args[1],
|
664 |
-
);
|
665 |
-
|
666 |
-
$comment = akismet_auto_check_comment( $comment );
|
667 |
-
|
668 |
-
if ( isset( $comment['akismet_result'] ) && 'true' == $comment['akismet_result'] ) {
|
669 |
-
// Lame: tightly coupled with the IXR classes. Unfortunately the action provides no context and no way to return anything.
|
670 |
-
$wp_xmlrpc_server->error( new IXR_Error( 0, 'Invalid discovery target' ) );
|
671 |
-
}
|
672 |
-
}
|
673 |
-
}
|
674 |
-
|
675 |
-
// Run this early in the pingback call, before doing a remote fetch of the source uri
|
676 |
-
add_action( 'xmlrpc_call', 'akismet_pre_check_pingback' );
|
677 |
-
|
678 |
-
global $wp_version;
|
679 |
-
if ( '3.0.5' == $wp_version ) {
|
680 |
-
remove_filter( 'comment_text', 'wp_kses_data' );
|
681 |
-
if ( is_admin() )
|
682 |
-
add_filter( 'comment_text', 'wp_kses_post' );
|
683 |
-
}
|
684 |
-
|
685 |
-
function akismet_fix_scheduled_recheck() {
|
686 |
-
$future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
|
687 |
-
if ( !$future_check ) {
|
688 |
-
return;
|
689 |
-
}
|
690 |
-
|
691 |
-
if ( get_option( 'akismet_alert_code' ) > 0 ) {
|
692 |
-
return;
|
693 |
-
}
|
694 |
-
|
695 |
-
$check_range = time() + 1200;
|
696 |
-
if ( $future_check > $check_range ) {
|
697 |
-
wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
|
698 |
-
wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
|
699 |
-
}
|
700 |
-
}
|
6 |
Plugin Name: Akismet
|
7 |
Plugin URI: http://akismet.com/?return=true
|
8 |
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
|
9 |
+
Version: 3.0-beta
|
10 |
Author: Automattic
|
11 |
Author URI: http://automattic.com/wordpress-plugins/
|
12 |
License: GPLv2 or later
|
13 |
+
Text Domain: akismet
|
14 |
*/
|
15 |
|
16 |
/*
|
35 |
exit;
|
36 |
}
|
37 |
|
38 |
+
define( 'AKISMET_VERSION', '3.0-beta' );
|
39 |
+
define( 'AKISMET__MINIMUM_WP_VERSION', '3.0' );
|
40 |
+
define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
41 |
+
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
42 |
+
define( 'AKISMET_DELETE_LIMIT', 100000 );
|
43 |
|
44 |
+
register_activation_hook( __FILE__, array( 'Akismet', 'plugin_activation' ) );
|
45 |
+
register_deactivation_hook( __FILE__, array( 'Akismet', 'plugin_deactivation' ) );
|
|
|
|
|
|
|
46 |
|
47 |
+
require_once( AKISMET__PLUGIN_DIR . 'class.akismet.php' );
|
48 |
+
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-widget.php' );
|
49 |
|
50 |
+
add_action( 'init', array( 'Akismet', 'init' ) );
|
51 |
|
52 |
+
if ( is_admin() ) {
|
53 |
+
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-admin.php' );
|
54 |
+
add_action( 'init', array( 'Akismet_Admin', 'init' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
+
//add wrapper class around deprecated akismet functions that are referenced elsewhere
|
58 |
+
require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class.akismet-admin.php
ADDED
@@ -0,0 +1,952 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Akismet_Admin {
|
4 |
+
const NONCE = 'akismet-update-key';
|
5 |
+
|
6 |
+
private static $initiated = false;
|
7 |
+
private static $notices = array();
|
8 |
+
|
9 |
+
public static function init() {
|
10 |
+
if ( ! self::$initiated ) {
|
11 |
+
self::init_hooks();
|
12 |
+
}
|
13 |
+
|
14 |
+
if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) {
|
15 |
+
self::enter_api_key();
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function init_hooks() {
|
20 |
+
// The standalone stats page was removed in 3.0 for an all-in-one config and stats page.
|
21 |
+
// Redirect any links that might have been bookmarked or in browser history.
|
22 |
+
if ( isset( $_GET['page'] ) && 'akismet-stats-display' == $_GET['page'] ) {
|
23 |
+
wp_safe_redirect( esc_url_raw( self::get_page_url( 'stats' ) ), 301 );
|
24 |
+
die;
|
25 |
+
}
|
26 |
+
|
27 |
+
self::$initiated = true;
|
28 |
+
|
29 |
+
add_action( 'admin_init', array( 'Akismet_Admin', 'admin_init' ) );
|
30 |
+
add_action( 'admin_menu', array( 'Akismet_Admin', 'admin_menu' ), 5 ); # Priority 5, so it's called before Jetpack's admin_menu.
|
31 |
+
add_action( 'admin_notices', array( 'Akismet_Admin', 'display_notice' ) );
|
32 |
+
add_action( 'admin_enqueue_scripts', array( 'Akismet_Admin', 'load_resources' ) );
|
33 |
+
add_action( 'activity_box_end', array( 'Akismet_Admin', 'dashboard_stats' ) );
|
34 |
+
add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) );
|
35 |
+
add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) );
|
36 |
+
add_action( 'transition_comment_status', array( 'Akismet_Admin', 'transition_comment_status' ), 10, 3 );
|
37 |
+
add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
38 |
+
add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
39 |
+
add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
|
40 |
+
add_action( 'wp_ajax_comment_author_reurl', array( 'Akismet_Admin', 'add_comment_author_url' ) );
|
41 |
+
|
42 |
+
add_filter( 'plugin_action_links', array( 'Akismet_Admin', 'plugin_action_links' ), 10, 2 );
|
43 |
+
add_filter( 'comment_row_actions', array( 'Akismet_Admin', 'comment_row_action' ), 10, 2 );
|
44 |
+
add_filter( 'comment_text', array( 'Akismet_Admin', 'text_add_link_class' ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
public static function admin_init() {
|
48 |
+
load_plugin_textdomain( 'akismet' );
|
49 |
+
add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
|
50 |
+
}
|
51 |
+
|
52 |
+
public static function admin_menu() {
|
53 |
+
if ( class_exists( 'Jetpack' ) )
|
54 |
+
add_action( 'jetpack_admin_menu', array( 'Akismet_Admin', 'load_menu' ) );
|
55 |
+
else
|
56 |
+
self::load_menu();
|
57 |
+
}
|
58 |
+
|
59 |
+
public static function admin_head() {
|
60 |
+
if ( !current_user_can( 'manage_options' ) )
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
public static function load_menu() {
|
65 |
+
if ( class_exists( 'Jetpack' ) )
|
66 |
+
$hook = add_submenu_page( 'jetpack', __( 'Akismet' , 'akismet'), __( 'Akismet' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
|
67 |
+
else
|
68 |
+
$hook = add_options_page( __('Akismet', 'akismet'), __('Akismet', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
|
69 |
+
|
70 |
+
if ( version_compare( $GLOBALS['wp_version'], '3.3', '>=' ) ) {
|
71 |
+
add_action( "load-$hook", array( 'Akismet_Admin', 'admin_help' ) );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
public static function load_resources() {
|
76 |
+
global $hook_suffix;
|
77 |
+
|
78 |
+
if ( in_array( $hook_suffix, array(
|
79 |
+
'index.php', # dashboard
|
80 |
+
'edit-comments.php',
|
81 |
+
'comment.php',
|
82 |
+
'post.php',
|
83 |
+
'settings_page_akismet-key-config',
|
84 |
+
'jetpack_page_akismet-key-config',
|
85 |
+
) ) ) {
|
86 |
+
wp_register_style( 'akismet.css', AKISMET__PLUGIN_URL . '_inc/akismet.css', array(), AKISMET_VERSION );
|
87 |
+
wp_enqueue_style( 'akismet.css');
|
88 |
+
|
89 |
+
wp_register_script( 'akismet.js', AKISMET__PLUGIN_URL . '_inc/akismet.js', array('jquery','postbox'), AKISMET_VERSION );
|
90 |
+
wp_enqueue_script( 'akismet.js' );
|
91 |
+
wp_localize_script( 'akismet.js', 'WPAkismet', array(
|
92 |
+
'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
|
93 |
+
'strings' => array(
|
94 |
+
'Remove this URL' => __( 'Remove this URL' , 'akismet'),
|
95 |
+
'Removing...' => __( 'Removing...' , 'akismet'),
|
96 |
+
'URL removed' => __( 'URL removed' , 'akismet'),
|
97 |
+
'(undo)' => __( '(undo)' , 'akismet'),
|
98 |
+
'Re-adding...' => __( 'Re-adding...' , 'akismet'),
|
99 |
+
)
|
100 |
+
) );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Add help to the Akismet page
|
106 |
+
*
|
107 |
+
* @return false if not the Akismet page
|
108 |
+
*/
|
109 |
+
public static function admin_help() {
|
110 |
+
$current_screen = get_current_screen();
|
111 |
+
|
112 |
+
// Screen Content
|
113 |
+
if ( current_user_can( 'manage_options' ) ) {
|
114 |
+
if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) ) {
|
115 |
+
//setup page
|
116 |
+
$current_screen->add_help_tab(
|
117 |
+
array(
|
118 |
+
'id' => 'overview',
|
119 |
+
'title' => __( 'Overview' , 'akismet'),
|
120 |
+
'content' =>
|
121 |
+
'<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
|
122 |
+
'<p>' . esc_html__( 'Akismet filters out your comment and trackback spam for you, so you can focus on more important things.' , 'akismet') . '</p>' .
|
123 |
+
'<p>' . esc_html__( 'On this page, you are able to setup the Akismet plugin.' , 'akismet') . '</p>',
|
124 |
+
)
|
125 |
+
);
|
126 |
+
|
127 |
+
$current_screen->add_help_tab(
|
128 |
+
array(
|
129 |
+
'id' => 'setup-signup',
|
130 |
+
'title' => __( 'New to Akismet' , 'akismet'),
|
131 |
+
'content' =>
|
132 |
+
'<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
|
133 |
+
'<p>' . esc_html__( 'You need to enter an API key to activate the Akismet service on your site.' , 'akismet') . '</p>' .
|
134 |
+
'<p>' . sprintf( __( 'Signup for an account on %s to get an API Key.' , 'akismet'), '<a href="https://akismet.com/plugin-signup/" target="_blank">Akismet.com</a>' ) . '</p>',
|
135 |
+
)
|
136 |
+
);
|
137 |
+
|
138 |
+
$current_screen->add_help_tab(
|
139 |
+
array(
|
140 |
+
'id' => 'setup-manual',
|
141 |
+
'title' => __( 'Enter an API Key' , 'akismet'),
|
142 |
+
'content' =>
|
143 |
+
'<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
|
144 |
+
'<p>' . esc_html__( 'If you already have an API key' , 'akismet') . '</p>' .
|
145 |
+
'<ol>' .
|
146 |
+
'<li>' . esc_html__( 'Copy and paste the API key into the text field.' , 'akismet') . '</li>' .
|
147 |
+
'<li>' . esc_html__( 'Click the Use this Key button.' , 'akismet') . '</li>' .
|
148 |
+
'</ol>',
|
149 |
+
)
|
150 |
+
);
|
151 |
+
}
|
152 |
+
elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' ) {
|
153 |
+
//stats page
|
154 |
+
$current_screen->add_help_tab(
|
155 |
+
array(
|
156 |
+
'id' => 'overview',
|
157 |
+
'title' => __( 'Overview' , 'akismet'),
|
158 |
+
'content' =>
|
159 |
+
'<p><strong>' . esc_html__( 'Akismet Stats' , 'akismet') . '</strong></p>' .
|
160 |
+
'<p>' . esc_html__( 'Akismet filters out your comment and trackback spam for you, so you can focus on more important things.' , 'akismet') . '</p>' .
|
161 |
+
'<p>' . esc_html__( 'On this page, you are able to view stats on spam filtered on your site.' , 'akismet') . '</p>',
|
162 |
+
)
|
163 |
+
);
|
164 |
+
}
|
165 |
+
else {
|
166 |
+
//configuration page
|
167 |
+
$current_screen->add_help_tab(
|
168 |
+
array(
|
169 |
+
'id' => 'overview',
|
170 |
+
'title' => __( 'Overview' , 'akismet'),
|
171 |
+
'content' =>
|
172 |
+
'<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
|
173 |
+
'<p>' . esc_html__( 'Akismet filters out your comment and trackback spam for you, so you can focus on more important things.' , 'akismet') . '</p>' .
|
174 |
+
'<p>' . esc_html__( 'On this page, you are able to enter/remove an API key, view account information and view spam stats.' , 'akismet') . '</p>',
|
175 |
+
)
|
176 |
+
);
|
177 |
+
|
178 |
+
$current_screen->add_help_tab(
|
179 |
+
array(
|
180 |
+
'id' => 'settings',
|
181 |
+
'title' => __( 'Settings' , 'akismet'),
|
182 |
+
'content' =>
|
183 |
+
'<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
|
184 |
+
'<p><strong>' . esc_html__( 'API Key' , 'akismet') . '</strong> - ' . esc_html__( 'Enter/remove an API key.' , 'akismet') . '</p>' .
|
185 |
+
'<p><strong>' . esc_html__( 'Comments' , 'akismet') . '</strong> - ' . esc_html__( 'Show the number of approved comments beside each comment author in the comments list page.' , 'akismet') . '</p>' .
|
186 |
+
'<p><strong>' . esc_html__( 'Strictness' , 'akismet') . '</strong> - ' . esc_html__( 'Choose to either discard the worst spam automatically or to always put all spam in spam folder.' , 'akismet') . '</p>',
|
187 |
+
)
|
188 |
+
);
|
189 |
+
|
190 |
+
$current_screen->add_help_tab(
|
191 |
+
array(
|
192 |
+
'id' => 'account',
|
193 |
+
'title' => __( 'Account' , 'akismet'),
|
194 |
+
'content' =>
|
195 |
+
'<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
|
196 |
+
'<p><strong>' . esc_html__( 'Subscription Type' , 'akismet') . '</strong> - ' . esc_html__( 'The Akismet subscription plan' , 'akismet') . '</p>' .
|
197 |
+
'<p><strong>' . esc_html__( 'Status' , 'akismet') . '</strong> - ' . esc_html__( 'The subscription status - active, cancelled or suspended' , 'akismet') . '</p>',
|
198 |
+
)
|
199 |
+
);
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
// Help Sidebar
|
204 |
+
$current_screen->set_help_sidebar(
|
205 |
+
'<p><strong>' . esc_html__( 'For more information:' , 'akismet') . '</strong></p>' .
|
206 |
+
'<p><a href="https://akismet.com/faq/" target="_blank">' . esc_html__( 'Akismet FAQ' , 'akismet') . '</a></p>' .
|
207 |
+
'<p><a href="https://akismet.com/support/" target="_blank">' . esc_html__( 'Akismet Support' , 'akismet') . '</a></p>'
|
208 |
+
);
|
209 |
+
}
|
210 |
+
|
211 |
+
public static function enter_api_key() {
|
212 |
+
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
|
213 |
+
die(__('Cheatin’ uh?', 'akismet'));
|
214 |
+
|
215 |
+
if ( !wp_verify_nonce( $_POST['_wpnonce'], self::NONCE ) )
|
216 |
+
return false;
|
217 |
+
|
218 |
+
foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
|
219 |
+
update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
|
220 |
+
}
|
221 |
+
|
222 |
+
if ( defined( 'WPCOM_API_KEY' ) )
|
223 |
+
return false; //shouldn't have option to save key if already defined
|
224 |
+
|
225 |
+
$new_key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
|
226 |
+
$old_key = Akismet::get_api_key();
|
227 |
+
|
228 |
+
if ( empty( $new_key ) ) {
|
229 |
+
if ( !empty( $old_key ) ) {
|
230 |
+
delete_option( 'wordpress_api_key' );
|
231 |
+
self::$notices[] = 'new-key-empty';
|
232 |
+
}
|
233 |
+
}
|
234 |
+
elseif ( $new_key != $old_key ) {
|
235 |
+
self::save_key( $new_key );
|
236 |
+
}
|
237 |
+
|
238 |
+
return true;
|
239 |
+
}
|
240 |
+
|
241 |
+
public static function save_key( $api_key ) {
|
242 |
+
$key_status = Akismet::verify_key( $api_key );
|
243 |
+
|
244 |
+
if ( $key_status == 'valid' ) {
|
245 |
+
$akismet_user = self::get_akismet_user( $api_key );
|
246 |
+
|
247 |
+
if ( $akismet_user ) {
|
248 |
+
if ( $akismet_user->status != 'missing' )
|
249 |
+
update_option( 'wordpress_api_key', $api_key );
|
250 |
+
|
251 |
+
if ( $akismet_user->status == 'active' )
|
252 |
+
self::$notices['status'] = 'new-key-valid';
|
253 |
+
else
|
254 |
+
self::$notices['status'] = $akismet_user->status;
|
255 |
+
}
|
256 |
+
else
|
257 |
+
self::$notices['status'] = 'new-key-invalid';
|
258 |
+
}
|
259 |
+
elseif ( in_array( $key_status, array( 'invalid', 'failed' ) ) )
|
260 |
+
self::$notices['status'] = 'new-key-'.$key_status;
|
261 |
+
}
|
262 |
+
|
263 |
+
public static function dashboard_stats() {
|
264 |
+
if ( !function_exists('did_action') || did_action( 'rightnow_end' ) )
|
265 |
+
return; // We already displayed this info in the "Right Now" section
|
266 |
+
|
267 |
+
if ( !$count = get_option('akismet_spam_count') )
|
268 |
+
return;
|
269 |
+
|
270 |
+
global $submenu;
|
271 |
+
|
272 |
+
echo '<h3>' . esc_html( _x( 'Spam', 'comments' , 'akismet') ) . '</h3>';
|
273 |
+
|
274 |
+
echo '<p>'.sprintf( _n(
|
275 |
+
'<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comment</a>.',
|
276 |
+
'<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.',
|
277 |
+
$count
|
278 |
+
, 'akismet'), 'http://akismet.com/?return=true', esc_url( add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( isset( $submenu['edit-comments.php'] ) ? 'edit-comments.php' : 'edit.php' ) ) ), number_format_i18n($count) ).'</p>';
|
279 |
+
}
|
280 |
+
|
281 |
+
// WP 2.5+
|
282 |
+
public static function rightnow_stats() {
|
283 |
+
global $submenu, $wp_db_version;
|
284 |
+
|
285 |
+
if ( 8645 < $wp_db_version ) // 2.7
|
286 |
+
$link = add_query_arg( array( 'comment_status' => 'spam' ), admin_url( 'edit-comments.php' ) );
|
287 |
+
elseif ( isset( $submenu['edit-comments.php'] ) )
|
288 |
+
$link = add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( 'edit-comments.php' ) );
|
289 |
+
else
|
290 |
+
$link = add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( 'edit.php' ) );
|
291 |
+
|
292 |
+
if ( $count = get_option('akismet_spam_count') ) {
|
293 |
+
$intro = sprintf( _n(
|
294 |
+
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
|
295 |
+
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
|
296 |
+
$count
|
297 |
+
, 'akismet'), 'http://akismet.com/?return=true', number_format_i18n( $count ) );
|
298 |
+
} else {
|
299 |
+
$intro = sprintf( __('<a href="%s">Akismet</a> blocks spam from getting to your blog. ', 'akismet'), 'http://akismet.com/?return=true' );
|
300 |
+
}
|
301 |
+
|
302 |
+
$link = function_exists( 'esc_url' ) ? esc_url( $link ) : clean_url( $link );
|
303 |
+
if ( $queue_count = self::get_spam_count() ) {
|
304 |
+
$queue_text = sprintf( _n(
|
305 |
+
'There’s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
|
306 |
+
'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
|
307 |
+
$queue_count
|
308 |
+
, 'akismet'), number_format_i18n( $queue_count ), $link );
|
309 |
+
} else {
|
310 |
+
$queue_text = sprintf( __( "There’s nothing in your <a href='%s'>spam queue</a> at the moment." , 'akismet'), $link );
|
311 |
+
}
|
312 |
+
|
313 |
+
$text = $intro . '<br />' . $queue_text;
|
314 |
+
echo "<p class='akismet-right-now'>$text</p>\n";
|
315 |
+
}
|
316 |
+
|
317 |
+
public static function check_for_spam_button( $comment_status ) {
|
318 |
+
if ( 'approved' == $comment_status )
|
319 |
+
return;
|
320 |
+
|
321 |
+
if ( function_exists('plugins_url') )
|
322 |
+
$link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
|
323 |
+
else
|
324 |
+
$link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
|
325 |
+
|
326 |
+
echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . esc_url( $link ) . '">' . esc_html__('Check for Spam', 'akismet') . '</a>';
|
327 |
+
echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="checkforspam-spinner" />';
|
328 |
+
}
|
329 |
+
|
330 |
+
public static function transition_comment_status( $new_status, $old_status, $comment ) {
|
331 |
+
if ( $new_status == $old_status )
|
332 |
+
return;
|
333 |
+
|
334 |
+
# we don't need to record a history item for deleted comments
|
335 |
+
if ( $new_status == 'delete' )
|
336 |
+
return;
|
337 |
+
|
338 |
+
if ( !is_admin() )
|
339 |
+
return;
|
340 |
+
|
341 |
+
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
|
342 |
+
return;
|
343 |
+
|
344 |
+
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
|
345 |
+
return;
|
346 |
+
|
347 |
+
// if this is present, it means the status has been changed by a re-check, not an explicit user action
|
348 |
+
if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
|
349 |
+
return;
|
350 |
+
|
351 |
+
global $current_user;
|
352 |
+
$reporter = '';
|
353 |
+
if ( is_object( $current_user ) )
|
354 |
+
$reporter = $current_user->user_login;
|
355 |
+
|
356 |
+
// Assumption alert:
|
357 |
+
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
|
358 |
+
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
|
359 |
+
// determine why the transition_comment_status action was triggered. And there are several different ways by which
|
360 |
+
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
|
361 |
+
// We'll assume that this is an explicit user action if POST or GET has an 'action' key.
|
362 |
+
if ( isset($_POST['action']) || isset($_GET['action']) ) {
|
363 |
+
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
|
364 |
+
return self::submit_spam_comment( $comment->comment_ID );
|
365 |
+
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
|
366 |
+
return self::submit_nonspam_comment( $comment->comment_ID );
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
Akismet::update_comment_history( $comment->comment_ID, sprintf( __('%1$s changed the comment status to %2$s', 'akismet'), $reporter, $new_status ), 'status-' . $new_status );
|
371 |
+
}
|
372 |
+
|
373 |
+
public static function recheck_queue() {
|
374 |
+
global $wpdb;
|
375 |
+
|
376 |
+
Akismet::fix_scheduled_recheck();
|
377 |
+
|
378 |
+
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
|
379 |
+
return;
|
380 |
+
|
381 |
+
$paginate = '';
|
382 |
+
if ( isset( $_POST['limit'] ) && isset( $_POST['offset'] ) ) {
|
383 |
+
$paginate = $wpdb->prepare( " LIMIT %d OFFSET %d", array( $_POST['limit'], $_POST['offset'] ) );
|
384 |
+
}
|
385 |
+
$moderation = $wpdb->get_results( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A );
|
386 |
+
|
387 |
+
foreach ( (array) $moderation as $c ) {
|
388 |
+
$c['user_ip'] = $c['comment_author_IP'];
|
389 |
+
$c['user_agent'] = $c['comment_agent'];
|
390 |
+
$c['referrer'] = '';
|
391 |
+
$c['blog'] = get_bloginfo('url');
|
392 |
+
$c['blog_lang'] = get_locale();
|
393 |
+
$c['blog_charset'] = get_option('blog_charset');
|
394 |
+
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
395 |
+
|
396 |
+
$c['user_role'] = '';
|
397 |
+
if ( isset( $c['user_ID'] ) )
|
398 |
+
$c['user_role'] = Akismet::get_user_roles($c['user_ID']);
|
399 |
+
|
400 |
+
if ( Akismet::is_test_mode() )
|
401 |
+
$c['is_test'] = 'true';
|
402 |
+
|
403 |
+
add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
|
404 |
+
|
405 |
+
$response = Akismet::http_post( http_build_query( $c ), 'comment-check' );
|
406 |
+
if ( 'true' == $response[1] ) {
|
407 |
+
wp_set_comment_status( $c['comment_ID'], 'spam' );
|
408 |
+
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
|
409 |
+
delete_comment_meta( $c['comment_ID'], 'akismet_error' );
|
410 |
+
delete_comment_meta( $c['comment_ID'], 'akismet_delayed_moderation_email' );
|
411 |
+
Akismet::update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam', 'akismet'), 'check-spam' );
|
412 |
+
|
413 |
+
} elseif ( 'false' == $response[1] ) {
|
414 |
+
update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
|
415 |
+
delete_comment_meta( $c['comment_ID'], 'akismet_error' );
|
416 |
+
delete_comment_meta( $c['comment_ID'], 'akismet_delayed_moderation_email' );
|
417 |
+
Akismet::update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment', 'akismet'), 'check-ham' );
|
418 |
+
// abnormal result: error
|
419 |
+
} else {
|
420 |
+
update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
|
421 |
+
Akismet::update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)', 'akismet'), substr($response[1], 0, 50)), 'check-error' );
|
422 |
+
}
|
423 |
+
|
424 |
+
delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
|
425 |
+
}
|
426 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
427 |
+
wp_send_json( array(
|
428 |
+
'processed' => count((array) $moderation),
|
429 |
+
));
|
430 |
+
}
|
431 |
+
else {
|
432 |
+
$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
|
433 |
+
wp_safe_redirect( $redirect_to );
|
434 |
+
exit;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
// Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
|
439 |
+
public static function remove_comment_author_url() {
|
440 |
+
if ( !empty( $_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
|
441 |
+
$comment = get_comment( intval( $_POST['id'] ), ARRAY_A );
|
442 |
+
if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
|
443 |
+
$comment['comment_author_url'] = '';
|
444 |
+
do_action( 'comment_remove_author_url' );
|
445 |
+
print( wp_update_comment( $comment ) );
|
446 |
+
die();
|
447 |
+
}
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
public static function add_comment_author_url() {
|
452 |
+
if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
|
453 |
+
$comment = get_comment( intval( $_POST['id'] ), ARRAY_A );
|
454 |
+
if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
|
455 |
+
$comment['comment_author_url'] = esc_url( $_POST['url'] );
|
456 |
+
do_action( 'comment_add_author_url' );
|
457 |
+
print( wp_update_comment( $comment ) );
|
458 |
+
die();
|
459 |
+
}
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
public static function comment_row_action( $a, $comment ) {
|
464 |
+
|
465 |
+
// failsafe for old WP versions
|
466 |
+
if ( !function_exists('add_comment_meta') )
|
467 |
+
return $a;
|
468 |
+
|
469 |
+
$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
|
470 |
+
$akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
|
471 |
+
$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
|
472 |
+
$comment_status = wp_get_comment_status( $comment->comment_ID );
|
473 |
+
$desc = null;
|
474 |
+
if ( $akismet_error ) {
|
475 |
+
$desc = __( 'Awaiting spam check' , 'akismet');
|
476 |
+
} elseif ( !$user_result || $user_result == $akismet_result ) {
|
477 |
+
// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
|
478 |
+
if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
|
479 |
+
$desc = __( 'Flagged as spam by Akismet' , 'akismet');
|
480 |
+
elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
|
481 |
+
$desc = __( 'Cleared by Akismet' , 'akismet');
|
482 |
+
} else {
|
483 |
+
$who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
|
484 |
+
if ( $user_result == 'true' )
|
485 |
+
$desc = sprintf( __('Flagged as spam by %s', 'akismet'), $who );
|
486 |
+
else
|
487 |
+
$desc = sprintf( __('Un-spammed by %s', 'akismet'), $who );
|
488 |
+
}
|
489 |
+
|
490 |
+
// add a History item to the hover links, just after Edit
|
491 |
+
if ( $akismet_result ) {
|
492 |
+
$b = array();
|
493 |
+
foreach ( $a as $k => $item ) {
|
494 |
+
$b[ $k ] = $item;
|
495 |
+
if (
|
496 |
+
$k == 'edit'
|
497 |
+
|| ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
|
498 |
+
) {
|
499 |
+
$b['history'] = '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' , 'akismet') . '"> '. esc_html__('History', 'akismet') . '</a>';
|
500 |
+
}
|
501 |
+
}
|
502 |
+
|
503 |
+
$a = $b;
|
504 |
+
}
|
505 |
+
|
506 |
+
if ( $desc )
|
507 |
+
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' , 'akismet') . '">'.esc_html( $desc ).'</a></span>';
|
508 |
+
|
509 |
+
if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) ) {
|
510 |
+
$comment_count = Akismet::get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
|
511 |
+
$comment_count = intval( $comment_count );
|
512 |
+
echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'. sprintf( esc_html( _n( '%s approved', '%s approved', $comment_count , 'akismet') ), number_format_i18n( $comment_count ) ) . '</span></span>';
|
513 |
+
}
|
514 |
+
|
515 |
+
return $a;
|
516 |
+
}
|
517 |
+
|
518 |
+
public static function comment_status_meta_box( $comment ) {
|
519 |
+
$history = Akismet::get_comment_history( $comment->comment_ID );
|
520 |
+
|
521 |
+
if ( $history ) {
|
522 |
+
echo '<div class="akismet-history" style="margin: 13px;">';
|
523 |
+
foreach ( $history as $row ) {
|
524 |
+
$time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
|
525 |
+
echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( esc_html__('%s ago', 'akismet'), human_time_diff( $row['time'] ) ) . '</span> - ';
|
526 |
+
echo esc_html( $row['message'] ) . '</div>';
|
527 |
+
}
|
528 |
+
echo '</div>';
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
public static function plugin_action_links( $links, $file ) {
|
533 |
+
if ( $file == plugin_basename( AKISMET__PLUGIN_URL . '/akismet.php' ) ) {
|
534 |
+
$links[] = '<a href="' . esc_url( self::get_page_url() ) . '">'.esc_html__( 'Settings' , 'akismet').'</a>';
|
535 |
+
}
|
536 |
+
|
537 |
+
return $links;
|
538 |
+
}
|
539 |
+
|
540 |
+
public static function text_add_link_callback( $m ) {
|
541 |
+
// bare link?
|
542 |
+
if ( $m[4] == $m[2] )
|
543 |
+
return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';
|
544 |
+
else
|
545 |
+
return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';
|
546 |
+
}
|
547 |
+
|
548 |
+
public static function text_add_link_class( $comment_text ) {
|
549 |
+
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', array( 'Akismet_Admin', 'text_add_link_callback' ), $comment_text );
|
550 |
+
}
|
551 |
+
|
552 |
+
public static function submit_spam_comment( $comment_id ) {
|
553 |
+
global $wpdb, $current_user, $current_site;
|
554 |
+
|
555 |
+
$comment_id = (int) $comment_id;
|
556 |
+
|
557 |
+
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
558 |
+
|
559 |
+
if ( !$comment ) // it was deleted
|
560 |
+
return;
|
561 |
+
|
562 |
+
if ( 'spam' != $comment->comment_approved )
|
563 |
+
return;
|
564 |
+
|
565 |
+
// use the original version stored in comment_meta if available
|
566 |
+
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
567 |
+
|
568 |
+
if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) )
|
569 |
+
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
570 |
+
|
571 |
+
$comment->blog = get_bloginfo('url');
|
572 |
+
$comment->blog_lang = get_locale();
|
573 |
+
$comment->blog_charset = get_option('blog_charset');
|
574 |
+
$comment->permalink = get_permalink($comment->comment_post_ID);
|
575 |
+
|
576 |
+
if ( is_object($current_user) )
|
577 |
+
$comment->reporter = $current_user->user_login;
|
578 |
+
|
579 |
+
if ( is_object($current_site) )
|
580 |
+
$comment->site_domain = $current_site->domain;
|
581 |
+
|
582 |
+
$comment->user_role = '';
|
583 |
+
if ( isset( $comment->user_ID ) )
|
584 |
+
$comment->user_role = Akismet::get_user_roles( $comment->user_ID );
|
585 |
+
|
586 |
+
if ( Akismet::is_test_mode() )
|
587 |
+
$comment->is_test = 'true';
|
588 |
+
|
589 |
+
$post = get_post( $comment->comment_post_ID );
|
590 |
+
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
591 |
+
|
592 |
+
$response = Akismet::http_post( http_build_query( $comment ), 'submit-spam' );
|
593 |
+
if ( $comment->reporter ) {
|
594 |
+
Akismet::update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam', 'akismet'), $comment->reporter ), 'report-spam' );
|
595 |
+
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
|
596 |
+
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
597 |
+
}
|
598 |
+
|
599 |
+
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
|
600 |
+
}
|
601 |
+
|
602 |
+
public static function submit_nonspam_comment( $comment_id ) {
|
603 |
+
global $wpdb, $current_user, $current_site;
|
604 |
+
|
605 |
+
$comment_id = (int) $comment_id;
|
606 |
+
|
607 |
+
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
608 |
+
if ( !$comment ) // it was deleted
|
609 |
+
return;
|
610 |
+
|
611 |
+
// use the original version stored in comment_meta if available
|
612 |
+
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
613 |
+
|
614 |
+
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
|
615 |
+
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
616 |
+
|
617 |
+
$comment->blog = get_bloginfo('url');
|
618 |
+
$comment->blog_lang = get_locale();
|
619 |
+
$comment->blog_charset = get_option('blog_charset');
|
620 |
+
$comment->permalink = get_permalink( $comment->comment_post_ID );
|
621 |
+
$comment->user_role = '';
|
622 |
+
|
623 |
+
if ( is_object($current_user) )
|
624 |
+
$comment->reporter = $current_user->user_login;
|
625 |
+
|
626 |
+
if ( is_object($current_site) )
|
627 |
+
$comment->site_domain = $current_site->domain;
|
628 |
+
|
629 |
+
if ( isset( $comment->user_ID ) )
|
630 |
+
$comment->user_role = Akismet::get_user_roles($comment->user_ID);
|
631 |
+
|
632 |
+
if ( Akismet::is_test_mode() )
|
633 |
+
$comment->is_test = 'true';
|
634 |
+
|
635 |
+
$post = get_post( $comment->comment_post_ID );
|
636 |
+
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
637 |
+
|
638 |
+
$response = Akismet::http_post( http_build_query( $comment ), 'submit-ham' );
|
639 |
+
if ( $comment->reporter ) {
|
640 |
+
Akismet::update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam', 'akismet'), $comment->reporter ), 'report-ham' );
|
641 |
+
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
|
642 |
+
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
643 |
+
}
|
644 |
+
|
645 |
+
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
|
646 |
+
}
|
647 |
+
|
648 |
+
// Total spam in queue
|
649 |
+
// get_option( 'akismet_spam_count' ) is the total caught ever
|
650 |
+
public static function get_spam_count( $type = false ) {
|
651 |
+
global $wpdb;
|
652 |
+
|
653 |
+
if ( !$type ) { // total
|
654 |
+
$count = wp_cache_get( 'akismet_spam_count', 'widget' );
|
655 |
+
if ( false === $count ) {
|
656 |
+
if ( function_exists('wp_count_comments') ) {
|
657 |
+
$count = wp_count_comments();
|
658 |
+
$count = $count->spam;
|
659 |
+
} else {
|
660 |
+
$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam'");
|
661 |
+
}
|
662 |
+
wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
|
663 |
+
}
|
664 |
+
return $count;
|
665 |
+
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
|
666 |
+
$type = '';
|
667 |
+
} else { // pingback, trackback, ...
|
668 |
+
$type = $wpdb->escape( $type );
|
669 |
+
}
|
670 |
+
|
671 |
+
return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam' AND comment_type='$type'");
|
672 |
+
}
|
673 |
+
|
674 |
+
// Check connectivity between the WordPress blog and Akismet's servers.
|
675 |
+
// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
|
676 |
+
public static function check_server_connectivity() {
|
677 |
+
$test_host = 'rest.akismet.com';
|
678 |
+
|
679 |
+
// Some web hosts may disable one or both functions
|
680 |
+
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
|
681 |
+
return array();
|
682 |
+
|
683 |
+
$ips = gethostbynamel( $test_host );
|
684 |
+
if ( !$ips || !is_array($ips) || !count($ips) )
|
685 |
+
return array();
|
686 |
+
|
687 |
+
$api_key = Akismet::get_api_key();
|
688 |
+
|
689 |
+
$servers = array();
|
690 |
+
foreach ( $ips as $ip ) {
|
691 |
+
$response = Akismet::verify_key( $api_key, $ip );
|
692 |
+
// even if the key is invalid, at least we know we have connectivity
|
693 |
+
if ( $response == 'valid' || $response == 'invalid' )
|
694 |
+
$servers[$ip] = true;
|
695 |
+
else
|
696 |
+
$servers[$ip] = false;
|
697 |
+
}
|
698 |
+
return $servers;
|
699 |
+
}
|
700 |
+
|
701 |
+
// Check the server connectivity and store the results in an option.
|
702 |
+
// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
|
703 |
+
// Returns the same associative array as check_server_connectivity()
|
704 |
+
public static function get_server_connectivity( $cache_timeout = 86400 ) {
|
705 |
+
$servers = get_option('akismet_available_servers');
|
706 |
+
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
|
707 |
+
return $servers;
|
708 |
+
|
709 |
+
// There's a race condition here but the effect is harmless.
|
710 |
+
$servers = self::check_server_connectivity();
|
711 |
+
update_option('akismet_available_servers', $servers);
|
712 |
+
update_option('akismet_connectivity_time', time());
|
713 |
+
return $servers;
|
714 |
+
}
|
715 |
+
|
716 |
+
public static function get_number_spam_waiting() {
|
717 |
+
global $wpdb;
|
718 |
+
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
|
719 |
+
}
|
720 |
+
|
721 |
+
public static function get_page_url( $page = 'config' ) {
|
722 |
+
|
723 |
+
$args = array( 'page' => 'akismet-key-config' );
|
724 |
+
|
725 |
+
if ( $page == 'stats' )
|
726 |
+
$args = array( 'page' => 'akismet-key-config', 'view' => 'stats' );
|
727 |
+
elseif ( $page == 'delete_key' )
|
728 |
+
$args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) );
|
729 |
+
|
730 |
+
$url = add_query_arg( $args, class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) );
|
731 |
+
|
732 |
+
return $url;
|
733 |
+
}
|
734 |
+
|
735 |
+
public static function get_akismet_user( $api_key ) {
|
736 |
+
$akismet_user = Akismet::http_post( http_build_query( array( 'key' => $api_key ) ), 'get-subscription' );
|
737 |
+
|
738 |
+
if ( ! empty( $akismet_user[1] ) )
|
739 |
+
$akismet_user = json_decode( $akismet_user[1] );
|
740 |
+
else
|
741 |
+
$akismet_user = false;
|
742 |
+
|
743 |
+
return $akismet_user;
|
744 |
+
}
|
745 |
+
|
746 |
+
public static function verify_wpcom_key( $api_key, $user_id, $token = '' ) {
|
747 |
+
$akismet_account = Akismet::http_post( http_build_query( array(
|
748 |
+
'user_id' => $user_id,
|
749 |
+
'api_key' => $api_key,
|
750 |
+
'token' => $token,
|
751 |
+
'get_account_type' => 'true'
|
752 |
+
) ), 'verify-wpcom-key' );
|
753 |
+
|
754 |
+
if ( ! empty( $akismet_account[1] ) )
|
755 |
+
$akismet_account = json_decode( $akismet_account[1] );
|
756 |
+
|
757 |
+
Akismet::log( compact( 'akismet_account' ) );
|
758 |
+
|
759 |
+
return $akismet_account;
|
760 |
+
}
|
761 |
+
|
762 |
+
public static function display_alert() {
|
763 |
+
Akismet::view( 'notice', array(
|
764 |
+
'type' => 'alert',
|
765 |
+
'code' => (int) get_option( 'akismet_alert_code' ),
|
766 |
+
'msg' => get_option( 'akismet_alert_msg' )
|
767 |
+
) );
|
768 |
+
}
|
769 |
+
|
770 |
+
public static function display_spam_check_warning() {
|
771 |
+
Akismet::fix_scheduled_recheck();
|
772 |
+
|
773 |
+
if ( self::get_number_spam_waiting() > 0 && wp_next_scheduled('akismet_schedule_cron_recheck') > time() )
|
774 |
+
Akismet::view( 'notice', array( 'type' => 'spam-check' ) );
|
775 |
+
}
|
776 |
+
|
777 |
+
public static function display_invalid_version() {
|
778 |
+
Akismet::view( 'notice', array( 'type' => 'version' ) );
|
779 |
+
}
|
780 |
+
|
781 |
+
public static function display_api_key_warning() {
|
782 |
+
Akismet::view( 'notice', array( 'type' => 'plugin' ) );
|
783 |
+
}
|
784 |
+
|
785 |
+
public static function display_page() {
|
786 |
+
if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) )
|
787 |
+
self::display_start_page();
|
788 |
+
elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' )
|
789 |
+
self::display_stats_page();
|
790 |
+
else
|
791 |
+
self::display_configuration_page();
|
792 |
+
}
|
793 |
+
|
794 |
+
public static function display_start_page() {
|
795 |
+
if ( isset( $_GET['action'] ) ) {
|
796 |
+
if ( $_GET['action'] == 'delete-key' ) {
|
797 |
+
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], self::NONCE ) )
|
798 |
+
delete_option( 'wordpress_api_key' );
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
+
if ( $api_key = Akismet::get_api_key() ) {
|
803 |
+
self::display_configuration_page();
|
804 |
+
return;
|
805 |
+
}
|
806 |
+
|
807 |
+
//the user can choose to auto connect their API key by clicking a button on the akismet done page
|
808 |
+
//if jetpack, get verified api key by using connected wpcom user id
|
809 |
+
//if no jetpack, get verified api key by using an akismet token
|
810 |
+
|
811 |
+
$akismet_user = false;
|
812 |
+
|
813 |
+
if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) )
|
814 |
+
$akismet_user = self::verify_wpcom_key( '', '', $_GET['token'] );
|
815 |
+
elseif ( $jetpack_user = self::get_jetpack_user() )
|
816 |
+
$akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] );
|
817 |
+
|
818 |
+
if ( isset( $_GET['action'] ) ) {
|
819 |
+
if ( $_GET['action'] == 'save-key' ) {
|
820 |
+
if ( is_object( $akismet_user ) ) {
|
821 |
+
self::save_key( $akismet_user->api_key );
|
822 |
+
self::display_notice();
|
823 |
+
self::display_configuration_page();
|
824 |
+
return;
|
825 |
+
}
|
826 |
+
}
|
827 |
+
}
|
828 |
+
|
829 |
+
echo '<h2 class="ak-header">'.esc_html__('Akismet', 'akismet').'</h2>';
|
830 |
+
|
831 |
+
self::display_status();
|
832 |
+
|
833 |
+
Akismet::view( 'start', compact( 'akismet_user' ) );
|
834 |
+
}
|
835 |
+
|
836 |
+
public static function display_stats_page() {
|
837 |
+
Akismet::view( 'stats' );
|
838 |
+
}
|
839 |
+
|
840 |
+
public static function display_configuration_page() {
|
841 |
+
$api_key = Akismet::get_api_key();
|
842 |
+
$akismet_user = self::get_akismet_user( $api_key );
|
843 |
+
|
844 |
+
// If unset, create the new strictness option using the old discard option to determine its default
|
845 |
+
if ( get_option( 'akismet_strictness' ) === false )
|
846 |
+
add_option( 'akismet_strictness', (get_option('akismet_discard_month') === 'true' ? '1' : '0') );
|
847 |
+
|
848 |
+
$blog = parse_url( get_option('home'), PHP_URL_HOST );
|
849 |
+
|
850 |
+
foreach( array( '6-months', 'all' ) as $interval ) {
|
851 |
+
$response = Akismet::http_post( http_build_query( array( 'blog' => urlencode( $blog ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
|
852 |
+
|
853 |
+
if ( ! empty( $response[1] ) ) {
|
854 |
+
$stat_totals[$interval] = json_decode( $response[1] );
|
855 |
+
}
|
856 |
+
}
|
857 |
+
|
858 |
+
if ( empty( self::$notices ) ) {
|
859 |
+
//show status
|
860 |
+
if ( $akismet_user->status == 'active' && $akismet_user->account_type == 'free-api-key' ) {
|
861 |
+
|
862 |
+
$time_saved = false;
|
863 |
+
|
864 |
+
if ( $stat_totals['all']->time_saved > 1800 ) {
|
865 |
+
$total_in_minutes = round( $stat_totals['all']->time_saved / 60 );
|
866 |
+
$total_in_hours = round( $total_in_minutes / 60 );
|
867 |
+
$total_in_days = round( $total_in_hours / 8 );
|
868 |
+
$cleaning_up = __( 'Cleaning up spam takes time.' , 'akismet');
|
869 |
+
|
870 |
+
if ( $total_in_days > 1 )
|
871 |
+
$time_saved = $cleaning_up . ' ' . sprintf( __( 'Since you joined us, Akismet has saved you %s days!' , 'akismet'), number_format_i18n( $total_in_days ) );
|
872 |
+
elseif ( $total_in_hours > 1 )
|
873 |
+
$time_saved = $cleaning_up . ' ' . sprintf( __( 'Since you joined us, Akismet has saved you %d hours!' , 'akismet'), $total_in_hours );
|
874 |
+
elseif ( $total_in_minutes >= 30 )
|
875 |
+
$time_saved = $cleaning_up . ' ' . sprintf( __( 'Since you joined us, Akismet has saved you %d minutes!' , 'akismet'), $total_in_minutes );
|
876 |
+
}
|
877 |
+
|
878 |
+
Akismet::view( 'notice', array( 'type' => 'active-notice', 'time_saved' => $time_saved ) );
|
879 |
+
}
|
880 |
+
|
881 |
+
if ( !empty( $akismet_user->limit_reached ) && in_array( $akismet_user->limit_reached, array( 'yellow', 'red' ) ) ) {
|
882 |
+
Akismet::view( 'notice', array( 'type' => 'limit-reached', 'level' => $akismet_user->limit_reached ) );
|
883 |
+
}
|
884 |
+
}
|
885 |
+
|
886 |
+
if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing' ) ) )
|
887 |
+
Akismet::view( 'notice', array( 'type' => $akismet_user->status ) );
|
888 |
+
|
889 |
+
Akismet::log( compact( 'stat_totals', 'akismet_user' ) );
|
890 |
+
Akismet::view( 'config', compact( 'api_key', 'blog', 'akismet_user', 'stat_totals' ) );
|
891 |
+
}
|
892 |
+
|
893 |
+
public static function display_notice() {
|
894 |
+
global $hook_suffix;
|
895 |
+
|
896 |
+
if ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config', 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) {
|
897 |
+
self::display_alert();
|
898 |
+
}
|
899 |
+
elseif ( $hook_suffix == 'plugins.php' && !Akismet::get_api_key() ) {
|
900 |
+
self::display_api_key_warning();
|
901 |
+
}
|
902 |
+
elseif ( $hook_suffix == 'edit-comments.php' && wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
|
903 |
+
self::display_spam_check_warning();
|
904 |
+
}
|
905 |
+
elseif ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config' ) ) && Akismet::get_api_key() ) {
|
906 |
+
self::display_status();
|
907 |
+
}
|
908 |
+
}
|
909 |
+
|
910 |
+
public static function display_status() {
|
911 |
+
$servers = self::get_server_connectivity();
|
912 |
+
$fail_count = count( $servers ) - count( array_filter( $servers ) );
|
913 |
+
$type = '';
|
914 |
+
|
915 |
+
if ( empty( $servers ) || $fail_count > 0 )
|
916 |
+
$type = 'servers-be-down';
|
917 |
+
|
918 |
+
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
|
919 |
+
$type = 'missing-functions';
|
920 |
+
|
921 |
+
if ( !empty( $type ) )
|
922 |
+
Akismet::view( 'notice', compact( 'type' ) );
|
923 |
+
elseif ( !empty( self::$notices ) ) {
|
924 |
+
foreach ( self::$notices as $type )
|
925 |
+
Akismet::view( 'notice', compact( 'type' ) );
|
926 |
+
}
|
927 |
+
}
|
928 |
+
|
929 |
+
private static function get_jetpack_user() {
|
930 |
+
if ( !class_exists('Jetpack') )
|
931 |
+
return false;
|
932 |
+
|
933 |
+
Jetpack::load_xml_rpc_client();
|
934 |
+
$xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) );
|
935 |
+
|
936 |
+
$xml->addCall( 'wpcom.getUserID' );
|
937 |
+
$xml->addCall( 'akismet.getAPIKey' );
|
938 |
+
$xml->query();
|
939 |
+
|
940 |
+
Akismet::log( compact( 'xml' ) );
|
941 |
+
|
942 |
+
if ( !$xml->isError() ) {
|
943 |
+
$responses = $xml->getResponse();
|
944 |
+
if ( count( $responses ) > 1 ) {
|
945 |
+
$api_key = array_shift( $responses[0] );
|
946 |
+
$user_id = (int) array_shift( $responses[1] );
|
947 |
+
return compact( 'api_key', 'user_id' );
|
948 |
+
}
|
949 |
+
}
|
950 |
+
return false;
|
951 |
+
}
|
952 |
+
}
|
widget.php → class.akismet-widget.php
RENAMED
@@ -5,10 +5,12 @@
|
|
5 |
class Akismet_Widget extends WP_Widget {
|
6 |
|
7 |
function __construct() {
|
|
|
|
|
8 |
parent::__construct(
|
9 |
'akismet_widget',
|
10 |
-
__( 'Akismet Widget' ),
|
11 |
-
array( 'description' => __( 'Display the number of spam comments Akismet has caught' ) )
|
12 |
);
|
13 |
|
14 |
if ( is_active_widget( false, false, $this->id_base ) ) {
|
@@ -23,7 +25,7 @@ class Akismet_Widget extends WP_Widget {
|
|
23 |
.a-stats {
|
24 |
width: auto;
|
25 |
}
|
26 |
-
.a-stats a {
|
27 |
background: #7CA821;
|
28 |
background-image:-moz-linear-gradient(0% 100% 90deg,#5F8E14,#7CA821);
|
29 |
background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#7CA821),to(#5F8E14));
|
@@ -41,7 +43,7 @@ class Akismet_Widget extends WP_Widget {
|
|
41 |
-webkit-border-radius:3px;
|
42 |
width: 100%;
|
43 |
}
|
44 |
-
.a-stats a:hover {
|
45 |
text-decoration: none;
|
46 |
background-image:-moz-linear-gradient(0% 100% 90deg,#6F9C1B,#659417);
|
47 |
background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#659417),to(#6F9C1B));
|
@@ -61,19 +63,19 @@ class Akismet_Widget extends WP_Widget {
|
|
61 |
|
62 |
function form( $instance ) {
|
63 |
if ( $instance ) {
|
64 |
-
$title =
|
65 |
}
|
66 |
else {
|
67 |
-
$title = __( 'Spam Blocked' );
|
68 |
}
|
69 |
?>
|
70 |
|
71 |
<p>
|
72 |
-
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php
|
73 |
-
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
|
74 |
</p>
|
75 |
|
76 |
-
<?php
|
77 |
}
|
78 |
|
79 |
function update( $new_instance, $old_instance ) {
|
@@ -93,7 +95,7 @@ class Akismet_Widget extends WP_Widget {
|
|
93 |
?>
|
94 |
|
95 |
<div class="a-stats">
|
96 |
-
<a href="http://akismet.com" target="_blank" title=""><?php printf( _n( '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', $count ), number_format_i18n( $count ) ); ?></a>
|
97 |
</div>
|
98 |
|
99 |
<?php
|
5 |
class Akismet_Widget extends WP_Widget {
|
6 |
|
7 |
function __construct() {
|
8 |
+
load_plugin_textdomain( 'akismet' );
|
9 |
+
|
10 |
parent::__construct(
|
11 |
'akismet_widget',
|
12 |
+
__( 'Akismet Widget' , 'akismet'),
|
13 |
+
array( 'description' => __( 'Display the number of spam comments Akismet has caught' , 'akismet') )
|
14 |
);
|
15 |
|
16 |
if ( is_active_widget( false, false, $this->id_base ) ) {
|
25 |
.a-stats {
|
26 |
width: auto;
|
27 |
}
|
28 |
+
.a-stats a {
|
29 |
background: #7CA821;
|
30 |
background-image:-moz-linear-gradient(0% 100% 90deg,#5F8E14,#7CA821);
|
31 |
background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#7CA821),to(#5F8E14));
|
43 |
-webkit-border-radius:3px;
|
44 |
width: 100%;
|
45 |
}
|
46 |
+
.a-stats a:hover {
|
47 |
text-decoration: none;
|
48 |
background-image:-moz-linear-gradient(0% 100% 90deg,#6F9C1B,#659417);
|
49 |
background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#659417),to(#6F9C1B));
|
63 |
|
64 |
function form( $instance ) {
|
65 |
if ( $instance ) {
|
66 |
+
$title = $instance['title'];
|
67 |
}
|
68 |
else {
|
69 |
+
$title = __( 'Spam Blocked' , 'akismet');
|
70 |
}
|
71 |
?>
|
72 |
|
73 |
<p>
|
74 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' , 'akismet'); ?></label>
|
75 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
76 |
</p>
|
77 |
|
78 |
+
<?php
|
79 |
}
|
80 |
|
81 |
function update( $new_instance, $old_instance ) {
|
95 |
?>
|
96 |
|
97 |
<div class="a-stats">
|
98 |
+
<a href="http://akismet.com" target="_blank" title=""><?php printf( _n( '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', $count , 'akismet'), number_format_i18n( $count ) ); ?></a>
|
99 |
</div>
|
100 |
|
101 |
<?php
|
class.akismet.php
ADDED
@@ -0,0 +1,764 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Akismet {
|
4 |
+
const API_HOST = 'rest.akismet.com';
|
5 |
+
const API_PORT = 80;
|
6 |
+
const MAX_DELAY_BEFORE_MODERATION_EMAIL = 86400; // One day in seconds
|
7 |
+
|
8 |
+
private static $last_comment = '';
|
9 |
+
private static $initiated = false;
|
10 |
+
private static $prevent_moderation_email_for_these_comments = array();
|
11 |
+
private static $last_comment_result = null;
|
12 |
+
|
13 |
+
public static function init() {
|
14 |
+
if ( ! self::$initiated ) {
|
15 |
+
self::init_hooks();
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Initializes WordPress hooks
|
21 |
+
*/
|
22 |
+
private static function init_hooks() {
|
23 |
+
self::$initiated = true;
|
24 |
+
|
25 |
+
add_action( 'wp_insert_comment', array( 'Akismet', 'auto_check_update_meta' ), 10, 2 );
|
26 |
+
add_action( 'preprocess_comment', array( 'Akismet', 'auto_check_comment' ), 1 );
|
27 |
+
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments' ) );
|
28 |
+
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
|
29 |
+
add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
|
30 |
+
|
31 |
+
$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
32 |
+
|
33 |
+
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
|
34 |
+
add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
|
35 |
+
|
36 |
+
add_action( 'admin_footer-edit-comments.php', array( 'Akismet', 'load_form_js' ) );
|
37 |
+
add_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
|
38 |
+
add_action( 'comment_form', array( 'Akismet', 'inject_ak_js' ) );
|
39 |
+
|
40 |
+
add_filter( 'comment_moderation_recipients', array( 'Akismet', 'disable_moderation_emails_if_unreachable' ), 1000, 2 );
|
41 |
+
add_filter( 'pre_comment_approved', array( 'Akismet', 'last_comment_status' ), 10, 2 );
|
42 |
+
|
43 |
+
if ( '3.0.5' == $GLOBALS['wp_version'] ) {
|
44 |
+
remove_filter( 'comment_text', 'wp_kses_data' );
|
45 |
+
if ( is_admin() )
|
46 |
+
add_filter( 'comment_text', 'wp_kses_post' );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
public static function get_api_key() {
|
51 |
+
return defined('WPCOM_API_KEY') ? constant('WPCOM_API_KEY') : get_option('wordpress_api_key');
|
52 |
+
}
|
53 |
+
|
54 |
+
public static function check_key_status( $key, $ip = null ) {
|
55 |
+
return self::http_post( http_build_query( array( 'key' => $key, 'blog' => get_option('home') ) ), 'verify-key', $ip );
|
56 |
+
}
|
57 |
+
|
58 |
+
public static function verify_key( $key, $ip = null ) {
|
59 |
+
$response = self::check_key_status( $key, $ip );
|
60 |
+
|
61 |
+
if ( $response[1] != 'valid' && $response[1] != 'invalid' )
|
62 |
+
return 'failed';
|
63 |
+
|
64 |
+
self::update_alert( $response );
|
65 |
+
|
66 |
+
return $response[1];
|
67 |
+
}
|
68 |
+
|
69 |
+
public static function auto_check_comment( $commentdata ) {
|
70 |
+
self::$last_comment_result = null;
|
71 |
+
|
72 |
+
$comment = $commentdata;
|
73 |
+
|
74 |
+
$comment['user_ip'] = self::get_ip_address();
|
75 |
+
$comment['user_agent'] = self::get_user_agent();
|
76 |
+
$comment['referrer'] = self::get_referer();
|
77 |
+
$comment['blog'] = get_option('home');
|
78 |
+
$comment['blog_lang'] = get_locale();
|
79 |
+
$comment['blog_charset'] = get_option('blog_charset');
|
80 |
+
$comment['permalink'] = get_permalink( $comment['comment_post_ID'] );
|
81 |
+
|
82 |
+
if ( !empty( $comment['user_ID'] ) )
|
83 |
+
$comment['user_role'] = Akismet::get_user_roles( $comment['user_ID'] );
|
84 |
+
|
85 |
+
$akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
86 |
+
$comment['akismet_comment_nonce'] = 'inactive';
|
87 |
+
if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
|
88 |
+
$comment['akismet_comment_nonce'] = 'failed';
|
89 |
+
if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
|
90 |
+
$comment['akismet_comment_nonce'] = 'passed';
|
91 |
+
|
92 |
+
// comment reply in wp-admin
|
93 |
+
if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
|
94 |
+
$comment['akismet_comment_nonce'] = 'passed';
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( self::is_test_mode() )
|
99 |
+
$comment['is_test'] = 'true';
|
100 |
+
|
101 |
+
foreach( $_POST as $key => $value ) {
|
102 |
+
if ( is_string( $value ) )
|
103 |
+
$comment["POST_{$key}"] = $value;
|
104 |
+
}
|
105 |
+
|
106 |
+
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
|
107 |
+
|
108 |
+
foreach ( $_SERVER as $key => $value ) {
|
109 |
+
if ( !in_array( $key, $ignore ) && is_string($value) )
|
110 |
+
$comment["$key"] = $value;
|
111 |
+
else
|
112 |
+
$comment["$key"] = '';
|
113 |
+
}
|
114 |
+
|
115 |
+
$post = get_post( $comment['comment_post_ID'] );
|
116 |
+
$comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
|
117 |
+
|
118 |
+
$response = self::http_post( http_build_query( $comment ), 'comment-check' );
|
119 |
+
|
120 |
+
do_action( 'akismet_comment_check_response', $response );
|
121 |
+
|
122 |
+
self::update_alert( $response );
|
123 |
+
|
124 |
+
$commentdata['comment_as_submitted'] = $comment;
|
125 |
+
$commentdata['akismet_result'] = $response[1];
|
126 |
+
|
127 |
+
if ( isset( $response[0]['x-akismet-pro-tip'] ) )
|
128 |
+
$commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
|
129 |
+
|
130 |
+
if ( 'true' == $response[1] ) {
|
131 |
+
// akismet_spam_count will be incremented later by comment_is_spam()
|
132 |
+
self::$last_comment_result = 'spam';
|
133 |
+
|
134 |
+
$discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard() );
|
135 |
+
|
136 |
+
do_action( 'akismet_spam_caught', $discard );
|
137 |
+
|
138 |
+
if ( $discard ) {
|
139 |
+
// akismet_result_spam() won't be called so bump the counter here
|
140 |
+
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
141 |
+
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
142 |
+
$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
|
143 |
+
wp_safe_redirect( esc_url_raw( $redirect_to ) );
|
144 |
+
die();
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
// if the response is neither true nor false, hold the comment for moderation and schedule a recheck
|
149 |
+
if ( 'true' != $response[1] && 'false' != $response[1] ) {
|
150 |
+
if ( !current_user_can('moderate_comments') ) {
|
151 |
+
// Comment status should be moderated
|
152 |
+
self::$last_comment_result = '0';
|
153 |
+
}
|
154 |
+
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_single_event') ) {
|
155 |
+
if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
|
156 |
+
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
self::$prevent_moderation_email_for_these_comments[] = $commentdata;
|
161 |
+
}
|
162 |
+
|
163 |
+
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
|
164 |
+
// WP 2.1+: delete old comments daily
|
165 |
+
if ( !wp_next_scheduled( 'akismet_scheduled_delete' ) )
|
166 |
+
wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
|
167 |
+
}
|
168 |
+
elseif ( (mt_rand(1, 10) == 3) ) {
|
169 |
+
// WP 2.0: run this one time in ten
|
170 |
+
self::delete_old_comments();
|
171 |
+
}
|
172 |
+
|
173 |
+
self::set_last_comment( $commentdata );
|
174 |
+
self::fix_scheduled_recheck();
|
175 |
+
|
176 |
+
return self::$last_comment;
|
177 |
+
}
|
178 |
+
|
179 |
+
public static function get_last_comment() {
|
180 |
+
return self::$last_comment;
|
181 |
+
}
|
182 |
+
|
183 |
+
public static function set_last_comment( $comment ) {
|
184 |
+
if ( is_null( $comment ) ) {
|
185 |
+
self::$last_comment = null;
|
186 |
+
}
|
187 |
+
else {
|
188 |
+
// We filter it here so that it matches the filtered comment data that we'll have to compare against later.
|
189 |
+
// wp_filter_comment expects comment_author_IP
|
190 |
+
self::$last_comment = wp_filter_comment(
|
191 |
+
array_merge(
|
192 |
+
array( 'comment_author_IP' => self::get_ip_address() ),
|
193 |
+
$comment
|
194 |
+
)
|
195 |
+
);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
// this fires on wp_insert_comment. we can't update comment_meta when auto_check_comment() runs
|
200 |
+
// because we don't know the comment ID at that point.
|
201 |
+
public static function auto_check_update_meta( $id, $comment ) {
|
202 |
+
|
203 |
+
// failsafe for old WP versions
|
204 |
+
if ( !function_exists('add_comment_meta') )
|
205 |
+
return false;
|
206 |
+
|
207 |
+
if ( !isset( self::$last_comment['comment_author_email'] ) )
|
208 |
+
self::$last_comment['comment_author_email'] = '';
|
209 |
+
|
210 |
+
// wp_insert_comment() might be called in other contexts, so make sure this is the same comment
|
211 |
+
// as was checked by auto_check_comment
|
212 |
+
if ( is_object( $comment ) && !empty( self::$last_comment ) && is_array( self::$last_comment ) ) {
|
213 |
+
if ( self::matches_last_comment( $comment ) ) {
|
214 |
+
|
215 |
+
load_plugin_textdomain( 'akismet' );
|
216 |
+
|
217 |
+
// normal result: true or false
|
218 |
+
if ( self::$last_comment['akismet_result'] == 'true' ) {
|
219 |
+
update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
|
220 |
+
self::update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam', 'akismet'), 'check-spam' );
|
221 |
+
if ( $comment->comment_approved != 'spam' )
|
222 |
+
self::update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s', 'akismet'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
|
223 |
+
}
|
224 |
+
elseif ( self::$last_comment['akismet_result'] == 'false' ) {
|
225 |
+
update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
|
226 |
+
self::update_comment_history( $comment->comment_ID, __('Akismet cleared this comment', 'akismet'), 'check-ham' );
|
227 |
+
if ( $comment->comment_approved == 'spam' ) {
|
228 |
+
if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
|
229 |
+
self::update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check', 'akismet'), 'wp-blacklisted' );
|
230 |
+
else
|
231 |
+
self::update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s', 'akismet'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
|
232 |
+
}
|
233 |
+
} // abnormal result: error
|
234 |
+
else {
|
235 |
+
update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
|
236 |
+
self::update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.', 'akismet'), substr(self::$last_comment['akismet_result'], 0, 50)), 'check-error' );
|
237 |
+
}
|
238 |
+
|
239 |
+
// record the complete original data as submitted for checking
|
240 |
+
if ( isset( self::$last_comment['comment_as_submitted'] ) )
|
241 |
+
update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', self::$last_comment['comment_as_submitted'] );
|
242 |
+
|
243 |
+
if ( isset( self::$last_comment['akismet_pro_tip'] ) )
|
244 |
+
update_comment_meta( $comment->comment_ID, 'akismet_pro_tip', self::$last_comment['akismet_pro_tip'] );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
public static function delete_old_comments() {
|
250 |
+
global $wpdb;
|
251 |
+
|
252 |
+
while( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", defined( 'AKISMET_DELETE_LIMIT' ) ? AKISMET_DELETE_LIMIT : 10000 ) ) ) {
|
253 |
+
if ( empty( $comment_ids ) )
|
254 |
+
return;
|
255 |
+
|
256 |
+
$wpdb->queries = array();
|
257 |
+
|
258 |
+
do_action( 'delete_comment', $comment_ids );
|
259 |
+
|
260 |
+
$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
|
261 |
+
|
262 |
+
$wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( $comma_comment_ids )");
|
263 |
+
$wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( $comma_comment_ids )");
|
264 |
+
|
265 |
+
clean_comment_cache( $comment_ids );
|
266 |
+
}
|
267 |
+
|
268 |
+
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number
|
269 |
+
$wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
|
270 |
+
}
|
271 |
+
|
272 |
+
public static function delete_old_comments_meta() {
|
273 |
+
global $wpdb;
|
274 |
+
|
275 |
+
$interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
|
276 |
+
|
277 |
+
# enfore a minimum of 1 day
|
278 |
+
$interval = absint( $interval );
|
279 |
+
if ( $interval < 1 )
|
280 |
+
$interval = 1;
|
281 |
+
|
282 |
+
// akismet_as_submitted meta values are large, so expire them
|
283 |
+
// after $interval days regardless of the comment status
|
284 |
+
while ( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT m.comment_id FROM {$wpdb->commentmeta} as m INNER JOIN {$wpdb->comments} as c USING(comment_id) WHERE m.meta_key = 'akismet_as_submitted' AND DATE_SUB(NOW(), INTERVAL %d DAY) > c.comment_date_gmt LIMIT 10000", $interval ) ) ) {
|
285 |
+
if ( empty( $comment_ids ) )
|
286 |
+
return;
|
287 |
+
|
288 |
+
$wpdb->queries = array();
|
289 |
+
|
290 |
+
foreach ( $comment_ids as $comment_id ) {
|
291 |
+
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
|
296 |
+
$wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
|
297 |
+
}
|
298 |
+
|
299 |
+
// how many approved comments does this author have?
|
300 |
+
public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
301 |
+
global $wpdb;
|
302 |
+
|
303 |
+
if ( !empty( $user_id ) )
|
304 |
+
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_approved = 1", $user_id ) );
|
305 |
+
|
306 |
+
if ( !empty( $comment_author_email ) )
|
307 |
+
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
|
308 |
+
|
309 |
+
return 0;
|
310 |
+
}
|
311 |
+
|
312 |
+
// get the full comment history for a given comment, as an array in reverse chronological order
|
313 |
+
public static function get_comment_history( $comment_id ) {
|
314 |
+
|
315 |
+
// failsafe for old WP versions
|
316 |
+
if ( !function_exists('add_comment_meta') )
|
317 |
+
return false;
|
318 |
+
|
319 |
+
$history = get_comment_meta( $comment_id, 'akismet_history', false );
|
320 |
+
usort( $history, array( 'Akismet', '_cmp_time' ) );
|
321 |
+
return $history;
|
322 |
+
}
|
323 |
+
|
324 |
+
// log an event for a given comment, storing it in comment_meta
|
325 |
+
public static function update_comment_history( $comment_id, $message, $event=null ) {
|
326 |
+
global $current_user;
|
327 |
+
|
328 |
+
// failsafe for old WP versions
|
329 |
+
if ( !function_exists('add_comment_meta') )
|
330 |
+
return false;
|
331 |
+
|
332 |
+
$user = '';
|
333 |
+
if ( is_object( $current_user ) && isset( $current_user->user_login ) )
|
334 |
+
$user = $current_user->user_login;
|
335 |
+
|
336 |
+
$event = array(
|
337 |
+
'time' => self::_get_microtime(),
|
338 |
+
'message' => $message,
|
339 |
+
'event' => $event,
|
340 |
+
'user' => $user,
|
341 |
+
);
|
342 |
+
|
343 |
+
// $unique = false so as to allow multiple values per comment
|
344 |
+
$r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
|
345 |
+
}
|
346 |
+
|
347 |
+
public static function check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
|
348 |
+
global $wpdb;
|
349 |
+
|
350 |
+
$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $id ), ARRAY_A );
|
351 |
+
if ( !$c )
|
352 |
+
return;
|
353 |
+
|
354 |
+
$c['user_ip'] = $c['comment_author_IP'];
|
355 |
+
$c['user_agent'] = $c['comment_agent'];
|
356 |
+
$c['referrer'] = '';
|
357 |
+
$c['blog'] = get_option('home');
|
358 |
+
$c['blog_lang'] = get_locale();
|
359 |
+
$c['blog_charset'] = get_option('blog_charset');
|
360 |
+
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
361 |
+
$c['recheck_reason'] = $recheck_reason;
|
362 |
+
|
363 |
+
if ( self::is_test_mode() )
|
364 |
+
$c['is_test'] = 'true';
|
365 |
+
|
366 |
+
$response = self::http_post( http_build_query( $c ), 'comment-check' );
|
367 |
+
|
368 |
+
return ( is_array( $response ) && ! empty( $response[1] ) ) ? $response[1] : false;
|
369 |
+
}
|
370 |
+
|
371 |
+
public static function cron_recheck() {
|
372 |
+
global $wpdb;
|
373 |
+
|
374 |
+
$api_key = self::get_api_key();
|
375 |
+
|
376 |
+
$status = self::verify_key( $api_key );
|
377 |
+
if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
|
378 |
+
// since there is currently a problem with the key, reschedule a check for 6 hours hence
|
379 |
+
wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
|
380 |
+
return false;
|
381 |
+
}
|
382 |
+
|
383 |
+
delete_option('akismet_available_servers');
|
384 |
+
|
385 |
+
$comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error' LIMIT 100" );
|
386 |
+
|
387 |
+
load_plugin_textdomain( 'akismet' );
|
388 |
+
|
389 |
+
foreach ( (array) $comment_errors as $comment_id ) {
|
390 |
+
// if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
|
391 |
+
$comment = get_comment( $comment_id );
|
392 |
+
if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
|
393 |
+
delete_comment_meta( $comment_id, 'akismet_error' );
|
394 |
+
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
|
395 |
+
continue;
|
396 |
+
}
|
397 |
+
|
398 |
+
add_comment_meta( $comment_id, 'akismet_rechecking', true );
|
399 |
+
$status = self::check_db_comment( $comment_id, 'retry' );
|
400 |
+
|
401 |
+
$msg = '';
|
402 |
+
if ( $status == 'true' ) {
|
403 |
+
$msg = __( 'Akismet caught this comment as spam during an automatic retry.' , 'akismet');
|
404 |
+
} elseif ( $status == 'false' ) {
|
405 |
+
$msg = __( 'Akismet cleared this comment during an automatic retry.' , 'akismet');
|
406 |
+
}
|
407 |
+
|
408 |
+
// If we got back a legit response then update the comment history
|
409 |
+
// other wise just bail now and try again later. No point in
|
410 |
+
// re-trying all the comments once we hit one failure.
|
411 |
+
if ( !empty( $msg ) ) {
|
412 |
+
delete_comment_meta( $comment_id, 'akismet_error' );
|
413 |
+
self::update_comment_history( $comment_id, $msg, 'cron-retry' );
|
414 |
+
update_comment_meta( $comment_id, 'akismet_result', $status );
|
415 |
+
// make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
|
416 |
+
$comment = get_comment( $comment_id );
|
417 |
+
if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
|
418 |
+
if ( $status == 'true' ) {
|
419 |
+
wp_spam_comment( $comment_id );
|
420 |
+
} elseif ( $status == 'false' ) {
|
421 |
+
// comment is good, but it's still in the pending queue. depending on the moderation settings
|
422 |
+
// we may need to change it to approved.
|
423 |
+
if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
|
424 |
+
wp_set_comment_status( $comment_id, 1 );
|
425 |
+
else if ( get_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true ) )
|
426 |
+
wp_notify_moderator( $comment_id );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
|
431 |
+
} else {
|
432 |
+
// If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
|
433 |
+
// send a moderation email now.
|
434 |
+
if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) {
|
435 |
+
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
|
436 |
+
wp_notify_moderator( $comment_id );
|
437 |
+
}
|
438 |
+
|
439 |
+
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
440 |
+
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
441 |
+
return;
|
442 |
+
}
|
443 |
+
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
444 |
+
}
|
445 |
+
|
446 |
+
$remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
|
447 |
+
if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
|
448 |
+
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
public static function fix_scheduled_recheck() {
|
453 |
+
$future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
|
454 |
+
if ( !$future_check ) {
|
455 |
+
return;
|
456 |
+
}
|
457 |
+
|
458 |
+
if ( get_option( 'akismet_alert_code' ) > 0 ) {
|
459 |
+
return;
|
460 |
+
}
|
461 |
+
|
462 |
+
$check_range = time() + 1200;
|
463 |
+
if ( $future_check > $check_range ) {
|
464 |
+
wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
|
465 |
+
wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
public static function add_comment_nonce( $post_id ) {
|
470 |
+
echo '<p style="display: none;">';
|
471 |
+
wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
|
472 |
+
echo '</p>';
|
473 |
+
}
|
474 |
+
|
475 |
+
public static function is_test_mode() {
|
476 |
+
return defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE;
|
477 |
+
}
|
478 |
+
|
479 |
+
public static function allow_discard() {
|
480 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
|
481 |
+
return false;
|
482 |
+
if ( is_user_logged_in() )
|
483 |
+
return false;
|
484 |
+
|
485 |
+
return ( get_option( 'akismet_strictness' ) === '1' );
|
486 |
+
}
|
487 |
+
|
488 |
+
public static function get_ip_address() {
|
489 |
+
return isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null;
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* Do these two comments, without checking the comment_ID, "match"?
|
494 |
+
*
|
495 |
+
* @param mixed $comment1 A comment object or array.
|
496 |
+
* @param mixed $comment2 A comment object or array.
|
497 |
+
* @return bool Whether the two comments should be treated as the same comment.
|
498 |
+
*/
|
499 |
+
private static function comments_match( $comment1, $comment2 ) {
|
500 |
+
$comment1 = (array) $comment1;
|
501 |
+
$comment2 = (array) $comment2;
|
502 |
+
|
503 |
+
return (
|
504 |
+
isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] )
|
505 |
+
&& intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] )
|
506 |
+
&& $comment1['comment_author'] == $comment2['comment_author']
|
507 |
+
&& $comment1['comment_author_email'] == $comment2['comment_author_email']
|
508 |
+
);
|
509 |
+
}
|
510 |
+
|
511 |
+
// Does the supplied comment match the details of the one most recently stored in self::$last_comment?
|
512 |
+
public static function matches_last_comment( $comment ) {
|
513 |
+
if ( is_object( $comment ) )
|
514 |
+
$comment = (array) $comment;
|
515 |
+
|
516 |
+
return self::comments_match( self::$last_comment, $comment );
|
517 |
+
}
|
518 |
+
|
519 |
+
private static function get_user_agent() {
|
520 |
+
return isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
521 |
+
}
|
522 |
+
|
523 |
+
private static function get_referer() {
|
524 |
+
return isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
|
525 |
+
}
|
526 |
+
|
527 |
+
// return a comma-separated list of role names for the given user
|
528 |
+
public static function get_user_roles( $user_id ) {
|
529 |
+
$roles = false;
|
530 |
+
|
531 |
+
if ( !class_exists('WP_User') )
|
532 |
+
return false;
|
533 |
+
|
534 |
+
if ( $user_id > 0 ) {
|
535 |
+
$comment_user = new WP_User( $user_id );
|
536 |
+
if ( isset( $comment_user->roles ) )
|
537 |
+
$roles = join( ',', $comment_user->roles );
|
538 |
+
}
|
539 |
+
|
540 |
+
if ( is_multisite() && is_super_admin( $user_id ) ) {
|
541 |
+
if ( empty( $roles ) ) {
|
542 |
+
$roles = 'super_admin';
|
543 |
+
} else {
|
544 |
+
$comment_user->roles[] = 'super_admin';
|
545 |
+
$roles = join( ',', $comment_user->roles );
|
546 |
+
}
|
547 |
+
}
|
548 |
+
|
549 |
+
return $roles;
|
550 |
+
}
|
551 |
+
|
552 |
+
// filter handler used to return a spam result to pre_comment_approved
|
553 |
+
public static function last_comment_status( $approved, $comment ) {
|
554 |
+
// Only do this if it's the correct comment
|
555 |
+
if ( is_null(self::$last_comment_result) || ! self::matches_last_comment( $comment ) ) {
|
556 |
+
self::log( "comment_is_spam mismatched comment, returning unaltered $approved" );
|
557 |
+
return $approved;
|
558 |
+
}
|
559 |
+
|
560 |
+
// bump the counter here instead of when the filter is added to reduce the possibility of overcounting
|
561 |
+
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
562 |
+
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
563 |
+
|
564 |
+
return self::$last_comment_result;
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* If Akismet is temporarily unreachable, we don't want to "spam" the blogger with
|
569 |
+
* moderation emails for comments that will be automatically cleared or spammed on
|
570 |
+
* the next retry.
|
571 |
+
*
|
572 |
+
* For comments that will be rechecked later, empty the list of email addresses that
|
573 |
+
* the moderation email would be sent to.
|
574 |
+
*
|
575 |
+
* @param array $emails An array of email addresses that the moderation email will be sent to.
|
576 |
+
* @param int $comment_id The ID of the relevant comment.
|
577 |
+
* @return array An array of email addresses that the moderation email will be sent to.
|
578 |
+
*/
|
579 |
+
public static function disable_moderation_emails_if_unreachable( $emails, $comment_id ) {
|
580 |
+
if ( ! empty( self::$prevent_moderation_email_for_these_comments ) && ! empty( $emails ) ) {
|
581 |
+
$comment = get_comment( $comment_id );
|
582 |
+
|
583 |
+
foreach ( self::$prevent_moderation_email_for_these_comments as $possible_match ) {
|
584 |
+
if ( self::comments_match( $possible_match, $comment ) ) {
|
585 |
+
update_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true );
|
586 |
+
return array();
|
587 |
+
}
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
return $emails;
|
592 |
+
}
|
593 |
+
|
594 |
+
public static function _cmp_time( $a, $b ) {
|
595 |
+
return $a['time'] > $b['time'] ? -1 : 1;
|
596 |
+
}
|
597 |
+
|
598 |
+
public static function _get_microtime() {
|
599 |
+
$mtime = explode( ' ', microtime() );
|
600 |
+
return $mtime[1] + $mtime[0];
|
601 |
+
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
* Make a POST request to the Akismet API.
|
605 |
+
*
|
606 |
+
* @param string $request The body of the request.
|
607 |
+
* @param string $path The path for the request.
|
608 |
+
* @param string $ip The specific IP address to hit.
|
609 |
+
* @return array A two-member array consisting of the headers and the response body, both empty in the case of a failure.
|
610 |
+
*/
|
611 |
+
public static function http_post( $request, $path, $ip=null ) {
|
612 |
+
|
613 |
+
$akismet_ua = sprintf( 'WordPress/%s | Akismet/%s', $GLOBALS['wp_version'], constant( 'AKISMET_VERSION' ) );
|
614 |
+
$akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
|
615 |
+
|
616 |
+
$content_length = strlen( $request );
|
617 |
+
|
618 |
+
$api_key = self::get_api_key();
|
619 |
+
$host = self::API_HOST;
|
620 |
+
|
621 |
+
if ( !empty( $api_key ) )
|
622 |
+
$host = $api_key.'.'.$host;
|
623 |
+
|
624 |
+
$http_host = $host;
|
625 |
+
// use a specific IP if provided
|
626 |
+
// needed by Akismet_Admin::check_server_connectivity()
|
627 |
+
if ( $ip && long2ip( ip2long( $ip ) ) ) {
|
628 |
+
$http_host = $ip;
|
629 |
+
}
|
630 |
+
|
631 |
+
$http_args = array(
|
632 |
+
'body' => $request,
|
633 |
+
'headers' => array(
|
634 |
+
'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),
|
635 |
+
'Host' => $host,
|
636 |
+
'User-Agent' => $akismet_ua,
|
637 |
+
),
|
638 |
+
'httpversion' => '1.0',
|
639 |
+
'timeout' => 15
|
640 |
+
);
|
641 |
+
|
642 |
+
$akismet_url = "http://{$http_host}/1.1/{$path}";
|
643 |
+
$response = wp_remote_post( $akismet_url, $http_args );
|
644 |
+
Akismet::log( compact( 'akismet_url', 'http_args', 'response' ) );
|
645 |
+
if ( is_wp_error( $response ) )
|
646 |
+
return array( '', '' );
|
647 |
+
|
648 |
+
return array( $response['headers'], $response['body'] );
|
649 |
+
}
|
650 |
+
|
651 |
+
// given a response from an API call like check_key_status(), update the alert code options if an alert is present.
|
652 |
+
private static function update_alert( $response ) {
|
653 |
+
$code = $msg = null;
|
654 |
+
if ( isset( $response[0]['x-akismet-alert-code'] ) ) {
|
655 |
+
$code = $response[0]['x-akismet-alert-code'];
|
656 |
+
$msg = $response[0]['x-akismet-alert-msg'];
|
657 |
+
}
|
658 |
+
|
659 |
+
// only call update_option() if the value has changed
|
660 |
+
if ( $code != get_option( 'akismet_alert_code' ) ) {
|
661 |
+
if ( ! $code ) {
|
662 |
+
delete_option( 'akismet_alert_code' );
|
663 |
+
delete_option( 'akismet_alert_msg' );
|
664 |
+
}
|
665 |
+
else {
|
666 |
+
update_option( 'akismet_alert_code', $code );
|
667 |
+
update_option( 'akismet_alert_msg', $msg );
|
668 |
+
}
|
669 |
+
}
|
670 |
+
}
|
671 |
+
|
672 |
+
public static function load_form_js() {
|
673 |
+
wp_enqueue_script( 'akismet-form', AKISMET__PLUGIN_URL . '_inc/form.js', array( 'jquery' ), AKISMET_VERSION );
|
674 |
+
wp_print_scripts( 'akismet-form' );
|
675 |
+
}
|
676 |
+
|
677 |
+
public static function inject_ak_js( $fields ) {
|
678 |
+
echo '<p style="display: none;">';
|
679 |
+
echo '<input type="hidden" id="ak_js" name="ak_js" value="' . mt_rand( 0, 250 ) . '"/>';
|
680 |
+
echo '</p>';
|
681 |
+
}
|
682 |
+
|
683 |
+
private static function bail_on_activation( $message, $deactivate = true ) {
|
684 |
+
?>
|
685 |
+
<!doctype html>
|
686 |
+
<html>
|
687 |
+
<head>
|
688 |
+
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
689 |
+
<style>
|
690 |
+
* {
|
691 |
+
text-align: center;
|
692 |
+
margin: 0;
|
693 |
+
padding: 0;
|
694 |
+
font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
|
695 |
+
}
|
696 |
+
p {
|
697 |
+
margin-top: 1em;
|
698 |
+
font-size: 18px;
|
699 |
+
}
|
700 |
+
</style>
|
701 |
+
<body>
|
702 |
+
<p><?php echo esc_html( $message ); ?></p>
|
703 |
+
</body>
|
704 |
+
</html>
|
705 |
+
<?php
|
706 |
+
if ( $deactivate ) {
|
707 |
+
$plugins = get_option( 'active_plugins' );
|
708 |
+
$akismet = plugin_basename( AKISMET__PLUGIN_DIR . 'akismet.php' );
|
709 |
+
$update = false;
|
710 |
+
foreach ( $plugins as $i => $plugin ) {
|
711 |
+
if ( $plugin === $akismet ) {
|
712 |
+
$plugins[$i] = false;
|
713 |
+
$update = true;
|
714 |
+
}
|
715 |
+
}
|
716 |
+
|
717 |
+
if ( $update ) {
|
718 |
+
update_option( 'active_plugins', array_filter( $plugins ) );
|
719 |
+
}
|
720 |
+
}
|
721 |
+
exit;
|
722 |
+
}
|
723 |
+
|
724 |
+
public static function view( $name, array $args = array() ) {
|
725 |
+
$args = apply_filters( 'akismet_view_arguments', $args, $name );
|
726 |
+
|
727 |
+
foreach ( $args AS $key => $val ) {
|
728 |
+
$$key = $val;
|
729 |
+
}
|
730 |
+
|
731 |
+
load_plugin_textdomain( 'akismet' );
|
732 |
+
|
733 |
+
$file = AKISMET__PLUGIN_DIR . 'views/'. $name . '.php';
|
734 |
+
|
735 |
+
include( $file );
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
|
740 |
+
* @static
|
741 |
+
*/
|
742 |
+
public static function plugin_activation() {
|
743 |
+
if ( version_compare( $GLOBALS['wp_version'], AKISMET__MINIMUM_WP_VERSION, '<' ) ) {
|
744 |
+
load_plugin_textdomain( 'akismet' );
|
745 |
+
|
746 |
+
$message = '<strong>'.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).'</strong> '.sprintf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/');
|
747 |
+
|
748 |
+
Akismet::bail_on_activation( $message );
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Removes all connection options
|
754 |
+
* @static
|
755 |
+
*/
|
756 |
+
public static function plugin_deactivation( ) {
|
757 |
+
//tidy up
|
758 |
+
}
|
759 |
+
|
760 |
+
public static function log( $akismet_debug ) {
|
761 |
+
if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG )
|
762 |
+
error_log( print_r( compact( 'akismet_debug' ), 1 ) ); //send message to debug.log when in debug mode
|
763 |
+
}
|
764 |
+
}
|
img/logo.png
DELETED
Binary file
|
img/logo@2x.png
DELETED
Binary file
|
index.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?php
|
2 |
-
# Silence is golden.
|
1 |
<?php
|
2 |
+
# Silence is golden.
|
legacy.php
DELETED
@@ -1,396 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {
|
4 |
-
global $wpdb;
|
5 |
-
|
6 |
-
$page = (int) $page;
|
7 |
-
if ( $page < 2 )
|
8 |
-
$page = 1;
|
9 |
-
|
10 |
-
$per_page = (int) $per_page;
|
11 |
-
if ( $per_page < 1 )
|
12 |
-
$per_page = 50;
|
13 |
-
|
14 |
-
$start = ( $page - 1 ) * $per_page;
|
15 |
-
$end = $start + $per_page;
|
16 |
-
|
17 |
-
if ( $type ) {
|
18 |
-
if ( 'comments' == $type || 'comment' == $type )
|
19 |
-
$type = '';
|
20 |
-
else
|
21 |
-
$type = $wpdb->escape( $type );
|
22 |
-
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");
|
23 |
-
}
|
24 |
-
|
25 |
-
// All
|
26 |
-
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
|
27 |
-
}
|
28 |
-
|
29 |
-
// Totals for each comment type
|
30 |
-
// returns array( type => count, ... )
|
31 |
-
function akismet_spam_totals() {
|
32 |
-
global $wpdb;
|
33 |
-
$totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
|
34 |
-
$return = array();
|
35 |
-
foreach ( $totals as $total )
|
36 |
-
$return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;
|
37 |
-
return $return;
|
38 |
-
}
|
39 |
-
|
40 |
-
function akismet_manage_page() {
|
41 |
-
global $wpdb, $submenu, $wp_db_version;
|
42 |
-
|
43 |
-
// WP 2.7 has its own spam management page
|
44 |
-
if ( 8645 <= $wp_db_version )
|
45 |
-
return;
|
46 |
-
|
47 |
-
$count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());
|
48 |
-
if ( isset( $submenu['edit-comments.php'] ) )
|
49 |
-
add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );
|
50 |
-
elseif ( function_exists('add_management_page') )
|
51 |
-
add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');
|
52 |
-
}
|
53 |
-
|
54 |
-
function akismet_caught() {
|
55 |
-
global $wpdb, $comment, $akismet_caught, $akismet_nonce;
|
56 |
-
|
57 |
-
akismet_recheck_queue();
|
58 |
-
if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
|
59 |
-
check_admin_referer( $akismet_nonce );
|
60 |
-
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
|
61 |
-
die(__('You do not have sufficient permission to moderate comments.'));
|
62 |
-
|
63 |
-
$i = 0;
|
64 |
-
foreach ($_POST['not_spam'] as $comment):
|
65 |
-
$comment = (int) $comment;
|
66 |
-
if ( function_exists('wp_set_comment_status') )
|
67 |
-
wp_set_comment_status($comment, 'approve');
|
68 |
-
else
|
69 |
-
$wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
|
70 |
-
akismet_submit_nonspam_comment($comment);
|
71 |
-
++$i;
|
72 |
-
endforeach;
|
73 |
-
$to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
|
74 |
-
wp_safe_redirect( $to );
|
75 |
-
exit;
|
76 |
-
}
|
77 |
-
if ('delete' == $_POST['action']) {
|
78 |
-
check_admin_referer( $akismet_nonce );
|
79 |
-
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
|
80 |
-
die(__('You do not have sufficient permission to moderate comments.'));
|
81 |
-
|
82 |
-
$delete_time = $wpdb->escape( $_POST['display_time'] );
|
83 |
-
$comment_ids = $wpdb->get_col( "SELECT comment_id FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
|
84 |
-
if ( !empty( $comment_ids ) ) {
|
85 |
-
do_action( 'delete_comment', $comment_ids );
|
86 |
-
$wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
|
87 |
-
wp_cache_delete( 'akismet_spam_count', 'widget' );
|
88 |
-
}
|
89 |
-
$to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
|
90 |
-
wp_safe_redirect( $to );
|
91 |
-
exit;
|
92 |
-
}
|
93 |
-
|
94 |
-
if ( isset( $_GET['recovered'] ) ) {
|
95 |
-
$i = (int) $_GET['recovered'];
|
96 |
-
echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";
|
97 |
-
}
|
98 |
-
|
99 |
-
if (isset( $_GET['deleted'] ) )
|
100 |
-
echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';
|
101 |
-
|
102 |
-
if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )
|
103 |
-
$link = 'edit-comments.php';
|
104 |
-
else
|
105 |
-
$link = 'edit.php';
|
106 |
-
?>
|
107 |
-
<style type="text/css">
|
108 |
-
.akismet-tabs {
|
109 |
-
list-style: none;
|
110 |
-
margin: 0;
|
111 |
-
padding: 0;
|
112 |
-
clear: both;
|
113 |
-
border-bottom: 1px solid #ccc;
|
114 |
-
height: 31px;
|
115 |
-
margin-bottom: 20px;
|
116 |
-
background: #ddd;
|
117 |
-
border-top: 1px solid #bdbdbd;
|
118 |
-
}
|
119 |
-
.akismet-tabs li {
|
120 |
-
float: left;
|
121 |
-
margin: 5px 0 0 20px;
|
122 |
-
}
|
123 |
-
.akismet-tabs a {
|
124 |
-
display: block;
|
125 |
-
padding: 4px .5em 3px;
|
126 |
-
border-bottom: none;
|
127 |
-
color: #036;
|
128 |
-
}
|
129 |
-
.akismet-tabs .active a {
|
130 |
-
background: #fff;
|
131 |
-
border: 1px solid #ccc;
|
132 |
-
border-bottom: none;
|
133 |
-
color: #000;
|
134 |
-
font-weight: bold;
|
135 |
-
padding-bottom: 4px;
|
136 |
-
}
|
137 |
-
#akismetsearch {
|
138 |
-
float: right;
|
139 |
-
margin-top: -.5em;
|
140 |
-
}
|
141 |
-
|
142 |
-
#akismetsearch p {
|
143 |
-
margin: 0;
|
144 |
-
padding: 0;
|
145 |
-
}
|
146 |
-
</style>
|
147 |
-
<div class="wrap">
|
148 |
-
<h2><?php _e('Caught Spam') ?></h2>
|
149 |
-
<?php
|
150 |
-
$count = get_option( 'akismet_spam_count' );
|
151 |
-
if ( $count ) {
|
152 |
-
?>
|
153 |
-
<p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p>
|
154 |
-
<?php
|
155 |
-
}
|
156 |
-
|
157 |
-
$spam_count = akismet_spam_count();
|
158 |
-
|
159 |
-
if ( 0 == $spam_count ) {
|
160 |
-
echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';
|
161 |
-
echo '</div>';
|
162 |
-
} else {
|
163 |
-
echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.').'</p>';
|
164 |
-
?>
|
165 |
-
<?php if ( !isset( $_POST['s'] ) ) { ?>
|
166 |
-
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
167 |
-
<?php akismet_nonce_field($akismet_nonce) ?>
|
168 |
-
<input type="hidden" name="action" value="delete" />
|
169 |
-
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?> <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" />
|
170 |
-
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
|
171 |
-
</form>
|
172 |
-
<?php } ?>
|
173 |
-
</div>
|
174 |
-
<div class="wrap">
|
175 |
-
<?php if ( isset( $_POST['s'] ) ) { ?>
|
176 |
-
<h2><?php _e('Search'); ?></h2>
|
177 |
-
<?php } else { ?>
|
178 |
-
<?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?>
|
179 |
-
<?php } ?>
|
180 |
-
<?php
|
181 |
-
if ( isset( $_POST['s'] ) ) {
|
182 |
-
$s = $wpdb->escape($_POST['s']);
|
183 |
-
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
|
184 |
-
(comment_author LIKE '%$s%' OR
|
185 |
-
comment_author_email LIKE '%$s%' OR
|
186 |
-
comment_author_url LIKE ('%$s%') OR
|
187 |
-
comment_author_IP LIKE ('%$s%') OR
|
188 |
-
comment_content LIKE ('%$s%') ) AND
|
189 |
-
comment_approved = 'spam'
|
190 |
-
ORDER BY comment_date DESC");
|
191 |
-
} else {
|
192 |
-
if ( isset( $_GET['apage'] ) )
|
193 |
-
$page = (int) $_GET['apage'];
|
194 |
-
else
|
195 |
-
$page = 1;
|
196 |
-
|
197 |
-
if ( $page < 2 )
|
198 |
-
$page = 1;
|
199 |
-
|
200 |
-
$current_type = false;
|
201 |
-
if ( isset( $_GET['ctype'] ) )
|
202 |
-
$current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
|
203 |
-
|
204 |
-
$comments = akismet_spam_comments( $current_type, $page );
|
205 |
-
$total = akismet_spam_count( $current_type );
|
206 |
-
$totals = akismet_spam_totals();
|
207 |
-
?>
|
208 |
-
<ul class="akismet-tabs">
|
209 |
-
<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
|
210 |
-
<?php
|
211 |
-
foreach ( $totals as $type => $type_count ) {
|
212 |
-
if ( 'comment' == $type ) {
|
213 |
-
$type = 'comments';
|
214 |
-
$show = __('Comments');
|
215 |
-
} else {
|
216 |
-
$show = ucwords( $type );
|
217 |
-
}
|
218 |
-
$type_count = number_format_i18n( $type_count );
|
219 |
-
$extra = $current_type === $type ? ' class="active"' : '';
|
220 |
-
echo "<li $extra><a href='edit-comments.php?page=akismet-admin&ctype=$type'>$show ($type_count)</a></li>";
|
221 |
-
}
|
222 |
-
do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
|
223 |
-
?>
|
224 |
-
</ul>
|
225 |
-
<?php
|
226 |
-
}
|
227 |
-
|
228 |
-
if ($comments) {
|
229 |
-
?>
|
230 |
-
<form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch">
|
231 |
-
<p> <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />
|
232 |
-
<input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam »')) ?>" /> </p>
|
233 |
-
</form>
|
234 |
-
<?php if ( $total > 50 ) {
|
235 |
-
$total_pages = ceil( $total / 50 );
|
236 |
-
$r = '';
|
237 |
-
if ( 1 < $page ) {
|
238 |
-
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
|
239 |
-
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('« Previous Page') .'</a>' . "\n";
|
240 |
-
}
|
241 |
-
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
|
242 |
-
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
|
243 |
-
if ( $page == $page_num ) :
|
244 |
-
$r .= "<strong>$page_num</strong>\n";
|
245 |
-
else :
|
246 |
-
$p = false;
|
247 |
-
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
|
248 |
-
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
|
249 |
-
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
|
250 |
-
$in = true;
|
251 |
-
elseif ( $in == true ) :
|
252 |
-
$r .= "...\n";
|
253 |
-
$in = false;
|
254 |
-
endif;
|
255 |
-
endif;
|
256 |
-
endfor;
|
257 |
-
}
|
258 |
-
if ( ( $page ) * 50 < $total || -1 == $total ) {
|
259 |
-
$args['apage'] = $page + 1;
|
260 |
-
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page »') .'</a>' . "\n";
|
261 |
-
}
|
262 |
-
echo "<p>$r</p>";
|
263 |
-
?>
|
264 |
-
|
265 |
-
<?php } ?>
|
266 |
-
<form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
267 |
-
<?php akismet_nonce_field($akismet_nonce) ?>
|
268 |
-
<input type="hidden" name="action" value="recover" />
|
269 |
-
<ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;">
|
270 |
-
<?php
|
271 |
-
$i = 0;
|
272 |
-
foreach($comments as $comment) {
|
273 |
-
$i++;
|
274 |
-
$comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
|
275 |
-
$post = get_post($comment->comment_post_ID);
|
276 |
-
$post_title = $post->post_title;
|
277 |
-
if ($i % 2) $class = 'class="alternate"';
|
278 |
-
else $class = '';
|
279 |
-
echo "\n\t<li id='comment-$comment->comment_ID' $class>";
|
280 |
-
?>
|
281 |
-
|
282 |
-
<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
|
283 |
-
|
284 |
-
<?php comment_text() ?>
|
285 |
-
|
286 |
-
<p><label for="spam-<?php echo $comment->comment_ID; ?>">
|
287 |
-
<input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" />
|
288 |
-
<?php _e('Not Spam') ?></label> — <?php comment_date('M j, g:i A'); ?> — [
|
289 |
-
<?php
|
290 |
-
$post = get_post($comment->comment_post_ID);
|
291 |
-
$post_title = wp_specialchars( $post->post_title, 'double' );
|
292 |
-
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
|
293 |
-
?>
|
294 |
-
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] </p>
|
295 |
-
|
296 |
-
|
297 |
-
<?php
|
298 |
-
}
|
299 |
-
?>
|
300 |
-
</ul>
|
301 |
-
<?php if ( $total > 50 ) {
|
302 |
-
$total_pages = ceil( $total / 50 );
|
303 |
-
$r = '';
|
304 |
-
if ( 1 < $page ) {
|
305 |
-
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
|
306 |
-
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('« Previous Page') .'</a>' . "\n";
|
307 |
-
}
|
308 |
-
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
|
309 |
-
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
|
310 |
-
if ( $page == $page_num ) :
|
311 |
-
$r .= "<strong>$page_num</strong>\n";
|
312 |
-
else :
|
313 |
-
$p = false;
|
314 |
-
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
|
315 |
-
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
|
316 |
-
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
|
317 |
-
$in = true;
|
318 |
-
elseif ( $in == true ) :
|
319 |
-
$r .= "...\n";
|
320 |
-
$in = false;
|
321 |
-
endif;
|
322 |
-
endif;
|
323 |
-
endfor;
|
324 |
-
}
|
325 |
-
if ( ( $page ) * 50 < $total || -1 == $total ) {
|
326 |
-
$args['apage'] = $page + 1;
|
327 |
-
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page »') .'</a>' . "\n";
|
328 |
-
}
|
329 |
-
echo "<p>$r</p>";
|
330 |
-
}
|
331 |
-
?>
|
332 |
-
<p class="submit">
|
333 |
-
<input type="submit" name="submit" value="<?php echo attribute_escape(__('De-spam marked comments »')); ?>" />
|
334 |
-
</p>
|
335 |
-
<p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.'); ?></p>
|
336 |
-
</form>
|
337 |
-
<?php
|
338 |
-
} else {
|
339 |
-
?>
|
340 |
-
<p><?php _e('No results found.'); ?></p>
|
341 |
-
<?php } ?>
|
342 |
-
|
343 |
-
<?php if ( !isset( $_POST['s'] ) ) { ?>
|
344 |
-
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
345 |
-
<?php akismet_nonce_field($akismet_nonce) ?>
|
346 |
-
<p><input type="hidden" name="action" value="delete" />
|
347 |
-
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?> <input type="submit" name="Submit" class="button" value="<?php echo attribute_escape(__('Delete all')); ?>" />
|
348 |
-
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
|
349 |
-
</form>
|
350 |
-
<?php } ?>
|
351 |
-
</div>
|
352 |
-
<?php
|
353 |
-
}
|
354 |
-
}
|
355 |
-
|
356 |
-
add_action('admin_menu', 'akismet_manage_page');
|
357 |
-
|
358 |
-
function redirect_old_akismet_urls( ) {
|
359 |
-
global $wp_db_version;
|
360 |
-
$script_name = array_pop( split( '/', $_SERVER['PHP_SELF'] ) );
|
361 |
-
|
362 |
-
$page = '';
|
363 |
-
if ( !empty( $_GET['page'] ) )
|
364 |
-
$page = $_GET['page'];
|
365 |
-
|
366 |
-
// 2.7 redirect for people who might have bookmarked the old page
|
367 |
-
if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
|
368 |
-
$new_url = esc_url( 'edit-comments.php?comment_status=spam' );
|
369 |
-
wp_safe_redirect( $new_url, 301 );
|
370 |
-
exit;
|
371 |
-
}
|
372 |
-
}
|
373 |
-
add_action( 'admin_init', 'redirect_old_akismet_urls' );
|
374 |
-
|
375 |
-
// For WP <= 2.3.x
|
376 |
-
global $pagenow;
|
377 |
-
|
378 |
-
if ( 'moderation.php' == $pagenow ) {
|
379 |
-
function akismet_recheck_button( $page ) {
|
380 |
-
global $submenu;
|
381 |
-
if ( isset( $submenu['edit-comments.php'] ) )
|
382 |
-
$link = 'edit-comments.php';
|
383 |
-
else
|
384 |
-
$link = 'edit.php';
|
385 |
-
$button = "<a href='$link?page=akismet-admin&recheckqueue=true&noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";
|
386 |
-
$page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );
|
387 |
-
return $page;
|
388 |
-
}
|
389 |
-
|
390 |
-
if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
|
391 |
-
ob_start( 'akismet_recheck_button' );
|
392 |
-
}
|
393 |
-
|
394 |
-
// This option causes tons of FPs, was removed in 2.1
|
395 |
-
function akismet_kill_proxy_check( $option ) { return 0; }
|
396 |
-
add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
=== Akismet ===
|
2 |
-
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, automattic
|
3 |
Tags: akismet, comments, spam
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.8.1
|
@@ -31,6 +31,19 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
31 |
|
32 |
== Changelog ==
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
= 2.6.0 =
|
35 |
* Add ajax paging to the check for spam button to handle large volumes of comments
|
36 |
* Optimize javascript and add localization support
|
1 |
=== Akismet ===
|
2 |
+
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic
|
3 |
Tags: akismet, comments, spam
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.8.1
|
31 |
|
32 |
== Changelog ==
|
33 |
|
34 |
+
= 3.0-beta =
|
35 |
+
* Move Akismet to Settings menu
|
36 |
+
* Drop Akismet Stats menu
|
37 |
+
* Add stats snapshot to Akismet settings
|
38 |
+
* Add Akismet subscription details and status to Akismet settings
|
39 |
+
* Add contextual help for each page
|
40 |
+
* Improve Akismet setup to use Jetpack to automate plugin setup
|
41 |
+
* Fix Update Check for Spam to use ajax to avoid page timing out
|
42 |
+
* Fix Akismet settings page to be responsive
|
43 |
+
* Drop legacy code
|
44 |
+
* Tidy up CSS an Javascript
|
45 |
+
* Replace the old discard setting with a new "discard pervasive spam" feature.
|
46 |
+
|
47 |
= 2.6.0 =
|
48 |
* Add ajax paging to the check for spam button to handle large volumes of comments
|
49 |
* Optimize javascript and add localization support
|
views/config.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
|
3 |
+
<h2><?php esc_html_e( 'Akismet' , 'akismet');?></h2>
|
4 |
+
|
5 |
+
<div class="have-key">
|
6 |
+
|
7 |
+
<?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?>
|
8 |
+
|
9 |
+
<div class="new-snapshot stats">
|
10 |
+
|
11 |
+
<span style="float:right;margin:10px 15px -5px 0px">
|
12 |
+
<a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>" class=""><?php esc_html_e( 'Summaries' , 'akismet');?></a>
|
13 |
+
</span>
|
14 |
+
|
15 |
+
<iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 215px; overflow: hidden;" src="<?php printf( 'http://akismet.com/web/1.0/snapshot.php?blog=%s&api_key=%s&height=180', $blog, $api_key );?>"></iframe>
|
16 |
+
<ul>
|
17 |
+
<li>
|
18 |
+
<h3><?php esc_html_e( 'Past six months' , 'akismet');?></h3>
|
19 |
+
<span><?php echo number_format( $stat_totals['6-months']->spam );?></span>
|
20 |
+
<?php esc_html_e( 'Spam blocked' , 'akismet');?>
|
21 |
+
</li>
|
22 |
+
<li>
|
23 |
+
<h3><?php esc_html_e( 'All time' , 'akismet');?></h3>
|
24 |
+
<span><?php echo number_format( $stat_totals['all']->spam );?></span>
|
25 |
+
<?php esc_html_e( 'Spam blocked' , 'akismet');?>
|
26 |
+
</li>
|
27 |
+
<li>
|
28 |
+
<h3><?php esc_html_e( 'Accuracy' , 'akismet');?></h3>
|
29 |
+
<span><?php echo $stat_totals['all']->accuracy; ?>%</span>
|
30 |
+
<?php printf(
|
31 |
+
esc_html(
|
32 |
+
_n( '%s missed spam, %s false positive', '%s missed spam, %s false positives', $stat_totals['all']->false_positives , 'akismet')
|
33 |
+
),
|
34 |
+
number_format( $stat_totals['all']->missed_spam ),
|
35 |
+
number_format( $stat_totals['all']->false_positives )
|
36 |
+
); ?>
|
37 |
+
</li>
|
38 |
+
</ul>
|
39 |
+
<div class="clearfix"></div>
|
40 |
+
</div>
|
41 |
+
<?php endif;?>
|
42 |
+
|
43 |
+
<?php if ( $akismet_user ):?>
|
44 |
+
|
45 |
+
<div id="wpcom-stats-meta-box-container" class="metabox-holder"><?php
|
46 |
+
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
47 |
+
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
48 |
+
?>
|
49 |
+
<script type="text/javascript">
|
50 |
+
jQuery(document).ready( function($) {
|
51 |
+
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
52 |
+
if(typeof postboxes !== 'undefined')
|
53 |
+
postboxes.add_postbox_toggles( 'plugins_page_akismet-key-config' );
|
54 |
+
});
|
55 |
+
</script>
|
56 |
+
<div class="postbox-container" style="width: 55%;margin-right: 10px;">
|
57 |
+
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
58 |
+
<div id="referrers" class="postbox ">
|
59 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
60 |
+
<h3 class="hndle"><span><?php esc_html_e( 'Settings' , 'akismet');?></span></h3>
|
61 |
+
<form name="akismet_conf" id="akismet-conf" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
|
62 |
+
<div class="inside">
|
63 |
+
<table cellspacing="0" class="akismet-settings">
|
64 |
+
<tbody>
|
65 |
+
<?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
|
66 |
+
<tr>
|
67 |
+
<th width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th>
|
68 |
+
<td width="5%"/>
|
69 |
+
<td align="left">
|
70 |
+
<span class="api-key"><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="regular-text code <?php echo $akismet_user->status;?>"></span>
|
71 |
+
</td>
|
72 |
+
</tr>
|
73 |
+
<?php endif; ?>
|
74 |
+
<tr>
|
75 |
+
<th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th>
|
76 |
+
<td></td>
|
77 |
+
<td align="left">
|
78 |
+
<p>
|
79 |
+
<label for="akismet_show_user_comments_approved" title="<?php esc_attr_e( 'Show approved comments' , 'akismet'); ?>"><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="1" type="checkbox" <?php checked('1', get_option('akismet_show_user_comments_approved')); ?>> <?php esc_html_e('Show the number of approved comments beside each comment author', 'akismet'); ?></label>
|
80 |
+
</p>
|
81 |
+
</td>
|
82 |
+
</tr>
|
83 |
+
<tr>
|
84 |
+
<th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th>
|
85 |
+
<td></td>
|
86 |
+
<td align="left">
|
87 |
+
<fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
|
88 |
+
<p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p>
|
89 |
+
<p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
|
90 |
+
</fieldset>
|
91 |
+
<span class="note"><strong><?php esc_html_e('Note:', 'akismet');?></strong> <?php printf( __( 'Spam in the <a href="%s">spam folder</a> older than 15 days is deleted automatically.' , 'akismet'), admin_url( 'edit-comments.php?type=spam' ) );?></span>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
+
</tbody>
|
95 |
+
</table>
|
96 |
+
</div>
|
97 |
+
<div id="major-publishing-actions">
|
98 |
+
<?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
|
99 |
+
<div id="delete-action">
|
100 |
+
<a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e('Disconnect this account', 'akismet'); ?></a>
|
101 |
+
</div>
|
102 |
+
<?php endif; ?>
|
103 |
+
<?php wp_nonce_field(Akismet_Admin::NONCE) ?>
|
104 |
+
<div id="publishing-action">
|
105 |
+
<input type="hidden" name="action" value="enter-key">
|
106 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>">
|
107 |
+
|
108 |
+
</div>
|
109 |
+
<div class="clear"></div>
|
110 |
+
</div>
|
111 |
+
</form>
|
112 |
+
</div>
|
113 |
+
</div>
|
114 |
+
</div>
|
115 |
+
<div class="postbox-container" style="width:44%;">
|
116 |
+
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
117 |
+
<div id="referrers" class="postbox ">
|
118 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
119 |
+
<h3 class="hndle"><span><?php esc_html_e( 'Account' , 'akismet');?></span></h3>
|
120 |
+
<div class="inside">
|
121 |
+
<table cellspacing="0">
|
122 |
+
<tbody>
|
123 |
+
<tr>
|
124 |
+
<th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th>
|
125 |
+
<td width="5%"/>
|
126 |
+
<td align="left">
|
127 |
+
<span><?php echo $akismet_user->account_name; ?></span>
|
128 |
+
</td>
|
129 |
+
</tr>
|
130 |
+
<tr>
|
131 |
+
<th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th>
|
132 |
+
<td width="5%"/>
|
133 |
+
<td align="left">
|
134 |
+
<span><?php echo ucwords( $akismet_user->status ); ?></span>
|
135 |
+
</td>
|
136 |
+
</tr>
|
137 |
+
<?php if ( $akismet_user->next_billing_date ) : ?>
|
138 |
+
<tr>
|
139 |
+
<th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th>
|
140 |
+
<td width="5%"/>
|
141 |
+
<td align="left">
|
142 |
+
<span><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></span>
|
143 |
+
</td>
|
144 |
+
</tr>
|
145 |
+
<?php endif; ?>
|
146 |
+
</tbody>
|
147 |
+
</table>
|
148 |
+
</div>
|
149 |
+
<div id="major-publishing-actions">
|
150 |
+
<div id="publishing-action">
|
151 |
+
<?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?>
|
152 |
+
</div>
|
153 |
+
<div class="clear"></div>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
</div>
|
158 |
+
</div>
|
159 |
+
|
160 |
+
<?php endif;?>
|
161 |
+
|
162 |
+
</div>
|
163 |
+
</div>
|
views/get.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<form name="akismet_activate" action="https://akismet.com/get/" method="POST">
|
2 |
+
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
|
3 |
+
<input type="hidden" name="redirect" value="<?php echo isset( $redirect ) ? $redirect : 'plugin-signup'; ?>"/>
|
4 |
+
<input type="submit" class="<?php echo isset( $classes ) && count( $classes ) > 0 ? implode( ' ', $classes ) : 'button button-primary';?>" value="<?php echo esc_attr( $text ); ?>"/>
|
5 |
+
</form>
|
views/notice.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ( $type == 'plugin' ) :?>
|
2 |
+
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
|
3 |
+
<style type="text/css">
|
4 |
+
.akismet_activate{min-width:825px;border:1px solid #4F800D;padding:5px;margin:15px 0;background:#83AF24;background-image:-webkit-gradient(linear,0% 0,80% 100%,from(#83AF24),to(#4F800D));background-image:-moz-linear-gradient(80% 100% 120deg,#4F800D,#83AF24);-moz-border-radius:3px;border-radius:3px;-webkit-border-radius:3px;position:relative;overflow:hidden}.akismet_activate .aa_a{position:absolute;top:-5px;right:10px;font-size:140px;color:#769F33;font-family:Georgia, "Times New Roman", Times, serif;z-index:1}.akismet_activate .aa_button{font-weight:bold;border:1px solid #029DD6;border-top:1px solid #06B9FD;font-size:15px;text-align:center;padding:9px 0 8px 0;color:#FFF;background:#029DD6;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#029DD6),to(#0079B1));background-image:-moz-linear-gradient(0% 100% 90deg,#0079B1,#029DD6);-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px}.akismet_activate .aa_button:hover{text-decoration:none !important;border:1px solid #029DD6;border-bottom:1px solid #00A8EF;font-size:15px;text-align:center;padding:9px 0 8px 0;color:#F0F8FB;background:#0079B1;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#0079B1),to(#0092BF));background-image:-moz-linear-gradient(0% 100% 90deg,#0092BF,#0079B1);-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px}.akismet_activate .aa_button_border{border:1px solid #006699;-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px;background:#029DD6;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#029DD6),to(#0079B1));background-image:-moz-linear-gradient(0% 100% 90deg,#0079B1,#029DD6)}.akismet_activate .aa_button_container{cursor:pointer;display:inline-block;background:#DEF1B8;padding:5px;-moz-border-radius:2px;border-radius:2px;-webkit-border-radius:2px;width:266px}.akismet_activate .aa_description{position:absolute;top:22px;left:285px;margin-left:25px;color:#E5F2B1;font-size:15px;z-index:1000}.akismet_activate .aa_description strong{color:#FFF;font-weight:normal}
|
5 |
+
</style>
|
6 |
+
<form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
|
7 |
+
<div class="akismet_activate">
|
8 |
+
<div class="aa_a">A</div>
|
9 |
+
<div class="aa_button_container" onclick="document.akismet_activate.submit();">
|
10 |
+
<div class="aa_button_border">
|
11 |
+
<div class="aa_button"><?php esc_html_e('Activate your Akismet account', 'akismet');?></div>
|
12 |
+
</div>
|
13 |
+
</div>
|
14 |
+
<div class="aa_description"><?php _e('<strong>Almost done</strong> - activate your account and say goodbye to comment spam', 'akismet');?></div>
|
15 |
+
</div>
|
16 |
+
</form>
|
17 |
+
</div>
|
18 |
+
<?php elseif ( $type == 'spam-check' ) :?>
|
19 |
+
<div id="akismet-warning" class="updated fade"><p><strong><?php esc_html_e('Akismet has detected a problem.', 'akismet');?></strong> <?php printf( __('Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation. Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.', 'akismet'), esc_url( Akismet_Admin::get_page_url() ) );?></p></div>
|
20 |
+
<?php elseif ( $type == 'version' ) :?>
|
21 |
+
<div id="akismet-warning" class="updated fade"><p><strong><?php printf( esc_html__('Akismet %s requires WordPress 3.0 or higher.', 'akismet'), AKISMET_VERSION);?></strong> <?php printf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'https://wordpress.org/extend/plugins/akismet/download/');?></p></div>
|
22 |
+
<?php elseif ( $type == 'alert' ) :?>
|
23 |
+
<div class='error'>
|
24 |
+
<p><strong><?php printf( esc_html__( 'Akismet Error Code: %s', 'akismet' ), $code ); ?></strong></p>
|
25 |
+
<p><?php echo esc_html( $msg ); ?></p>
|
26 |
+
<p><?php
|
27 |
+
|
28 |
+
/* translators: the placeholder is a clickable URL that leads to more information regarding an error code. */
|
29 |
+
printf( esc_html__( 'For more information: %s' , 'akismet'), '<a href="https://akismet.com/errors/' . $code . '">https://akismet.com/errors/' . $code . '</a>' );
|
30 |
+
|
31 |
+
?>
|
32 |
+
</p>
|
33 |
+
</div>
|
34 |
+
<?php elseif ( $type == 'missing-functions' ) :?>
|
35 |
+
<div class="wrap alert critical">
|
36 |
+
<h3 class="key-status failed"><?php esc_html_e('Network functions are disabled.', 'akismet'); ?></h3>
|
37 |
+
<p class="description"><?php printf( __('Your web host or server administrator has disabled PHP’s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet’s system requirements</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
38 |
+
</div>
|
39 |
+
<?php elseif ( $type == 'servers-be-down' ) :?>
|
40 |
+
<div class="wrap alert critical">
|
41 |
+
<h3 class="key-status failed"><?php esc_html_e("We can’t connect to your site.", 'akismet'); ?></h3>
|
42 |
+
<p class="description"><?php printf( __('Your firewall may be blocking us. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
43 |
+
</div>
|
44 |
+
<?php elseif ( $type == 'active-dunning' ) :?>
|
45 |
+
<div class="wrap alert critical">
|
46 |
+
<h3 class="key-status"><?php esc_html_e("Please update your payment details.", 'akismet'); ?></h3>
|
47 |
+
<p class="description"><?php printf( __('We cannot process your transaction. Please contact your bank for assistance, and <a href="%s" target="_blank">update your payment details</a>.', 'akismet'), 'https://akismet.com/account/'); ?></p>
|
48 |
+
</div>
|
49 |
+
<?php elseif ( $type == 'cancelled' ) :?>
|
50 |
+
<div class="wrap alert critical">
|
51 |
+
<h3 class="key-status"><?php esc_html_e("Your subscription is cancelled.", 'akismet'); ?></h3>
|
52 |
+
<p class="description"><?php printf( __('Please visit the <a href="%s" target="_blank">Akismet account page</a> to reactivate your subscription.', 'akismet'), 'https://akismet.com/account/'); ?></p>
|
53 |
+
</div>
|
54 |
+
<?php elseif ( $type == 'suspended' ) :?>
|
55 |
+
<div class="wrap alert critical">
|
56 |
+
<h3 class="key-status failed"><?php esc_html_e("Your subscription is suspended.", 'akismet'); ?></h3>
|
57 |
+
<p class="description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
|
58 |
+
</div>
|
59 |
+
<?php elseif ( $type == 'active-notice' && $time_saved ) :?>
|
60 |
+
<div class="wrap alert active">
|
61 |
+
<h3 class="key-status"><?php echo esc_html( $time_saved ); ?></h3>
|
62 |
+
<p class="description"><?php printf( __('You can help us fight spam and upgrade your account by <a href="%s" target="_blank">contributing a token amount</a>.', 'akismet'), 'https://akismet.com/account/upgrade/'); ?></p>
|
63 |
+
</div>
|
64 |
+
<?php elseif ( $type == 'missing' ) :?>
|
65 |
+
<div class="wrap alert critical">
|
66 |
+
<h3 class="key-status failed"><?php esc_html_e("Your subscription is missing.", 'akismet'); ?></h3>
|
67 |
+
<p class="description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
|
68 |
+
</div>
|
69 |
+
<?php elseif ( $type == 'new-key-valid' ) :?>
|
70 |
+
<div class="wrap alert active">
|
71 |
+
<h3 class="key-status"><?php esc_html_e('Your Akismet account has been successfully set up and activated. Happy blogging!', 'akismet'); ?></h3>
|
72 |
+
</div>
|
73 |
+
<?php elseif ( $type == 'new-key-invalid' ) :?>
|
74 |
+
<div class="wrap alert critical">
|
75 |
+
<h3 class="key-status"><?php esc_html_e( 'The key you entered is invalid. Please double-check it.' , 'akismet'); ?></h3>
|
76 |
+
</div>
|
77 |
+
<?php elseif ( $type == 'new-key-failed' ) :?>
|
78 |
+
<div class="wrap alert critical">
|
79 |
+
<h3 class="key-status"><?php esc_html_e( 'The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.' , 'akismet'); ?></h3>
|
80 |
+
</div>
|
81 |
+
<?php elseif ( $type == 'limit-reached' && in_array( $level, array( 'yellow', 'red' ) ) ) :?>
|
82 |
+
<div class="wrap alert critical">
|
83 |
+
<?php if ( $level == 'yellow' ): ?>
|
84 |
+
<h3 class="key-status failed"><?php esc_html_e("You're using your Akismet key on more sites than your Pro subscription allows.", 'akismet'); ?></h3>
|
85 |
+
<p class="description"><?php printf( __('If you would like to use Akismet on more than 10 sites, you will need to <a href="%s" target="_blank">upgrade to an Enterprise subscription</a>. If you have any questions, please <a href="%s" target="_blank">get in touch with our support team</a>', 'akismet'), 'https://akismet.com/account/', 'https://akismet.com/contact/'); ?></p>
|
86 |
+
<?php elseif ( $level == 'red' ): ?>
|
87 |
+
<h3 class="key-status failed"><?php esc_html_e("You're using Akismet on far too many sites for your Pro subscription.", 'akismet'); ?></h3>
|
88 |
+
<p class="description"><?php printf( __('To continue your service, <a href="%s" target="_blank">upgrade to an Enterprise subscription</a>, which covers an unlimited number of sites. Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet'), 'https://akismet.com/account/', 'https://akismet.com/contact/'); ?></p>
|
89 |
+
<?php endif; ?>
|
90 |
+
</div>
|
91 |
+
<?php endif;?>
|
views/start.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="no-key config-wrap"><?php
|
2 |
+
if ( $akismet_user ) :
|
3 |
+
if ( $akismet_user->status == 'active' ) : // ask do they want to use akismet account found using jetpack wpcom connection ?>
|
4 |
+
<p style="margin-right:10px"><?php esc_html_e('Akismet eliminates the comment and trackback spam you get on your site. To setup Akismet, select one of the options below.', 'akismet'); ?></p>
|
5 |
+
<div class="activate-highlight activate-option">
|
6 |
+
<div class="option-description">
|
7 |
+
<strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
|
8 |
+
<?php echo esc_attr( $akismet_user->user_email ); ?>
|
9 |
+
</div>
|
10 |
+
<form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="right">
|
11 |
+
<input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
|
12 |
+
<input type="hidden" name="action" value="enter-key">
|
13 |
+
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
14 |
+
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Use this Akismet account' , 'akismet'); ?>"/>
|
15 |
+
</form>
|
16 |
+
</div>
|
17 |
+
<div class="activate-highlight secondary activate-option">
|
18 |
+
<div class="option-description">
|
19 |
+
<strong><?php esc_html_e('Create a new API key with a different email address', 'akismet'); ?></strong>
|
20 |
+
<p><?php esc_html_e('Use this option if you want to setup a new Akismet account.', 'akismet'); ?></p>
|
21 |
+
</div>
|
22 |
+
<?php Akismet::view( 'get', array( 'text' => __( 'Register a different email address' , 'akismet'), 'classes' => array( 'right', 'button', 'button-secondary' ) ) ); ?>
|
23 |
+
</div>
|
24 |
+
<div class="activate-highlight secondary activate-option">
|
25 |
+
<div class="option-description">
|
26 |
+
<strong><?php esc_html_e('Manually enter an API key', 'akismet'); ?></strong>
|
27 |
+
<p><?php esc_html_e('If you have another API key you want to use.', 'akismet'); ?></p>
|
28 |
+
</div>
|
29 |
+
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
|
30 |
+
<input id="key" name="key" type="text" size="15" maxlength="12" value="" class="regular-text code">
|
31 |
+
<input type="hidden" name="action" value="enter-key">
|
32 |
+
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
33 |
+
<input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
|
34 |
+
</form>
|
35 |
+
</div>
|
36 |
+
<?php elseif ( $akismet_user->status == 'missing' ) : //no akismet account, ask do they want to use jetpack wpcom account to create one, then redirect to plans page?>
|
37 |
+
<p><?php esc_html_e('Akismet eliminates the comment and trackback spam you get on your site. Register your email address below to get started.', 'akismet'); ?></p>
|
38 |
+
<div class="activate-highlight activate-option">
|
39 |
+
<div class="option-description">
|
40 |
+
<strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
|
41 |
+
<?php echo esc_attr( $akismet_user->user_email ); ?>
|
42 |
+
</div>
|
43 |
+
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="right">
|
44 |
+
<input type="hidden" name="passback_url" value="<?php echo esc_attr( Akismet_Admin::get_page_url() ); ?>"/>
|
45 |
+
<input type="hidden" name="auto-connect" value="<?php echo $akismet_user->ID;?>"/>
|
46 |
+
<input type="hidden" name="redirect" value="plugin-signup"/>
|
47 |
+
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Register Akismet' , 'akismet'); ?>"/>
|
48 |
+
</form>
|
49 |
+
</div>
|
50 |
+
<div class="activate-highlight secondary activate-option">
|
51 |
+
<div class="option-description">
|
52 |
+
<strong><?php esc_html_e('Create a new API key with a different email address', 'akismet'); ?></strong>
|
53 |
+
<p><?php esc_html_e('Use this option if you want to setup a new Akismet account.', 'akismet'); ?></p>
|
54 |
+
</div>
|
55 |
+
<?php Akismet::view( 'get', array( 'text' => __( 'Register a different email address' , 'akismet'), 'classes' => array( 'right', 'button', 'button-secondary' ) ) ); ?>
|
56 |
+
</div>
|
57 |
+
<div class="activate-highlight secondary activate-option">
|
58 |
+
<div class="option-description">
|
59 |
+
<strong><?php esc_html_e('Manually enter an API key', 'akismet'); ?></strong>
|
60 |
+
<p><?php esc_html_e('If you have another API key you want to use.', 'akismet'); ?></p>
|
61 |
+
</div>
|
62 |
+
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
|
63 |
+
<input id="key" name="key" type="text" size="15" maxlength="12" value="" class="regular-text code">
|
64 |
+
<input type="hidden" name="action" value="enter-key">
|
65 |
+
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
66 |
+
<input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
|
67 |
+
</form>
|
68 |
+
</div>
|
69 |
+
<?php elseif ( $akismet_user->status == 'suspended' ) : //has an akismet account but the key is suspended, need to upgrade their account to unsuspend key ?>
|
70 |
+
<p><?php esc_html_e('Akismet eliminates the comment and trackback spam you get on your site.', 'akismet'); ?></p>
|
71 |
+
<div class="activate-highlight centered activate-option">
|
72 |
+
<strong class="small-heading"><?php esc_html_e( 'Connected via Jetpack' , 'akismet'); ?></strong>
|
73 |
+
<h3 class="alert-text"><?php printf( esc_html__( 'Your subscription for %s is suspended' , 'akismet'), $akismet_user->user_email ); ?></h3>
|
74 |
+
<p><?php esc_html_e('No worries! Get in touch and we’ll help sort this out.', 'akismet'); ?></p>
|
75 |
+
<a href="https://akismet.com/contact" class="button button-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet'); ?></a>
|
76 |
+
|
77 |
+
</div><?php
|
78 |
+
endif;
|
79 |
+
else :?>
|
80 |
+
<p><?php esc_html_e('Akismet eliminates the comment and trackback spam you get on your site. To setup Akismet, select one of the options below.', 'akismet'); ?></p>
|
81 |
+
<div class="activate-highlight activate-option">
|
82 |
+
<div class="option-description">
|
83 |
+
<strong><?php esc_html_e( 'New to Akismet?' , 'akismet');?></strong>
|
84 |
+
<p><?php esc_html_e('Get started now to squash the comment and trackback spam you get.', 'akismet'); ?></p>
|
85 |
+
</div>
|
86 |
+
<?php Akismet::view( 'get', array( 'text' => __( 'Get an Akismet account' , 'akismet'), 'classes' => array( 'right', 'button', 'button-primary' ) ) ); ?>
|
87 |
+
</div>
|
88 |
+
<div class="activate-highlight secondary activate-option">
|
89 |
+
<div class="option-description">
|
90 |
+
<strong><?php esc_html_e('Manually enter an API key', 'akismet'); ?></strong>
|
91 |
+
<p><?php esc_html_e('If you have another API key you want to use.', 'akismet'); ?></p>
|
92 |
+
</div>
|
93 |
+
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
|
94 |
+
<input id="key" name="key" type="text" size="15" maxlength="12" value="" class="regular-text code">
|
95 |
+
<input type="hidden" name="action" value="enter-key">
|
96 |
+
<?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
|
97 |
+
<input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
|
98 |
+
</form>
|
99 |
+
</div><?php
|
100 |
+
endif;?>
|
101 |
+
</div>
|
views/stats.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<h2><?php esc_html_e( 'Akismet Stats' , 'akismet');?><?php if ( !isset( $hide_settings_link ) ): ?> <a href="<?php echo esc_url( Akismet_Admin::get_page_url() );?>" class="add-new-h2"><?php esc_html_e( 'Settings' , 'akismet');?></a><?php endif;?></h2>
|
3 |
+
<iframe src="<?php echo esc_url( sprintf( '%s://akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s', is_ssl()?'https':'http', urlencode( get_bloginfo('url') ), Akismet::get_api_key() ) ); ?>" width="100%" height="2500px" frameborder="0" id="akismet-stats-frame"></iframe>
|
4 |
+
</div>
|
views/strict.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<tr valign="top">
|
2 |
+
<th scope="row"><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></th>
|
3 |
+
<td><fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
|
4 |
+
<p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Strict: silently discard the worst and most pervasive spam.', 'akismet'); ?></label></p>
|
5 |
+
<p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Safe: always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
|
6 |
+
</fieldset></td>
|
7 |
+
</tr>
|
wrapper.php
ADDED
@@ -0,0 +1,293 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
|
4 |
+
|
5 |
+
$wpcom_api_key = defined( 'WPCOM_API_KEY' ) ? constant( 'WPCOM_API_KEY' ) : '';
|
6 |
+
$akismet_api_host = Akismet::get_api_key() . '.rest.akismet.com';
|
7 |
+
$akismet_api_port = 80;
|
8 |
+
|
9 |
+
function akismet_test_mode() {
|
10 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::is_test_mode()' );
|
11 |
+
|
12 |
+
return Akismet::is_test_mode();
|
13 |
+
}
|
14 |
+
|
15 |
+
function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) {
|
16 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::http_post()' );
|
17 |
+
|
18 |
+
$path = str_ireplace( '/1.1/', '', $path );
|
19 |
+
|
20 |
+
return Akismet::http_post( $request, $path, $ip );
|
21 |
+
}
|
22 |
+
|
23 |
+
function akismet_microtime() {
|
24 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::_get_microtime()' );
|
25 |
+
|
26 |
+
return Akismet::_get_microtime();
|
27 |
+
}
|
28 |
+
|
29 |
+
function akismet_delete_old() {
|
30 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::delete_old_comments()' );
|
31 |
+
|
32 |
+
return Akismet::delete_old_comments();
|
33 |
+
}
|
34 |
+
|
35 |
+
function akismet_delete_old_metadata() {
|
36 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::delete_old_comments_meta()' );
|
37 |
+
|
38 |
+
return Akismet::delete_old_comments_meta();
|
39 |
+
}
|
40 |
+
|
41 |
+
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
|
42 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::check_db_comment()' );
|
43 |
+
|
44 |
+
return Akismet::check_db_comment( $id, $recheck_reason );
|
45 |
+
}
|
46 |
+
|
47 |
+
function akismet_rightnow() {
|
48 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::rightnow_stats()' );
|
49 |
+
|
50 |
+
if ( !class_exists( 'Akismet_Admin' ) )
|
51 |
+
return false;
|
52 |
+
|
53 |
+
return Akismet_Admin::rightnow_stats();
|
54 |
+
}
|
55 |
+
|
56 |
+
function akismet_admin_init() {
|
57 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
58 |
+
}
|
59 |
+
function akismet_version_warning() {
|
60 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
61 |
+
}
|
62 |
+
function akismet_load_js_and_css() {
|
63 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
64 |
+
}
|
65 |
+
function akismet_nonce_field( $action = -1 ) {
|
66 |
+
_deprecated_function( __FUNCTION__, '3.0', 'wp_nonce_field' );
|
67 |
+
|
68 |
+
return wp_nonce_field( $action );
|
69 |
+
}
|
70 |
+
function akismet_plugin_action_links( $links, $file ) {
|
71 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::plugin_action_links()' );
|
72 |
+
|
73 |
+
return Akismet_Admin::plugin_action_links( $links, $file );
|
74 |
+
}
|
75 |
+
function akismet_conf() {
|
76 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
77 |
+
}
|
78 |
+
function akismet_stats_display() {
|
79 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
80 |
+
}
|
81 |
+
function akismet_stats() {
|
82 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::dashboard_stats()' );
|
83 |
+
|
84 |
+
return Akismet_Admin::dashboard_stats();
|
85 |
+
}
|
86 |
+
function akismet_admin_warnings() {
|
87 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
88 |
+
}
|
89 |
+
function akismet_comment_row_action( $a, $comment ) {
|
90 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::comment_row_action()' );
|
91 |
+
|
92 |
+
return Akismet_Admin::comment_row_actions( $a, $comment );
|
93 |
+
}
|
94 |
+
function akismet_comment_status_meta_box( $comment ) {
|
95 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::comment_status_meta_box()' );
|
96 |
+
|
97 |
+
return Akismet_Admin::comment_status_meta_box( $comment );
|
98 |
+
}
|
99 |
+
function akismet_comments_columns( $columns ) {
|
100 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
101 |
+
|
102 |
+
return $columns;
|
103 |
+
}
|
104 |
+
function akismet_comment_column_row( $column, $comment_id ) {
|
105 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
106 |
+
}
|
107 |
+
function akismet_text_add_link_callback( $m ) {
|
108 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::text_add_link_callback()' );
|
109 |
+
|
110 |
+
return Akismet_Admin::text_add_link_callback( $m );
|
111 |
+
}
|
112 |
+
function akismet_text_add_link_class( $comment_text ) {
|
113 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::text_add_link_class()' );
|
114 |
+
|
115 |
+
return Akismet_Admin::text_add_link_class( $comment_text );
|
116 |
+
}
|
117 |
+
function akismet_check_for_spam_button( $comment_status ) {
|
118 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::check_for_spam_button()' );
|
119 |
+
|
120 |
+
return Akismet_Admin::check_for_spam_button( $comment_status );
|
121 |
+
}
|
122 |
+
function akismet_submit_nonspam_comment( $comment_id ) {
|
123 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::submit_nonspam_comment()' );
|
124 |
+
|
125 |
+
return Akismet_Admin::submit_nonspam_comment( $comment_id );
|
126 |
+
}
|
127 |
+
function akismet_submit_spam_comment( $comment_id ) {
|
128 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::submit_spam_comment()' );
|
129 |
+
|
130 |
+
return Akismet_Admin::submit_spam_comment( $comment_id );
|
131 |
+
}
|
132 |
+
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
|
133 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::transition_comment_status()' );
|
134 |
+
|
135 |
+
return Akismet_Admin::transition_comment_status( $new_status, $old_status, $comment );
|
136 |
+
}
|
137 |
+
function akismet_spam_count( $type = false ) {
|
138 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::get_spam_count()' );
|
139 |
+
|
140 |
+
return Akismet_Admin::get_spam_count( $type );
|
141 |
+
}
|
142 |
+
function akismet_recheck_queue() {
|
143 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::recheck_queue()' );
|
144 |
+
|
145 |
+
return Akismet_Admin::recheck_queue();
|
146 |
+
}
|
147 |
+
function akismet_remove_comment_author_url() {
|
148 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::remove_comment_author_url()' );
|
149 |
+
|
150 |
+
return Akismet_Admin::remove_comment_author_url();
|
151 |
+
}
|
152 |
+
function akismet_add_comment_author_url() {
|
153 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::add_comment_author_url()' );
|
154 |
+
|
155 |
+
return Akismet_Admin::add_comment_author_url();
|
156 |
+
}
|
157 |
+
function akismet_check_server_connectivity() {
|
158 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::check_server_connectivity()' );
|
159 |
+
|
160 |
+
return Akismet_Admin::check_server_connectivity();
|
161 |
+
}
|
162 |
+
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
|
163 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::()' );
|
164 |
+
|
165 |
+
return Akismet_Admin::get_server_connectivity( $cache_timeout );
|
166 |
+
}
|
167 |
+
function akismet_server_connectivity_ok() {
|
168 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
169 |
+
|
170 |
+
return true;
|
171 |
+
}
|
172 |
+
function akismet_admin_menu() {
|
173 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::admin_menu()' );
|
174 |
+
|
175 |
+
return Akismet_Admin::admin_menu();
|
176 |
+
}
|
177 |
+
function akismet_load_menu() {
|
178 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::load_menu()' );
|
179 |
+
|
180 |
+
return Akismet_Admin::load_menu();
|
181 |
+
}
|
182 |
+
function akismet_init() {
|
183 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
184 |
+
}
|
185 |
+
function akismet_get_key() {
|
186 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::get_api_key()' );
|
187 |
+
|
188 |
+
return Akismet::get_api_key();
|
189 |
+
}
|
190 |
+
function akismet_check_key_status( $key, $ip = null ) {
|
191 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::check_key_status()' );
|
192 |
+
|
193 |
+
return Akismet::check_key_status( $key, $ip );
|
194 |
+
}
|
195 |
+
function akismet_update_alert( $response ) {
|
196 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::update_alert()' );
|
197 |
+
|
198 |
+
return Akismet::update_alert( $response );
|
199 |
+
}
|
200 |
+
function akismet_verify_key( $key, $ip = null ) {
|
201 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::verify_key()' );
|
202 |
+
|
203 |
+
return Akismet::verify_key( $key, $ip );
|
204 |
+
}
|
205 |
+
function akismet_get_user_roles( $user_id ) {
|
206 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::get_user_roles()' );
|
207 |
+
|
208 |
+
return Akismet::get_user_roles( $user_id );
|
209 |
+
}
|
210 |
+
function akismet_result_spam( $approved ) {
|
211 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::comment_is_spam()' );
|
212 |
+
|
213 |
+
return Akismet::comment_is_spam( $approved );
|
214 |
+
}
|
215 |
+
function akismet_result_hold( $approved ) {
|
216 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::comment_needs_moderation()' );
|
217 |
+
|
218 |
+
return Akismet::comment_needs_moderation( $approved );
|
219 |
+
}
|
220 |
+
function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
221 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::get_user_comments_approved()' );
|
222 |
+
|
223 |
+
return Akismet::get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url );
|
224 |
+
}
|
225 |
+
function akismet_update_comment_history( $comment_id, $message, $event = null ) {
|
226 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::update_comment_history()' );
|
227 |
+
|
228 |
+
return Akismet::update_comment_history( $comment_id, $message, $event );
|
229 |
+
}
|
230 |
+
function akismet_get_comment_history( $comment_id ) {
|
231 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::get_comment_history()' );
|
232 |
+
|
233 |
+
return Akismet::get_comment_history( $comment_id );
|
234 |
+
}
|
235 |
+
function akismet_cmp_time( $a, $b ) {
|
236 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::_cmp_time()' );
|
237 |
+
|
238 |
+
return Akismet::_cmp_time( $a, $b );
|
239 |
+
}
|
240 |
+
function akismet_auto_check_update_meta( $id, $comment ) {
|
241 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::auto_check_update_meta()' );
|
242 |
+
|
243 |
+
return Akismet::auto_check_update_meta( $id, $comment );
|
244 |
+
}
|
245 |
+
function akismet_auto_check_comment( $commentdata ) {
|
246 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::auto_check_comment()' );
|
247 |
+
|
248 |
+
return Akismet::auto_check_comment( $commentdata );
|
249 |
+
}
|
250 |
+
function akismet_get_ip_address() {
|
251 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::get_ip_address()' );
|
252 |
+
|
253 |
+
return Akismet::get_ip_address();
|
254 |
+
}
|
255 |
+
function akismet_cron_recheck() {
|
256 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::cron_recheck()' );
|
257 |
+
|
258 |
+
return Akismet::cron_recheck();
|
259 |
+
}
|
260 |
+
function akismet_add_comment_nonce() {
|
261 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::add_comment_nonce()' );
|
262 |
+
|
263 |
+
return Akismet::add_comment_nonce( $post_id );
|
264 |
+
}
|
265 |
+
function akismet_fix_scheduled_recheck() {
|
266 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::fix_scheduled_recheck()' );
|
267 |
+
|
268 |
+
return Akismet::fix_scheduled_recheck();
|
269 |
+
}
|
270 |
+
function akismet_spam_comments() {
|
271 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
272 |
+
|
273 |
+
return array();
|
274 |
+
}
|
275 |
+
function akismet_spam_totals() {
|
276 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
277 |
+
|
278 |
+
return array();
|
279 |
+
}
|
280 |
+
function akismet_manage_page() {
|
281 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
282 |
+
}
|
283 |
+
function akismet_caught() {
|
284 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
285 |
+
}
|
286 |
+
function redirect_old_akismet_urls() {
|
287 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
288 |
+
}
|
289 |
+
function akismet_kill_proxy_check( $option ) {
|
290 |
+
_deprecated_function( __FUNCTION__, '3.0' );
|
291 |
+
|
292 |
+
return 0;
|
293 |
+
}
|