Akismet Anti-Spam - Version 3.1.6

Version Description

Release Date - 14 December 2015

  • Improve the notices shown after activating Akismet.
  • Update some strings to allow for the proper plural forms in all languages.
Download this release

Release Info

Developer eoigal
Plugin Icon 128x128 Akismet Anti-Spam
Version 3.1.6
Comparing to
See all releases

Code changes from version 2.5.10 to 3.1.6

LICENSE.txt ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
_inc/akismet.css ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ table.comments td.comment p a {
37
+ text-decoration: underline;
38
+ }
39
+ table.comments td.comment p a:after {
40
+ content: attr(href);
41
+ color: #aaa;
42
+ display: inline-block; /* Show the URL without the link's underline extending under it. */
43
+ padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */
44
+ }
45
+ .mshot-arrow {
46
+ width: 0;
47
+ height: 0;
48
+ border-top: 10px solid transparent;
49
+ border-bottom: 10px solid transparent;
50
+ border-right: 10px solid #5C5C5C;
51
+ position: absolute;
52
+ left: -6px;
53
+ top: 91px;
54
+ }
55
+ .mshot-container {
56
+ background: #5C5C5C;
57
+ position: absolute;
58
+ top: -94px;
59
+ padding: 7px;
60
+ width: 450px;
61
+ height: 338px;
62
+ z-index: 20000;
63
+ -moz-border-radius: 6px;
64
+ border-radius: 6px;
65
+ -webkit-border-radius: 6px;
66
+ }
67
+ .akismet-mshot {
68
+ position: absolute;
69
+ z-index: 100;
70
+ }
71
+ .akismet-mshot .mshot-image {
72
+ margin: 0;
73
+ height: 338px;
74
+ width: 450px;
75
+ }
76
+ h2.ak-header {
77
+ padding: 30px;
78
+ background: #649316 url('img/logo-full-2x.png') no-repeat 20px center;
79
+ background-size: 185px 33px;
80
+ height: 33px;
81
+ text-indent: -9999em;
82
+ margin-right: 10px;
83
+ }
84
+ .checkforspam {
85
+ display: inline-block !important;
86
+ }
87
+ .checkforspam-spinner {
88
+ display: inline-block;
89
+ margin-top: 7px;
90
+ }
91
+
92
+ .config-wrap {
93
+ margin-top: 2em;
94
+ max-width: 700px;
95
+ }
96
+
97
+ .activate-option {
98
+ background: #e3e3e3;
99
+ border-radius: 3px;
100
+ margin-bottom: 30px;
101
+ overflow: hidden;
102
+ padding: 20px;
103
+ }
104
+ .activate-option.clicked {
105
+ background: #649316;
106
+ color: #fff;
107
+ }
108
+ .activate-option.clicked:hover {
109
+ background: #68802E;
110
+ color: #fff;
111
+ }
112
+
113
+ .activate-option .button.button-secondary {
114
+ margin: 15px 0;
115
+ }
116
+
117
+ .activate-option p {
118
+ margin: 10px 0 10px;
119
+ }
120
+
121
+ .activate-highlight {
122
+ background: #fff;
123
+ padding: 30px;
124
+ margin-right: 10px;
125
+ }
126
+
127
+ .activate-highlight.secondary {
128
+ background: #ddd;
129
+ padding: 20px 30px;
130
+ }
131
+
132
+ .activate-highlight h3 {
133
+ margin: 0 0 0.3em;
134
+ }
135
+ .activate-highlight p {
136
+ color: #777;
137
+ }
138
+ .activate-highlight .button-primary {
139
+ margin-top: 15px;
140
+ }
141
+
142
+ #akismet-enter-api-key .regular-text {
143
+ width: 18em;
144
+ margin-top: 15px;
145
+ }
146
+
147
+ .right {
148
+ float: right;
149
+ }
150
+
151
+ .alert-text {
152
+ color: #dd3d36;
153
+ }
154
+ .success {
155
+ color: #649316;
156
+ }
157
+ .option-description {
158
+ float: left;
159
+ font-size: 16px;
160
+ }
161
+ .option-description span {
162
+ color: #666;
163
+ display: block;
164
+ font-size: 14px;
165
+ margin-top: 5px;
166
+ }
167
+ .option-action {
168
+ float: right;
169
+ }
170
+ .key-config-link {
171
+ font-size: 14px;
172
+ margin-left: 20px;
173
+ }
174
+ .jetpack-account {
175
+ float: left;
176
+ font-size: 18px;
177
+ margin-right: 40px;
178
+ }
179
+ .small-heading {
180
+ color: #777;
181
+ display: block;
182
+ font-size: 12px;
183
+ font-weight: bold;
184
+ margin-bottom: 5px;
185
+ text-transform: uppercase;
186
+ }
187
+ .inline-label {
188
+ background: #ddd;
189
+ border-radius: 3px;
190
+ font-size: 11px;
191
+ padding: 3px 8px;
192
+ text-transform: uppercase;
193
+ }
194
+ .inline-label.alert {
195
+ background: #e54747;
196
+ color: #fff;
197
+ }
198
+ .jetpack-account .inline-label {
199
+ margin-left: 5px;
200
+ }
201
+ .option-action .manual-key {
202
+ margin-top: 7px;
203
+ }
204
+
205
+ .alert {
206
+ border: 1px solid #e5e5e5;
207
+ padding: 0.4em 1em 1.4em 1em;
208
+ border-radius: 3px;
209
+ -webkit-border-radius: 3px;
210
+ border-width: 1px;
211
+ border-style: solid;
212
+ }
213
+
214
+ .alert h3.key-status {
215
+ color: #fff;
216
+ margin: 1em 0 0.5em 0;
217
+ }
218
+
219
+ .alert.critical {
220
+ background-color: #993300;
221
+ }
222
+
223
+ .alert.active {
224
+ background-color: #649316;
225
+ }
226
+
227
+ .alert p.key-status {
228
+ font-size: 24px;
229
+ }
230
+
231
+ .alert p.description {
232
+ color:#fff;
233
+ font-size: 14px;
234
+ margin: 0 0;
235
+ font-style: normal;
236
+ }
237
+
238
+ .alert p.description a,
239
+ .alert p.description a,
240
+ .alert p.description a,
241
+ .alert p.description a {
242
+ color: #fff;
243
+ }
244
+
245
+ .new-snapshot {
246
+ margin-top: 1em;
247
+ padding: 1em;
248
+ text-align: center;
249
+ }
250
+
251
+ .new-snapshot.stats {
252
+ background: #fff;
253
+ border: 1px solid #e5e5e5;
254
+ }
255
+
256
+ .new-snapshot h3 {
257
+ background: #f5f5f5;
258
+ color: #888;
259
+ font-size: 11px;
260
+ margin: 0;
261
+ padding: 3px;
262
+ }
263
+
264
+ .new-snapspot ul {
265
+ font-size: 12px;
266
+ width: 100%;
267
+ }
268
+
269
+ .new-snapshot ul li {
270
+ color: #999;
271
+ float: left;
272
+ font-size: 11px;
273
+ padding: 0 20px;
274
+ text-transform: uppercase;
275
+ width: 33%;
276
+ box-sizing: border-box;
277
+ -moz-box-sizing: border-box;
278
+ -webkit-box-sizing: border-box;
279
+ -ms-box-sizing: border-box;
280
+ }
281
+
282
+ .new-snapshot.stats ul li:first-child,
283
+ .new-snapshot.stats ul li:nth-child(2) {
284
+ border-right:1px dotted #ccc;
285
+ }
286
+
287
+ .new-snapshot.account ul li:nth-child(2) {
288
+ border-right: none;
289
+ }
290
+
291
+ .new-snapshot ul li span {
292
+ color: #52accc;
293
+ display: block;
294
+ font-size: 32px;
295
+ font-weight: lighter;
296
+ line-height: 1.5em;
297
+ }
298
+
299
+ .new-snapshot.stats {
300
+ }
301
+
302
+ .new-snapshot.account,
303
+ .new-snapshot.settings {
304
+ float: left;
305
+ padding: 0;
306
+ text-align: left;
307
+ width: 50%;
308
+ box-sizing: border-box;
309
+ -moz-box-sizing: border-box;
310
+ -webkit-box-sizing: border-box;
311
+ -ms-box-sizing: border-box;
312
+ }
313
+
314
+ .account-container {
315
+ background: #fff;
316
+ border: 1px solid #e5e5e5;
317
+ margin-right: 0.5em;
318
+ }
319
+
320
+ .settings-container {
321
+ background: #fff;
322
+ border: 1px solid #e5e5e5;
323
+ margin-left: 0.5em;
324
+ }
325
+
326
+ .new-snapshot.account ul li {
327
+ width:100%
328
+ }
329
+
330
+ .new-snapshot.account ul li span {
331
+ font-size: 14px;
332
+ font-weight: normal;
333
+ }
334
+
335
+
336
+ .new-snapshot.settings ul li {
337
+ border: none;
338
+ display: block;
339
+ width:100%
340
+ }
341
+
342
+ .new-snapshot.settings ul li span {
343
+ display: block;
344
+ font-size: 14px;
345
+ font-weight: normal;
346
+ }
347
+
348
+ .new-snapshot.settings p.submit {
349
+ margin: 0;
350
+ text-align: center;
351
+ }
352
+
353
+ .akismet-settings th:first-child {
354
+ vertical-align: top;
355
+ padding-top: 15px;
356
+ }
357
+
358
+ .akismet-settings th.akismet-api-key {
359
+ vertical-align: middle;
360
+ padding-top: 0;
361
+ }
362
+
363
+ .akismet-settings input[type=text] {
364
+ width: 75%;
365
+ }
366
+
367
+ .akismet-settings span.note{
368
+ float: left;
369
+ padding-left: 23px;
370
+ font-size: 75%;
371
+ margin-top: -10px;
372
+ }
373
+
374
+ .clearfix {
375
+ clear:both;
376
+ }
_inc/akismet.js ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function ( $ ) {
2
+ var mshotRemovalTimer = null;
3
+ var mshotSecondTryTimer = null
4
+ var mshotThirdTryTimer = null
5
+
6
+ $( 'a.activate-option' ).click( function(){
7
+ var link = $( this );
8
+ if ( link.hasClass( 'clicked' ) ) {
9
+ link.removeClass( 'clicked' );
10
+ }
11
+ else {
12
+ link.addClass( 'clicked' );
13
+ }
14
+ $( '.toggle-have-key' ).slideToggle( 'slow', function() {});
15
+ return false;
16
+ });
17
+ $('.akismet-status').each(function () {
18
+ var thisId = $(this).attr('commentid');
19
+ $(this).prependTo('#comment-' + thisId + ' .column-comment');
20
+ });
21
+ $('.akismet-user-comment-count').each(function () {
22
+ var thisId = $(this).attr('commentid');
23
+ $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
24
+ });
25
+ $('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title]').each(function () {
26
+ // Comment author URLs are the only URL with a title attribute in the author column.
27
+ var thisTitle = $(this).attr('title');
28
+
29
+ var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
30
+
31
+ $(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
32
+
33
+ if (thisTitle) {
34
+ $(this).after(
35
+ $( '<a href="#" class="remove_url">x</a>' )
36
+ .attr( 'commentid', thisCommentId[1] )
37
+ .attr( 'title', WPAkismet.strings['Remove this URL'] )
38
+ );
39
+ }
40
+ });
41
+ $('.remove_url').live('click', function () {
42
+ var thisId = $(this).attr('commentid');
43
+ var data = {
44
+ action: 'comment_author_deurl',
45
+ _wpnonce: WPAkismet.comment_author_url_nonce,
46
+ id: thisId
47
+ };
48
+ $.ajax({
49
+ url: ajaxurl,
50
+ type: 'POST',
51
+ data: data,
52
+ beforeSend: function () {
53
+ // Removes "x" link
54
+ $("a[commentid='"+ thisId +"']").hide();
55
+ // Show temp status
56
+ $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
57
+ },
58
+ success: function (response) {
59
+ if (response) {
60
+ // Show status/undo link
61
+ $("#author_comment_url_"+ thisId)
62
+ .attr('cid', thisId)
63
+ .addClass('akismet_undo_link_removal')
64
+ .html(
65
+ $( '<span/>' ).text( WPAkismet.strings['URL removed'] )
66
+ )
67
+ .append( ' ' )
68
+ .append(
69
+ $( '<span/>' )
70
+ .text( WPAkismet.strings['(undo)'] )
71
+ .addClass( 'akismet-span-link' )
72
+ );
73
+ }
74
+ }
75
+ });
76
+
77
+ return false;
78
+ });
79
+ $('.akismet_undo_link_removal').live('click', function () {
80
+ var thisId = $(this).attr('cid');
81
+ var thisUrl = $(this).attr('href');
82
+ var data = {
83
+ action: 'comment_author_reurl',
84
+ _wpnonce: WPAkismet.comment_author_url_nonce,
85
+ id: thisId,
86
+ url: thisUrl
87
+ };
88
+ $.ajax({
89
+ url: ajaxurl,
90
+ type: 'POST',
91
+ data: data,
92
+ beforeSend: function () {
93
+ // Show temp status
94
+ $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
95
+ },
96
+ success: function (response) {
97
+ if (response) {
98
+ // Add "x" link
99
+ $("a[commentid='"+ thisId +"']").show();
100
+ // Show link. Core strips leading http://, so let's do that too.
101
+ $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
102
+ }
103
+ }
104
+ });
105
+
106
+ return false;
107
+ });
108
+
109
+ // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
110
+ $( 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, table.comments td.comment p a' ).mouseover( function () {
111
+ clearTimeout( mshotRemovalTimer );
112
+
113
+ if ( $( '.akismet-mshot' ).length > 0 ) {
114
+ if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
115
+ // The preview is already showing for this link.
116
+ return;
117
+ }
118
+ else {
119
+ // A new link is being hovered, so remove the old preview.
120
+ $( '.akismet-mshot' ).remove();
121
+ }
122
+ }
123
+
124
+ clearTimeout( mshotSecondTryTimer );
125
+ clearTimeout( mshotThirdTryTimer );
126
+
127
+ var thisHref = $.URLEncode( $( this ).attr( 'href' ) );
128
+
129
+ var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="//s0.wordpress.com/mshots/v1/' + thisHref + '?w=450" width="450" height="338" class="mshot-image" /></div>' );
130
+ mShot.data( 'link', this );
131
+
132
+ var offset = $( this ).offset();
133
+
134
+ mShot.offset( {
135
+ left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
136
+ top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
137
+ } );
138
+
139
+ mshotSecondTryTimer = setTimeout( function () {
140
+ mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2' );
141
+ }, 6000 );
142
+
143
+ mshotThirdTryTimer = setTimeout( function () {
144
+ mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3' );
145
+ }, 12000 );
146
+
147
+ $( 'body' ).append( mShot );
148
+ } ).mouseout( function () {
149
+ mshotRemovalTimer = setTimeout( function () {
150
+ clearTimeout( mshotSecondTryTimer );
151
+ clearTimeout( mshotThirdTryTimer );
152
+
153
+ $( '.akismet-mshot' ).remove();
154
+ }, 200 );
155
+ } );
156
+
157
+ $('.checkforspam:not(.button-disabled)').click( function(e) {
158
+ $('.checkforspam:not(.button-disabled)').addClass('button-disabled');
159
+ $('.checkforspam-spinner').addClass( 'spinner' );
160
+ akismet_check_for_spam(0, 100);
161
+ e.preventDefault();
162
+ });
163
+
164
+ function akismet_check_for_spam(offset, limit) {
165
+ $.post(
166
+ ajaxurl,
167
+ {
168
+ 'action': 'akismet_recheck_queue',
169
+ 'offset': offset,
170
+ 'limit': limit
171
+ },
172
+ function(result) {
173
+ if (result.processed < limit) {
174
+ window.location.reload();
175
+ }
176
+ else {
177
+ akismet_check_for_spam(offset + limit, limit);
178
+ }
179
+ }
180
+ );
181
+ }
182
+ });
183
+ // URL encode plugin
184
+ jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
185
+ while(x<c.length){var m=r.exec(c.substr(x));
186
+ if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
187
+ }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
188
+ o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
189
+ });
_inc/form.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var ak_js = document.getElementById( "ak_js" );
2
+
3
+ if ( ! ak_js ) {
4
+ ak_js = document.createElement( 'input' );
5
+ ak_js.setAttribute( 'id', 'ak_js' );
6
+ ak_js.setAttribute( 'name', 'ak_js' );
7
+ ak_js.setAttribute( 'type', 'hidden' );
8
+ }
9
+ else {
10
+ ak_js.parentNode.removeChild( ak_js );
11
+ }
12
+
13
+ ak_js.setAttribute( 'value', ( new Date() ).getTime() );
14
+
15
+ var commentForm = document.getElementById( 'commentform' );
16
+
17
+ if ( commentForm ) {
18
+ commentForm.appendChild( ak_js );
19
+ }
20
+ else {
21
+ var replyRowContainer = document.getElementById( 'replyrow' );
22
+
23
+ if ( replyRowContainer ) {
24
+ var children = replyRowContainer.getElementsByTagName( 'td' );
25
+
26
+ if ( children.length > 0 ) {
27
+ children[0].appendChild( ak_js );
28
+ }
29
+ }
30
+ }
_inc/img/logo-full-2x.png ADDED
Binary file
admin.php DELETED
@@ -1,909 +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(), '2.5.9' );
43
- wp_enqueue_style( 'akismet.css');
44
-
45
- wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'), '2.5.9' );
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
- ) );
50
- }
51
- }
52
-
53
-
54
- function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
55
- $akismet_nonce = 'akismet-update-key';
56
-
57
- function akismet_plugin_action_links( $links, $file ) {
58
- if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
59
- $links[] = '<a href="' . admin_url( 'admin.php?page=akismet-key-config' ) . '">'.__( 'Settings' ).'</a>';
60
- }
61
-
62
- return $links;
63
- }
64
-
65
- add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 );
66
-
67
- function akismet_conf() {
68
- global $akismet_nonce, $current_user;
69
-
70
- $new_key_link = 'https://akismet.com/get/';
71
- $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' ) ) );
72
- $stats_link = esc_url( add_query_arg( array( 'page' => 'akismet-stats-display' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'index.php' ) ) );
73
- $api_key = akismet_get_key();
74
- $show_key_form = $api_key;
75
- $key_status = 'empty';
76
- $saved_ok = false;
77
- $key_status_text = '';
78
-
79
- $ms = array();
80
-
81
- if ( isset( $_POST['submit'] ) ) {
82
- if ( function_exists('current_user_can') && !current_user_can('manage_options') )
83
- die(__('Cheatin&#8217; uh?'));
84
-
85
- $show_key_form = true;
86
-
87
- check_admin_referer( $akismet_nonce );
88
- $key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
89
- $home_url = parse_url( get_bloginfo('url') );
90
-
91
- if ( empty( $home_url['host'] ) )
92
- $ms[] = 'bad_home_url';
93
-
94
- if ( empty( $key ) ) {
95
- if ( $api_key ) {
96
- delete_option('wordpress_api_key');
97
- $saved_ok = true;
98
- $ms[] = 'new_key_empty';
99
- }
100
- else
101
- $ms[] = 'key_empty';
102
- }
103
- else
104
- $key_status = akismet_verify_key( $key );
105
-
106
- if ( $key != $api_key && $key_status == 'valid' ) {
107
- $ms[] = 'new_key_valid';
108
- update_option('wordpress_api_key', $key);
109
- }
110
- elseif ( $key_status == 'invalid' )
111
- $ms[] = 'new_key_invalid';
112
- elseif ( $key_status == 'failed' )
113
- $ms[] = 'new_key_failed';
114
-
115
- $api_key = $key_status == 'valid' ? $key : false;
116
-
117
- if ( isset( $_POST['akismet_discard_month'] ) )
118
- update_option( 'akismet_discard_month', 'true' );
119
- else
120
- update_option( 'akismet_discard_month', 'false' );
121
-
122
- if ( isset( $_POST['akismet_show_user_comments_approved'] ) )
123
- update_option( 'akismet_show_user_comments_approved', 'true' );
124
- else
125
- update_option( 'akismet_show_user_comments_approved', 'false' );
126
-
127
- if ( empty( $ms ) )
128
- $saved_ok = true;
129
-
130
- }
131
- elseif ( isset( $_POST['check'] ) ) {
132
- $show_key_form = true;
133
- check_admin_referer( $akismet_nonce );
134
- akismet_get_server_connectivity(0);
135
- }
136
- elseif ( isset( $_GET['show'] ) && $_GET['show'] == 'enter-api-key' ) {
137
- $show_key_form = true;
138
- }
139
-
140
- if ( $show_key_form ) {
141
- //check current key status
142
- //only get this if showing the key form otherwise takes longer for page to load for new user
143
- //no need to get it if we already know it and its valid
144
- if ( in_array( $key_status, array( 'invalid', 'failed', 'empty' ) ) ) {
145
- $key = get_option('wordpress_api_key');
146
- if ( empty( $key ) ) {
147
- //no key saved yet - maybe connection to Akismet down?
148
- if ( in_array( $key_status, array( 'invalid', 'empty' ) ) ) {
149
- if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
150
- $ms[] = 'no_connection';
151
- }
152
- }
153
- else
154
- $key_status = akismet_verify_key( $key );
155
- }
156
-
157
- if ( !isset( $_POST['submit'] ) ) {
158
- if ( $key_status == 'invalid' )
159
- $ms[] = 'key_invalid';
160
- elseif ( !empty( $key ) && $key_status == 'failed' )
161
- $ms[] = 'key_failed';
162
- }
163
- }
164
-
165
- $key_status_strings = array(
166
- 'empty' => __( 'Empty' ),
167
- 'valid' => __( 'Valid' ),
168
- 'invalid' => __( 'Invalid' ),
169
- 'failed' => __( 'Failed' ),
170
- );
171
-
172
- $messages = array(
173
- 'new_key_empty' => array( 'class' => 'updated fade', 'text' => __('Your key has been cleared.' ) ),
174
- 'new_key_valid' => array( 'class' => 'updated fade', 'text' => __('Your Akismet account has been successfully set up and activated. Happy blogging!' ) ),
175
- 'new_key_invalid' => array( 'class' => 'error', 'text' => __('The key you entered is invalid. Please double-check it.' ) ),
176
- '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.' ) ),
177
- 'no_connection' => array( 'class' => 'error', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.' ) ),
178
- 'key_empty' => array( 'class' => 'updated fade', 'text' => __('Please enter an API key' ) ),
179
- 'key_invalid' => array( 'class' => 'error', 'text' => __('This key is invalid.' ) ),
180
- '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.' ) ),
181
- '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') ) )
182
- );
183
- ?>
184
-
185
-
186
- <div class="wrap">
187
- <?php if ( !$api_key ) : ?>
188
- <h2 class="ak-header"><?php _e('Akismet'); ?></h2>
189
- <?php else: ?>
190
- <h2 class="ak-header"><?php printf( __( 'Akismet <a href="%s" class="add-new-h2">Stats</a>' ), $stats_link ); ?></h2>
191
- <?php endif; ?>
192
- <div class="no-key <?php echo $show_key_form ? 'hidden' : '';?>">
193
- <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>
194
- <form name="akismet_activate" action="https://akismet.com/get/" method="POST">
195
- <input type="hidden" name="return" value="1"/>
196
- <input type="hidden" name="jetpack" value="<?php echo (string) class_exists( 'Jetpack' );?>"/>
197
- <input type="hidden" name="user" value="<?php echo esc_attr( $current_user->user_login );?>"/>
198
- <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Create a new Akismet Key' ); ?>"/>
199
- </form>
200
- <br/>
201
- <a href="<?php echo $config_link;?>"><?php _e('I already have a key'); ?></a>
202
- </div>
203
- <div class="have-key <?php echo $show_key_form ? '' : 'hidden';?>">
204
- <?php if ( !empty($_POST['submit'] ) && $saved_ok ) : ?>
205
- <div id="message" class="updated fade"><p><strong><?php _e('Settings saved.') ?></strong></p></div>
206
- <?php endif; ?>
207
- <?php if ( isset($_GET['message']) && $_GET['message'] == 'success' ) : ?>
208
- <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>
209
- <?php endif; ?>
210
- <?php foreach( $ms as $m ) : ?>
211
- <div class="<?php echo $messages[$m]['class']; ?>"><p><strong><?php echo $messages[$m]['text']; ?></strong></p></div>
212
- <?php endforeach; ?>
213
- <form action="" method="post" id="akismet-conf">
214
- <table class="form-table">
215
- <tbody>
216
- <tr>
217
- <th><label for="key"><?php _e('Akismet API Key');?></label></th>
218
- <td>
219
- <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>
220
- <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>
221
- </td>
222
- </tr>
223
- <?php if ( $api_key ):?>
224
- <tr valign="top">
225
- <th scope="row"><?php _e('Settings');?></th>
226
- <td>
227
- <fieldset><legend class="screen-reader-text"><span><?php _e('Settings');?></span></legend>
228
- <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>
229
- <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>
230
- </fieldset>
231
- </td>
232
- </tr>
233
- <?php endif; ?>
234
- </tbody>
235
- </table>
236
- <?php akismet_nonce_field($akismet_nonce) ?>
237
- <p class="submit">
238
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save Changes');?>">
239
- </p>
240
- </form>
241
-
242
- <?php if ( $api_key ) : ?>
243
- <h3><?php _e('Server Connectivity'); ?></h3>
244
- <form action="" method="post" id="akismet-connectivity">
245
- <table class="form-table">
246
- <tbody>
247
- <tr>
248
- <th><label for="key"><?php _e('Server Status');?></label></th>
249
- <td>
250
- <?php if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) : ?>
251
- <p class="key-status failed"><?php _e('Network functions are disabled.'); ?></p>
252
- <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>
253
- <?php else :
254
- $servers = akismet_get_server_connectivity();
255
- $fail_count = count( $servers ) - count( array_filter( $servers ) );
256
- if ( is_array( $servers ) && count( $servers ) > 0 ) {
257
- if ( $fail_count > 0 && $fail_count < count( $servers ) ) { // some connections work, some fail ?>
258
- <p class="key-status some"><?php _e('Unable to reach some Akismet servers.'); ?></p>
259
- <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>
260
- <?php } elseif ( $fail_count > 0 ) { // all connections fail ?>
261
- <p class="key-status failed"><?php _e('Unable to reach any Akismet servers.'); ?></p>
262
- <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>
263
- <?php } else { // all connections work ?>
264
- <p class="key-status valid"><?php _e('All Akismet servers are available.'); ?></p>
265
- <p class="description"><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
266
- <?php }
267
- } else { //can't connect to any server ?>
268
- <p class="key-status failed"><?php _e('Unable to find Akismet servers.'); ?></p>
269
- <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>
270
- <?php }
271
- endif; ?>
272
- </td>
273
- </tr>
274
- <?php if ( !empty( $servers ) ) : ?>
275
- <tr valign="top">
276
- <th scope="row"><?php _e('Network Status');?></th>
277
- <td>
278
- <table class="network-status">
279
- <thead>
280
- <th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th>
281
- </thead>
282
- <tbody>
283
- <?php
284
- asort($servers);
285
- foreach ( $servers as $ip => $status ) : ?>
286
- <tr>
287
- <td align="center"><?php echo esc_html( $ip ); ?></td>
288
- <td class="key-status <?php echo $status ? 'valid' : 'failed'; ?>"><?php echo $status ? __('Accessible') : __('Re-trying'); ?></td>
289
- </tr>
290
- <?php endforeach; ?>
291
- </tbody>
292
- </table>
293
- <br/>
294
- <input type="submit" name="check" id="submit" class="button" style="margin-left: 13.3em;" value="<?php _e('Check Network Status');?>">
295
- </td>
296
- </tr>
297
- <?php endif; ?>
298
- <tr valign="top">
299
- <th scope="row"><?php _e('Last Checked');?></th>
300
- <td>
301
- <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>
302
- <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>
303
- </td>
304
- </tbody>
305
- </table>
306
- <?php akismet_nonce_field($akismet_nonce) ?>
307
- </form>
308
- <?php endif;?>
309
- </div>
310
- </div>
311
- <?php
312
- }
313
-
314
- function akismet_stats_display() {
315
- global $akismet_api_host, $akismet_api_port;
316
-
317
- $blog = urlencode( get_bloginfo('url') );
318
- $api_key = akismet_get_key();
319
- $config_link = esc_url( add_query_arg( array( 'page' => 'akismet-key-config' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'plugins.php' ) ) );?>
320
-
321
- <div class="wrap"><?php
322
- if ( !$api_key ) :?>
323
- <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
324
- else :?>
325
- <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
326
- endif;?>
327
- </div><?php
328
- }
329
-
330
- function akismet_stats() {
331
- if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
332
- return;
333
- if ( !$count = get_option('akismet_spam_count') )
334
- return;
335
- $path = plugin_basename(__FILE__);
336
- echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
337
- global $submenu;
338
- if ( isset( $submenu['edit-comments.php'] ) )
339
- $link = 'edit-comments.php';
340
- else
341
- $link = 'edit.php';
342
- 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', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
343
- }
344
- add_action('activity_box_end', 'akismet_stats');
345
-
346
- function akismet_admin_warnings() {
347
- global $wpcom_api_key, $pagenow;
348
-
349
- if (
350
- $pagenow == 'edit-comments.php'
351
- || ( !empty( $_GET['page'] ) && $_GET['page'] == 'akismet-key-config' )
352
- || ( !empty( $_GET['page'] ) && $_GET['page'] == 'akismet-stats-display' )
353
- ) {
354
- if ( get_option( 'akismet_alert_code' ) ) {
355
- function akismet_alert() {
356
- $alert = array(
357
- 'code' => (int) get_option( 'akismet_alert_code' ),
358
- 'msg' => get_option( 'akismet_alert_msg' )
359
- );
360
- ?>
361
- <div class='error'>
362
- <p><strong><?php _e( 'Akismet Error Code');?>: <?php echo $alert['code']; ?></strong></p>
363
- <p><?php esc_html_e( $alert['msg'] ); ?></p>
364
- <p><?php //FIXME: need to revert this to using __() in next version
365
- printf( translate( 'For more information:' ) . ' <a href="%s">%s</a>' , 'https://akismet.com/errors/'.$alert['code'], 'https://akismet.com/errors/'.$alert['code'] );?>
366
- </p>
367
- </div>
368
- <?php
369
- }
370
-
371
- add_action( 'admin_notices', 'akismet_alert' );
372
- }
373
- }
374
-
375
- if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
376
- function akismet_warning() {
377
- global $hook_suffix, $current_user;
378
-
379
- if ( $hook_suffix == 'plugins.php' ) {
380
- echo '
381
- <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
382
- <style type="text/css">
383
- .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}
384
- </style>
385
- <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">
386
- <input type="hidden" name="return" value="1"/>
387
- <input type="hidden" name="jetpack" value="'.(string) class_exists( 'Jetpack' ).'"/>
388
- <input type="hidden" name="user" value="'.esc_attr( $current_user->user_login ).'"/>
389
- <div class="akismet_activate">
390
- <div class="aa_a">A</div>
391
- <div class="aa_button_container" onclick="document.akismet_activate.submit();">
392
- <div class="aa_button_border">
393
- <div class="aa_button">'.__('Activate your Akismet account').'</div>
394
- </div>
395
- </div>
396
- <div class="aa_description">'.__('<strong>Almost done</strong> - activate your account and say goodbye to comment spam').'</div>
397
- </div>
398
- </form>
399
- </div>
400
- ';
401
- }
402
- }
403
-
404
- add_action('admin_notices', 'akismet_warning');
405
- return;
406
- } elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) && wp_next_scheduled('akismet_schedule_cron_recheck') ) {
407
- function akismet_warning() {
408
- global $wpdb;
409
- akismet_fix_scheduled_recheck();
410
- $waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" );
411
- $next_check = wp_next_scheduled('akismet_schedule_cron_recheck');
412
- if ( $waiting > 0 && $next_check > time() )
413
- echo '
414
- <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>
415
- ';
416
- }
417
- add_action('admin_notices', 'akismet_warning');
418
- return;
419
- }
420
- }
421
-
422
- // FIXME placeholder
423
-
424
- function akismet_comment_row_action( $a, $comment ) {
425
-
426
- // failsafe for old WP versions
427
- if ( !function_exists('add_comment_meta') )
428
- return $a;
429
-
430
- $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
431
- $akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
432
- $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
433
- $comment_status = wp_get_comment_status( $comment->comment_ID );
434
- $desc = null;
435
- if ( $akismet_error ) {
436
- $desc = __( 'Awaiting spam check' );
437
- } elseif ( !$user_result || $user_result == $akismet_result ) {
438
- // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
439
- if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
440
- $desc = __( 'Flagged as spam by Akismet' );
441
- elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
442
- $desc = __( 'Cleared by Akismet' );
443
- } else {
444
- $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
445
- if ( $user_result == 'true' )
446
- $desc = sprintf( __('Flagged as spam by %s'), $who );
447
- else
448
- $desc = sprintf( __('Un-spammed by %s'), $who );
449
- }
450
-
451
- // add a History item to the hover links, just after Edit
452
- if ( $akismet_result ) {
453
- $b = array();
454
- foreach ( $a as $k => $item ) {
455
- $b[ $k ] = $item;
456
- if (
457
- $k == 'edit'
458
- || ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
459
- ) {
460
- $b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
461
- }
462
- }
463
-
464
- $a = $b;
465
- }
466
-
467
- if ( $desc )
468
- echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.esc_html( $desc ).'</a></span>';
469
-
470
- if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
471
- $comment_count = akismet_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
472
- $comment_count = intval( $comment_count );
473
- 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>';
474
- }
475
-
476
- return $a;
477
- }
478
-
479
- add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );
480
-
481
- function akismet_comment_status_meta_box($comment) {
482
- $history = akismet_get_comment_history( $comment->comment_ID );
483
-
484
- if ( $history ) {
485
- echo '<div class="akismet-history" style="margin: 13px;">';
486
- foreach ( $history as $row ) {
487
- $time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
488
- echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';
489
- echo esc_html( $row['message'] ) . '</div>';
490
- }
491
-
492
- echo '</div>';
493
-
494
- }
495
- }
496
-
497
-
498
- // add an extra column header to the comments screen
499
- function akismet_comments_columns( $columns ) {
500
- $columns[ 'akismet' ] = __( 'Akismet' );
501
- return $columns;
502
- }
503
-
504
- #add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );
505
-
506
- // Show stuff in the extra column
507
- function akismet_comment_column_row( $column, $comment_id ) {
508
- if ( $column != 'akismet' )
509
- return;
510
-
511
- $history = akismet_get_comment_history( $comment_id );
512
-
513
- if ( $history ) {
514
- echo '<dl class="akismet-history">';
515
- foreach ( $history as $row ) {
516
- echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';
517
- echo '<dd>' . esc_html( $row['message'] ) . '</dd>';
518
- }
519
-
520
- echo '</dl>';
521
- }
522
- }
523
-
524
- #add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );
525
-
526
- // END FIXME
527
-
528
- // WP 2.5+
529
- function akismet_rightnow() {
530
- global $submenu, $wp_db_version;
531
-
532
- if ( 8645 < $wp_db_version ) // 2.7
533
- $link = 'edit-comments.php?comment_status=spam';
534
- elseif ( isset( $submenu['edit-comments.php'] ) )
535
- $link = 'edit-comments.php?page=akismet-admin';
536
- else
537
- $link = 'edit.php?page=akismet-admin';
538
-
539
- if ( $count = get_option('akismet_spam_count') ) {
540
- $intro = sprintf( _n(
541
- '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
542
- '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
543
- $count
544
- ), 'http://akismet.com/?return=true', number_format_i18n( $count ) );
545
- } else {
546
- $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/?return=true' );
547
- }
548
-
549
- $link = function_exists( 'esc_url' ) ? esc_url( $link ) : clean_url( $link );
550
- if ( $queue_count = akismet_spam_count() ) {
551
- $queue_text = sprintf( _n(
552
- 'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
553
- 'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
554
- $queue_count
555
- ), number_format_i18n( $queue_count ), $link );
556
- } else {
557
- $queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $link );
558
- }
559
-
560
- $text = $intro . '<br />' . $queue_text;
561
- echo "<p class='akismet-right-now'>$text</p>\n";
562
- }
563
-
564
- add_action('rightnow_end', 'akismet_rightnow');
565
-
566
-
567
- // For WP >= 2.5
568
- function akismet_check_for_spam_button($comment_status) {
569
- if ( 'approved' == $comment_status )
570
- return;
571
- if ( function_exists('plugins_url') )
572
- $link = 'admin.php?action=akismet_recheck_queue';
573
- else
574
- $link = 'edit-comments.php?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true';
575
- echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
576
- }
577
- add_action('manage_comments_nav', 'akismet_check_for_spam_button');
578
-
579
- function akismet_submit_nonspam_comment ( $comment_id ) {
580
- global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
581
- $comment_id = (int) $comment_id;
582
-
583
- $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
584
- if ( !$comment ) // it was deleted
585
- return;
586
-
587
- // use the original version stored in comment_meta if available
588
- $as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
589
- if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
590
- $comment = (object) array_merge( (array)$comment, $as_submitted );
591
- }
592
-
593
- $comment->blog = get_bloginfo('url');
594
- $comment->blog_lang = get_locale();
595
- $comment->blog_charset = get_option('blog_charset');
596
- $comment->permalink = get_permalink($comment->comment_post_ID);
597
- if ( is_object($current_user) ) {
598
- $comment->reporter = $current_user->user_login;
599
- }
600
- if ( is_object($current_site) ) {
601
- $comment->site_domain = $current_site->domain;
602
- }
603
-
604
- $comment->user_role = '';
605
- if ( isset( $comment->user_ID ) )
606
- $comment->user_role = akismet_get_user_roles($comment->user_ID);
607
-
608
- if ( akismet_test_mode() )
609
- $comment->is_test = 'true';
610
-
611
- $post = get_post( $comment->comment_post_ID );
612
- $comment->comment_post_modified_gmt = $post->post_modified_gmt;
613
-
614
- $query_string = '';
615
- foreach ( $comment as $key => $data )
616
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
617
-
618
- $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
619
- if ( $comment->reporter ) {
620
- akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam'), $comment->reporter ), 'report-ham' );
621
- update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
622
- update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
623
- }
624
-
625
- do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
626
- }
627
-
628
- function akismet_submit_spam_comment ( $comment_id ) {
629
- global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
630
- $comment_id = (int) $comment_id;
631
-
632
- $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
633
- if ( !$comment ) // it was deleted
634
- return;
635
- if ( 'spam' != $comment->comment_approved )
636
- return;
637
-
638
- // use the original version stored in comment_meta if available
639
- $as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
640
- if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
641
- $comment = (object) array_merge( (array)$comment, $as_submitted );
642
- }
643
-
644
- $comment->blog = get_bloginfo('url');
645
- $comment->blog_lang = get_locale();
646
- $comment->blog_charset = get_option('blog_charset');
647
- $comment->permalink = get_permalink($comment->comment_post_ID);
648
- if ( is_object($current_user) ) {
649
- $comment->reporter = $current_user->user_login;
650
- }
651
- if ( is_object($current_site) ) {
652
- $comment->site_domain = $current_site->domain;
653
- }
654
-
655
- $comment->user_role = '';
656
- if ( isset( $comment->user_ID ) )
657
- $comment->user_role = akismet_get_user_roles($comment->user_ID);
658
-
659
- if ( akismet_test_mode() )
660
- $comment->is_test = 'true';
661
-
662
- $post = get_post( $comment->comment_post_ID );
663
- $comment->comment_post_modified_gmt = $post->post_modified_gmt;
664
-
665
- $query_string = '';
666
- foreach ( $comment as $key => $data )
667
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
668
-
669
- $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
670
- if ( $comment->reporter ) {
671
- akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam'), $comment->reporter ), 'report-spam' );
672
- update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
673
- update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
674
- }
675
- do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
676
- }
677
-
678
- // For WP 2.7+
679
- function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
680
- if ( $new_status == $old_status )
681
- return;
682
-
683
- # we don't need to record a history item for deleted comments
684
- if ( $new_status == 'delete' )
685
- return;
686
-
687
- if ( !is_admin() )
688
- return;
689
-
690
- if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
691
- return;
692
-
693
- if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
694
- return;
695
-
696
- // if this is present, it means the status has been changed by a re-check, not an explicit user action
697
- if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
698
- return;
699
-
700
- global $current_user;
701
- $reporter = '';
702
- if ( is_object( $current_user ) )
703
- $reporter = $current_user->user_login;
704
-
705
- // Assumption alert:
706
- // We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
707
- // is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
708
- // determine why the transition_comment_status action was triggered. And there are several different ways by which
709
- // to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
710
- // We'll assume that this is an explicit user action if POST or GET has an 'action' key.
711
- if ( isset($_POST['action']) || isset($_GET['action']) ) {
712
- if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
713
- return akismet_submit_spam_comment( $comment->comment_ID );
714
- } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
715
- return akismet_submit_nonspam_comment( $comment->comment_ID );
716
- }
717
- }
718
-
719
- akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
720
- }
721
-
722
- add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
723
-
724
- // Total spam in queue
725
- // get_option( 'akismet_spam_count' ) is the total caught ever
726
- function akismet_spam_count( $type = false ) {
727
- global $wpdb;
728
-
729
- if ( !$type ) { // total
730
- $count = wp_cache_get( 'akismet_spam_count', 'widget' );
731
- if ( false === $count ) {
732
- if ( function_exists('wp_count_comments') ) {
733
- $count = wp_count_comments();
734
- $count = $count->spam;
735
- } else {
736
- $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
737
- }
738
- wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
739
- }
740
- return $count;
741
- } elseif ( 'comments' == $type || 'comment' == $type ) { // comments
742
- $type = '';
743
- } else { // pingback, trackback, ...
744
- $type = $wpdb->escape( $type );
745
- }
746
-
747
- return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
748
- }
749
-
750
-
751
- function akismet_recheck_queue() {
752
- global $wpdb, $akismet_api_host, $akismet_api_port;
753
-
754
- akismet_fix_scheduled_recheck();
755
-
756
- if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
757
- return;
758
-
759
- $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
760
- foreach ( (array) $moderation as $c ) {
761
- $c['user_ip'] = $c['comment_author_IP'];
762
- $c['user_agent'] = $c['comment_agent'];
763
- $c['referrer'] = '';
764
- $c['blog'] = get_bloginfo('url');
765
- $c['blog_lang'] = get_locale();
766
- $c['blog_charset'] = get_option('blog_charset');
767
- $c['permalink'] = get_permalink($c['comment_post_ID']);
768
-
769
- $c['user_role'] = '';
770
- if ( isset( $c['user_ID'] ) )
771
- $c['user_role'] = akismet_get_user_roles($c['user_ID']);
772
-
773
- if ( akismet_test_mode() )
774
- $c['is_test'] = 'true';
775
-
776
- $id = (int) $c['comment_ID'];
777
-
778
- $query_string = '';
779
- foreach ( $c as $key => $data )
780
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
781
-
782
- add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
783
- $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
784
- if ( 'true' == $response[1] ) {
785
- wp_set_comment_status($c['comment_ID'], 'spam');
786
- update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
787
- delete_comment_meta( $c['comment_ID'], 'akismet_error' );
788
- akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
789
-
790
- } elseif ( 'false' == $response[1] ) {
791
- update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
792
- delete_comment_meta( $c['comment_ID'], 'akismet_error' );
793
- akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
794
- // abnormal result: error
795
- } else {
796
- update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
797
- 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' );
798
- }
799
-
800
- delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
801
- }
802
- $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
803
- wp_safe_redirect( $redirect_to );
804
- exit;
805
- }
806
-
807
- add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
808
-
809
- // Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
810
- function akismet_remove_comment_author_url() {
811
- if ( !empty($_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
812
- global $wpdb;
813
- $comment = get_comment( intval($_POST['id']), ARRAY_A );
814
- if (current_user_can('edit_comment', $comment['comment_ID'])) {
815
- $comment['comment_author_url'] = '';
816
- do_action( 'comment_remove_author_url' );
817
- print(wp_update_comment( $comment ));
818
- die();
819
- }
820
- }
821
- }
822
-
823
- add_action('wp_ajax_comment_author_deurl', 'akismet_remove_comment_author_url');
824
-
825
- function akismet_add_comment_author_url() {
826
- if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
827
- global $wpdb;
828
- $comment = get_comment( intval($_POST['id']), ARRAY_A );
829
- if (current_user_can('edit_comment', $comment['comment_ID'])) {
830
- $comment['comment_author_url'] = esc_url($_POST['url']);
831
- do_action( 'comment_add_author_url' );
832
- print(wp_update_comment( $comment ));
833
- die();
834
- }
835
- }
836
- }
837
-
838
- add_action('wp_ajax_comment_author_reurl', 'akismet_add_comment_author_url');
839
-
840
- // Check connectivity between the WordPress blog and Akismet's servers.
841
- // 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).
842
- function akismet_check_server_connectivity() {
843
- global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
844
-
845
- $test_host = 'rest.akismet.com';
846
-
847
- // Some web hosts may disable one or both functions
848
- if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
849
- return array();
850
-
851
- $ips = gethostbynamel($test_host);
852
- if ( !$ips || !is_array($ips) || !count($ips) )
853
- return array();
854
-
855
- $servers = array();
856
- foreach ( $ips as $ip ) {
857
- $response = akismet_verify_key( akismet_get_key(), $ip );
858
- // even if the key is invalid, at least we know we have connectivity
859
- if ( $response == 'valid' || $response == 'invalid' )
860
- $servers[$ip] = true;
861
- else
862
- $servers[$ip] = false;
863
- }
864
-
865
- return $servers;
866
- }
867
-
868
- // Check the server connectivity and store the results in an option.
869
- // Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
870
- // Returns the same associative array as akismet_check_server_connectivity()
871
- function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
872
- $servers = get_option('akismet_available_servers');
873
- if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
874
- return $servers;
875
-
876
- // There's a race condition here but the effect is harmless.
877
- $servers = akismet_check_server_connectivity();
878
- update_option('akismet_available_servers', $servers);
879
- update_option('akismet_connectivity_time', time());
880
- return $servers;
881
- }
882
-
883
- // Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
884
- function akismet_server_connectivity_ok() {
885
- // skip the check on WPMU because the status page is hidden
886
- global $wpcom_api_key;
887
- if ( $wpcom_api_key )
888
- return true;
889
- $servers = akismet_get_server_connectivity();
890
- return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
891
- }
892
-
893
- function akismet_admin_menu() {
894
- if ( class_exists( 'Jetpack' ) ) {
895
- add_action( 'jetpack_admin_menu', 'akismet_load_menu' );
896
- } else {
897
- akismet_load_menu();
898
- }
899
- }
900
-
901
- function akismet_load_menu() {
902
- if ( class_exists( 'Jetpack' ) ) {
903
- add_submenu_page( 'jetpack', __( 'Akismet' ), __( 'Akismet' ), 'manage_options', 'akismet-key-config', 'akismet_conf' );
904
- add_submenu_page( 'jetpack', __( 'Akismet Stats' ), __( 'Akismet Stats' ), 'manage_options', 'akismet-stats-display', 'akismet_stats_display' );
905
- } else {
906
- add_submenu_page('plugins.php', __('Akismet'), __('Akismet'), 'manage_options', 'akismet-key-config', 'akismet_conf');
907
- add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
908
- }
909
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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}table.comments td.comment p a{text-decoration:underline}table.comments td.comment p a:after{content:attr(href);color:#aaa;display:inline-block;padding:0 1ex}.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}
 
akismet.gif DELETED
Binary file
akismet.js DELETED
@@ -1,126 +0,0 @@
1
- jQuery(document).ready(function () {
2
- jQuery( '.switch-have-key' ).click( function() {
3
- var no_key = jQuery( this ).parents().find('div.no-key');
4
- var have_key = jQuery( this ).parents().find('div.have-key');
5
-
6
- no_key.addClass( 'hidden' );
7
- have_key.removeClass( 'hidden' );
8
-
9
- return false;
10
- });
11
- jQuery( 'p.need-key a' ).click( function(){
12
- document.akismet_activate.submit();
13
- });
14
- jQuery('.akismet-status').each(function () {
15
- var thisId = jQuery(this).attr('commentid');
16
- jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
17
- });
18
- jQuery('.akismet-user-comment-count').each(function () {
19
- var thisId = jQuery(this).attr('commentid');
20
- jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
21
- });
22
- jQuery('#the-comment-list tr.comment .column-author a[title ^= "http://"]').each(function () {
23
- var thisTitle = jQuery(this).attr('title');
24
- thisCommentId = jQuery(this).parents('tr:first').attr('id').split("-");
25
-
26
- jQuery(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
27
-
28
- if (thisTitle) {
29
- jQuery(this).after(' <a href="#" class="remove_url" commentid="'+ thisCommentId[1] +'" title="Remove this URL">x</a>');
30
- }
31
- });
32
- jQuery('.remove_url').live('click', function () {
33
- var thisId = jQuery(this).attr('commentid');
34
- var data = {
35
- action: 'comment_author_deurl',
36
- _wpnonce: WPAkismet.comment_author_url_nonce,
37
- id: thisId
38
- };
39
- jQuery.ajax({
40
- url: ajaxurl,
41
- type: 'POST',
42
- data: data,
43
- beforeSend: function () {
44
- // Removes "x" link
45
- jQuery("a[commentid='"+ thisId +"']").hide();
46
- // Show temp status
47
- jQuery("#author_comment_url_"+ thisId).html('<span>Removing...</span>');
48
- },
49
- success: function (response) {
50
- if (response) {
51
- // Show status/undo link
52
- jQuery("#author_comment_url_"+ thisId).attr('cid', thisId).addClass('akismet_undo_link_removal').html('<span>URL removed (</span>undo<span>)</span>');
53
- }
54
- }
55
- });
56
-
57
- return false;
58
- });
59
- jQuery('.akismet_undo_link_removal').live('click', function () {
60
- var thisId = jQuery(this).attr('cid');
61
- var thisUrl = jQuery(this).attr('href').replace("http://www.", "").replace("http://", "");
62
- var data = {
63
- action: 'comment_author_reurl',
64
- _wpnonce: WPAkismet.comment_author_url_nonce,
65
- id: thisId,
66
- url: thisUrl
67
- };
68
- jQuery.ajax({
69
- url: ajaxurl,
70
- type: 'POST',
71
- data: data,
72
- beforeSend: function () {
73
- // Show temp status
74
- jQuery("#author_comment_url_"+ thisId).html('<span>Re-adding…</span>');
75
- },
76
- success: function (response) {
77
- if (response) {
78
- // Add "x" link
79
- jQuery("a[commentid='"+ thisId +"']").show();
80
- // Show link
81
- jQuery("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
82
- }
83
- }
84
- });
85
-
86
- return false;
87
- });
88
- jQuery('a[id^="author_comment_url"]').mouseover(function () {
89
- var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
90
- // Need to determine size of author column
91
- var thisParentWidth = jQuery(this).parent().width();
92
- // It changes based on if there is a gravatar present
93
- thisParentWidth = (jQuery(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px';
94
- if (jQuery(this).find('.mShot').length == 0 && !jQuery(this).hasClass('akismet_undo_link_removal')) {
95
- var thisId = jQuery(this).attr('id').replace('author_comment_url_', '');
96
- jQuery('.widefat td').css('overflow', 'visible');
97
- jQuery(this).css('position', 'relative');
98
- var thisHref = jQuery.URLEncode(jQuery(this).attr('href'));
99
- jQuery(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="'+wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image_'+thisId+'" style="margin: 0;" /></div>');
100
- setTimeout(function () {
101
- jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2');
102
- }, 6000);
103
- setTimeout(function () {
104
- jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3');
105
- }, 12000);
106
- } else {
107
- jQuery(this).find('.mShot').css('left', thisParentWidth).show();
108
- }
109
- }).mouseout(function () {
110
- jQuery(this).find('.mShot').hide();
111
- });
112
- });
113
- // URL encode plugin
114
- jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
115
- while(x<c.length){var m=r.exec(c.substr(x));
116
- if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
117
- }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
118
- o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
119
- });
120
- // Preload mshot images after everything else has loaded
121
- jQuery(window).load(function() {
122
- var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
123
- jQuery('a[id^="author_comment_url"]').each(function () {
124
- jQuery.get(wpcomProtocol+'s0.wordpress.com/mshots/v1/'+jQuery.URLEncode(jQuery(this).attr('href'))+'?w=450');
125
- });
126
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
akismet.php CHANGED
@@ -4,12 +4,13 @@
4
  */
5
  /*
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: 2.5.10
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
 
13
  */
14
 
15
  /*
@@ -26,6 +27,8 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 
29
  */
30
 
31
  // Make sure we don't expose any info if called directly
@@ -34,580 +37,25 @@ if ( !function_exists( 'add_action' ) ) {
34
  exit;
35
  }
36
 
37
- define('AKISMET_VERSION', '2.5.10');
38
- define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
39
-
40
- /** If you hardcode a WP.com API key here, all key config screens will be hidden */
41
- if ( defined('WPCOM_API_KEY') )
42
- $wpcom_api_key = constant('WPCOM_API_KEY');
43
- else
44
- $wpcom_api_key = '';
45
-
46
- if ( isset($wp_db_version) && $wp_db_version <= 9872 )
47
- include_once dirname( __FILE__ ) . '/legacy.php';
48
-
49
- include_once dirname( __FILE__ ) . '/widget.php';
50
-
51
- if ( is_admin() )
52
- require_once dirname( __FILE__ ) . '/admin.php';
53
-
54
- function akismet_init() {
55
- global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
56
-
57
- if ( $wpcom_api_key )
58
- $akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
59
- else
60
- $akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
61
-
62
- $akismet_api_port = 80;
63
- }
64
- add_action('init', 'akismet_init');
65
-
66
- function akismet_get_key() {
67
- global $wpcom_api_key;
68
- if ( !empty($wpcom_api_key) )
69
- return $wpcom_api_key;
70
- return get_option('wordpress_api_key');
71
- }
72
-
73
- function akismet_check_key_status( $key, $ip = null ) {
74
- global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
75
- $blog = urlencode( get_option('home') );
76
- if ( $wpcom_api_key )
77
- $key = $wpcom_api_key;
78
- $response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);
79
- return $response;
80
- }
81
-
82
- // given a response from an API call like akismet_check_key_status(), update the alert code options if an alert is present.
83
- function akismet_update_alert( $response ) {
84
- $code = $msg = null;
85
- if ( isset($response[0]['x-akismet-alert-code']) ) {
86
- $code = $response[0]['x-akismet-alert-code'];
87
- $msg = $response[0]['x-akismet-alert-msg'];
88
- }
89
-
90
- // only call update_option() if the value has changed
91
- if ( $code != get_option( 'akismet_alert_code' ) ) {
92
- update_option( 'akismet_alert_code', $code );
93
- update_option( 'akismet_alert_msg', $msg );
94
- }
95
- }
96
-
97
- function akismet_verify_key( $key, $ip = null ) {
98
- $response = akismet_check_key_status( $key, $ip );
99
- akismet_update_alert( $response );
100
- if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )
101
- return 'failed';
102
- return $response[1];
103
- }
104
-
105
- // if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
106
- function akismet_test_mode() {
107
- if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
108
- return true;
109
- return false;
110
- }
111
-
112
- // return a comma-separated list of role names for the given user
113
- function akismet_get_user_roles( $user_id ) {
114
- $roles = false;
115
-
116
- if ( !class_exists('WP_User') )
117
- return false;
118
-
119
- if ( $user_id > 0 ) {
120
- $comment_user = new WP_User($user_id);
121
- if ( isset($comment_user->roles) )
122
- $roles = join(',', $comment_user->roles);
123
- }
124
-
125
- if ( is_multisite() && is_super_admin( $user_id ) ) {
126
- if ( empty( $roles ) ) {
127
- $roles = 'super_admin';
128
- } else {
129
- $comment_user->roles[] = 'super_admin';
130
- $roles = join( ',', $comment_user->roles );
131
- }
132
- }
133
-
134
- return $roles;
135
- }
136
-
137
- // Returns array with headers in $response[0] and body in $response[1]
138
- function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
139
- global $wp_version;
140
-
141
- $akismet_ua = "WordPress/{$wp_version} | ";
142
- $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
143
-
144
- $akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
145
-
146
- $content_length = strlen( $request );
147
-
148
- $http_host = $host;
149
- // use a specific IP if provided
150
- // needed by akismet_check_server_connectivity()
151
- if ( $ip && long2ip( ip2long( $ip ) ) ) {
152
- $http_host = $ip;
153
- } else {
154
- $http_host = $host;
155
- }
156
-
157
- // use the WP HTTP class if it is available
158
- if ( function_exists( 'wp_remote_post' ) ) {
159
- $http_args = array(
160
- 'body' => $request,
161
- 'headers' => array(
162
- 'Content-Type' => 'application/x-www-form-urlencoded; ' .
163
- 'charset=' . get_option( 'blog_charset' ),
164
- 'Host' => $host,
165
- 'User-Agent' => $akismet_ua
166
- ),
167
- 'httpversion' => '1.0',
168
- 'timeout' => 15
169
- );
170
- $akismet_url = "http://{$http_host}{$path}";
171
- $response = wp_remote_post( $akismet_url, $http_args );
172
- if ( is_wp_error( $response ) )
173
- return '';
174
-
175
- return array( $response['headers'], $response['body'] );
176
- } else {
177
- $http_request = "POST $path HTTP/1.0\r\n";
178
- $http_request .= "Host: $host\r\n";
179
- $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
180
- $http_request .= "Content-Length: {$content_length}\r\n";
181
- $http_request .= "User-Agent: {$akismet_ua}\r\n";
182
- $http_request .= "\r\n";
183
- $http_request .= $request;
184
-
185
- $response = '';
186
- if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
187
- fwrite( $fs, $http_request );
188
-
189
- while ( !feof( $fs ) )
190
- $response .= fgets( $fs, 1160 ); // One TCP-IP packet
191
- fclose( $fs );
192
- $response = explode( "\r\n\r\n", $response, 2 );
193
- }
194
- return $response;
195
- }
196
- }
197
-
198
- // filter handler used to return a spam result to pre_comment_approved
199
- function akismet_result_spam( $approved ) {
200
- // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
201
- if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
202
- update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
203
- // this is a one-shot deal
204
- remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
205
- return 'spam';
206
- }
207
-
208
- function akismet_result_hold( $approved ) {
209
- // once only
210
- remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
211
- return '0';
212
- }
213
-
214
- // how many approved comments does this author have?
215
- function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
216
- global $wpdb;
217
-
218
- if ( !empty($user_id) )
219
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
220
-
221
- if ( !empty($comment_author_email) )
222
- 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 ) );
223
-
224
- return 0;
225
- }
226
-
227
- function akismet_microtime() {
228
- $mtime = explode( ' ', microtime() );
229
- return $mtime[1] + $mtime[0];
230
- }
231
-
232
- // log an event for a given comment, storing it in comment_meta
233
- function akismet_update_comment_history( $comment_id, $message, $event=null ) {
234
- global $current_user;
235
-
236
- // failsafe for old WP versions
237
- if ( !function_exists('add_comment_meta') )
238
- return false;
239
-
240
- $user = '';
241
- if ( is_object($current_user) && isset($current_user->user_login) )
242
- $user = $current_user->user_login;
243
-
244
- $event = array(
245
- 'time' => akismet_microtime(),
246
- 'message' => $message,
247
- 'event' => $event,
248
- 'user' => $user,
249
- );
250
-
251
- // $unique = false so as to allow multiple values per comment
252
- $r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
253
- }
254
-
255
- // get the full comment history for a given comment, as an array in reverse chronological order
256
- function akismet_get_comment_history( $comment_id ) {
257
-
258
- // failsafe for old WP versions
259
- if ( !function_exists('add_comment_meta') )
260
- return false;
261
-
262
- $history = get_comment_meta( $comment_id, 'akismet_history', false );
263
- usort( $history, 'akismet_cmp_time' );
264
- return $history;
265
- }
266
-
267
- function akismet_cmp_time( $a, $b ) {
268
- return $a['time'] > $b['time'] ? -1 : 1;
269
- }
270
-
271
- // this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
272
- // because we don't know the comment ID at that point.
273
- function akismet_auto_check_update_meta( $id, $comment ) {
274
- global $akismet_last_comment;
275
-
276
- // failsafe for old WP versions
277
- if ( !function_exists('add_comment_meta') )
278
- return false;
279
-
280
- if ( !isset( $akismet_last_comment['comment_author_email'] ) )
281
- $akismet_last_comment['comment_author_email'] = '';
282
-
283
- // wp_insert_comment() might be called in other contexts, so make sure this is the same comment
284
- // as was checked by akismet_auto_check_comment
285
- if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
286
- if ( isset($akismet_last_comment['comment_post_ID']) && intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
287
- && $akismet_last_comment['comment_author'] == $comment->comment_author
288
- && $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
289
- // normal result: true or false
290
- if ( $akismet_last_comment['akismet_result'] == 'true' ) {
291
- update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
292
- akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
293
- if ( $comment->comment_approved != 'spam' )
294
- akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
295
- } elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
296
- update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
297
- akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
298
- if ( $comment->comment_approved == 'spam' ) {
299
- 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) )
300
- akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
301
- else
302
- akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
303
- }
304
- // abnormal result: error
305
- } else {
306
- update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
307
- 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' );
308
- }
309
-
310
- // record the complete original data as submitted for checking
311
- if ( isset($akismet_last_comment['comment_as_submitted']) )
312
- update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
313
- }
314
- }
315
- }
316
-
317
- add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
318
-
319
-
320
- function akismet_auto_check_comment( $commentdata ) {
321
- global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
322
-
323
- $comment = $commentdata;
324
- $comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
325
- $comment['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
326
- $comment['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
327
- $comment['blog'] = get_option('home');
328
- $comment['blog_lang'] = get_locale();
329
- $comment['blog_charset'] = get_option('blog_charset');
330
- $comment['permalink'] = get_permalink($comment['comment_post_ID']);
331
-
332
- if ( !empty( $comment['user_ID'] ) ) {
333
- $comment['user_role'] = akismet_get_user_roles( $comment['user_ID'] );
334
- }
335
-
336
- $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
337
- $comment['akismet_comment_nonce'] = 'inactive';
338
- if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
339
- $comment['akismet_comment_nonce'] = 'failed';
340
- if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
341
- $comment['akismet_comment_nonce'] = 'passed';
342
-
343
- // comment reply in wp-admin
344
- if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
345
- $comment['akismet_comment_nonce'] = 'passed';
346
-
347
- }
348
-
349
- if ( akismet_test_mode() )
350
- $comment['is_test'] = 'true';
351
-
352
- foreach ($_POST as $key => $value ) {
353
- if ( is_string($value) )
354
- $comment["POST_{$key}"] = $value;
355
- }
356
 
357
- $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
 
358
 
359
- foreach ( $_SERVER as $key => $value ) {
360
- if ( !in_array( $key, $ignore ) && is_string($value) )
361
- $comment["$key"] = $value;
362
- else
363
- $comment["$key"] = '';
364
- }
365
 
366
- $post = get_post( $comment['comment_post_ID'] );
367
- $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
368
-
369
- $query_string = '';
370
- foreach ( $comment as $key => $data )
371
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
372
-
373
- $commentdata['comment_as_submitted'] = $comment;
374
-
375
- $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
376
- do_action( 'akismet_comment_check_response', $response );
377
- akismet_update_alert( $response );
378
- $commentdata['akismet_result'] = $response[1];
379
- if ( 'true' == $response[1] ) {
380
- // akismet_spam_count will be incremented later by akismet_result_spam()
381
- add_filter('pre_comment_approved', 'akismet_result_spam');
382
-
383
- do_action( 'akismet_spam_caught' );
384
-
385
- $last_updated = strtotime( $post->post_modified_gmt );
386
- $diff = time() - $last_updated;
387
- $diff = $diff / 86400;
388
-
389
- if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' && empty($comment['user_ID']) ) {
390
- // akismet_result_spam() won't be called so bump the counter here
391
- if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
392
- update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
393
- $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
394
- wp_safe_redirect( $redirect_to );
395
- die();
396
- }
397
- }
398
-
399
- // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
400
- if ( 'true' != $response[1] && 'false' != $response[1] ) {
401
- if ( !current_user_can('moderate_comments') ) {
402
- add_filter('pre_comment_approved', 'akismet_result_hold');
403
- }
404
- if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
405
- wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
406
- }
407
- }
408
-
409
- if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
410
- // WP 2.1+: delete old comments daily
411
- if ( !wp_next_scheduled('akismet_scheduled_delete') )
412
- wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete');
413
- } elseif ( (mt_rand(1, 10) == 3) ) {
414
- // WP 2.0: run this one time in ten
415
- akismet_delete_old();
416
- }
417
- $akismet_last_comment = $commentdata;
418
-
419
- akismet_fix_scheduled_recheck();
420
- return $commentdata;
421
- }
422
-
423
- add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
424
-
425
- function akismet_delete_old() {
426
- global $wpdb;
427
- $now_gmt = current_time('mysql', 1);
428
- $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
429
- if ( empty( $comment_ids ) )
430
- return;
431
-
432
- $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
433
-
434
- do_action( 'delete_comment', $comment_ids );
435
- $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
436
- $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
437
- clean_comment_cache( $comment_ids );
438
- $n = mt_rand(1, 5000);
439
- if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
440
- $wpdb->query("OPTIMIZE TABLE $wpdb->comments");
441
 
 
 
 
442
  }
443
 
444
- function akismet_delete_old_metadata() {
445
- global $wpdb;
446
-
447
- $now_gmt = current_time( 'mysql', 1 );
448
- $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
449
-
450
- # enfore a minimum of 1 day
451
- $interval = absint( $interval );
452
- if ( $interval < 1 ) {
453
- return;
454
- }
455
-
456
- // akismet_as_submitted meta values are large, so expire them
457
- // after $interval days regardless of the comment status
458
- while ( TRUE ) {
459
- $comment_ids = $wpdb->get_col( "SELECT $wpdb->comments.comment_id FROM $wpdb->commentmeta INNER JOIN $wpdb->comments USING(comment_id) WHERE meta_key = 'akismet_as_submitted' AND DATE_SUB('$now_gmt', INTERVAL {$interval} DAY) > comment_date_gmt LIMIT 10000" );
460
 
461
- if ( empty( $comment_ids ) ) {
462
- return;
463
- }
464
-
465
- foreach ( $comment_ids as $comment_id ) {
466
- delete_comment_meta( $comment_id, 'akismet_as_submitted' );
467
- }
468
- }
469
-
470
- /*
471
- $n = mt_rand( 1, 5000 );
472
- if ( apply_filters( 'akismet_optimize_table', ( $n == 11 ), 'commentmeta' ) ) { // lucky number
473
- $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" );
474
- }
475
- */
476
- }
477
-
478
- add_action('akismet_scheduled_delete', 'akismet_delete_old');
479
- add_action('akismet_scheduled_delete', 'akismet_delete_old_metadata');
480
-
481
- function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
482
- global $wpdb, $akismet_api_host, $akismet_api_port;
483
-
484
- $id = (int) $id;
485
- $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
486
- if ( !$c )
487
- return;
488
-
489
- $c['user_ip'] = $c['comment_author_IP'];
490
- $c['user_agent'] = $c['comment_agent'];
491
- $c['referrer'] = '';
492
- $c['blog'] = get_option('home');
493
- $c['blog_lang'] = get_locale();
494
- $c['blog_charset'] = get_option('blog_charset');
495
- $c['permalink'] = get_permalink($c['comment_post_ID']);
496
- $id = $c['comment_ID'];
497
- if ( akismet_test_mode() )
498
- $c['is_test'] = 'true';
499
- $c['recheck_reason'] = $recheck_reason;
500
-
501
- $query_string = '';
502
- foreach ( $c as $key => $data )
503
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
504
-
505
- $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
506
- return ( is_array( $response ) && isset( $response[1] ) ) ? $response[1] : false;
507
- }
508
-
509
- function akismet_cron_recheck() {
510
- global $wpdb;
511
-
512
- $status = akismet_verify_key( akismet_get_key() );
513
- if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
514
- // since there is currently a problem with the key, reschedule a check for 6 hours hence
515
- wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
516
- return false;
517
- }
518
-
519
- delete_option('akismet_available_servers');
520
-
521
- $comment_errors = $wpdb->get_col( "
522
- SELECT comment_id
523
- FROM {$wpdb->prefix}commentmeta
524
- WHERE meta_key = 'akismet_error'
525
- LIMIT 100
526
- " );
527
-
528
- foreach ( (array) $comment_errors as $comment_id ) {
529
- // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
530
- $comment = get_comment( $comment_id );
531
- if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
532
- delete_comment_meta( $comment_id, 'akismet_error' );
533
- continue;
534
- }
535
-
536
- add_comment_meta( $comment_id, 'akismet_rechecking', true );
537
- $status = akismet_check_db_comment( $comment_id, 'retry' );
538
-
539
- $msg = '';
540
- if ( $status == 'true' ) {
541
- $msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
542
- } elseif ( $status == 'false' ) {
543
- $msg = __( 'Akismet cleared this comment during an automatic retry.' );
544
- }
545
-
546
- // If we got back a legit response then update the comment history
547
- // other wise just bail now and try again later. No point in
548
- // re-trying all the comments once we hit one failure.
549
- if ( !empty( $msg ) ) {
550
- delete_comment_meta( $comment_id, 'akismet_error' );
551
- akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
552
- update_comment_meta( $comment_id, 'akismet_result', $status );
553
- // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
554
- $comment = get_comment( $comment_id );
555
- if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
556
- if ( $status == 'true' ) {
557
- wp_spam_comment( $comment_id );
558
- } elseif ( $status == 'false' ) {
559
- // comment is good, but it's still in the pending queue. depending on the moderation settings
560
- // we may need to change it to approved.
561
- 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) )
562
- wp_set_comment_status( $comment_id, 1 );
563
- }
564
- }
565
- } else {
566
- delete_comment_meta( $comment_id, 'akismet_rechecking' );
567
- wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
568
- return;
569
- }
570
- delete_comment_meta( $comment_id, 'akismet_rechecking' );
571
- }
572
-
573
- $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" );
574
- if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
575
- wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
576
- }
577
- }
578
- add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
579
-
580
- function akismet_add_comment_nonce( $post_id ) {
581
- echo '<p style="display: none;">';
582
- wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
583
- echo '</p>';
584
- }
585
-
586
- $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
587
-
588
- if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
589
- add_action( 'comment_form', 'akismet_add_comment_nonce' );
590
-
591
- global $wp_version;
592
- if ( '3.0.5' == $wp_version ) {
593
- remove_filter( 'comment_text', 'wp_kses_data' );
594
- if ( is_admin() )
595
- add_filter( 'comment_text', 'wp_kses_post' );
596
- }
597
-
598
- function akismet_fix_scheduled_recheck() {
599
- $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
600
- if ( !$future_check ) {
601
- return;
602
- }
603
-
604
- if ( get_option( 'akismet_alert_code' ) > 0 ) {
605
- return;
606
- }
607
-
608
- $check_range = time() + 1200;
609
- if ( $future_check > $check_range ) {
610
- wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
611
- wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
612
- }
613
- }
4
  */
5
  /*
6
  Plugin Name: Akismet
7
+ Plugin URI: http://akismet.com/
8
+ Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected 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/">Sign up for an Akismet plan</a> to get an API key, and 3) Go to your Akismet configuration page, and save your API key.
9
+ Version: 3.1.6
10
  Author: Automattic
11
  Author URI: http://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
13
+ Text Domain: akismet
14
  */
15
 
16
  /*
27
  You should have received a copy of the GNU General Public License
28
  along with this program; if not, write to the Free Software
29
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
+
31
+ Copyright 2005-2015 Automattic, Inc.
32
  */
33
 
34
  // Make sure we don't expose any info if called directly
37
  exit;
38
  }
39
 
40
+ define( 'AKISMET_VERSION', '3.1.6' );
41
+ define( 'AKISMET__MINIMUM_WP_VERSION', '3.2' );
42
+ define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
43
+ define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
44
+ define( 'AKISMET_DELETE_LIMIT', 100000 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ register_activation_hook( __FILE__, array( 'Akismet', 'plugin_activation' ) );
47
+ register_deactivation_hook( __FILE__, array( 'Akismet', 'plugin_deactivation' ) );
48
 
49
+ require_once( AKISMET__PLUGIN_DIR . 'class.akismet.php' );
50
+ require_once( AKISMET__PLUGIN_DIR . 'class.akismet-widget.php' );
 
 
 
 
51
 
52
+ add_action( 'init', array( 'Akismet', 'init' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ if ( is_admin() ) {
55
+ require_once( AKISMET__PLUGIN_DIR . 'class.akismet-admin.php' );
56
+ add_action( 'init', array( 'Akismet_Admin', 'init' ) );
57
  }
58
 
59
+ //add wrapper class around deprecated akismet functions that are referenced elsewhere
60
+ require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class.akismet-admin.php ADDED
@@ -0,0 +1,1001 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ private static $allowed = array(
9
+ 'a' => array(
10
+ 'href' => true,
11
+ 'title' => true,
12
+ ),
13
+ 'b' => array(),
14
+ 'code' => array(),
15
+ 'del' => array(
16
+ 'datetime' => true,
17
+ ),
18
+ 'em' => array(),
19
+ 'i' => array(),
20
+ 'q' => array(
21
+ 'cite' => true,
22
+ ),
23
+ 'strike' => array(),
24
+ 'strong' => array(),
25
+ );
26
+
27
+ public static function init() {
28
+ if ( ! self::$initiated ) {
29
+ self::init_hooks();
30
+ }
31
+
32
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) {
33
+ self::enter_api_key();
34
+ }
35
+ }
36
+
37
+ public static function init_hooks() {
38
+ // The standalone stats page was removed in 3.0 for an all-in-one config and stats page.
39
+ // Redirect any links that might have been bookmarked or in browser history.
40
+ if ( isset( $_GET['page'] ) && 'akismet-stats-display' == $_GET['page'] ) {
41
+ wp_safe_redirect( esc_url_raw( self::get_page_url( 'stats' ) ), 301 );
42
+ die;
43
+ }
44
+
45
+ self::$initiated = true;
46
+
47
+ add_action( 'admin_init', array( 'Akismet_Admin', 'admin_init' ) );
48
+ add_action( 'admin_menu', array( 'Akismet_Admin', 'admin_menu' ), 5 ); # Priority 5, so it's called before Jetpack's admin_menu.
49
+ add_action( 'admin_notices', array( 'Akismet_Admin', 'display_notice' ) );
50
+ add_action( 'admin_enqueue_scripts', array( 'Akismet_Admin', 'load_resources' ) );
51
+ add_action( 'activity_box_end', array( 'Akismet_Admin', 'dashboard_stats' ) );
52
+ add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) );
53
+ add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) );
54
+ add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
55
+ add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
56
+ add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
57
+ add_action( 'wp_ajax_comment_author_reurl', array( 'Akismet_Admin', 'add_comment_author_url' ) );
58
+ add_action( 'jetpack_auto_activate_akismet', array( 'Akismet_Admin', 'connect_jetpack_user' ) );
59
+
60
+ add_filter( 'plugin_action_links', array( 'Akismet_Admin', 'plugin_action_links' ), 10, 2 );
61
+ add_filter( 'comment_row_actions', array( 'Akismet_Admin', 'comment_row_action' ), 10, 2 );
62
+
63
+ add_filter( 'plugin_action_links_'.plugin_basename( plugin_dir_path( __FILE__ ) . 'akismet.php'), array( 'Akismet_Admin', 'admin_plugin_settings_link' ) );
64
+
65
+ add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 );
66
+ }
67
+
68
+ public static function admin_init() {
69
+ load_plugin_textdomain( 'akismet' );
70
+ add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
71
+ }
72
+
73
+ public static function admin_menu() {
74
+ if ( class_exists( 'Jetpack' ) )
75
+ add_action( 'jetpack_admin_menu', array( 'Akismet_Admin', 'load_menu' ) );
76
+ else
77
+ self::load_menu();
78
+ }
79
+
80
+ public static function admin_head() {
81
+ if ( !current_user_can( 'manage_options' ) )
82
+ return;
83
+ }
84
+
85
+ public static function admin_plugin_settings_link( $links ) {
86
+ $settings_link = '<a href="'.esc_url( self::get_page_url() ).'">'.__('Settings', 'akismet').'</a>';
87
+ array_unshift( $links, $settings_link );
88
+ return $links;
89
+ }
90
+
91
+ public static function load_menu() {
92
+ if ( class_exists( 'Jetpack' ) )
93
+ $hook = add_submenu_page( 'jetpack', __( 'Akismet' , 'akismet'), __( 'Akismet' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
94
+ else
95
+ $hook = add_options_page( __('Akismet', 'akismet'), __('Akismet', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
96
+
97
+ if ( version_compare( $GLOBALS['wp_version'], '3.3', '>=' ) ) {
98
+ add_action( "load-$hook", array( 'Akismet_Admin', 'admin_help' ) );
99
+ }
100
+ }
101
+
102
+ public static function load_resources() {
103
+ global $hook_suffix;
104
+
105
+ if ( in_array( $hook_suffix, array(
106
+ 'index.php', # dashboard
107
+ 'edit-comments.php',
108
+ 'comment.php',
109
+ 'post.php',
110
+ 'settings_page_akismet-key-config',
111
+ 'jetpack_page_akismet-key-config',
112
+ ) ) ) {
113
+ wp_register_style( 'akismet.css', AKISMET__PLUGIN_URL . '_inc/akismet.css', array(), AKISMET_VERSION );
114
+ wp_enqueue_style( 'akismet.css');
115
+
116
+ wp_register_script( 'akismet.js', AKISMET__PLUGIN_URL . '_inc/akismet.js', array('jquery','postbox'), AKISMET_VERSION );
117
+ wp_enqueue_script( 'akismet.js' );
118
+ wp_localize_script( 'akismet.js', 'WPAkismet', array(
119
+ 'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
120
+ 'strings' => array(
121
+ 'Remove this URL' => __( 'Remove this URL' , 'akismet'),
122
+ 'Removing...' => __( 'Removing...' , 'akismet'),
123
+ 'URL removed' => __( 'URL removed' , 'akismet'),
124
+ '(undo)' => __( '(undo)' , 'akismet'),
125
+ 'Re-adding...' => __( 'Re-adding...' , 'akismet'),
126
+ )
127
+ ) );
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Add help to the Akismet page
133
+ *
134
+ * @return false if not the Akismet page
135
+ */
136
+ public static function admin_help() {
137
+ $current_screen = get_current_screen();
138
+
139
+ // Screen Content
140
+ if ( current_user_can( 'manage_options' ) ) {
141
+ if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) ) {
142
+ //setup page
143
+ $current_screen->add_help_tab(
144
+ array(
145
+ 'id' => 'overview',
146
+ 'title' => __( 'Overview' , 'akismet'),
147
+ 'content' =>
148
+ '<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
149
+ '<p>' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '</p>' .
150
+ '<p>' . esc_html__( 'On this page, you are able to set up the Akismet plugin.' , 'akismet') . '</p>',
151
+ )
152
+ );
153
+
154
+ $current_screen->add_help_tab(
155
+ array(
156
+ 'id' => 'setup-signup',
157
+ 'title' => __( 'New to Akismet' , 'akismet'),
158
+ 'content' =>
159
+ '<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
160
+ '<p>' . esc_html__( 'You need to enter an API key to activate the Akismet service on your site.' , 'akismet') . '</p>' .
161
+ '<p>' . sprintf( __( 'Sign up for an account on %s to get an API Key.' , 'akismet'), '<a href="https://akismet.com/plugin-signup/" target="_blank">Akismet.com</a>' ) . '</p>',
162
+ )
163
+ );
164
+
165
+ $current_screen->add_help_tab(
166
+ array(
167
+ 'id' => 'setup-manual',
168
+ 'title' => __( 'Enter an API Key' , 'akismet'),
169
+ 'content' =>
170
+ '<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
171
+ '<p>' . esc_html__( 'If you already have an API key' , 'akismet') . '</p>' .
172
+ '<ol>' .
173
+ '<li>' . esc_html__( 'Copy and paste the API key into the text field.' , 'akismet') . '</li>' .
174
+ '<li>' . esc_html__( 'Click the Use this Key button.' , 'akismet') . '</li>' .
175
+ '</ol>',
176
+ )
177
+ );
178
+ }
179
+ elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' ) {
180
+ //stats page
181
+ $current_screen->add_help_tab(
182
+ array(
183
+ 'id' => 'overview',
184
+ 'title' => __( 'Overview' , 'akismet'),
185
+ 'content' =>
186
+ '<p><strong>' . esc_html__( 'Akismet Stats' , 'akismet') . '</strong></p>' .
187
+ '<p>' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '</p>' .
188
+ '<p>' . esc_html__( 'On this page, you are able to view stats on spam filtered on your site.' , 'akismet') . '</p>',
189
+ )
190
+ );
191
+ }
192
+ else {
193
+ //configuration page
194
+ $current_screen->add_help_tab(
195
+ array(
196
+ 'id' => 'overview',
197
+ 'title' => __( 'Overview' , 'akismet'),
198
+ 'content' =>
199
+ '<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
200
+ '<p>' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '</p>' .
201
+ '<p>' . esc_html__( 'On this page, you are able to enter/remove an API key, view account information and view spam stats.' , 'akismet') . '</p>',
202
+ )
203
+ );
204
+
205
+ $current_screen->add_help_tab(
206
+ array(
207
+ 'id' => 'settings',
208
+ 'title' => __( 'Settings' , 'akismet'),
209
+ 'content' =>
210
+ '<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
211
+ '<p><strong>' . esc_html__( 'API Key' , 'akismet') . '</strong> - ' . esc_html__( 'Enter/remove an API key.' , 'akismet') . '</p>' .
212
+ '<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>' .
213
+ '<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>',
214
+ )
215
+ );
216
+
217
+ $current_screen->add_help_tab(
218
+ array(
219
+ 'id' => 'account',
220
+ 'title' => __( 'Account' , 'akismet'),
221
+ 'content' =>
222
+ '<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
223
+ '<p><strong>' . esc_html__( 'Subscription Type' , 'akismet') . '</strong> - ' . esc_html__( 'The Akismet subscription plan' , 'akismet') . '</p>' .
224
+ '<p><strong>' . esc_html__( 'Status' , 'akismet') . '</strong> - ' . esc_html__( 'The subscription status - active, cancelled or suspended' , 'akismet') . '</p>',
225
+ )
226
+ );
227
+ }
228
+ }
229
+
230
+ // Help Sidebar
231
+ $current_screen->set_help_sidebar(
232
+ '<p><strong>' . esc_html__( 'For more information:' , 'akismet') . '</strong></p>' .
233
+ '<p><a href="https://akismet.com/faq/" target="_blank">' . esc_html__( 'Akismet FAQ' , 'akismet') . '</a></p>' .
234
+ '<p><a href="https://akismet.com/support/" target="_blank">' . esc_html__( 'Akismet Support' , 'akismet') . '</a></p>'
235
+ );
236
+ }
237
+
238
+ public static function enter_api_key() {
239
+ if ( function_exists('current_user_can') && !current_user_can('manage_options') )
240
+ die(__('Cheatin&#8217; uh?', 'akismet'));
241
+
242
+ if ( !wp_verify_nonce( $_POST['_wpnonce'], self::NONCE ) )
243
+ return false;
244
+
245
+ foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
246
+ update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
247
+ }
248
+
249
+ if ( defined( 'WPCOM_API_KEY' ) )
250
+ return false; //shouldn't have option to save key if already defined
251
+
252
+ $new_key = preg_replace( '/[^a-f0-9]/i', '', $_POST['key'] );
253
+ $old_key = Akismet::get_api_key();
254
+
255
+ if ( empty( $new_key ) ) {
256
+ if ( !empty( $old_key ) ) {
257
+ delete_option( 'wordpress_api_key' );
258
+ self::$notices[] = 'new-key-empty';
259
+ }
260
+ }
261
+ elseif ( $new_key != $old_key ) {
262
+ self::save_key( $new_key );
263
+ }
264
+
265
+ return true;
266
+ }
267
+
268
+ public static function save_key( $api_key ) {
269
+ $key_status = Akismet::verify_key( $api_key );
270
+
271
+ if ( $key_status == 'valid' ) {
272
+ $akismet_user = self::get_akismet_user( $api_key );
273
+
274
+ if ( $akismet_user ) {
275
+ if ( in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) ) )
276
+ update_option( 'wordpress_api_key', $api_key );
277
+
278
+ if ( $akismet_user->status == 'active' )
279
+ self::$notices['status'] = 'new-key-valid';
280
+ elseif ( $akismet_user->status == 'notice' )
281
+ self::$notices['status'] = $akismet_user;
282
+ else
283
+ self::$notices['status'] = $akismet_user->status;
284
+ }
285
+ else
286
+ self::$notices['status'] = 'new-key-invalid';
287
+ }
288
+ elseif ( in_array( $key_status, array( 'invalid', 'failed' ) ) )
289
+ self::$notices['status'] = 'new-key-'.$key_status;
290
+ }
291
+
292
+ public static function dashboard_stats() {
293
+ if ( !function_exists('did_action') || did_action( 'rightnow_end' ) )
294
+ return; // We already displayed this info in the "Right Now" section
295
+
296
+ if ( !$count = get_option('akismet_spam_count') )
297
+ return;
298
+
299
+ global $submenu;
300
+
301
+ echo '<h3>' . esc_html( _x( 'Spam', 'comments' , 'akismet') ) . '</h3>';
302
+
303
+ echo '<p>'.sprintf( _n(
304
+ '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comment</a>.',
305
+ '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.',
306
+ $count
307
+ , 'akismet'), 'https://akismet.com/wordpress/', 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>';
308
+ }
309
+
310
+ // WP 2.5+
311
+ public static function rightnow_stats() {
312
+ if ( $count = get_option('akismet_spam_count') ) {
313
+ $intro = sprintf( _n(
314
+ '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
315
+ '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
316
+ $count
317
+ , 'akismet'), 'https://akismet.com/wordpress/', number_format_i18n( $count ) );
318
+ } else {
319
+ $intro = sprintf( __('<a href="%s">Akismet</a> blocks spam from getting to your blog. ', 'akismet'), 'https://akismet.com/wordpress/' );
320
+ }
321
+
322
+ $link = add_query_arg( array( 'comment_status' => 'spam' ), admin_url( 'edit-comments.php' ) );
323
+
324
+ if ( $queue_count = self::get_spam_count() ) {
325
+ $queue_text = sprintf( _n(
326
+ 'There&#8217;s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
327
+ 'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
328
+ $queue_count
329
+ , 'akismet'), number_format_i18n( $queue_count ), esc_url( $link ) );
330
+ } else {
331
+ $queue_text = sprintf( __( "There&#8217;s nothing in your <a href='%s'>spam queue</a> at the moment." , 'akismet'), esc_url( $link ) );
332
+ }
333
+
334
+ $text = $intro . '<br />' . $queue_text;
335
+ echo "<p class='akismet-right-now'>$text</p>\n";
336
+ }
337
+
338
+ public static function check_for_spam_button( $comment_status ) {
339
+ // The "Check for Spam" button should only appear when the page might be showing
340
+ // a comment with comment_approved=0, which means an un-trashed, un-spammed,
341
+ // not-yet-moderated comment.
342
+ if ( 'all' != $comment_status && 'moderated' != $comment_status ) {
343
+ return;
344
+ }
345
+
346
+ if ( function_exists('plugins_url') )
347
+ $link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
348
+ else
349
+ $link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
350
+
351
+ echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . esc_url( $link ) . '">' . esc_html__('Check for Spam', 'akismet') . '</a><span class="checkforspam-spinner"></span>';
352
+ }
353
+
354
+ public static function recheck_queue() {
355
+ global $wpdb;
356
+
357
+ Akismet::fix_scheduled_recheck();
358
+
359
+ if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
360
+ return;
361
+
362
+ $paginate = '';
363
+ if ( isset( $_POST['limit'] ) && isset( $_POST['offset'] ) ) {
364
+ $paginate = $wpdb->prepare( " LIMIT %d OFFSET %d", array( $_POST['limit'], $_POST['offset'] ) );
365
+ }
366
+ $moderation = $wpdb->get_results( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A );
367
+
368
+ foreach ( (array) $moderation as $c ) {
369
+ $c['user_ip'] = $c['comment_author_IP'];
370
+ $c['user_agent'] = $c['comment_agent'];
371
+ $c['referrer'] = '';
372
+ $c['blog'] = get_bloginfo('url');
373
+ $c['blog_lang'] = get_locale();
374
+ $c['blog_charset'] = get_option('blog_charset');
375
+ $c['permalink'] = get_permalink($c['comment_post_ID']);
376
+
377
+ $c['user_role'] = '';
378
+ if ( isset( $c['user_ID'] ) )
379
+ $c['user_role'] = Akismet::get_user_roles($c['user_ID']);
380
+
381
+ if ( Akismet::is_test_mode() )
382
+ $c['is_test'] = 'true';
383
+
384
+ add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
385
+
386
+ $response = Akismet::http_post( Akismet::build_query( $c ), 'comment-check' );
387
+
388
+ if ( 'true' == $response[1] ) {
389
+ wp_set_comment_status( $c['comment_ID'], 'spam' );
390
+ update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
391
+ delete_comment_meta( $c['comment_ID'], 'akismet_error' );
392
+ delete_comment_meta( $c['comment_ID'], 'akismet_delayed_moderation_email' );
393
+ Akismet::update_comment_history( $c['comment_ID'], '', 'recheck-spam' );
394
+
395
+ } elseif ( 'false' == $response[1] ) {
396
+ update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
397
+ delete_comment_meta( $c['comment_ID'], 'akismet_error' );
398
+ delete_comment_meta( $c['comment_ID'], 'akismet_delayed_moderation_email' );
399
+ Akismet::update_comment_history( $c['comment_ID'], '', 'recheck-ham' );
400
+ // abnormal result: error
401
+ } else {
402
+ update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
403
+ Akismet::update_comment_history(
404
+ $c['comment_ID'],
405
+ '',
406
+ 'recheck-error',
407
+ array( 'response' => substr( $response[1], 0, 50 ) )
408
+ );
409
+ }
410
+
411
+ delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
412
+ }
413
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
414
+ wp_send_json( array(
415
+ 'processed' => count((array) $moderation),
416
+ ));
417
+ }
418
+ else {
419
+ $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
420
+ wp_safe_redirect( $redirect_to );
421
+ exit;
422
+ }
423
+ }
424
+
425
+ // Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
426
+ public static function remove_comment_author_url() {
427
+ if ( !empty( $_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
428
+ $comment = get_comment( intval( $_POST['id'] ), ARRAY_A );
429
+ if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
430
+ $comment['comment_author_url'] = '';
431
+ do_action( 'comment_remove_author_url' );
432
+ print( wp_update_comment( $comment ) );
433
+ die();
434
+ }
435
+ }
436
+ }
437
+
438
+ public static function add_comment_author_url() {
439
+ if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
440
+ $comment = get_comment( intval( $_POST['id'] ), ARRAY_A );
441
+ if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
442
+ $comment['comment_author_url'] = esc_url( $_POST['url'] );
443
+ do_action( 'comment_add_author_url' );
444
+ print( wp_update_comment( $comment ) );
445
+ die();
446
+ }
447
+ }
448
+ }
449
+
450
+ public static function comment_row_action( $a, $comment ) {
451
+
452
+ // failsafe for old WP versions
453
+ if ( !function_exists('add_comment_meta') )
454
+ return $a;
455
+
456
+ $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
457
+ $akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
458
+ $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
459
+ $comment_status = wp_get_comment_status( $comment->comment_ID );
460
+ $desc = null;
461
+ if ( $akismet_error ) {
462
+ $desc = __( 'Awaiting spam check' , 'akismet');
463
+ } elseif ( !$user_result || $user_result == $akismet_result ) {
464
+ // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
465
+ if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
466
+ $desc = __( 'Flagged as spam by Akismet' , 'akismet');
467
+ elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
468
+ $desc = __( 'Cleared by Akismet' , 'akismet');
469
+ } else {
470
+ $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
471
+ if ( $user_result == 'true' )
472
+ $desc = sprintf( __('Flagged as spam by %s', 'akismet'), $who );
473
+ else
474
+ $desc = sprintf( __('Un-spammed by %s', 'akismet'), $who );
475
+ }
476
+
477
+ // add a History item to the hover links, just after Edit
478
+ if ( $akismet_result ) {
479
+ $b = array();
480
+ foreach ( $a as $k => $item ) {
481
+ $b[ $k ] = $item;
482
+ if (
483
+ $k == 'edit'
484
+ || ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
485
+ ) {
486
+ $b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' , 'akismet') . '"> '. esc_html__('History', 'akismet') . '</a>';
487
+ }
488
+ }
489
+
490
+ $a = $b;
491
+ }
492
+
493
+ if ( $desc )
494
+ echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' , 'akismet') . '">'.esc_html( $desc ).'</a></span>';
495
+
496
+ $show_user_comments = apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') );
497
+ $show_user_comments = $show_user_comments === 'false' ? false : $show_user_comments; //option used to be saved as 'false' / 'true'
498
+
499
+ if ( $show_user_comments ) {
500
+ $comment_count = Akismet::get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
501
+ $comment_count = intval( $comment_count );
502
+ 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>';
503
+ }
504
+
505
+ return $a;
506
+ }
507
+
508
+ public static function comment_status_meta_box( $comment ) {
509
+ $history = Akismet::get_comment_history( $comment->comment_ID );
510
+
511
+ if ( $history ) {
512
+ echo '<div class="akismet-history" style="margin: 13px;">';
513
+
514
+ foreach ( $history as $row ) {
515
+ $time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
516
+
517
+ $message = '';
518
+
519
+ if ( ! empty( $row['message'] ) ) {
520
+ // Old versions of Akismet stored the message as a literal string in the commentmeta.
521
+ // New versions don't do that for two reasons:
522
+ // 1) Save space.
523
+ // 2) The message can be translated into the current language of the blog, not stuck
524
+ // in the language of the blog when the comment was made.
525
+ $message = $row['message'];
526
+ }
527
+
528
+ // If possible, use a current translation.
529
+ switch ( $row['event'] ) {
530
+ case 'recheck-spam';
531
+ $message = __( 'Akismet re-checked and caught this comment as spam.', 'akismet' );
532
+ break;
533
+ case 'check-spam':
534
+ $message = __( 'Akismet caught this comment as spam.', 'akismet' );
535
+ break;
536
+ case 'recheck-ham':
537
+ $message = __( 'Akismet re-checked and cleared this comment.', 'akismet' );
538
+ break;
539
+ case 'check-ham':
540
+ $message = __( 'Akismet cleared this comment.', 'akismet' );
541
+ break;
542
+ case 'wp-blacklisted':
543
+ $message = __( 'Comment was caught by wp_blacklist_check.', 'akismet' );
544
+ break;
545
+ case 'report-spam':
546
+ if ( isset( $row['user'] ) ) {
547
+ $message = sprintf( __( '%s reported this comment as spam.', 'akismet' ), $row['user'] );
548
+ }
549
+ else if ( ! $message ) {
550
+ $message = __( 'This comment was reported as spam.', 'akismet' );
551
+ }
552
+ break;
553
+ case 'report-ham':
554
+ if ( isset( $row['user'] ) ) {
555
+ $message = sprintf( __( '%s reported this comment as not spam.', 'akismet' ), $row['user'] );
556
+ }
557
+ else if ( ! $message ) {
558
+ $message = __( 'This comment was reported as not spam.', 'akismet' );
559
+ }
560
+ break;
561
+ case 'cron-retry-spam':
562
+ $message = __( 'Akismet caught this comment as spam during an automatic retry.' , 'akismet');
563
+ break;
564
+ case 'cron-retry-ham':
565
+ $message = __( 'Akismet cleared this comment during an automatic retry.', 'akismet');
566
+ break;
567
+ case 'check-error':
568
+ if ( isset( $row['meta'], $row['meta']['response'] ) ) {
569
+ $message = sprintf( __( 'Akismet was unable to check this comment (response: %s) but will automatically retry later.', 'akismet'), $row['meta']['response'] );
570
+ }
571
+ break;
572
+ case 'recheck-error':
573
+ if ( isset( $row['meta'], $row['meta']['response'] ) ) {
574
+ $message = sprintf( __( 'Akismet was unable to recheck this comment (response: %s).', 'akismet'), $row['meta']['response'] );
575
+ }
576
+ break;
577
+ default:
578
+ if ( preg_match( '/^status-changed/', $row['event'] ) ) {
579
+ // Half of these used to be saved without the dash after 'status-changed'.
580
+ // See https://plugins.trac.wordpress.org/changeset/1150658/akismet/trunk
581
+ $new_status = preg_replace( '/^status-changed-?/', '', $row['event'] );
582
+ $message = sprintf( __( 'Comment status was changed to %s', 'akismet' ), $new_status );
583
+ }
584
+ else if ( preg_match( '/^status-/', $row['event'] ) ) {
585
+ $new_status = preg_replace( '/^status-/', '', $row['event'] );
586
+
587
+ if ( isset( $row['user'] ) ) {
588
+ $message = sprintf( __( '%1$s changed the comment status to %2$s.', 'akismet' ), $row['user'], $new_status );
589
+ }
590
+ }
591
+ break;
592
+
593
+ }
594
+
595
+ echo '<div style="margin-bottom: 13px;">';
596
+ echo '<span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( esc_html__('%s ago', 'akismet'), human_time_diff( $row['time'] ) ) . '</span>';
597
+ echo ' - ';
598
+ echo esc_html( $message );
599
+ echo '</div>';
600
+ }
601
+
602
+ echo '</div>';
603
+ }
604
+ }
605
+
606
+ public static function plugin_action_links( $links, $file ) {
607
+ if ( $file == plugin_basename( AKISMET__PLUGIN_URL . '/akismet.php' ) ) {
608
+ $links[] = '<a href="' . esc_url( self::get_page_url() ) . '">'.esc_html__( 'Settings' , 'akismet').'</a>';
609
+ }
610
+
611
+ return $links;
612
+ }
613
+
614
+ // Total spam in queue
615
+ // get_option( 'akismet_spam_count' ) is the total caught ever
616
+ public static function get_spam_count( $type = false ) {
617
+ global $wpdb;
618
+
619
+ if ( !$type ) { // total
620
+ $count = wp_cache_get( 'akismet_spam_count', 'widget' );
621
+ if ( false === $count ) {
622
+ if ( function_exists('wp_count_comments') ) {
623
+ $count = wp_count_comments();
624
+ $count = $count->spam;
625
+ } else {
626
+ $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam'");
627
+ }
628
+ wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
629
+ }
630
+ return $count;
631
+ } elseif ( 'comments' == $type || 'comment' == $type ) { // comments
632
+ $type = '';
633
+ }
634
+
635
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam' AND comment_type = %s", $type ) );
636
+ }
637
+
638
+ // Check connectivity between the WordPress blog and Akismet's servers.
639
+ // 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).
640
+ public static function check_server_ip_connectivity() {
641
+
642
+ $servers = $ips = array();
643
+
644
+ // Some web hosts may disable this function
645
+ if ( function_exists('gethostbynamel') ) {
646
+
647
+ $ips = gethostbynamel( 'rest.akismet.com' );
648
+ if ( $ips && is_array($ips) && count($ips) ) {
649
+ $api_key = Akismet::get_api_key();
650
+
651
+ foreach ( $ips as $ip ) {
652
+ $response = Akismet::verify_key( $api_key, $ip );
653
+ // even if the key is invalid, at least we know we have connectivity
654
+ if ( $response == 'valid' || $response == 'invalid' )
655
+ $servers[$ip] = 'connected';
656
+ else
657
+ $servers[$ip] = $response ? $response : 'unable to connect';
658
+ }
659
+ }
660
+ }
661
+
662
+ return $servers;
663
+ }
664
+
665
+ // Simpler connectivity check
666
+ public static function check_server_connectivity($cache_timeout = 86400) {
667
+
668
+ $debug = array();
669
+ $debug[ 'PHP_VERSION' ] = PHP_VERSION;
670
+ $debug[ 'WORDPRESS_VERSION' ] = $GLOBALS['wp_version'];
671
+ $debug[ 'AKISMET_VERSION' ] = AKISMET_VERSION;
672
+ $debug[ 'AKISMET__PLUGIN_DIR' ] = AKISMET__PLUGIN_DIR;
673
+ $debug[ 'SITE_URL' ] = site_url();
674
+ $debug[ 'HOME_URL' ] = home_url();
675
+
676
+ $servers = get_option('akismet_available_servers');
677
+ if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false ) {
678
+ $servers = self::check_server_ip_connectivity();
679
+ update_option('akismet_available_servers', $servers);
680
+ update_option('akismet_connectivity_time', time());
681
+ }
682
+
683
+ $response = wp_remote_get( 'http://rest.akismet.com/1.1/test' );
684
+
685
+ $debug[ 'gethostbynamel' ] = function_exists('gethostbynamel') ? 'exists' : 'not here';
686
+ $debug[ 'Servers' ] = $servers;
687
+ $debug[ 'Test Connection' ] = $response;
688
+
689
+ Akismet::log( $debug );
690
+
691
+ if ( $response && 'connected' == wp_remote_retrieve_body( $response ) )
692
+ return true;
693
+
694
+ return false;
695
+ }
696
+
697
+ // Check the server connectivity and store the available servers in an option.
698
+ public static function get_server_connectivity($cache_timeout = 86400) {
699
+ return self::check_server_connectivity( $cache_timeout );
700
+ }
701
+
702
+ public static function get_number_spam_waiting() {
703
+ global $wpdb;
704
+ return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
705
+ }
706
+
707
+ public static function get_page_url( $page = 'config' ) {
708
+
709
+ $args = array( 'page' => 'akismet-key-config' );
710
+
711
+ if ( $page == 'stats' )
712
+ $args = array( 'page' => 'akismet-key-config', 'view' => 'stats' );
713
+ elseif ( $page == 'delete_key' )
714
+ $args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) );
715
+
716
+ $url = add_query_arg( $args, class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) );
717
+
718
+ return $url;
719
+ }
720
+
721
+ public static function get_akismet_user( $api_key ) {
722
+ $akismet_user = false;
723
+
724
+ $subscription_verification = Akismet::http_post( Akismet::build_query( array( 'key' => $api_key, 'blog' => get_bloginfo( 'url' ) ) ), 'get-subscription' );
725
+
726
+ if ( ! empty( $subscription_verification[1] ) ) {
727
+ if ( 'invalid' !== $subscription_verification[1] ) {
728
+ $akismet_user = json_decode( $subscription_verification[1] );
729
+ }
730
+ }
731
+
732
+ return $akismet_user;
733
+ }
734
+
735
+ public static function get_stats( $api_key ) {
736
+ $stat_totals = array();
737
+
738
+ foreach( array( '6-months', 'all' ) as $interval ) {
739
+ $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_bloginfo( 'url' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
740
+
741
+ if ( ! empty( $response[1] ) ) {
742
+ $stat_totals[$interval] = json_decode( $response[1] );
743
+ }
744
+ }
745
+
746
+ return $stat_totals;
747
+ }
748
+
749
+ public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) {
750
+ $akismet_account = Akismet::http_post( Akismet::build_query( array_merge( array(
751
+ 'user_id' => $user_id,
752
+ 'api_key' => $api_key,
753
+ 'get_account_type' => 'true'
754
+ ), $extra ) ), 'verify-wpcom-key' );
755
+
756
+ if ( ! empty( $akismet_account[1] ) )
757
+ $akismet_account = json_decode( $akismet_account[1] );
758
+
759
+ Akismet::log( compact( 'akismet_account' ) );
760
+
761
+ return $akismet_account;
762
+ }
763
+
764
+ public static function connect_jetpack_user() {
765
+
766
+ if ( $jetpack_user = self::get_jetpack_user() ) {
767
+ if ( isset( $jetpack_user['user_id'] ) && isset( $jetpack_user['api_key'] ) ) {
768
+ $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'], array( 'action' => 'connect_jetpack_user' ) );
769
+
770
+ if ( is_object( $akismet_user ) ) {
771
+ self::save_key( $akismet_user->api_key );
772
+ return in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) );
773
+ }
774
+ }
775
+ }
776
+
777
+ return false;
778
+ }
779
+
780
+ public static function display_alert() {
781
+ Akismet::view( 'notice', array(
782
+ 'type' => 'alert',
783
+ 'code' => (int) get_option( 'akismet_alert_code' ),
784
+ 'msg' => get_option( 'akismet_alert_msg' )
785
+ ) );
786
+ }
787
+
788
+ public static function display_spam_check_warning() {
789
+ Akismet::fix_scheduled_recheck();
790
+
791
+ if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::get_number_spam_waiting() > 0 ) {
792
+ $link_text = apply_filters( 'akismet_spam_check_warning_link_text', sprintf( __( 'Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.', 'akismet'), esc_url( self::get_page_url() ) ) );
793
+ Akismet::view( 'notice', array( 'type' => 'spam-check', 'link_text' => $link_text ) );
794
+ }
795
+ }
796
+
797
+ public static function display_invalid_version() {
798
+ Akismet::view( 'notice', array( 'type' => 'version' ) );
799
+ }
800
+
801
+ public static function display_api_key_warning() {
802
+ Akismet::view( 'notice', array( 'type' => 'plugin' ) );
803
+ }
804
+
805
+ public static function display_page() {
806
+ if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) )
807
+ self::display_start_page();
808
+ elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' )
809
+ self::display_stats_page();
810
+ else
811
+ self::display_configuration_page();
812
+ }
813
+
814
+ public static function display_start_page() {
815
+ if ( isset( $_GET['action'] ) ) {
816
+ if ( $_GET['action'] == 'delete-key' ) {
817
+ if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], self::NONCE ) )
818
+ delete_option( 'wordpress_api_key' );
819
+ }
820
+ }
821
+
822
+ if ( $api_key = Akismet::get_api_key() && ( empty( self::$notices['status'] ) || 'existing-key-invalid' != self::$notices['status'] ) ) {
823
+ self::display_configuration_page();
824
+ return;
825
+ }
826
+
827
+ //the user can choose to auto connect their API key by clicking a button on the akismet done page
828
+ //if jetpack, get verified api key by using connected wpcom user id
829
+ //if no jetpack, get verified api key by using an akismet token
830
+
831
+ $akismet_user = false;
832
+
833
+ if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) )
834
+ $akismet_user = self::verify_wpcom_key( '', '', array( 'token' => $_GET['token'] ) );
835
+ elseif ( $jetpack_user = self::get_jetpack_user() )
836
+ $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] );
837
+
838
+ if ( isset( $_GET['action'] ) ) {
839
+ if ( $_GET['action'] == 'save-key' ) {
840
+ if ( is_object( $akismet_user ) ) {
841
+ self::save_key( $akismet_user->api_key );
842
+ self::display_notice();
843
+ self::display_configuration_page();
844
+ return;
845
+ }
846
+ }
847
+ }
848
+
849
+ echo '<h2 class="ak-header">'.esc_html__('Akismet', 'akismet').'</h2>';
850
+
851
+ self::display_status();
852
+
853
+ Akismet::view( 'start', compact( 'akismet_user' ) );
854
+ }
855
+
856
+ public static function display_stats_page() {
857
+ Akismet::view( 'stats' );
858
+ }
859
+
860
+ public static function display_configuration_page() {
861
+ $api_key = Akismet::get_api_key();
862
+ $akismet_user = self::get_akismet_user( $api_key );
863
+
864
+ if ( ! $akismet_user ) {
865
+ // This could happen if the user's key became invalid after it was previously valid and successfully set up.
866
+ self::$notices['status'] = 'existing-key-invalid';
867
+ self::display_start_page();
868
+ return;
869
+ }
870
+
871
+ $stat_totals = self::get_stats( $api_key );
872
+
873
+ // If unset, create the new strictness option using the old discard option to determine its default
874
+ if ( get_option( 'akismet_strictness' ) === false )
875
+ add_option( 'akismet_strictness', (get_option('akismet_discard_month') === 'true' ? '1' : '0') );
876
+
877
+ if ( empty( self::$notices ) ) {
878
+ //show status
879
+ if ( ! empty( $stat_totals['all'] ) && isset( $stat_totals['all']->time_saved ) && $akismet_user->status == 'active' && $akismet_user->account_type == 'free-api-key' ) {
880
+
881
+ $time_saved = false;
882
+
883
+ if ( $stat_totals['all']->time_saved > 1800 ) {
884
+ $total_in_minutes = round( $stat_totals['all']->time_saved / 60 );
885
+ $total_in_hours = round( $total_in_minutes / 60 );
886
+ $total_in_days = round( $total_in_hours / 8 );
887
+ $cleaning_up = __( 'Cleaning up spam takes time.' , 'akismet');
888
+
889
+ if ( $total_in_days > 1 )
890
+ $time_saved = $cleaning_up . ' ' . sprintf( _n( 'Akismet has saved you %s day!', 'Akismet has saved you %s days!', $total_in_days, 'akismet' ), number_format_i18n( $total_in_days ) );
891
+ elseif ( $total_in_hours > 1 )
892
+ $time_saved = $cleaning_up . ' ' . sprintf( _n( 'Akismet has saved you %d hour!', 'Akismet has saved you %d hours!', $total_in_hours, 'akismet' ), $total_in_hours );
893
+ elseif ( $total_in_minutes >= 30 )
894
+ $time_saved = $cleaning_up . ' ' . sprintf( _n( 'Akismet has saved you %d minute!', 'Akismet has saved you %d minutes!', $total_in_minutes, 'akismet' ), $total_in_minutes );
895
+ }
896
+
897
+ Akismet::view( 'notice', array( 'type' => 'active-notice', 'time_saved' => $time_saved ) );
898
+ }
899
+
900
+ if ( !empty( $akismet_user->limit_reached ) && in_array( $akismet_user->limit_reached, array( 'yellow', 'red' ) ) ) {
901
+ Akismet::view( 'notice', array( 'type' => 'limit-reached', 'level' => $akismet_user->limit_reached ) );
902
+ }
903
+ }
904
+
905
+ if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing', 'no-sub' ) ) )
906
+ Akismet::view( 'notice', array( 'type' => $akismet_user->status ) );
907
+
908
+ Akismet::log( compact( 'stat_totals', 'akismet_user' ) );
909
+ Akismet::view( 'config', compact( 'api_key', 'akismet_user', 'stat_totals' ) );
910
+ }
911
+
912
+ public static function display_notice() {
913
+ global $hook_suffix;
914
+
915
+ 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 ) {
916
+ Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state
917
+
918
+ if ( get_option( 'akismet_alert_code' ) > 0 )
919
+ self::display_alert();
920
+ }
921
+ elseif ( $hook_suffix == 'plugins.php' && !Akismet::get_api_key() ) {
922
+ self::display_api_key_warning();
923
+ }
924
+ elseif ( $hook_suffix == 'edit-comments.php' && wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
925
+ self::display_spam_check_warning();
926
+ }
927
+ elseif ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config' ) ) && Akismet::get_api_key() ) {
928
+ self::display_status();
929
+ }
930
+ }
931
+
932
+ public static function display_status() {
933
+ $type = '';
934
+
935
+ if ( !self::get_server_connectivity() )
936
+ $type = 'servers-be-down';
937
+
938
+ if ( !empty( $type ) )
939
+ Akismet::view( 'notice', compact( 'type' ) );
940
+ elseif ( !empty( self::$notices ) ) {
941
+ foreach ( self::$notices as $type ) {
942
+ if ( is_object( $type ) ) {
943
+ $notice_header = $notice_text = '';
944
+
945
+ if ( property_exists( $type, 'notice_header' ) )
946
+ $notice_header = wp_kses( $type->notice_header, self::$allowed );
947
+
948
+ if ( property_exists( $type, 'notice_text' ) )
949
+ $notice_text = wp_kses( $type->notice_text, self::$allowed );
950
+
951
+ if ( property_exists( $type, 'status' ) ) {
952
+ $type = wp_kses( $type->status, self::$allowed );
953
+ Akismet::view( 'notice', compact( 'type', 'notice_header', 'notice_text' ) );
954
+ }
955
+ }
956
+ else
957
+ Akismet::view( 'notice', compact( 'type' ) );
958
+ }
959
+ }
960
+ }
961
+
962
+ private static function get_jetpack_user() {
963
+ if ( !class_exists('Jetpack') )
964
+ return false;
965
+
966
+ Jetpack::load_xml_rpc_client();
967
+ $xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) );
968
+
969
+ $xml->addCall( 'wpcom.getUserID' );
970
+ $xml->addCall( 'akismet.getAPIKey' );
971
+ $xml->query();
972
+
973
+ Akismet::log( compact( 'xml' ) );
974
+
975
+ if ( !$xml->isError() ) {
976
+ $responses = $xml->getResponse();
977
+ if ( count( $responses ) > 1 ) {
978
+ $api_key = array_shift( $responses[0] );
979
+ $user_id = (int) array_shift( $responses[1] );
980
+ return compact( 'api_key', 'user_id' );
981
+ }
982
+ }
983
+ return false;
984
+ }
985
+
986
+ /**
987
+ * Some commentmeta isn't useful in an export file. Suppress it (when supported).
988
+ *
989
+ * @param bool $exclude
990
+ * @param string $key The meta key
991
+ * @param object $meta The meta object
992
+ * @return bool Whether to exclude this meta entry from the export.
993
+ */
994
+ public static function exclude_commentmeta_from_export( $exclude, $key, $meta ) {
995
+ if ( in_array( $key, array( 'akismet_as_submitted', 'akismet_rechecking', 'akismet_delayed_moderation_email' ) ) ) {
996
+ return true;
997
+ }
998
+
999
+ return $exclude;
1000
+ }
1001
+ }
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 = esc_attr( $instance['title'] );
65
  }
66
  else {
67
- $title = __( 'Spam Blocked' );
68
  }
69
  ?>
70
 
71
  <p>
72
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
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,1147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ private static $comment_as_submitted_allowed_keys = array( 'blog' => '', 'blog_charset' => '', 'blog_lang' => '', 'blog_ua' => '', 'comment_agent' => '', 'comment_author' => '', 'comment_author_IP' => '', 'comment_author_email' => '', 'comment_author_url' => '', 'comment_content' => '', 'comment_date_gmt' => '', 'comment_tags' => '', 'comment_type' => '', 'guid' => '', 'is_test' => '', 'permalink' => '', 'reporter' => '', 'site_domain' => '', 'submit_referer' => '', 'submit_uri' => '', 'user_ID' => '', 'user_agent' => '', 'user_id' => '', 'user_ip' => '' );
13
+
14
+ public static function init() {
15
+ if ( ! self::$initiated ) {
16
+ self::init_hooks();
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Initializes WordPress hooks
22
+ */
23
+ private static function init_hooks() {
24
+ self::$initiated = true;
25
+
26
+ add_action( 'wp_insert_comment', array( 'Akismet', 'auto_check_update_meta' ), 10, 2 );
27
+ add_filter( 'preprocess_comment', array( 'Akismet', 'auto_check_comment' ), 1 );
28
+ add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments' ) );
29
+ add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
30
+ add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
31
+
32
+ $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
33
+
34
+ if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
35
+ add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
36
+
37
+ add_action( 'admin_head-edit-comments.php', array( 'Akismet', 'load_form_js' ) );
38
+ add_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
39
+ add_action( 'comment_form', array( 'Akismet', 'inject_ak_js' ) );
40
+
41
+ add_filter( 'comment_moderation_recipients', array( 'Akismet', 'disable_moderation_emails_if_unreachable' ), 1000, 2 );
42
+ add_filter( 'pre_comment_approved', array( 'Akismet', 'last_comment_status' ), 10, 2 );
43
+
44
+ add_action( 'transition_comment_status', array( 'Akismet', 'transition_comment_status' ), 10, 3 );
45
+
46
+ // Run this early in the pingback call, before doing a remote fetch of the source uri
47
+ add_action( 'xmlrpc_call', array( 'Akismet', 'pre_check_pingback' ) );
48
+ }
49
+
50
+ public static function get_api_key() {
51
+ return apply_filters( 'akismet_get_api_key', 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( Akismet::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
+ return $response[1];
65
+ }
66
+
67
+ public static function deactivate_key( $key ) {
68
+ $response = self::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option('home') ) ), 'deactivate' );
69
+
70
+ if ( $response[1] != 'deactivated' )
71
+ return 'failed';
72
+
73
+ return $response[1];
74
+ }
75
+
76
+ public static function auto_check_comment( $commentdata ) {
77
+ self::$last_comment_result = null;
78
+
79
+ $comment = $commentdata;
80
+
81
+ $comment['user_ip'] = self::get_ip_address();
82
+ $comment['user_agent'] = self::get_user_agent();
83
+ $comment['referrer'] = self::get_referer();
84
+ $comment['blog'] = get_option('home');
85
+ $comment['blog_lang'] = get_locale();
86
+ $comment['blog_charset'] = get_option('blog_charset');
87
+ $comment['permalink'] = get_permalink( $comment['comment_post_ID'] );
88
+
89
+ if ( !empty( $comment['user_ID'] ) )
90
+ $comment['user_role'] = Akismet::get_user_roles( $comment['user_ID'] );
91
+
92
+ $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
93
+ $comment['akismet_comment_nonce'] = 'inactive';
94
+ if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
95
+ $comment['akismet_comment_nonce'] = 'failed';
96
+ if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
97
+ $comment['akismet_comment_nonce'] = 'passed';
98
+
99
+ // comment reply in wp-admin
100
+ if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
101
+ $comment['akismet_comment_nonce'] = 'passed';
102
+
103
+ }
104
+
105
+ if ( self::is_test_mode() )
106
+ $comment['is_test'] = 'true';
107
+
108
+ foreach( $_POST as $key => $value ) {
109
+ if ( is_string( $value ) )
110
+ $comment["POST_{$key}"] = $value;
111
+ }
112
+
113
+ $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
114
+
115
+ foreach ( $_SERVER as $key => $value ) {
116
+ if ( !in_array( $key, $ignore ) && is_string($value) )
117
+ $comment["$key"] = $value;
118
+ else
119
+ $comment["$key"] = '';
120
+ }
121
+
122
+ $post = get_post( $comment['comment_post_ID'] );
123
+ $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
124
+
125
+ $response = self::http_post( Akismet::build_query( $comment ), 'comment-check' );
126
+
127
+ do_action( 'akismet_comment_check_response', $response );
128
+
129
+ $commentdata['comment_as_submitted'] = array_intersect_key( $comment, self::$comment_as_submitted_allowed_keys );
130
+ $commentdata['akismet_result'] = $response[1];
131
+
132
+ if ( isset( $response[0]['x-akismet-pro-tip'] ) )
133
+ $commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
134
+
135
+ if ( isset( $response[0]['x-akismet-error'] ) ) {
136
+ // An error occurred that we anticipated (like a suspended key) and want the user to act on.
137
+ // Send to moderation.
138
+ self::$last_comment_result = '0';
139
+ }
140
+ else if ( 'true' == $response[1] ) {
141
+ // akismet_spam_count will be incremented later by comment_is_spam()
142
+ self::$last_comment_result = 'spam';
143
+
144
+ $discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard() );
145
+
146
+ do_action( 'akismet_spam_caught', $discard );
147
+
148
+ if ( $discard ) {
149
+ // akismet_result_spam() won't be called so bump the counter here
150
+ if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
151
+ update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
152
+ $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
153
+ wp_safe_redirect( esc_url_raw( $redirect_to ) );
154
+ die();
155
+ }
156
+ }
157
+
158
+ // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
159
+ if ( 'true' != $response[1] && 'false' != $response[1] ) {
160
+ if ( !current_user_can('moderate_comments') ) {
161
+ // Comment status should be moderated
162
+ self::$last_comment_result = '0';
163
+ }
164
+ if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_single_event') ) {
165
+ if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
166
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
167
+ do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
168
+ }
169
+ }
170
+
171
+ self::$prevent_moderation_email_for_these_comments[] = $commentdata;
172
+ }
173
+
174
+ if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
175
+ // WP 2.1+: delete old comments daily
176
+ if ( !wp_next_scheduled( 'akismet_scheduled_delete' ) )
177
+ wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
178
+ }
179
+ elseif ( (mt_rand(1, 10) == 3) ) {
180
+ // WP 2.0: run this one time in ten
181
+ self::delete_old_comments();
182
+ }
183
+
184
+ self::set_last_comment( $commentdata );
185
+ self::fix_scheduled_recheck();
186
+
187
+ return $commentdata;
188
+ }
189
+
190
+ public static function get_last_comment() {
191
+ return self::$last_comment;
192
+ }
193
+
194
+ public static function set_last_comment( $comment ) {
195
+ if ( is_null( $comment ) ) {
196
+ self::$last_comment = null;
197
+ }
198
+ else {
199
+ // We filter it here so that it matches the filtered comment data that we'll have to compare against later.
200
+ // wp_filter_comment expects comment_author_IP
201
+ self::$last_comment = wp_filter_comment(
202
+ array_merge(
203
+ array( 'comment_author_IP' => self::get_ip_address() ),
204
+ $comment
205
+ )
206
+ );
207
+ }
208
+ }
209
+
210
+ // this fires on wp_insert_comment. we can't update comment_meta when auto_check_comment() runs
211
+ // because we don't know the comment ID at that point.
212
+ public static function auto_check_update_meta( $id, $comment ) {
213
+
214
+ // failsafe for old WP versions
215
+ if ( !function_exists('add_comment_meta') )
216
+ return false;
217
+
218
+ if ( !isset( self::$last_comment['comment_author_email'] ) )
219
+ self::$last_comment['comment_author_email'] = '';
220
+
221
+ // wp_insert_comment() might be called in other contexts, so make sure this is the same comment
222
+ // as was checked by auto_check_comment
223
+ if ( is_object( $comment ) && !empty( self::$last_comment ) && is_array( self::$last_comment ) ) {
224
+ if ( self::matches_last_comment( $comment ) ) {
225
+
226
+ load_plugin_textdomain( 'akismet' );
227
+
228
+ // normal result: true or false
229
+ if ( self::$last_comment['akismet_result'] == 'true' ) {
230
+ update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
231
+ self::update_comment_history( $comment->comment_ID, '', 'check-spam' );
232
+ if ( $comment->comment_approved != 'spam' )
233
+ self::update_comment_history(
234
+ $comment->comment_ID,
235
+ '',
236
+ 'status-changed-'.$comment->comment_approved
237
+ );
238
+ }
239
+ elseif ( self::$last_comment['akismet_result'] == 'false' ) {
240
+ update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
241
+ self::update_comment_history( $comment->comment_ID, '', 'check-ham' );
242
+ if ( $comment->comment_approved == 'spam' ) {
243
+ 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) )
244
+ self::update_comment_history( $comment->comment_ID, '', 'wp-blacklisted' );
245
+ else
246
+ self::update_comment_history( $comment->comment_ID, '', 'status-changed-'.$comment->comment_approved );
247
+ }
248
+ } // abnormal result: error
249
+ else {
250
+ update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
251
+ self::update_comment_history(
252
+ $comment->comment_ID,
253
+ '',
254
+ 'check-error',
255
+ array( 'response' => substr( self::$last_comment['akismet_result'], 0, 50 ) )
256
+ );
257
+ }
258
+
259
+ // record the complete original data as submitted for checking
260
+ if ( isset( self::$last_comment['comment_as_submitted'] ) )
261
+ update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', self::$last_comment['comment_as_submitted'] );
262
+
263
+ if ( isset( self::$last_comment['akismet_pro_tip'] ) )
264
+ update_comment_meta( $comment->comment_ID, 'akismet_pro_tip', self::$last_comment['akismet_pro_tip'] );
265
+ }
266
+ }
267
+ }
268
+
269
+ public static function delete_old_comments() {
270
+ global $wpdb;
271
+
272
+ /**
273
+ * Determines how many comments will be deleted in each batch.
274
+ *
275
+ * @param int The default, as defined by AKISMET_DELETE_LIMIT.
276
+ */
277
+ $delete_limit = apply_filters( 'akismet_delete_comment_limit', defined( 'AKISMET_DELETE_LIMIT' ) ? AKISMET_DELETE_LIMIT : 10000 );
278
+ $delete_limit = max( 1, intval( $delete_limit ) );
279
+
280
+ /**
281
+ * Determines how many days a comment will be left in the Spam queue before being deleted.
282
+ *
283
+ * @param int The default number of days.
284
+ */
285
+ $delete_interval = apply_filters( 'akismet_delete_comment_interval', 15 );
286
+ $delete_interval = max( 1, intval( $delete_interval ) );
287
+
288
+ while ( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL %d DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", $delete_interval, $delete_limit ) ) ) {
289
+ if ( empty( $comment_ids ) )
290
+ return;
291
+
292
+ $wpdb->queries = array();
293
+
294
+ foreach ( $comment_ids as $comment_id ) {
295
+ do_action( 'delete_comment', $comment_id );
296
+ }
297
+
298
+ $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
299
+
300
+ $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( $comma_comment_ids )");
301
+ $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( $comma_comment_ids )");
302
+
303
+ clean_comment_cache( $comment_ids );
304
+ }
305
+
306
+ if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number
307
+ $wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
308
+ }
309
+
310
+ public static function delete_old_comments_meta() {
311
+ global $wpdb;
312
+
313
+ $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
314
+
315
+ # enfore a minimum of 1 day
316
+ $interval = absint( $interval );
317
+ if ( $interval < 1 )
318
+ $interval = 1;
319
+
320
+ // akismet_as_submitted meta values are large, so expire them
321
+ // after $interval days regardless of the comment status
322
+ 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 ) ) ) {
323
+ if ( empty( $comment_ids ) )
324
+ return;
325
+
326
+ $wpdb->queries = array();
327
+
328
+ foreach ( $comment_ids as $comment_id ) {
329
+ delete_comment_meta( $comment_id, 'akismet_as_submitted' );
330
+ }
331
+ }
332
+
333
+ if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
334
+ $wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
335
+ }
336
+
337
+ // how many approved comments does this author have?
338
+ public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
339
+ global $wpdb;
340
+
341
+ if ( !empty( $user_id ) )
342
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_approved = 1", $user_id ) );
343
+
344
+ if ( !empty( $comment_author_email ) )
345
+ 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 ) );
346
+
347
+ return 0;
348
+ }
349
+
350
+ // get the full comment history for a given comment, as an array in reverse chronological order
351
+ public static function get_comment_history( $comment_id ) {
352
+
353
+ // failsafe for old WP versions
354
+ if ( !function_exists('add_comment_meta') )
355
+ return false;
356
+
357
+ $history = get_comment_meta( $comment_id, 'akismet_history', false );
358
+ usort( $history, array( 'Akismet', '_cmp_time' ) );
359
+ return $history;
360
+ }
361
+
362
+ /**
363
+ * Log an event for a given comment, storing it in comment_meta.
364
+ *
365
+ * @param int $comment_id The ID of the relevant comment.
366
+ * @param string $message The string description of the event. No longer used.
367
+ * @param string $event The event code.
368
+ * @param array $meta Metadata about the history entry. e.g., the user that reported or changed the status of a given comment.
369
+ */
370
+ public static function update_comment_history( $comment_id, $message, $event=null, $meta=null ) {
371
+ global $current_user;
372
+
373
+ // failsafe for old WP versions
374
+ if ( !function_exists('add_comment_meta') )
375
+ return false;
376
+
377
+ $user = '';
378
+
379
+ $event = array(
380
+ 'time' => self::_get_microtime(),
381
+ 'event' => $event,
382
+ );
383
+
384
+ if ( is_object( $current_user ) && isset( $current_user->user_login ) ) {
385
+ $event['user'] = $current_user->user_login;
386
+ }
387
+
388
+ if ( ! empty( $meta ) ) {
389
+ $event['meta'] = $meta;
390
+ }
391
+
392
+ // $unique = false so as to allow multiple values per comment
393
+ $r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
394
+ }
395
+
396
+ public static function check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
397
+ global $wpdb;
398
+
399
+ $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $id ), ARRAY_A );
400
+ if ( !$c )
401
+ return;
402
+
403
+ $c['user_ip'] = $c['comment_author_IP'];
404
+ $c['user_agent'] = $c['comment_agent'];
405
+ $c['referrer'] = '';
406
+ $c['blog'] = get_option('home');
407
+ $c['blog_lang'] = get_locale();
408
+ $c['blog_charset'] = get_option('blog_charset');
409
+ $c['permalink'] = get_permalink($c['comment_post_ID']);
410
+ $c['recheck_reason'] = $recheck_reason;
411
+
412
+ if ( self::is_test_mode() )
413
+ $c['is_test'] = 'true';
414
+
415
+ $response = self::http_post( Akismet::build_query( $c ), 'comment-check' );
416
+
417
+ return ( is_array( $response ) && ! empty( $response[1] ) ) ? $response[1] : false;
418
+ }
419
+
420
+
421
+
422
+ public static function transition_comment_status( $new_status, $old_status, $comment ) {
423
+
424
+ if ( $new_status == $old_status )
425
+ return;
426
+
427
+ # we don't need to record a history item for deleted comments
428
+ if ( $new_status == 'delete' )
429
+ return;
430
+
431
+ if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
432
+ return;
433
+
434
+ if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
435
+ return;
436
+
437
+ // if this is present, it means the status has been changed by a re-check, not an explicit user action
438
+ if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
439
+ return;
440
+
441
+ global $current_user;
442
+ $reporter = '';
443
+ if ( is_object( $current_user ) )
444
+ $reporter = $current_user->user_login;
445
+
446
+ // Assumption alert:
447
+ // We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
448
+ // is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
449
+ // determine why the transition_comment_status action was triggered. And there are several different ways by which
450
+ // to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
451
+ // We'll assume that this is an explicit user action if certain POST/GET variables exist.
452
+ if ( ( isset( $_POST['status'] ) && in_array( $_POST['status'], array( 'spam', 'unspam' ) ) ) ||
453
+ ( isset( $_POST['spam'] ) && (int) $_POST['spam'] == 1 ) ||
454
+ ( isset( $_POST['unspam'] ) && (int) $_POST['unspam'] == 1 ) ||
455
+ ( isset( $_POST['comment_status'] ) && in_array( $_POST['comment_status'], array( 'spam', 'unspam' ) ) ) ||
456
+ ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'spam', 'unspam' ) ) ) ||
457
+ ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) )
458
+ ) {
459
+ if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
460
+ return self::submit_spam_comment( $comment->comment_ID );
461
+ } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
462
+ return self::submit_nonspam_comment( $comment->comment_ID );
463
+ }
464
+ }
465
+
466
+ self::update_comment_history( $comment->comment_ID, '', 'status-' . $new_status );
467
+ }
468
+
469
+ public static function submit_spam_comment( $comment_id ) {
470
+ global $wpdb, $current_user, $current_site;
471
+
472
+ $comment_id = (int) $comment_id;
473
+
474
+ $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
475
+
476
+ if ( !$comment ) // it was deleted
477
+ return;
478
+
479
+ if ( 'spam' != $comment->comment_approved )
480
+ return;
481
+
482
+ // use the original version stored in comment_meta if available
483
+ $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
484
+
485
+ if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) )
486
+ $comment = (object) array_merge( (array)$comment, $as_submitted );
487
+
488
+ $comment->blog = get_bloginfo('url');
489
+ $comment->blog_lang = get_locale();
490
+ $comment->blog_charset = get_option('blog_charset');
491
+ $comment->permalink = get_permalink($comment->comment_post_ID);
492
+
493
+ if ( is_object($current_user) )
494
+ $comment->reporter = $current_user->user_login;
495
+
496
+ if ( is_object($current_site) )
497
+ $comment->site_domain = $current_site->domain;
498
+
499
+ $comment->user_role = '';
500
+ if ( isset( $comment->user_ID ) )
501
+ $comment->user_role = Akismet::get_user_roles( $comment->user_ID );
502
+
503
+ if ( self::is_test_mode() )
504
+ $comment->is_test = 'true';
505
+
506
+ $post = get_post( $comment->comment_post_ID );
507
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
508
+
509
+ $response = Akismet::http_post( Akismet::build_query( $comment ), 'submit-spam' );
510
+ if ( $comment->reporter ) {
511
+ self::update_comment_history( $comment_id, '', 'report-spam' );
512
+ update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
513
+ update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
514
+ }
515
+
516
+ do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
517
+ }
518
+
519
+ public static function submit_nonspam_comment( $comment_id ) {
520
+ global $wpdb, $current_user, $current_site;
521
+
522
+ $comment_id = (int) $comment_id;
523
+
524
+ $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
525
+ if ( !$comment ) // it was deleted
526
+ return;
527
+
528
+ // use the original version stored in comment_meta if available
529
+ $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
530
+
531
+ if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
532
+ $comment = (object) array_merge( (array)$comment, $as_submitted );
533
+
534
+ $comment->blog = get_bloginfo('url');
535
+ $comment->blog_lang = get_locale();
536
+ $comment->blog_charset = get_option('blog_charset');
537
+ $comment->permalink = get_permalink( $comment->comment_post_ID );
538
+ $comment->user_role = '';
539
+
540
+ if ( is_object($current_user) )
541
+ $comment->reporter = $current_user->user_login;
542
+
543
+ if ( is_object($current_site) )
544
+ $comment->site_domain = $current_site->domain;
545
+
546
+ if ( isset( $comment->user_ID ) )
547
+ $comment->user_role = Akismet::get_user_roles($comment->user_ID);
548
+
549
+ if ( Akismet::is_test_mode() )
550
+ $comment->is_test = 'true';
551
+
552
+ $post = get_post( $comment->comment_post_ID );
553
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
554
+
555
+ $response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );
556
+ if ( $comment->reporter ) {
557
+ self::update_comment_history( $comment_id, '', 'report-ham' );
558
+ update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
559
+ update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
560
+ }
561
+
562
+ do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
563
+ }
564
+
565
+ public static function cron_recheck() {
566
+ global $wpdb;
567
+
568
+ $api_key = self::get_api_key();
569
+
570
+ $status = self::verify_key( $api_key );
571
+ if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
572
+ // since there is currently a problem with the key, reschedule a check for 6 hours hence
573
+ wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
574
+ do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status );
575
+ return false;
576
+ }
577
+
578
+ delete_option('akismet_available_servers');
579
+
580
+ $comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error' LIMIT 100" );
581
+
582
+ load_plugin_textdomain( 'akismet' );
583
+
584
+ foreach ( (array) $comment_errors as $comment_id ) {
585
+ // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
586
+ $comment = get_comment( $comment_id );
587
+ if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
588
+ delete_comment_meta( $comment_id, 'akismet_error' );
589
+ delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
590
+ continue;
591
+ }
592
+
593
+ add_comment_meta( $comment_id, 'akismet_rechecking', true );
594
+ $status = self::check_db_comment( $comment_id, 'retry' );
595
+
596
+ $event = '';
597
+ if ( $status == 'true' ) {
598
+ $event = 'cron-retry-spam';
599
+ } elseif ( $status == 'false' ) {
600
+ $event = 'cron-retry-ham';
601
+ }
602
+
603
+ // If we got back a legit response then update the comment history
604
+ // other wise just bail now and try again later. No point in
605
+ // re-trying all the comments once we hit one failure.
606
+ if ( !empty( $event ) ) {
607
+ delete_comment_meta( $comment_id, 'akismet_error' );
608
+ self::update_comment_history( $comment_id, '', $event );
609
+ update_comment_meta( $comment_id, 'akismet_result', $status );
610
+ // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
611
+ $comment = get_comment( $comment_id );
612
+ if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
613
+ if ( $status == 'true' ) {
614
+ wp_spam_comment( $comment_id );
615
+ } elseif ( $status == 'false' ) {
616
+ // comment is good, but it's still in the pending queue. depending on the moderation settings
617
+ // we may need to change it to approved.
618
+ 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) )
619
+ wp_set_comment_status( $comment_id, 1 );
620
+ else if ( get_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true ) )
621
+ wp_notify_moderator( $comment_id );
622
+ }
623
+ }
624
+
625
+ delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
626
+ } else {
627
+ // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
628
+ // send a moderation email now.
629
+ if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) {
630
+ delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
631
+ wp_notify_moderator( $comment_id );
632
+ }
633
+
634
+ delete_comment_meta( $comment_id, 'akismet_rechecking' );
635
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
636
+ do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status );
637
+ return;
638
+ }
639
+ delete_comment_meta( $comment_id, 'akismet_rechecking' );
640
+ }
641
+
642
+ $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
643
+ if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
644
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
645
+ do_action( 'akismet_scheduled_recheck', 'remaining' );
646
+ }
647
+ }
648
+
649
+ public static function fix_scheduled_recheck() {
650
+ $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
651
+ if ( !$future_check ) {
652
+ return;
653
+ }
654
+
655
+ if ( get_option( 'akismet_alert_code' ) > 0 ) {
656
+ return;
657
+ }
658
+
659
+ $check_range = time() + 1200;
660
+ if ( $future_check > $check_range ) {
661
+ wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
662
+ wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
663
+ do_action( 'akismet_scheduled_recheck', 'fix-scheduled-recheck' );
664
+ }
665
+ }
666
+
667
+ public static function add_comment_nonce( $post_id ) {
668
+ echo '<p style="display: none;">';
669
+ wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
670
+ echo '</p>';
671
+ }
672
+
673
+ public static function is_test_mode() {
674
+ return defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE;
675
+ }
676
+
677
+ public static function allow_discard() {
678
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
679
+ return false;
680
+ if ( is_user_logged_in() )
681
+ return false;
682
+
683
+ return ( get_option( 'akismet_strictness' ) === '1' );
684
+ }
685
+
686
+ public static function get_ip_address() {
687
+ return isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null;
688
+ }
689
+
690
+ /**
691
+ * Do these two comments, without checking the comment_ID, "match"?
692
+ *
693
+ * @param mixed $comment1 A comment object or array.
694
+ * @param mixed $comment2 A comment object or array.
695
+ * @return bool Whether the two comments should be treated as the same comment.
696
+ */
697
+ private static function comments_match( $comment1, $comment2 ) {
698
+ $comment1 = (array) $comment1;
699
+ $comment2 = (array) $comment2;
700
+
701
+ return (
702
+ isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] )
703
+ && intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] )
704
+ && (
705
+ // The comment author length max is 255 characters, limited by the TINYTEXT column type.
706
+ substr( $comment1['comment_author'], 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
707
+ || substr( stripslashes( $comment1['comment_author'] ), 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
708
+ || substr( $comment1['comment_author'], 0, 255 ) == substr( stripslashes( $comment2['comment_author'] ), 0, 255 )
709
+ )
710
+ && (
711
+ // The email max length is 100 characters, limited by the VARCHAR(100) column type.
712
+ substr( $comment1['comment_author_email'], 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
713
+ || substr( stripslashes( $comment1['comment_author_email'] ), 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
714
+ || substr( $comment1['comment_author_email'], 0, 100 ) == substr( stripslashes( $comment2['comment_author_email'] ), 0, 100 )
715
+ // Very long emails can be truncated and then stripped if the [0:100] substring isn't a valid address.
716
+ || ( ! $comment1['comment_author_email'] && strlen( $comment2['comment_author_email'] ) > 100 )
717
+ || ( ! $comment2['comment_author_email'] && strlen( $comment1['comment_author_email'] ) > 100 )
718
+ )
719
+ );
720
+ }
721
+
722
+ // Does the supplied comment match the details of the one most recently stored in self::$last_comment?
723
+ public static function matches_last_comment( $comment ) {
724
+ if ( is_object( $comment ) )
725
+ $comment = (array) $comment;
726
+
727
+ return self::comments_match( self::$last_comment, $comment );
728
+ }
729
+
730
+ private static function get_user_agent() {
731
+ return isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null;
732
+ }
733
+
734
+ private static function get_referer() {
735
+ return isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
736
+ }
737
+
738
+ // return a comma-separated list of role names for the given user
739
+ public static function get_user_roles( $user_id ) {
740
+ $roles = false;
741
+
742
+ if ( !class_exists('WP_User') )
743
+ return false;
744
+
745
+ if ( $user_id > 0 ) {
746
+ $comment_user = new WP_User( $user_id );
747
+ if ( isset( $comment_user->roles ) )
748
+ $roles = join( ',', $comment_user->roles );
749
+ }
750
+
751
+ if ( is_multisite() && is_super_admin( $user_id ) ) {
752
+ if ( empty( $roles ) ) {
753
+ $roles = 'super_admin';
754
+ } else {
755
+ $comment_user->roles[] = 'super_admin';
756
+ $roles = join( ',', $comment_user->roles );
757
+ }
758
+ }
759
+
760
+ return $roles;
761
+ }
762
+
763
+ // filter handler used to return a spam result to pre_comment_approved
764
+ public static function last_comment_status( $approved, $comment ) {
765
+ // Only do this if it's the correct comment
766
+ if ( is_null(self::$last_comment_result) || ! self::matches_last_comment( $comment ) ) {
767
+ self::log( "comment_is_spam mismatched comment, returning unaltered $approved" );
768
+ return $approved;
769
+ }
770
+
771
+ // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
772
+ if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
773
+ update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
774
+
775
+ return self::$last_comment_result;
776
+ }
777
+
778
+ /**
779
+ * If Akismet is temporarily unreachable, we don't want to "spam" the blogger with
780
+ * moderation emails for comments that will be automatically cleared or spammed on
781
+ * the next retry.
782
+ *
783
+ * For comments that will be rechecked later, empty the list of email addresses that
784
+ * the moderation email would be sent to.
785
+ *
786
+ * @param array $emails An array of email addresses that the moderation email will be sent to.
787
+ * @param int $comment_id The ID of the relevant comment.
788
+ * @return array An array of email addresses that the moderation email will be sent to.
789
+ */
790
+ public static function disable_moderation_emails_if_unreachable( $emails, $comment_id ) {
791
+ if ( ! empty( self::$prevent_moderation_email_for_these_comments ) && ! empty( $emails ) ) {
792
+ $comment = get_comment( $comment_id );
793
+
794
+ foreach ( self::$prevent_moderation_email_for_these_comments as $possible_match ) {
795
+ if ( self::comments_match( $possible_match, $comment ) ) {
796
+ update_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true );
797
+ return array();
798
+ }
799
+ }
800
+ }
801
+
802
+ return $emails;
803
+ }
804
+
805
+ public static function _cmp_time( $a, $b ) {
806
+ return $a['time'] > $b['time'] ? -1 : 1;
807
+ }
808
+
809
+ public static function _get_microtime() {
810
+ $mtime = explode( ' ', microtime() );
811
+ return $mtime[1] + $mtime[0];
812
+ }
813
+
814
+ /**
815
+ * Make a POST request to the Akismet API.
816
+ *
817
+ * @param string $request The body of the request.
818
+ * @param string $path The path for the request.
819
+ * @param string $ip The specific IP address to hit.
820
+ * @return array A two-member array consisting of the headers and the response body, both empty in the case of a failure.
821
+ */
822
+ public static function http_post( $request, $path, $ip=null ) {
823
+
824
+ $akismet_ua = sprintf( 'WordPress/%s | Akismet/%s', $GLOBALS['wp_version'], constant( 'AKISMET_VERSION' ) );
825
+ $akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
826
+
827
+ $content_length = strlen( $request );
828
+
829
+ $api_key = self::get_api_key();
830
+ $host = self::API_HOST;
831
+
832
+ if ( !empty( $api_key ) )
833
+ $host = $api_key.'.'.$host;
834
+
835
+ $http_host = $host;
836
+ // use a specific IP if provided
837
+ // needed by Akismet_Admin::check_server_connectivity()
838
+ if ( $ip && long2ip( ip2long( $ip ) ) ) {
839
+ $http_host = $ip;
840
+ }
841
+
842
+ $http_args = array(
843
+ 'body' => $request,
844
+ 'headers' => array(
845
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),
846
+ 'Host' => $host,
847
+ 'User-Agent' => $akismet_ua,
848
+ ),
849
+ 'httpversion' => '1.0',
850
+ 'timeout' => 15
851
+ );
852
+
853
+ $akismet_url = $http_akismet_url = "http://{$http_host}/1.1/{$path}";
854
+
855
+ /**
856
+ * Try SSL first; if that fails, try without it and don't try it again for a while.
857
+ */
858
+
859
+ $ssl = $ssl_failed = false;
860
+
861
+ // Check if SSL requests were disabled fewer than X hours ago.
862
+ $ssl_disabled = get_option( 'akismet_ssl_disabled' );
863
+
864
+ if ( $ssl_disabled && $ssl_disabled < ( time() - 60 * 60 * 24 ) ) { // 24 hours
865
+ $ssl_disabled = false;
866
+ delete_option( 'akismet_ssl_disabled' );
867
+ }
868
+ else if ( $ssl_disabled ) {
869
+ do_action( 'akismet_ssl_disabled' );
870
+ }
871
+
872
+ if ( ! $ssl_disabled && function_exists( 'wp_http_supports') && ( $ssl = wp_http_supports( array( 'ssl' ) ) ) ) {
873
+ $akismet_url = set_url_scheme( $akismet_url, 'https' );
874
+
875
+ do_action( 'akismet_https_request_pre' );
876
+ }
877
+
878
+ $response = wp_remote_post( $akismet_url, $http_args );
879
+
880
+ Akismet::log( compact( 'akismet_url', 'http_args', 'response' ) );
881
+
882
+ if ( $ssl && is_wp_error( $response ) ) {
883
+ do_action( 'akismet_https_request_failure', $response );
884
+
885
+ // Intermittent connection problems may cause the first HTTPS
886
+ // request to fail and subsequent HTTP requests to succeed randomly.
887
+ // Retry the HTTPS request once before disabling SSL for a time.
888
+ $response = wp_remote_post( $akismet_url, $http_args );
889
+
890
+ Akismet::log( compact( 'akismet_url', 'http_args', 'response' ) );
891
+
892
+ if ( is_wp_error( $response ) ) {
893
+ $ssl_failed = true;
894
+
895
+ do_action( 'akismet_https_request_failure', $response );
896
+
897
+ do_action( 'akismet_http_request_pre' );
898
+
899
+ // Try the request again without SSL.
900
+ $response = wp_remote_post( $http_akismet_url, $http_args );
901
+
902
+ Akismet::log( compact( 'http_akismet_url', 'http_args', 'response' ) );
903
+ }
904
+ }
905
+
906
+ if ( is_wp_error( $response ) ) {
907
+ do_action( 'akismet_request_failure', $response );
908
+
909
+ return array( '', '' );
910
+ }
911
+
912
+ if ( $ssl_failed ) {
913
+ // The request failed when using SSL but succeeded without it. Disable SSL for future requests.
914
+ update_option( 'akismet_ssl_disabled', time() );
915
+
916
+ do_action( 'akismet_https_disabled' );
917
+ }
918
+
919
+ $simplified_response = array( $response['headers'], $response['body'] );
920
+
921
+ self::update_alert( $simplified_response );
922
+
923
+ return $simplified_response;
924
+ }
925
+
926
+ // given a response from an API call like check_key_status(), update the alert code options if an alert is present.
927
+ private static function update_alert( $response ) {
928
+ $code = $msg = null;
929
+ if ( isset( $response[0]['x-akismet-alert-code'] ) ) {
930
+ $code = $response[0]['x-akismet-alert-code'];
931
+ $msg = $response[0]['x-akismet-alert-msg'];
932
+ }
933
+
934
+ // only call update_option() if the value has changed
935
+ if ( $code != get_option( 'akismet_alert_code' ) ) {
936
+ if ( ! $code ) {
937
+ delete_option( 'akismet_alert_code' );
938
+ delete_option( 'akismet_alert_msg' );
939
+ }
940
+ else {
941
+ update_option( 'akismet_alert_code', $code );
942
+ update_option( 'akismet_alert_msg', $msg );
943
+ }
944
+ }
945
+ }
946
+
947
+ public static function load_form_js() {
948
+ // WP < 3.3 can't enqueue a script this late in the game and still have it appear in the footer.
949
+ // Once we drop support for everything pre-3.3, this can change back to a single enqueue call.
950
+ wp_register_script( 'akismet-form', AKISMET__PLUGIN_URL . '_inc/form.js', array(), AKISMET_VERSION, true );
951
+ add_action( 'wp_footer', array( 'Akismet', 'print_form_js' ) );
952
+ add_action( 'admin_footer', array( 'Akismet', 'print_form_js' ) );
953
+ }
954
+
955
+ public static function print_form_js() {
956
+ wp_print_scripts( 'akismet-form' );
957
+ }
958
+
959
+ public static function inject_ak_js( $fields ) {
960
+ echo '<p style="display: none;">';
961
+ echo '<input type="hidden" id="ak_js" name="ak_js" value="' . mt_rand( 0, 250 ) . '"/>';
962
+ echo '</p>';
963
+ }
964
+
965
+ private static function bail_on_activation( $message, $deactivate = true ) {
966
+ ?>
967
+ <!doctype html>
968
+ <html>
969
+ <head>
970
+ <meta charset="<?php bloginfo( 'charset' ); ?>">
971
+ <style>
972
+ * {
973
+ text-align: center;
974
+ margin: 0;
975
+ padding: 0;
976
+ font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
977
+ }
978
+ p {
979
+ margin-top: 1em;
980
+ font-size: 18px;
981
+ }
982
+ </style>
983
+ <body>
984
+ <p><?php echo esc_html( $message ); ?></p>
985
+ </body>
986
+ </html>
987
+ <?php
988
+ if ( $deactivate ) {
989
+ $plugins = get_option( 'active_plugins' );
990
+ $akismet = plugin_basename( AKISMET__PLUGIN_DIR . 'akismet.php' );
991
+ $update = false;
992
+ foreach ( $plugins as $i => $plugin ) {
993
+ if ( $plugin === $akismet ) {
994
+ $plugins[$i] = false;
995
+ $update = true;
996
+ }
997
+ }
998
+
999
+ if ( $update ) {
1000
+ update_option( 'active_plugins', array_filter( $plugins ) );
1001
+ }
1002
+ }
1003
+ exit;
1004
+ }
1005
+
1006
+ public static function view( $name, array $args = array() ) {
1007
+ $args = apply_filters( 'akismet_view_arguments', $args, $name );
1008
+
1009
+ foreach ( $args AS $key => $val ) {
1010
+ $$key = $val;
1011
+ }
1012
+
1013
+ load_plugin_textdomain( 'akismet' );
1014
+
1015
+ $file = AKISMET__PLUGIN_DIR . 'views/'. $name . '.php';
1016
+
1017
+ include( $file );
1018
+ }
1019
+
1020
+ /**
1021
+ * Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
1022
+ * @static
1023
+ */
1024
+ public static function plugin_activation() {
1025
+ if ( version_compare( $GLOBALS['wp_version'], AKISMET__MINIMUM_WP_VERSION, '<' ) ) {
1026
+ load_plugin_textdomain( 'akismet' );
1027
+
1028
+ $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'), 'https://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/');
1029
+
1030
+ Akismet::bail_on_activation( $message );
1031
+ }
1032
+ }
1033
+
1034
+ /**
1035
+ * Removes all connection options
1036
+ * @static
1037
+ */
1038
+ public static function plugin_deactivation( ) {
1039
+ return self::deactivate_key( self::get_api_key() );
1040
+ }
1041
+
1042
+ /**
1043
+ * Essentially a copy of WP's build_query but one that doesn't expect pre-urlencoded values.
1044
+ *
1045
+ * @param array $args An array of key => value pairs
1046
+ * @return string A string ready for use as a URL query string.
1047
+ */
1048
+ public static function build_query( $args ) {
1049
+ return _http_build_query( $args, '', '&' );
1050
+ }
1051
+
1052
+ /**
1053
+ * Log debugging info to the error log.
1054
+ *
1055
+ * Enabled when WP_DEBUG_LOG is enabled, but can be disabled via the akismet_debug_log filter.
1056
+ *
1057
+ * @param mixed $akismet_debug The data to log.
1058
+ */
1059
+ public static function log( $akismet_debug ) {
1060
+ if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) {
1061
+ error_log( print_r( compact( 'akismet_debug' ), true ) );
1062
+ }
1063
+ }
1064
+
1065
+ public static function pre_check_pingback( $method ) {
1066
+ if ( $method !== 'pingback.ping' )
1067
+ return;
1068
+
1069
+ global $wp_xmlrpc_server;
1070
+
1071
+ if ( !is_object( $wp_xmlrpc_server ) )
1072
+ return false;
1073
+
1074
+ // Lame: tightly coupled with the IXR class.
1075
+ $args = $wp_xmlrpc_server->message->params;
1076
+
1077
+ if ( !empty( $args[1] ) ) {
1078
+ $post_id = url_to_postid( $args[1] );
1079
+
1080
+ // If this gets through the pre-check, make sure we properly identify the outbound request as a pingback verification
1081
+ Akismet::pingback_forwarded_for( null, $args[0] );
1082
+ add_filter( 'http_request_args', array( 'Akismet', 'pingback_forwarded_for' ), 10, 2 );
1083
+
1084
+ $comment = array(
1085
+ 'comment_author_url' => $args[0],
1086
+ 'comment_post_ID' => $post_id,
1087
+ 'comment_author' => '',
1088
+ 'comment_author_email' => '',
1089
+ 'comment_content' => '',
1090
+ 'comment_type' => 'pingback',
1091
+ 'akismet_pre_check' => '1',
1092
+ 'comment_pingback_target' => $args[1],
1093
+ );
1094
+
1095
+ $comment = Akismet::auto_check_comment( $comment );
1096
+
1097
+ if ( isset( $comment['akismet_result'] ) && 'true' == $comment['akismet_result'] ) {
1098
+ // Lame: tightly coupled with the IXR classes. Unfortunately the action provides no context and no way to return anything.
1099
+ $wp_xmlrpc_server->error( new IXR_Error( 0, 'Invalid discovery target' ) );
1100
+ }
1101
+ }
1102
+ }
1103
+
1104
+ public static function pingback_forwarded_for( $r, $url ) {
1105
+ static $urls = array();
1106
+
1107
+ // Call this with $r == null to prime the callback to add headers on a specific URL
1108
+ if ( is_null( $r ) && !in_array( $url, $urls ) ) {
1109
+ $urls[] = $url;
1110
+ }
1111
+
1112
+ // Add X-Pingback-Forwarded-For header, but only for requests to a specific URL (the apparent pingback source)
1113
+ if ( is_array( $r ) && is_array( $r['headers'] ) && !isset( $r['headers']['X-Pingback-Forwarded-For'] ) && in_array( $url, $urls ) ) {
1114
+ $remote_ip = preg_replace( '/[^a-fx0-9:.,]/i', '', $_SERVER['REMOTE_ADDR'] );
1115
+
1116
+ // Note: this assumes REMOTE_ADDR is correct, and it may not be if a reverse proxy or CDN is in use
1117
+ $r['headers']['X-Pingback-Forwarded-For'] = $remote_ip;
1118
+
1119
+ // Also identify the request as a pingback verification in the UA string so it appears in logs
1120
+ $r['user-agent'] .= '; verifying pingback from ' . $remote_ip;
1121
+ }
1122
+
1123
+ return $r;
1124
+ }
1125
+
1126
+ /**
1127
+ * Ensure that we are loading expected scalar values from akismet_as_submitted commentmeta.
1128
+ *
1129
+ * @param mixed $meta_value
1130
+ * @return mixed
1131
+ */
1132
+ private static function sanitize_comment_as_submitted( $meta_value ) {
1133
+ if ( empty( $meta_value ) ) {
1134
+ return $meta_value;
1135
+ }
1136
+
1137
+ $meta_value = (array) $meta_value;
1138
+
1139
+ foreach ( $meta_value as $key => $value ) {
1140
+ if ( ! isset( self::$comment_as_submitted_allowed_keys[$key] ) || ! is_scalar( $value ) ) {
1141
+ unset( $meta_value[$key] );
1142
+ }
1143
+ }
1144
+
1145
+ return $meta_value;
1146
+ }
1147
+ }
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&#8217;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); ?>&nbsp; &nbsp; <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&amp;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 &raquo;')) ?>" /> </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 )) . '">'. __('&laquo; 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 &raquo;') .'</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> &#8212; <?php comment_date('M j, g:i A'); ?> &#8212; [
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 )) . '">'. __('&laquo; 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 &raquo;') .'</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 &raquo;')); ?>" />
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); ?>&nbsp; &nbsp; <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&amp;recheckqueue=true&amp;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,27 +1,26 @@
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.6
6
- Stable tag: 2.5.9
7
  License: GPLv2 or later
8
 
9
- Akismet checks your comments against the Akismet web service to see if they look like spam or not.
10
 
11
  == Description ==
12
 
13
- Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you
14
- review the spam it catches under your blog's "Comments" admin screen.
15
 
16
- Major new features in Akismet 2.5 include:
17
 
18
- * A comment status history, so you can easily see which comments were caught or cleared by Akismet, and which were spammed or unspammed by a moderator
19
- * Links are highlighted in the comment body, to reveal hidden or misleading links
20
- * If your web host is unable to reach Akismet's servers, the plugin will automatically retry when your connection is back up
21
- * Moderators can see the number of approved comments for each user
22
- * Spam and Unspam reports now include more information, to help improve accuracy
23
 
24
- PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
25
 
26
  == Installation ==
27
 
@@ -31,20 +30,127 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
31
 
32
  == Changelog ==
33
 
34
- = 2.5.10 =
 
 
 
 
 
 
 
 
35
  * Closes a potential XSS vulnerability.
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  = 2.5.9 =
 
 
38
  * Update 'Already have a key' link to redirect page rather than depend on javascript
39
  * Fix some non-translatable strings to be translatable
40
  * Update Activation banner in plugins page to redirect user to Akismet config page
41
 
42
  = 2.5.8 =
 
 
43
  * Simplify the activation process for new users
44
  * Remove the reporter_ip parameter
45
  * Minor preventative security improvements
46
 
47
  = 2.5.7 =
 
 
48
  * FireFox Stats iframe preview bug
49
  * Fix mshots preview when using https
50
  * Add .htaccess to block direct access to files
@@ -54,6 +160,8 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
54
  * Fix prepare() warnings in WP 3.5
55
 
56
  = 2.5.6 =
 
 
57
  * Prevent retry scheduling problems on sites where wp_cron is misbehaving
58
  * Preload mshot previews
59
  * Modernize the widget code
@@ -65,10 +173,14 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
65
  * Improve error messages when verifying an API key
66
 
67
  = 2.5.5 =
 
 
68
  * Add nonce check for comment author URL remove action
69
  * Fix the settings link
70
 
71
  = 2.5.4 =
 
 
72
  * Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
73
  * Added author URL quick removal functionality
74
  * Added mShot preview on Author URL hover
@@ -77,11 +189,14 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
77
  * Purge old Akismet comment meta data, default of 15 days
78
 
79
  = 2.5.3 =
 
 
80
  * Specify the license is GPL v2 or later
81
  * Fix a bug that could result in orphaned commentmeta entries
82
  * Include hotfix for WordPress 3.0.5 filter issue
83
 
84
  = 2.5.2 =
 
85
 
86
  * Properly format the comment count for author counts
87
  * Look for super admins on multisite installs when looking up user roles
@@ -91,6 +206,7 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
91
  * Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
92
 
93
  = 2.5.1 =
 
94
 
95
  * Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
96
  * Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
@@ -109,6 +225,7 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
109
  * Hid "flagged by..." notification while on dashboard
110
 
111
  = 2.5.0 =
 
112
 
113
  * Track comment actions under 'Akismet Status' on the edit comment screen
114
  * Fix a few remaining deprecated function calls ( props Mike Glendinning )
@@ -124,6 +241,7 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
124
  * New option, "Use a nonce on the comment form."
125
 
126
  = 2.4.0 =
 
127
 
128
  * Spell out that the license is GPLv2
129
  * Fix PHP warnings
@@ -133,6 +251,7 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
133
  * General code clean up
134
 
135
  = 2.3.0 =
 
136
 
137
  * Fix "Are you sure" nonce message on config screen in WPMU
138
  * Fix XHTML compliance issue in sidebar widget
@@ -140,10 +259,12 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
140
  * Localize the widget title (core ticket #13879)
141
 
142
  = 2.2.9 =
 
143
 
144
  * Eliminate a potential conflict with some plugins that may cause spurious reports
145
 
146
  = 2.2.8 =
 
147
 
148
  * Fix bug in initial comment check for ipv6 addresses
149
  * Report comments as ham when they are moved from spam to moderation
@@ -153,12 +274,14 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
153
  * Better handling of comments by logged-in users
154
 
155
  = 2.2.7 =
 
156
 
157
  * Add a new AKISMET_VERSION constant
158
  * Reduce the possibility of over-counting spam when another spam filter plugin is in use
159
  * Disable the connectivity check when the API key is hard-coded for WPMU
160
 
161
  = 2.2.6 =
 
162
 
163
  * Fix a global warning introduced in 2.2.5
164
  * Add changelog and additional readme.txt tags
@@ -166,10 +289,12 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
166
  * Support a new WPCOM_API_KEY constant for easier use with WordPress MU
167
 
168
  = 2.2.5 =
 
169
 
170
  * Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
171
 
172
  = 2.2.4 =
 
173
 
174
  * Fixed a key problem affecting the stats feature in WordPress MU
175
  * Provide additional blog information in Akismet API calls
1
  === Akismet ===
2
+ Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
3
+ Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
+ Requires at least: 3.2
5
+ Tested up to: 4.4
6
+ Stable tag: 3.1.6
7
  License: GPLv2 or later
8
 
9
+ Akismet checks your comments against the Akismet Web service to see if they look like spam or not.
10
 
11
  == Description ==
12
 
13
+ Akismet checks your comments against the Akismet Web service to see if they look like spam or not and lets you review the spam it catches under your blog's "Comments" admin screen.
 
14
 
15
+ Major features in Akismet include:
16
 
17
+ * Automatically checks all comments and filters out the ones that look like spam.
18
+ * Each comment has a status history, so you can easily see which comments were caught or cleared by Akismet and which were spammed or unspammed by a moderator.
19
+ * URLs are shown in the comment body to reveal hidden or misleading links.
20
+ * Moderators can see the number of approved comments for each user.
21
+ * A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site.
22
 
23
+ PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites.
24
 
25
  == Installation ==
26
 
30
 
31
  == Changelog ==
32
 
33
+ = 3.1.6 =
34
+ *Release Date - 14 December 2015*
35
+
36
+ * Improve the notices shown after activating Akismet.
37
+ * Update some strings to allow for the proper plural forms in all languages.
38
+
39
+ = 3.1.5 =
40
+ *Release Date - 13 October 2015*
41
+
42
  * Closes a potential XSS vulnerability.
43
 
44
+ = 3.1.4 =
45
+ *Release Date - 24 September 2015*
46
+
47
+ * Fixed a bug that was preventing some users from automatically connecting using Jetpack if they didn't have a current Akismet subscription.
48
+ * Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
49
+ * Error messages and instructions have been simplified to be more understandable.
50
+ * Link previews are enabled for all links inside comments, not just the author's website link.
51
+
52
+ = 3.1.3 =
53
+ *Release Date - 6 July 2015*
54
+
55
+ * Notify users when their account status changes after previously being successfully set up. This should help any users who are seeing blank Akismet settings screens.
56
+
57
+ = 3.1.2 =
58
+ *Release Date - 7 June 2015*
59
+
60
+ * Reduced the amount of space Akismet uses in the commentmeta table.
61
+ * Fixed a bug where some comments with quotes in the author name weren't getting history entries
62
+ * Pre-emptive security improvements to ensure that the Akismet plugin can't be used by attackers to compromise a WordPress installation.
63
+ * Better UI for the key entry field: allow whitespace to be included at the beginning or end of the key and strip it out automatically when the form is submitted.
64
+ * When deactivating the plugin, notify the Akismet API so the site can be marked as inactive.
65
+ * Clearer error messages.
66
+
67
+ = 3.1.1 =
68
+ *Release Date - 17th March, 2015*
69
+
70
+ * Improvements to the "Remove comment author URL" JavaScript
71
+ * Include the pingback pre-check from the 2.6 branch.
72
+
73
+ = 3.1 =
74
+ *Release Date - 11th March, 2015*
75
+
76
+ * Use HTTPS by default for all requests to Akismet.
77
+ * Fix for a situation where Akismet might strip HTML from a comment.
78
+
79
+ = 3.0.4 =
80
+ *Release Date - 11th December, 2014*
81
+
82
+ * Fix to make .htaccess compatible with Apache 2.4.
83
+ * Fix to allow removal of https author URLs.
84
+ * Fix to avoid stripping part of the author URL when removing and re-adding.
85
+ * Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect.
86
+ * Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account
87
+
88
+ = 3.0.3 =
89
+ *Release Date - 3rd November, 2014*
90
+
91
+ * Fix for sending the wrong data to delete_comment action that could have prevented old spam comments from being deleted.
92
+ * Added a filter to disable logging of Akismet debugging information.
93
+ * Added a filter for the maximum comment age when deleting old spam comments.
94
+ * Added a filter for the number per batch when deleting old spam comments.
95
+ * Removed the "Check for Spam" button from the Spam folder.
96
+
97
+ = 3.0.2 =
98
+ *Release Date - 18th August, 2014*
99
+
100
+ * Performance improvements.
101
+ * Fixed a bug that could truncate the comment data being sent to Akismet for checking.
102
+
103
+ = 3.0.1 =
104
+ *Release Date - 9th July, 2014*
105
+
106
+ * Removed dependency on PHP's fsockopen function
107
+ * Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app
108
+ * Remove jQuery dependency for comment form JavaScript
109
+ * Remove unnecessary data from some Akismet comment meta
110
+ * Suspended keys will now result in all comments being put in moderation, not spam.
111
+
112
+ = 3.0.0 =
113
+ *Release Date - 15th April, 2014*
114
+
115
+ * Move Akismet to Settings menu
116
+ * Drop Akismet Stats menu
117
+ * Add stats snapshot to Akismet settings
118
+ * Add Akismet subscription details and status to Akismet settings
119
+ * Add contextual help for each page
120
+ * Improve Akismet setup to use Jetpack to automate plugin setup
121
+ * Fix "Check for Spam" to use AJAX to avoid page timing out
122
+ * Fix Akismet settings page to be responsive
123
+ * Drop legacy code
124
+ * Tidy up CSS and Javascript
125
+ * Replace the old discard setting with a new "discard pervasive spam" feature.
126
+
127
+ = 2.6.0 =
128
+ *Release Date - 18th March, 2014*
129
+
130
+ * Add ajax paging to the check for spam button to handle large volumes of comments
131
+ * Optimize javascript and add localization support
132
+ * Fix bug in link to spam comments from right now dashboard widget
133
+ * Fix bug with deleting old comments to avoid timeouts dealing with large volumes of comments
134
+ * Include X-Pingback-Forwarded-For header in outbound WordPress pingback verifications
135
+ * Add pre-check for pingbacks, to stop spam before an outbound verification request is made
136
+
137
  = 2.5.9 =
138
+ *Release Date - 1st August, 2013*
139
+
140
  * Update 'Already have a key' link to redirect page rather than depend on javascript
141
  * Fix some non-translatable strings to be translatable
142
  * Update Activation banner in plugins page to redirect user to Akismet config page
143
 
144
  = 2.5.8 =
145
+ *Release Date - 20th January, 2013*
146
+
147
  * Simplify the activation process for new users
148
  * Remove the reporter_ip parameter
149
  * Minor preventative security improvements
150
 
151
  = 2.5.7 =
152
+ *Release Date - 13th December, 2012*
153
+
154
  * FireFox Stats iframe preview bug
155
  * Fix mshots preview when using https
156
  * Add .htaccess to block direct access to files
160
  * Fix prepare() warnings in WP 3.5
161
 
162
  = 2.5.6 =
163
+ *Release Date - 26th April, 2012*
164
+
165
  * Prevent retry scheduling problems on sites where wp_cron is misbehaving
166
  * Preload mshot previews
167
  * Modernize the widget code
173
  * Improve error messages when verifying an API key
174
 
175
  = 2.5.5 =
176
+ *Release Date - 11th January, 2012*
177
+
178
  * Add nonce check for comment author URL remove action
179
  * Fix the settings link
180
 
181
  = 2.5.4 =
182
+ *Release Date - 5th January, 2012*
183
+
184
  * Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
185
  * Added author URL quick removal functionality
186
  * Added mShot preview on Author URL hover
189
  * Purge old Akismet comment meta data, default of 15 days
190
 
191
  = 2.5.3 =
192
+ *Release Date - 8th Febuary, 2011*
193
+
194
  * Specify the license is GPL v2 or later
195
  * Fix a bug that could result in orphaned commentmeta entries
196
  * Include hotfix for WordPress 3.0.5 filter issue
197
 
198
  = 2.5.2 =
199
+ *Release Date - 14th January, 2011*
200
 
201
  * Properly format the comment count for author counts
202
  * Look for super admins on multisite installs when looking up user roles
206
  * Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
207
 
208
  = 2.5.1 =
209
+ *Release Date - 17th December, 2010*
210
 
211
  * Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
212
  * Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
225
  * Hid "flagged by..." notification while on dashboard
226
 
227
  = 2.5.0 =
228
+ *Release Date - 7th December, 2010*
229
 
230
  * Track comment actions under 'Akismet Status' on the edit comment screen
231
  * Fix a few remaining deprecated function calls ( props Mike Glendinning )
241
  * New option, "Use a nonce on the comment form."
242
 
243
  = 2.4.0 =
244
+ *Release Date - 23rd August, 2010*
245
 
246
  * Spell out that the license is GPLv2
247
  * Fix PHP warnings
251
  * General code clean up
252
 
253
  = 2.3.0 =
254
+ *Release Date - 5th June, 2010*
255
 
256
  * Fix "Are you sure" nonce message on config screen in WPMU
257
  * Fix XHTML compliance issue in sidebar widget
259
  * Localize the widget title (core ticket #13879)
260
 
261
  = 2.2.9 =
262
+ *Release Date - 2nd June, 2010*
263
 
264
  * Eliminate a potential conflict with some plugins that may cause spurious reports
265
 
266
  = 2.2.8 =
267
+ *Release Date - 27th May, 2010*
268
 
269
  * Fix bug in initial comment check for ipv6 addresses
270
  * Report comments as ham when they are moved from spam to moderation
274
  * Better handling of comments by logged-in users
275
 
276
  = 2.2.7 =
277
+ *Release Date - 17th December, 2009*
278
 
279
  * Add a new AKISMET_VERSION constant
280
  * Reduce the possibility of over-counting spam when another spam filter plugin is in use
281
  * Disable the connectivity check when the API key is hard-coded for WPMU
282
 
283
  = 2.2.6 =
284
+ *Release Date - 20th July, 2009*
285
 
286
  * Fix a global warning introduced in 2.2.5
287
  * Add changelog and additional readme.txt tags
289
  * Support a new WPCOM_API_KEY constant for easier use with WordPress MU
290
 
291
  = 2.2.5 =
292
+ *Release Date - 13th July, 2009*
293
 
294
  * Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
295
 
296
  = 2.2.4 =
297
+ *Release Date - 3rd June, 2009*
298
 
299
  * Fixed a key problem affecting the stats feature in WordPress MU
300
  * Provide additional blog information in Akismet API calls
views/config.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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( '//akismet.com/web/1.0/snapshot.php?blog=%s&api_key=%s&height=180&locale=%s', urlencode( get_bloginfo('url') ), Akismet::get_api_key(), get_locale() );?>"></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 echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, '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 echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, '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( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ); ?>
31
+ |
32
+ <?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?>
33
+ </li>
34
+ </ul>
35
+ <div class="clearfix"></div>
36
+ </div>
37
+ <?php endif;?>
38
+
39
+ <?php if ( $akismet_user ):?>
40
+
41
+ <div id="wpcom-stats-meta-box-container" class="metabox-holder"><?php
42
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
43
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
44
+ ?>
45
+ <script type="text/javascript">
46
+ jQuery(document).ready( function($) {
47
+ jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
48
+ if(typeof postboxes !== 'undefined')
49
+ postboxes.add_postbox_toggles( 'plugins_page_akismet-key-config' );
50
+ });
51
+ </script>
52
+ <div class="postbox-container" style="width: 55%;margin-right: 10px;">
53
+ <div id="normal-sortables" class="meta-box-sortables ui-sortable">
54
+ <div id="referrers" class="postbox ">
55
+ <div class="handlediv" title="Click to toggle"><br></div>
56
+ <h3 class="hndle"><span><?php esc_html_e( 'Settings' , 'akismet');?></span></h3>
57
+ <form name="akismet_conf" id="akismet-conf" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
58
+ <div class="inside">
59
+ <table cellspacing="0" class="akismet-settings">
60
+ <tbody>
61
+ <?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
62
+ <tr>
63
+ <th class="akismet-api-key" width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th>
64
+ <td width="5%"/>
65
+ <td align="left">
66
+ <span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="regular-text code <?php echo $akismet_user->status;?>"></span>
67
+ </td>
68
+ </tr>
69
+ <?php endif; ?>
70
+ <?php if ( isset( $_GET['ssl_status'] ) ) { ?>
71
+ <tr>
72
+ <th align="left" scope="row"><?php esc_html_e( 'SSL Status', 'akismet' ); ?></th>
73
+ <td></td>
74
+ <td align="left">
75
+ <p>
76
+ <?php
77
+
78
+ if ( ! function_exists( 'wp_http_supports' ) ) {
79
+ ?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php printf( esc_html( 'Your WordPress installation does not include the function %s; upgrade to the latest version of WordPress.', 'akismet' ), '<code>wp_http_supports</code>' ); ?><?php
80
+ }
81
+ else if ( ! wp_http_supports( array( 'ssl' ) ) ) {
82
+ ?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?><?php
83
+ }
84
+ else {
85
+ $ssl_disabled = get_option( 'akismet_ssl_disabled' );
86
+
87
+ if ( $ssl_disabled ) {
88
+ ?><b><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?><?php
89
+ }
90
+ else {
91
+ ?><b><?php esc_html_e( 'Enabled.', 'akismet' ); ?></b> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?><?php
92
+ }
93
+ }
94
+
95
+ ?>
96
+ </p>
97
+ </td>
98
+ </tr>
99
+ <?php } ?>
100
+ <tr>
101
+ <th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th>
102
+ <td></td>
103
+ <td align="left">
104
+ <p>
105
+ <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>
106
+ </p>
107
+ </td>
108
+ </tr>
109
+ <tr>
110
+ <th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th>
111
+ <td></td>
112
+ <td align="left">
113
+ <fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
114
+ <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>
115
+ <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>
116
+ </fieldset>
117
+ <span class="note"><strong><?php esc_html_e('Note:', 'akismet');?></strong>
118
+ <?php
119
+
120
+ $delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
121
+
122
+ printf(
123
+ _n(
124
+ 'Spam in the <a href="%1$s">spam folder</a> older than 1 day is deleted automatically.',
125
+ 'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.',
126
+ $delete_interval,
127
+ 'akismet'
128
+ ),
129
+ admin_url( 'edit-comments.php?comment_status=spam' ),
130
+ $delete_interval
131
+ );
132
+
133
+ ?>
134
+ </td>
135
+ </tr>
136
+ </tbody>
137
+ </table>
138
+ </div>
139
+ <div id="major-publishing-actions">
140
+ <?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
141
+ <div id="delete-action">
142
+ <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>
143
+ </div>
144
+ <?php endif; ?>
145
+ <?php wp_nonce_field(Akismet_Admin::NONCE) ?>
146
+ <div id="publishing-action">
147
+ <input type="hidden" name="action" value="enter-key">
148
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>">
149
+
150
+ </div>
151
+ <div class="clear"></div>
152
+ </div>
153
+ </form>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ <div class="postbox-container" style="width:44%;">
158
+ <div id="normal-sortables" class="meta-box-sortables ui-sortable">
159
+ <div id="referrers" class="postbox ">
160
+ <div class="handlediv" title="Click to toggle"><br></div>
161
+ <h3 class="hndle"><span><?php esc_html_e( 'Account' , 'akismet');?></span></h3>
162
+ <div class="inside">
163
+ <table cellspacing="0">
164
+ <tbody>
165
+ <tr>
166
+ <th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th>
167
+ <td width="5%"/>
168
+ <td align="left">
169
+ <span><?php echo $akismet_user->account_name; ?></span>
170
+ </td>
171
+ </tr>
172
+ <tr>
173
+ <th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th>
174
+ <td width="5%"/>
175
+ <td align="left">
176
+ <span><?php
177
+ if ( 'cancelled' == $akismet_user->status ) :
178
+ esc_html_e( 'Cancelled', 'akismet' );
179
+ elseif ( 'suspended' == $akismet_user->status ) :
180
+ esc_html_e( 'Suspended', 'akismet' );
181
+ elseif ( 'missing' == $akismet_user->status ) :
182
+ esc_html_e( 'Missing', 'akismet' );
183
+ elseif ( 'no-sub' == $akismet_user->status ) :
184
+ esc_html_e( 'No Subscription Found', 'akismet' );
185
+ else :
186
+ esc_html_e( 'Active', 'akismet' );
187
+ endif; ?></span>
188
+ </td>
189
+ </tr>
190
+ <?php if ( $akismet_user->next_billing_date ) : ?>
191
+ <tr>
192
+ <th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th>
193
+ <td width="5%"/>
194
+ <td align="left">
195
+ <span><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></span>
196
+ </td>
197
+ </tr>
198
+ <?php endif; ?>
199
+ </tbody>
200
+ </table>
201
+ </div>
202
+ <div id="major-publishing-actions">
203
+ <div id="publishing-action">
204
+ <?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?>
205
+ </div>
206
+ <div class="clear"></div>
207
+ </div>
208
+ </div>
209
+ </div>
210
+ </div>
211
+ </div>
212
+
213
+ <?php endif;?>
214
+
215
+ </div>
216
+ </div>
views/get.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <form name="akismet_activate" action="https://akismet.com/get/" method="POST" target="_blank">
2
+ <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
3
+ <input type="hidden" name="blog" value="<?php echo esc_url( get_bloginfo('url') ); ?>"/>
4
+ <input type="hidden" name="redirect" value="<?php echo isset( $redirect ) ? $redirect : 'plugin-signup'; ?>"/>
5
+ <input type="submit" class="<?php echo isset( $classes ) && count( $classes ) > 0 ? implode( ' ', $classes ) : 'button button-primary';?>" value="<?php echo esc_attr( $text ); ?>"/>
6
+ </form>
views/notice.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Akismet and say goodbye to spam', 'akismet');?></div>
15
+ </div>
16
+ </form>
17
+ </div>
18
+ <?php elseif ( $type == 'spam-check' ) :?>
19
+ <div id="akismet-warning" class="updated fade">
20
+ <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' );?></strong></p>
21
+ <p><?php printf( __( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ) ); ?></p>
22
+ <?php if ( $link_text ) { ?>
23
+ <p><?php echo $link_text; ?></p>
24
+ <?php } ?>
25
+ </div>
26
+ <?php elseif ( $type == 'version' ) :?>
27
+ <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>
28
+ <?php elseif ( $type == 'alert' ) :?>
29
+ <div class='error'>
30
+ <p><strong><?php printf( esc_html__( 'Akismet Error Code: %s', 'akismet' ), $code ); ?></strong></p>
31
+ <p><?php echo esc_html( $msg ); ?></p>
32
+ <p><?php
33
+
34
+ /* translators: the placeholder is a clickable URL that leads to more information regarding an error code. */
35
+ printf( esc_html__( 'For more information: %s' , 'akismet'), '<a href="https://akismet.com/errors/' . $code . '">https://akismet.com/errors/' . $code . '</a>' );
36
+
37
+ ?>
38
+ </p>
39
+ </div>
40
+ <?php elseif ( $type == 'notice' ) :?>
41
+ <div class="wrap alert critical">
42
+ <h3 class="key-status failed"><?php echo $notice_header; ?></h3>
43
+ <p class="description">
44
+ <?php echo $notice_text; ?>
45
+ </p>
46
+ </div>
47
+ <?php elseif ( $type == 'missing-functions' ) :?>
48
+ <div class="wrap alert critical">
49
+ <h3 class="key-status failed"><?php esc_html_e('Network functions are disabled.', 'akismet'); ?></h3>
50
+ <p class="description"><?php printf( __('Your web host or server administrator has disabled PHP&#8217;s <code>gethostbynamel</code> function. <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&#8217;s system requirements</a>.', 'akismet'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
51
+ </div>
52
+ <?php elseif ( $type == 'servers-be-down' ) :?>
53
+ <div class="wrap alert critical">
54
+ <h3 class="key-status failed"><?php esc_html_e("Akismet can&#8217;t connect to your site.", 'akismet'); ?></h3>
55
+ <p class="description"><?php printf( __('Your firewall may be blocking Akismet. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
56
+ </div>
57
+ <?php elseif ( $type == 'active-dunning' ) :?>
58
+ <div class="wrap alert critical">
59
+ <h3 class="key-status"><?php esc_html_e("Please update your payment information.", 'akismet'); ?></h3>
60
+ <p class="description"><?php printf( __('We cannot process your payment. Please <a href="%s" target="_blank">update your payment details</a>.', 'akismet'), 'https://akismet.com/account/'); ?></p>
61
+ </div>
62
+ <?php elseif ( $type == 'cancelled' ) :?>
63
+ <div class="wrap alert critical">
64
+ <h3 class="key-status"><?php esc_html_e("Your Akismet plan has been cancelled.", 'akismet'); ?></h3>
65
+ <p class="description"><?php printf( __('Please visit your <a href="%s" target="_blank">Akismet account page</a> to reactivate your subscription.', 'akismet'), 'https://akismet.com/account/'); ?></p>
66
+ </div>
67
+ <?php elseif ( $type == 'suspended' ) :?>
68
+ <div class="wrap alert critical">
69
+ <h3 class="key-status failed"><?php esc_html_e("Your Akismet subscription is suspended.", 'akismet'); ?></h3>
70
+ <p class="description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
71
+ </div>
72
+ <?php elseif ( $type == 'active-notice' && $time_saved ) :?>
73
+ <div class="wrap alert active">
74
+ <h3 class="key-status"><?php echo esc_html( $time_saved ); ?></h3>
75
+ <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>
76
+ </div>
77
+ <?php elseif ( $type == 'missing' ) :?>
78
+ <div class="wrap alert critical">
79
+ <h3 class="key-status failed"><?php esc_html_e( 'There is a problem with your API key.', 'akismet'); ?></h3>
80
+ <p class="description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
81
+ </div>
82
+ <?php elseif ( $type == 'no-sub' ) :?>
83
+ <div class="wrap alert critical">
84
+ <h3 class="key-status failed"><?php esc_html_e( 'You don&#8217;t have an Akismet plan.', 'akismet'); ?></h3>
85
+ <p class="description">
86
+ <?php printf( __( 'In 2012, Akismet began using subscription plans for all accounts (even free ones). A plan has not been assigned to your account, and we&#8217;d appreciate it if you&#8217;d <a href="%s" target="_blank">sign into your account</a> and choose one.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?>
87
+ <br /><br />
88
+ <?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/' ); ?>
89
+ </p>
90
+ </div>
91
+ <?php elseif ( $type == 'new-key-valid' ) :?>
92
+ <div class="wrap alert active">
93
+ <h3 class="key-status"><?php esc_html_e('Akismet is now activated. Happy blogging!', 'akismet'); ?></h3>
94
+ </div>
95
+ <?php elseif ( $type == 'new-key-invalid' ) :?>
96
+ <div class="wrap alert critical">
97
+ <h3 class="key-status"><?php esc_html_e( 'The key you entered is invalid. Please double-check it.' , 'akismet'); ?></h3>
98
+ </div>
99
+ <?php elseif ( $type == 'existing-key-invalid' ) :?>
100
+ <div class="wrap alert critical">
101
+ <h3 class="key-status"><?php esc_html_e( 'Your API key is no longer valid. Please enter a new key or contact support@akismet.com.' , 'akismet'); ?></h3>
102
+ </div>
103
+ <?php elseif ( $type == 'new-key-failed' ) :?>
104
+ <div class="wrap alert critical">
105
+ <h3 class="key-status"><?php esc_html_e( 'The API key you entered could not be verified.' , 'akismet'); ?></h3>
106
+ <p class="description"><?php printf( __('The connection to akismet.com could not be established. Please refer to <a href="%s" target="_blank">our guide about firewalls</a> and check your server configuration.', 'akismet'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
107
+ </div>
108
+ <?php elseif ( $type == 'limit-reached' && in_array( $level, array( 'yellow', 'red' ) ) ) :?>
109
+ <div class="wrap alert critical">
110
+ <?php if ( $level == 'yellow' ): ?>
111
+ <h3 class="key-status failed"><?php esc_html_e( 'You&#8217;re using your Akismet key on more sites than your Pro subscription allows.', 'akismet' ); ?></h3>
112
+ <p class="description">
113
+ <?php printf( __( 'Your Pro subscription allows the use of Akismet on only one site. Please <a href="%s" target="_blank">purchase additional Pro subscriptions</a> or upgrade to an Enterprise subscription that allows the use of Akismet on unlimited sites.', 'akismet' ), 'http://docs.akismet.com/billing/add-more-sites/' ); ?>
114
+ <br /><br />
115
+ <?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?>
116
+ </p>
117
+ <?php elseif ( $level == 'red' ): ?>
118
+ <h3 class="key-status failed"><?php esc_html_e( 'You&#8217;re using Akismet on far too many sites for your Pro subscription.', 'akismet' ); ?></h3>
119
+ <p class="description">
120
+ <?php printf( __( 'To continue your service, <a href="%s" target="_blank">upgrade to an Enterprise subscription</a>, which covers an unlimited number of sites.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?></p>
121
+ <br /><br />
122
+ <?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?></p>
123
+ </p>
124
+ <?php endif; ?>
125
+ </div>
126
+ <?php endif;?>
views/start.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="no-key config-wrap"><?php
2
+ if ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) :
3
+ if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) :?>
4
+ <p><?php esc_html_e('Akismet eliminates spam from your site. Register below to get started.', '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_html( $akismet_user->user_email ); ?>
9
+ </div>
10
+ <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="right" target="_blank">
11
+ <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
12
+ <input type="hidden" name="blog" value="<?php echo esc_url( get_bloginfo('url') ); ?>"/>
13
+ <input type="hidden" name="auto-connect" value="<?php echo $akismet_user->ID;?>"/>
14
+ <input type="hidden" name="redirect" value="plugin-signup"/>
15
+ <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Register for Akismet' , 'akismet'); ?>"/>
16
+ </form>
17
+ </div>
18
+ <?php elseif ( $akismet_user->status == 'cancelled' ) :?>
19
+ <p><?php esc_html_e('Akismet eliminates spam from your site.', 'akismet'); ?></p>
20
+ <div class="activate-highlight activate-option">
21
+ <div class="option-description" style="width:75%;">
22
+ <strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
23
+ <?php printf( esc_html__( 'Your subscription for %s is cancelled' , 'akismet'), $akismet_user->user_email ); ?>
24
+ </div>
25
+ <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="right" target="_blank">
26
+ <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
27
+ <input type="hidden" name="blog" value="<?php echo esc_url( get_bloginfo('url') ); ?>"/>
28
+ <input type="hidden" name="user_id" value="<?php echo $akismet_user->ID;?>"/>
29
+ <input type="hidden" name="redirect" value="upgrade"/>
30
+ <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Reactivate Akismet' , 'akismet'); ?>"/>
31
+ </form>
32
+ </div>
33
+ <?php elseif ( $akismet_user->status == 'suspended' ) : ?>
34
+ <p><?php esc_html_e('Akismet eliminates spam from your site.', 'akismet'); ?></p>
35
+ <div class="activate-highlight centered activate-option">
36
+ <strong class="small-heading"><?php esc_html_e( 'Connected via Jetpack' , 'akismet'); ?></strong>
37
+ <h3 class="alert-text"><?php printf( esc_html__( 'Your subscription for %s is suspended' , 'akismet'), $akismet_user->user_email ); ?></h3>
38
+ <p><?php esc_html_e('No worries! Get in touch and we&#8217;ll sort this out.', 'akismet'); ?></p>
39
+ <a href="https://akismet.com/contact" class="button button-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet'); ?></a>
40
+ </div>
41
+ <?php else : // ask do they want to use akismet account found using jetpack wpcom connection ?>
42
+ <p style="margin-right:10px"><?php esc_html_e('Akismet eliminates spam from your site. To set up Akismet, select one of the options below.', 'akismet'); ?></p>
43
+ <div class="activate-highlight activate-option">
44
+ <div class="option-description">
45
+ <strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
46
+ <?php echo esc_html( $akismet_user->user_email ); ?>
47
+ </div>
48
+ <form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="right">
49
+ <input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
50
+ <input type="hidden" name="action" value="enter-key">
51
+ <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
52
+ <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Use this account' , 'akismet'); ?>"/>
53
+ </form>
54
+ </div>
55
+ <?php endif;?>
56
+ <div class="activate-highlight secondary activate-option">
57
+ <div class="option-description">
58
+ <strong><?php esc_html_e('Sign up for a plan with a different email address', 'akismet'); ?></strong>
59
+ <p><?php esc_html_e('Use this option to use Akismet independently of your Jetpack connection.', 'akismet'); ?></p>
60
+ </div>
61
+ <?php Akismet::view( 'get', array( 'text' => __( 'Sign up with a different email address' , 'akismet'), 'classes' => array( 'right', 'button', 'button-secondary' ) ) ); ?>
62
+ </div>
63
+ <div class="activate-highlight secondary activate-option">
64
+ <div class="option-description">
65
+ <strong><?php esc_html_e('Enter an API key', 'akismet'); ?></strong>
66
+ <p><?php esc_html_e('Already have your key? Enter it here.', 'akismet'); ?></p>
67
+ </div>
68
+ <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
69
+ <input id="key" name="key" type="text" size="15" value="" class="regular-text code">
70
+ <input type="hidden" name="action" value="enter-key">
71
+ <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
72
+ <input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
73
+ </form>
74
+ </div>
75
+ <?php else :?>
76
+ <p><?php esc_html_e('Akismet eliminates spam from your site. To set up Akismet, select one of the options below.', 'akismet'); ?></p>
77
+ <div class="activate-highlight activate-option">
78
+ <div class="option-description">
79
+ <strong><?php esc_html_e( 'Activate Akismet' , 'akismet');?></strong>
80
+ <p><?php esc_html_e('Log in or sign up now.', 'akismet'); ?></p>
81
+ </div>
82
+ <?php Akismet::view( 'get', array( 'text' => __( 'Get your API key' , 'akismet'), 'classes' => array( 'right', 'button', 'button-primary' ) ) ); ?>
83
+ </div>
84
+ <div class="activate-highlight secondary activate-option">
85
+ <div class="option-description">
86
+ <strong><?php esc_html_e('Manually enter an API key', 'akismet'); ?></strong>
87
+ <p><?php esc_html_e('If you already know your API key.', 'akismet'); ?></p>
88
+ </div>
89
+ <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
90
+ <input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( Akismet::get_api_key() ); ?>" class="regular-text code">
91
+ <input type="hidden" name="action" value="enter-key">
92
+ <?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
93
+ <input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
94
+ </form>
95
+ </div><?php
96
+ endif;?>
97
+ </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( '//akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s&locale=%s', urlencode( get_bloginfo('url') ), Akismet::get_api_key(), get_locale() ) ); ?>" width="100%" height="2500px" frameborder="0" id="akismet-stats-frame"></iframe>
4
+ </div>
views/strict.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset>
2
+ <legend class="screen-reader-text">
3
+ <span><?php esc_html_e( 'Akismet anti-spam strictness', 'akismet' ); ?></span>
4
+ </legend>
5
+ <p>
6
+ <label for="akismet_strictness_1">
7
+ <input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked( '1', get_option( 'akismet_strictness' ) ); ?> />
8
+ <?php esc_html_e( 'Strict: silently discard the worst and most pervasive spam.', 'akismet' ); ?>
9
+ </label>
10
+ </p>
11
+ <p>
12
+ <label for="akismet_strictness_0">
13
+ <input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked( '0', get_option( 'akismet_strictness' ) ); ?> />
14
+ <?php esc_html_e( 'Safe: always put spam in the Spam folder for review.', 'akismet' ); ?>
15
+ </label>
16
+ </p>
17
+ </fieldset>
wrapper.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ return Akismet::is_test_mode();
11
+ }
12
+
13
+ function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) {
14
+ $path = str_replace( '/1.1/', '', $path );
15
+
16
+ return Akismet::http_post( $request, $path, $ip );
17
+ }
18
+
19
+ function akismet_microtime() {
20
+ return Akismet::_get_microtime();
21
+ }
22
+
23
+ function akismet_delete_old() {
24
+ return Akismet::delete_old_comments();
25
+ }
26
+
27
+ function akismet_delete_old_metadata() {
28
+ return Akismet::delete_old_comments_meta();
29
+ }
30
+
31
+ function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
32
+ return Akismet::check_db_comment( $id, $recheck_reason );
33
+ }
34
+
35
+ function akismet_rightnow() {
36
+ if ( !class_exists( 'Akismet_Admin' ) )
37
+ return false;
38
+
39
+ return Akismet_Admin::rightnow_stats();
40
+ }
41
+
42
+ function akismet_admin_init() {
43
+ _deprecated_function( __FUNCTION__, '3.0' );
44
+ }
45
+ function akismet_version_warning() {
46
+ _deprecated_function( __FUNCTION__, '3.0' );
47
+ }
48
+ function akismet_load_js_and_css() {
49
+ _deprecated_function( __FUNCTION__, '3.0' );
50
+ }
51
+ function akismet_nonce_field( $action = -1 ) {
52
+ return wp_nonce_field( $action );
53
+ }
54
+ function akismet_plugin_action_links( $links, $file ) {
55
+ return Akismet_Admin::plugin_action_links( $links, $file );
56
+ }
57
+ function akismet_conf() {
58
+ _deprecated_function( __FUNCTION__, '3.0' );
59
+ }
60
+ function akismet_stats_display() {
61
+ _deprecated_function( __FUNCTION__, '3.0' );
62
+ }
63
+ function akismet_stats() {
64
+ return Akismet_Admin::dashboard_stats();
65
+ }
66
+ function akismet_admin_warnings() {
67
+ _deprecated_function( __FUNCTION__, '3.0' );
68
+ }
69
+ function akismet_comment_row_action( $a, $comment ) {
70
+ return Akismet_Admin::comment_row_actions( $a, $comment );
71
+ }
72
+ function akismet_comment_status_meta_box( $comment ) {
73
+ return Akismet_Admin::comment_status_meta_box( $comment );
74
+ }
75
+ function akismet_comments_columns( $columns ) {
76
+ _deprecated_function( __FUNCTION__, '3.0' );
77
+
78
+ return $columns;
79
+ }
80
+ function akismet_comment_column_row( $column, $comment_id ) {
81
+ _deprecated_function( __FUNCTION__, '3.0' );
82
+ }
83
+ function akismet_text_add_link_callback( $m ) {
84
+ return Akismet_Admin::text_add_link_callback( $m );
85
+ }
86
+ function akismet_text_add_link_class( $comment_text ) {
87
+ return Akismet_Admin::text_add_link_class( $comment_text );
88
+ }
89
+ function akismet_check_for_spam_button( $comment_status ) {
90
+ return Akismet_Admin::check_for_spam_button( $comment_status );
91
+ }
92
+ function akismet_submit_nonspam_comment( $comment_id ) {
93
+ return Akismet::submit_nonspam_comment( $comment_id );
94
+ }
95
+ function akismet_submit_spam_comment( $comment_id ) {
96
+ return Akismet::submit_spam_comment( $comment_id );
97
+ }
98
+ function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
99
+ return Akismet::transition_comment_status( $new_status, $old_status, $comment );
100
+ }
101
+ function akismet_spam_count( $type = false ) {
102
+ return Akismet_Admin::get_spam_count( $type );
103
+ }
104
+ function akismet_recheck_queue() {
105
+ return Akismet_Admin::recheck_queue();
106
+ }
107
+ function akismet_remove_comment_author_url() {
108
+ return Akismet_Admin::remove_comment_author_url();
109
+ }
110
+ function akismet_add_comment_author_url() {
111
+ return Akismet_Admin::add_comment_author_url();
112
+ }
113
+ function akismet_check_server_connectivity() {
114
+ return Akismet_Admin::check_server_connectivity();
115
+ }
116
+ function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
117
+ return Akismet_Admin::get_server_connectivity( $cache_timeout );
118
+ }
119
+ function akismet_server_connectivity_ok() {
120
+ _deprecated_function( __FUNCTION__, '3.0' );
121
+
122
+ return true;
123
+ }
124
+ function akismet_admin_menu() {
125
+ return Akismet_Admin::admin_menu();
126
+ }
127
+ function akismet_load_menu() {
128
+ return Akismet_Admin::load_menu();
129
+ }
130
+ function akismet_init() {
131
+ _deprecated_function( __FUNCTION__, '3.0' );
132
+ }
133
+ function akismet_get_key() {
134
+ return Akismet::get_api_key();
135
+ }
136
+ function akismet_check_key_status( $key, $ip = null ) {
137
+ return Akismet::check_key_status( $key, $ip );
138
+ }
139
+ function akismet_update_alert( $response ) {
140
+ return Akismet::update_alert( $response );
141
+ }
142
+ function akismet_verify_key( $key, $ip = null ) {
143
+ return Akismet::verify_key( $key, $ip );
144
+ }
145
+ function akismet_get_user_roles( $user_id ) {
146
+ return Akismet::get_user_roles( $user_id );
147
+ }
148
+ function akismet_result_spam( $approved ) {
149
+ return Akismet::comment_is_spam( $approved );
150
+ }
151
+ function akismet_result_hold( $approved ) {
152
+ return Akismet::comment_needs_moderation( $approved );
153
+ }
154
+ function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
155
+ return Akismet::get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url );
156
+ }
157
+ function akismet_update_comment_history( $comment_id, $message, $event = null ) {
158
+ return Akismet::update_comment_history( $comment_id, $message, $event );
159
+ }
160
+ function akismet_get_comment_history( $comment_id ) {
161
+ return Akismet::get_comment_history( $comment_id );
162
+ }
163
+ function akismet_cmp_time( $a, $b ) {
164
+ return Akismet::_cmp_time( $a, $b );
165
+ }
166
+ function akismet_auto_check_update_meta( $id, $comment ) {
167
+ return Akismet::auto_check_update_meta( $id, $comment );
168
+ }
169
+ function akismet_auto_check_comment( $commentdata ) {
170
+ return Akismet::auto_check_comment( $commentdata );
171
+ }
172
+ function akismet_get_ip_address() {
173
+ return Akismet::get_ip_address();
174
+ }
175
+ function akismet_cron_recheck() {
176
+ return Akismet::cron_recheck();
177
+ }
178
+ function akismet_add_comment_nonce() {
179
+ return Akismet::add_comment_nonce( $post_id );
180
+ }
181
+ function akismet_fix_scheduled_recheck() {
182
+ return Akismet::fix_scheduled_recheck();
183
+ }
184
+ function akismet_spam_comments() {
185
+ _deprecated_function( __FUNCTION__, '3.0' );
186
+
187
+ return array();
188
+ }
189
+ function akismet_spam_totals() {
190
+ _deprecated_function( __FUNCTION__, '3.0' );
191
+
192
+ return array();
193
+ }
194
+ function akismet_manage_page() {
195
+ _deprecated_function( __FUNCTION__, '3.0' );
196
+ }
197
+ function akismet_caught() {
198
+ _deprecated_function( __FUNCTION__, '3.0' );
199
+ }
200
+ function redirect_old_akismet_urls() {
201
+ _deprecated_function( __FUNCTION__, '3.0' );
202
+ }
203
+ function akismet_kill_proxy_check( $option ) {
204
+ _deprecated_function( __FUNCTION__, '3.0' );
205
+
206
+ return 0;
207
+ }
208
+ function akismet_pingback_forwarded_for( $r, $url ) {
209
+ return Akismet::pingback_forwarded_for( $r, $url );
210
+ }
211
+ function akismet_pre_check_pingback( $method ) {
212
+ return Akismet::pre_check_pingback( $method );
213
+ }