Version Description
- Closes a potential XSS vulnerability.
Download this release
Release Info
Developer | cfinke |
Plugin | Akismet Anti-Spam |
Version | 2.5.10 |
Comparing to | |
See all releases |
Code changes from version 3.1.4 to 2.5.10
- .htaccess +0 -34
- LICENSE.txt +0 -339
- _inc/akismet.css +0 -375
- _inc/akismet.js +0 -189
- _inc/form.js +0 -30
- _inc/img/logo-full-2x.png +0 -0
- admin.php +909 -0
- akismet.css +1 -0
- akismet.gif +0 -0
- akismet.js +126 -0
- akismet.php +573 -21
- class.akismet-admin.php +0 -978
- class.akismet.php +0 -1153
- img/logo.png +0 -0
- img/logo@2x.png +0 -0
- index.php +1 -1
- legacy.php +396 -0
- readme.txt +17 -131
- views/config.php +0 -220
- views/get.php +0 -6
- views/notice.php +0 -119
- views/start.php +0 -97
- views/stats.php +0 -4
- views/strict.php +0 -17
- class.akismet-widget.php → widget.php +10 -12
- wrapper.php +0 -213
.htaccess
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
# Only allow direct access to specific Web-available files.
|
2 |
-
|
3 |
-
# Apache 2.2
|
4 |
-
<IfModule !mod_authz_core.c>
|
5 |
-
Order Deny,Allow
|
6 |
-
Deny from all
|
7 |
-
</IfModule>
|
8 |
-
|
9 |
-
# Apache 2.4
|
10 |
-
<IfModule mod_authz_core.c>
|
11 |
-
Require all denied
|
12 |
-
</IfModule>
|
13 |
-
|
14 |
-
# Akismet CSS and JS
|
15 |
-
<FilesMatch "^(form|akismet)\.(css|js)$">
|
16 |
-
<IfModule !mod_authz_core.c>
|
17 |
-
Allow from all
|
18 |
-
</IfModule>
|
19 |
-
|
20 |
-
<IfModule mod_authz_core.c>
|
21 |
-
Require all granted
|
22 |
-
</IfModule>
|
23 |
-
</FilesMatch>
|
24 |
-
|
25 |
-
# Akismet images
|
26 |
-
<FilesMatch "^(.+)\.(png|gif)$">
|
27 |
-
<IfModule !mod_authz_core.c>
|
28 |
-
Allow from all
|
29 |
-
</IfModule>
|
30 |
-
|
31 |
-
<IfModule mod_authz_core.c>
|
32 |
-
Require all granted
|
33 |
-
</IfModule>
|
34 |
-
</FilesMatch>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE.txt
DELETED
@@ -1,339 +0,0 @@
|
|
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
DELETED
@@ -1,375 +0,0 @@
|
|
1 |
-
|
2 |
-
#submitted-on {
|
3 |
-
position: relative;
|
4 |
-
}
|
5 |
-
#the-comment-list .author .akismet-user-comment-count {
|
6 |
-
display: inline;
|
7 |
-
}
|
8 |
-
#the-comment-list .author a span {
|
9 |
-
text-decoration: none;
|
10 |
-
color: #999;
|
11 |
-
}
|
12 |
-
#the-comment-list .author a span.akismet-span-link {
|
13 |
-
text-decoration: inherit;
|
14 |
-
color: inherit;
|
15 |
-
}
|
16 |
-
#the-comment-list .remove_url {
|
17 |
-
margin-left: 3px;
|
18 |
-
color: #999;
|
19 |
-
padding: 2px 3px 2px 0;
|
20 |
-
}
|
21 |
-
#the-comment-list .remove_url:hover {
|
22 |
-
color: #A7301F;
|
23 |
-
font-weight: bold;
|
24 |
-
padding: 2px 2px 2px 0;
|
25 |
-
}
|
26 |
-
#dashboard_recent_comments .akismet-status {
|
27 |
-
display: none;
|
28 |
-
}
|
29 |
-
.akismet-status {
|
30 |
-
float: right;
|
31 |
-
}
|
32 |
-
.akismet-status a {
|
33 |
-
color: #AAA;
|
34 |
-
font-style: italic;
|
35 |
-
}
|
36 |
-
span.comment-link a {
|
37 |
-
text-decoration: underline;
|
38 |
-
}
|
39 |
-
span.comment-link:after {
|
40 |
-
content: " "attr(title) " ";
|
41 |
-
color: #aaa;
|
42 |
-
text-decoration: none;
|
43 |
-
}
|
44 |
-
.mshot-arrow {
|
45 |
-
width: 0;
|
46 |
-
height: 0;
|
47 |
-
border-top: 10px solid transparent;
|
48 |
-
border-bottom: 10px solid transparent;
|
49 |
-
border-right: 10px solid #5C5C5C;
|
50 |
-
position: absolute;
|
51 |
-
left: -6px;
|
52 |
-
top: 91px;
|
53 |
-
}
|
54 |
-
.mshot-container {
|
55 |
-
background: #5C5C5C;
|
56 |
-
position: absolute;
|
57 |
-
top: -94px;
|
58 |
-
padding: 7px;
|
59 |
-
width: 450px;
|
60 |
-
height: 338px;
|
61 |
-
z-index: 20000;
|
62 |
-
-moz-border-radius: 6px;
|
63 |
-
border-radius: 6px;
|
64 |
-
-webkit-border-radius: 6px;
|
65 |
-
}
|
66 |
-
.akismet-mshot {
|
67 |
-
position: absolute;
|
68 |
-
z-index: 100;
|
69 |
-
}
|
70 |
-
.akismet-mshot .mshot-image {
|
71 |
-
margin: 0;
|
72 |
-
height: 338px;
|
73 |
-
width: 450px;
|
74 |
-
}
|
75 |
-
h2.ak-header {
|
76 |
-
padding: 30px;
|
77 |
-
background: #649316 url('img/logo-full-2x.png') no-repeat 20px center;
|
78 |
-
background-size: 185px 33px;
|
79 |
-
height: 33px;
|
80 |
-
text-indent: -9999em;
|
81 |
-
margin-right: 10px;
|
82 |
-
}
|
83 |
-
.checkforspam {
|
84 |
-
display: inline-block !important;
|
85 |
-
}
|
86 |
-
.checkforspam-spinner {
|
87 |
-
display: inline-block;
|
88 |
-
margin-top: 7px;
|
89 |
-
}
|
90 |
-
|
91 |
-
.config-wrap {
|
92 |
-
margin-top: 2em;
|
93 |
-
max-width: 700px;
|
94 |
-
}
|
95 |
-
|
96 |
-
.activate-option {
|
97 |
-
background: #e3e3e3;
|
98 |
-
border-radius: 3px;
|
99 |
-
margin-bottom: 30px;
|
100 |
-
overflow: hidden;
|
101 |
-
padding: 20px;
|
102 |
-
}
|
103 |
-
.activate-option.clicked {
|
104 |
-
background: #649316;
|
105 |
-
color: #fff;
|
106 |
-
}
|
107 |
-
.activate-option.clicked:hover {
|
108 |
-
background: #68802E;
|
109 |
-
color: #fff;
|
110 |
-
}
|
111 |
-
|
112 |
-
.activate-option .button.button-secondary {
|
113 |
-
margin: 15px 0;
|
114 |
-
}
|
115 |
-
|
116 |
-
.activate-option p {
|
117 |
-
margin: 10px 0 10px;
|
118 |
-
}
|
119 |
-
|
120 |
-
.activate-highlight {
|
121 |
-
background: #fff;
|
122 |
-
padding: 30px;
|
123 |
-
margin-right: 10px;
|
124 |
-
}
|
125 |
-
|
126 |
-
.activate-highlight.secondary {
|
127 |
-
background: #ddd;
|
128 |
-
padding: 20px 30px;
|
129 |
-
}
|
130 |
-
|
131 |
-
.activate-highlight h3 {
|
132 |
-
margin: 0 0 0.3em;
|
133 |
-
}
|
134 |
-
.activate-highlight p {
|
135 |
-
color: #777;
|
136 |
-
}
|
137 |
-
.activate-highlight .button-primary {
|
138 |
-
margin-top: 15px;
|
139 |
-
}
|
140 |
-
|
141 |
-
#akismet-enter-api-key .regular-text {
|
142 |
-
width: 18em;
|
143 |
-
margin-top: 15px;
|
144 |
-
}
|
145 |
-
|
146 |
-
.right {
|
147 |
-
float: right;
|
148 |
-
}
|
149 |
-
|
150 |
-
.alert-text {
|
151 |
-
color: #dd3d36;
|
152 |
-
}
|
153 |
-
.success {
|
154 |
-
color: #649316;
|
155 |
-
}
|
156 |
-
.option-description {
|
157 |
-
float: left;
|
158 |
-
font-size: 16px;
|
159 |
-
}
|
160 |
-
.option-description span {
|
161 |
-
color: #666;
|
162 |
-
display: block;
|
163 |
-
font-size: 14px;
|
164 |
-
margin-top: 5px;
|
165 |
-
}
|
166 |
-
.option-action {
|
167 |
-
float: right;
|
168 |
-
}
|
169 |
-
.key-config-link {
|
170 |
-
font-size: 14px;
|
171 |
-
margin-left: 20px;
|
172 |
-
}
|
173 |
-
.jetpack-account {
|
174 |
-
float: left;
|
175 |
-
font-size: 18px;
|
176 |
-
margin-right: 40px;
|
177 |
-
}
|
178 |
-
.small-heading {
|
179 |
-
color: #777;
|
180 |
-
display: block;
|
181 |
-
font-size: 12px;
|
182 |
-
font-weight: bold;
|
183 |
-
margin-bottom: 5px;
|
184 |
-
text-transform: uppercase;
|
185 |
-
}
|
186 |
-
.inline-label {
|
187 |
-
background: #ddd;
|
188 |
-
border-radius: 3px;
|
189 |
-
font-size: 11px;
|
190 |
-
padding: 3px 8px;
|
191 |
-
text-transform: uppercase;
|
192 |
-
}
|
193 |
-
.inline-label.alert {
|
194 |
-
background: #e54747;
|
195 |
-
color: #fff;
|
196 |
-
}
|
197 |
-
.jetpack-account .inline-label {
|
198 |
-
margin-left: 5px;
|
199 |
-
}
|
200 |
-
.option-action .manual-key {
|
201 |
-
margin-top: 7px;
|
202 |
-
}
|
203 |
-
|
204 |
-
.alert {
|
205 |
-
border: 1px solid #e5e5e5;
|
206 |
-
padding: 0.4em 1em 1.4em 1em;
|
207 |
-
border-radius: 3px;
|
208 |
-
-webkit-border-radius: 3px;
|
209 |
-
border-width: 1px;
|
210 |
-
border-style: solid;
|
211 |
-
}
|
212 |
-
|
213 |
-
.alert h3.key-status {
|
214 |
-
color: #fff;
|
215 |
-
margin: 1em 0 0.5em 0;
|
216 |
-
}
|
217 |
-
|
218 |
-
.alert.critical {
|
219 |
-
background-color: #993300;
|
220 |
-
}
|
221 |
-
|
222 |
-
.alert.active {
|
223 |
-
background-color: #649316;
|
224 |
-
}
|
225 |
-
|
226 |
-
.alert p.key-status {
|
227 |
-
font-size: 24px;
|
228 |
-
}
|
229 |
-
|
230 |
-
.alert p.description {
|
231 |
-
color:#fff;
|
232 |
-
font-size: 14px;
|
233 |
-
margin: 0 0;
|
234 |
-
font-style: normal;
|
235 |
-
}
|
236 |
-
|
237 |
-
.alert p.description a,
|
238 |
-
.alert p.description a,
|
239 |
-
.alert p.description a,
|
240 |
-
.alert p.description a {
|
241 |
-
color: #fff;
|
242 |
-
}
|
243 |
-
|
244 |
-
.new-snapshot {
|
245 |
-
margin-top: 1em;
|
246 |
-
padding: 1em;
|
247 |
-
text-align: center;
|
248 |
-
}
|
249 |
-
|
250 |
-
.new-snapshot.stats {
|
251 |
-
background: #fff;
|
252 |
-
border: 1px solid #e5e5e5;
|
253 |
-
}
|
254 |
-
|
255 |
-
.new-snapshot h3 {
|
256 |
-
background: #f5f5f5;
|
257 |
-
color: #888;
|
258 |
-
font-size: 11px;
|
259 |
-
margin: 0;
|
260 |
-
padding: 3px;
|
261 |
-
}
|
262 |
-
|
263 |
-
.new-snapspot ul {
|
264 |
-
font-size: 12px;
|
265 |
-
width: 100%;
|
266 |
-
}
|
267 |
-
|
268 |
-
.new-snapshot ul li {
|
269 |
-
color: #999;
|
270 |
-
float: left;
|
271 |
-
font-size: 11px;
|
272 |
-
padding: 0 20px;
|
273 |
-
text-transform: uppercase;
|
274 |
-
width: 33%;
|
275 |
-
box-sizing: border-box;
|
276 |
-
-moz-box-sizing: border-box;
|
277 |
-
-webkit-box-sizing: border-box;
|
278 |
-
-ms-box-sizing: border-box;
|
279 |
-
}
|
280 |
-
|
281 |
-
.new-snapshot.stats ul li:first-child,
|
282 |
-
.new-snapshot.stats ul li:nth-child(2) {
|
283 |
-
border-right:1px dotted #ccc;
|
284 |
-
}
|
285 |
-
|
286 |
-
.new-snapshot.account ul li:nth-child(2) {
|
287 |
-
border-right: none;
|
288 |
-
}
|
289 |
-
|
290 |
-
.new-snapshot ul li span {
|
291 |
-
color: #52accc;
|
292 |
-
display: block;
|
293 |
-
font-size: 32px;
|
294 |
-
font-weight: lighter;
|
295 |
-
line-height: 1.5em;
|
296 |
-
}
|
297 |
-
|
298 |
-
.new-snapshot.stats {
|
299 |
-
}
|
300 |
-
|
301 |
-
.new-snapshot.account,
|
302 |
-
.new-snapshot.settings {
|
303 |
-
float: left;
|
304 |
-
padding: 0;
|
305 |
-
text-align: left;
|
306 |
-
width: 50%;
|
307 |
-
box-sizing: border-box;
|
308 |
-
-moz-box-sizing: border-box;
|
309 |
-
-webkit-box-sizing: border-box;
|
310 |
-
-ms-box-sizing: border-box;
|
311 |
-
}
|
312 |
-
|
313 |
-
.account-container {
|
314 |
-
background: #fff;
|
315 |
-
border: 1px solid #e5e5e5;
|
316 |
-
margin-right: 0.5em;
|
317 |
-
}
|
318 |
-
|
319 |
-
.settings-container {
|
320 |
-
background: #fff;
|
321 |
-
border: 1px solid #e5e5e5;
|
322 |
-
margin-left: 0.5em;
|
323 |
-
}
|
324 |
-
|
325 |
-
.new-snapshot.account ul li {
|
326 |
-
width:100%
|
327 |
-
}
|
328 |
-
|
329 |
-
.new-snapshot.account ul li span {
|
330 |
-
font-size: 14px;
|
331 |
-
font-weight: normal;
|
332 |
-
}
|
333 |
-
|
334 |
-
|
335 |
-
.new-snapshot.settings ul li {
|
336 |
-
border: none;
|
337 |
-
display: block;
|
338 |
-
width:100%
|
339 |
-
}
|
340 |
-
|
341 |
-
.new-snapshot.settings ul li span {
|
342 |
-
display: block;
|
343 |
-
font-size: 14px;
|
344 |
-
font-weight: normal;
|
345 |
-
}
|
346 |
-
|
347 |
-
.new-snapshot.settings p.submit {
|
348 |
-
margin: 0;
|
349 |
-
text-align: center;
|
350 |
-
}
|
351 |
-
|
352 |
-
.akismet-settings th:first-child {
|
353 |
-
vertical-align: top;
|
354 |
-
padding-top: 15px;
|
355 |
-
}
|
356 |
-
|
357 |
-
.akismet-settings th.akismet-api-key {
|
358 |
-
vertical-align: middle;
|
359 |
-
padding-top: 0;
|
360 |
-
}
|
361 |
-
|
362 |
-
.akismet-settings input[type=text] {
|
363 |
-
width: 75%;
|
364 |
-
}
|
365 |
-
|
366 |
-
.akismet-settings span.note{
|
367 |
-
float: left;
|
368 |
-
padding-left: 23px;
|
369 |
-
font-size: 75%;
|
370 |
-
margin-top: -10px;
|
371 |
-
}
|
372 |
-
|
373 |
-
.clearfix {
|
374 |
-
clear:both;
|
375 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_inc/akismet.js
DELETED
@@ -1,189 +0,0 @@
|
|
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 a.comment-link' ).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
DELETED
@@ -1,30 +0,0 @@
|
|
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
DELETED
Binary file
|
admin.php
ADDED
@@ -0,0 +1,909 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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’ 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&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&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&recheckqueue=true&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
ADDED
@@ -0,0 +1 @@
|
|
|
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
ADDED
Binary file
|
akismet.js
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,13 +4,12 @@
|
|
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
|
9 |
-
Version:
|
10 |
Author: Automattic
|
11 |
Author URI: http://automattic.com/wordpress-plugins/
|
12 |
License: GPLv2 or later
|
13 |
-
Text Domain: akismet
|
14 |
*/
|
15 |
|
16 |
/*
|
@@ -27,8 +26,6 @@ GNU General Public License for more details.
|
|
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,25 +34,580 @@ if ( !function_exists( 'add_action' ) ) {
|
|
37 |
exit;
|
38 |
}
|
39 |
|
40 |
-
define(
|
41 |
-
define(
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
register_deactivation_hook( __FILE__, array( 'Akismet', 'plugin_deactivation' ) );
|
48 |
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
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 |
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 |
+
}
|
class.akismet-admin.php
DELETED
@@ -1,978 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Akismet_Admin {
|
4 |
-
const NONCE = 'akismet-update-key';
|
5 |
-
|
6 |
-
private static $initiated = false;
|
7 |
-
private static $notices = array();
|
8 |
-
|
9 |
-
public static function init() {
|
10 |
-
if ( ! self::$initiated ) {
|
11 |
-
self::init_hooks();
|
12 |
-
}
|
13 |
-
|
14 |
-
if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) {
|
15 |
-
self::enter_api_key();
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
public static function init_hooks() {
|
20 |
-
// The standalone stats page was removed in 3.0 for an all-in-one config and stats page.
|
21 |
-
// Redirect any links that might have been bookmarked or in browser history.
|
22 |
-
if ( isset( $_GET['page'] ) && 'akismet-stats-display' == $_GET['page'] ) {
|
23 |
-
wp_safe_redirect( esc_url_raw( self::get_page_url( 'stats' ) ), 301 );
|
24 |
-
die;
|
25 |
-
}
|
26 |
-
|
27 |
-
self::$initiated = true;
|
28 |
-
|
29 |
-
add_action( 'admin_init', array( 'Akismet_Admin', 'admin_init' ) );
|
30 |
-
add_action( 'admin_menu', array( 'Akismet_Admin', 'admin_menu' ), 5 ); # Priority 5, so it's called before Jetpack's admin_menu.
|
31 |
-
add_action( 'admin_notices', array( 'Akismet_Admin', 'display_notice' ) );
|
32 |
-
add_action( 'admin_enqueue_scripts', array( 'Akismet_Admin', 'load_resources' ) );
|
33 |
-
add_action( 'activity_box_end', array( 'Akismet_Admin', 'dashboard_stats' ) );
|
34 |
-
add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) );
|
35 |
-
add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) );
|
36 |
-
add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
37 |
-
add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
38 |
-
add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
|
39 |
-
add_action( 'wp_ajax_comment_author_reurl', array( 'Akismet_Admin', 'add_comment_author_url' ) );
|
40 |
-
add_action( 'jetpack_auto_activate_akismet', array( 'Akismet_Admin', 'connect_jetpack_user' ) );
|
41 |
-
|
42 |
-
add_filter( 'plugin_action_links', array( 'Akismet_Admin', 'plugin_action_links' ), 10, 2 );
|
43 |
-
add_filter( 'comment_row_actions', array( 'Akismet_Admin', 'comment_row_action' ), 10, 2 );
|
44 |
-
add_filter( 'comment_text', array( 'Akismet_Admin', 'text_add_link_class' ) );
|
45 |
-
|
46 |
-
add_filter( 'plugin_action_links_'.plugin_basename( plugin_dir_path( __FILE__ ) . 'akismet.php'), array( 'Akismet_Admin', 'admin_plugin_settings_link' ) );
|
47 |
-
|
48 |
-
add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 );
|
49 |
-
}
|
50 |
-
|
51 |
-
public static function admin_init() {
|
52 |
-
load_plugin_textdomain( 'akismet' );
|
53 |
-
add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
|
54 |
-
}
|
55 |
-
|
56 |
-
public static function admin_menu() {
|
57 |
-
if ( class_exists( 'Jetpack' ) )
|
58 |
-
add_action( 'jetpack_admin_menu', array( 'Akismet_Admin', 'load_menu' ) );
|
59 |
-
else
|
60 |
-
self::load_menu();
|
61 |
-
}
|
62 |
-
|
63 |
-
public static function admin_head() {
|
64 |
-
if ( !current_user_can( 'manage_options' ) )
|
65 |
-
return;
|
66 |
-
}
|
67 |
-
|
68 |
-
public static function admin_plugin_settings_link( $links ) {
|
69 |
-
$settings_link = '<a href="'.esc_url( self::get_page_url() ).'">'.__('Settings', 'akismet').'</a>';
|
70 |
-
array_unshift( $links, $settings_link );
|
71 |
-
return $links;
|
72 |
-
}
|
73 |
-
|
74 |
-
public static function load_menu() {
|
75 |
-
if ( class_exists( 'Jetpack' ) )
|
76 |
-
$hook = add_submenu_page( 'jetpack', __( 'Akismet' , 'akismet'), __( 'Akismet' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
|
77 |
-
else
|
78 |
-
$hook = add_options_page( __('Akismet', 'akismet'), __('Akismet', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
|
79 |
-
|
80 |
-
if ( version_compare( $GLOBALS['wp_version'], '3.3', '>=' ) ) {
|
81 |
-
add_action( "load-$hook", array( 'Akismet_Admin', 'admin_help' ) );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
public static function load_resources() {
|
86 |
-
global $hook_suffix;
|
87 |
-
|
88 |
-
if ( in_array( $hook_suffix, array(
|
89 |
-
'index.php', # dashboard
|
90 |
-
'edit-comments.php',
|
91 |
-
'comment.php',
|
92 |
-
'post.php',
|
93 |
-
'settings_page_akismet-key-config',
|
94 |
-
'jetpack_page_akismet-key-config',
|
95 |
-
) ) ) {
|
96 |
-
wp_register_style( 'akismet.css', AKISMET__PLUGIN_URL . '_inc/akismet.css', array(), AKISMET_VERSION );
|
97 |
-
wp_enqueue_style( 'akismet.css');
|
98 |
-
|
99 |
-
wp_register_script( 'akismet.js', AKISMET__PLUGIN_URL . '_inc/akismet.js', array('jquery','postbox'), AKISMET_VERSION );
|
100 |
-
wp_enqueue_script( 'akismet.js' );
|
101 |
-
wp_localize_script( 'akismet.js', 'WPAkismet', array(
|
102 |
-
'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
|
103 |
-
'strings' => array(
|
104 |
-
'Remove this URL' => __( 'Remove this URL' , 'akismet'),
|
105 |
-
'Removing...' => __( 'Removing...' , 'akismet'),
|
106 |
-
'URL removed' => __( 'URL removed' , 'akismet'),
|
107 |
-
'(undo)' => __( '(undo)' , 'akismet'),
|
108 |
-
'Re-adding...' => __( 'Re-adding...' , 'akismet'),
|
109 |
-
)
|
110 |
-
) );
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Add help to the Akismet page
|
116 |
-
*
|
117 |
-
* @return false if not the Akismet page
|
118 |
-
*/
|
119 |
-
public static function admin_help() {
|
120 |
-
$current_screen = get_current_screen();
|
121 |
-
|
122 |
-
// Screen Content
|
123 |
-
if ( current_user_can( 'manage_options' ) ) {
|
124 |
-
if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) ) {
|
125 |
-
//setup page
|
126 |
-
$current_screen->add_help_tab(
|
127 |
-
array(
|
128 |
-
'id' => 'overview',
|
129 |
-
'title' => __( 'Overview' , 'akismet'),
|
130 |
-
'content' =>
|
131 |
-
'<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
|
132 |
-
'<p>' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '</p>' .
|
133 |
-
'<p>' . esc_html__( 'On this page, you are able to set up the Akismet plugin.' , 'akismet') . '</p>',
|
134 |
-
)
|
135 |
-
);
|
136 |
-
|
137 |
-
$current_screen->add_help_tab(
|
138 |
-
array(
|
139 |
-
'id' => 'setup-signup',
|
140 |
-
'title' => __( 'New to Akismet' , 'akismet'),
|
141 |
-
'content' =>
|
142 |
-
'<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
|
143 |
-
'<p>' . esc_html__( 'You need to enter an API key to activate the Akismet service on your site.' , 'akismet') . '</p>' .
|
144 |
-
'<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>',
|
145 |
-
)
|
146 |
-
);
|
147 |
-
|
148 |
-
$current_screen->add_help_tab(
|
149 |
-
array(
|
150 |
-
'id' => 'setup-manual',
|
151 |
-
'title' => __( 'Enter an API Key' , 'akismet'),
|
152 |
-
'content' =>
|
153 |
-
'<p><strong>' . esc_html__( 'Akismet Setup' , 'akismet') . '</strong></p>' .
|
154 |
-
'<p>' . esc_html__( 'If you already have an API key' , 'akismet') . '</p>' .
|
155 |
-
'<ol>' .
|
156 |
-
'<li>' . esc_html__( 'Copy and paste the API key into the text field.' , 'akismet') . '</li>' .
|
157 |
-
'<li>' . esc_html__( 'Click the Use this Key button.' , 'akismet') . '</li>' .
|
158 |
-
'</ol>',
|
159 |
-
)
|
160 |
-
);
|
161 |
-
}
|
162 |
-
elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' ) {
|
163 |
-
//stats page
|
164 |
-
$current_screen->add_help_tab(
|
165 |
-
array(
|
166 |
-
'id' => 'overview',
|
167 |
-
'title' => __( 'Overview' , 'akismet'),
|
168 |
-
'content' =>
|
169 |
-
'<p><strong>' . esc_html__( 'Akismet Stats' , 'akismet') . '</strong></p>' .
|
170 |
-
'<p>' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '</p>' .
|
171 |
-
'<p>' . esc_html__( 'On this page, you are able to view stats on spam filtered on your site.' , 'akismet') . '</p>',
|
172 |
-
)
|
173 |
-
);
|
174 |
-
}
|
175 |
-
else {
|
176 |
-
//configuration page
|
177 |
-
$current_screen->add_help_tab(
|
178 |
-
array(
|
179 |
-
'id' => 'overview',
|
180 |
-
'title' => __( 'Overview' , 'akismet'),
|
181 |
-
'content' =>
|
182 |
-
'<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
|
183 |
-
'<p>' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '</p>' .
|
184 |
-
'<p>' . esc_html__( 'On this page, you are able to enter/remove an API key, view account information and view spam stats.' , 'akismet') . '</p>',
|
185 |
-
)
|
186 |
-
);
|
187 |
-
|
188 |
-
$current_screen->add_help_tab(
|
189 |
-
array(
|
190 |
-
'id' => 'settings',
|
191 |
-
'title' => __( 'Settings' , 'akismet'),
|
192 |
-
'content' =>
|
193 |
-
'<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
|
194 |
-
'<p><strong>' . esc_html__( 'API Key' , 'akismet') . '</strong> - ' . esc_html__( 'Enter/remove an API key.' , 'akismet') . '</p>' .
|
195 |
-
'<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>' .
|
196 |
-
'<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>',
|
197 |
-
)
|
198 |
-
);
|
199 |
-
|
200 |
-
$current_screen->add_help_tab(
|
201 |
-
array(
|
202 |
-
'id' => 'account',
|
203 |
-
'title' => __( 'Account' , 'akismet'),
|
204 |
-
'content' =>
|
205 |
-
'<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' .
|
206 |
-
'<p><strong>' . esc_html__( 'Subscription Type' , 'akismet') . '</strong> - ' . esc_html__( 'The Akismet subscription plan' , 'akismet') . '</p>' .
|
207 |
-
'<p><strong>' . esc_html__( 'Status' , 'akismet') . '</strong> - ' . esc_html__( 'The subscription status - active, cancelled or suspended' , 'akismet') . '</p>',
|
208 |
-
)
|
209 |
-
);
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
// Help Sidebar
|
214 |
-
$current_screen->set_help_sidebar(
|
215 |
-
'<p><strong>' . esc_html__( 'For more information:' , 'akismet') . '</strong></p>' .
|
216 |
-
'<p><a href="https://akismet.com/faq/" target="_blank">' . esc_html__( 'Akismet FAQ' , 'akismet') . '</a></p>' .
|
217 |
-
'<p><a href="https://akismet.com/support/" target="_blank">' . esc_html__( 'Akismet Support' , 'akismet') . '</a></p>'
|
218 |
-
);
|
219 |
-
}
|
220 |
-
|
221 |
-
public static function enter_api_key() {
|
222 |
-
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
|
223 |
-
die(__('Cheatin’ uh?', 'akismet'));
|
224 |
-
|
225 |
-
if ( !wp_verify_nonce( $_POST['_wpnonce'], self::NONCE ) )
|
226 |
-
return false;
|
227 |
-
|
228 |
-
foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
|
229 |
-
update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
|
230 |
-
}
|
231 |
-
|
232 |
-
if ( defined( 'WPCOM_API_KEY' ) )
|
233 |
-
return false; //shouldn't have option to save key if already defined
|
234 |
-
|
235 |
-
$new_key = preg_replace( '/[^a-f0-9]/i', '', $_POST['key'] );
|
236 |
-
$old_key = Akismet::get_api_key();
|
237 |
-
|
238 |
-
if ( empty( $new_key ) ) {
|
239 |
-
if ( !empty( $old_key ) ) {
|
240 |
-
delete_option( 'wordpress_api_key' );
|
241 |
-
self::$notices[] = 'new-key-empty';
|
242 |
-
}
|
243 |
-
}
|
244 |
-
elseif ( $new_key != $old_key ) {
|
245 |
-
self::save_key( $new_key );
|
246 |
-
}
|
247 |
-
|
248 |
-
return true;
|
249 |
-
}
|
250 |
-
|
251 |
-
public static function save_key( $api_key ) {
|
252 |
-
$key_status = Akismet::verify_key( $api_key );
|
253 |
-
|
254 |
-
if ( $key_status == 'valid' ) {
|
255 |
-
$akismet_user = self::get_akismet_user( $api_key );
|
256 |
-
|
257 |
-
if ( $akismet_user ) {
|
258 |
-
if ( in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) ) )
|
259 |
-
update_option( 'wordpress_api_key', $api_key );
|
260 |
-
|
261 |
-
if ( $akismet_user->status == 'active' )
|
262 |
-
self::$notices['status'] = 'new-key-valid';
|
263 |
-
else
|
264 |
-
self::$notices['status'] = $akismet_user->status;
|
265 |
-
}
|
266 |
-
else
|
267 |
-
self::$notices['status'] = 'new-key-invalid';
|
268 |
-
}
|
269 |
-
elseif ( in_array( $key_status, array( 'invalid', 'failed' ) ) )
|
270 |
-
self::$notices['status'] = 'new-key-'.$key_status;
|
271 |
-
}
|
272 |
-
|
273 |
-
public static function dashboard_stats() {
|
274 |
-
if ( !function_exists('did_action') || did_action( 'rightnow_end' ) )
|
275 |
-
return; // We already displayed this info in the "Right Now" section
|
276 |
-
|
277 |
-
if ( !$count = get_option('akismet_spam_count') )
|
278 |
-
return;
|
279 |
-
|
280 |
-
global $submenu;
|
281 |
-
|
282 |
-
echo '<h3>' . esc_html( _x( 'Spam', 'comments' , 'akismet') ) . '</h3>';
|
283 |
-
|
284 |
-
echo '<p>'.sprintf( _n(
|
285 |
-
'<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comment</a>.',
|
286 |
-
'<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.',
|
287 |
-
$count
|
288 |
-
, '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>';
|
289 |
-
}
|
290 |
-
|
291 |
-
// WP 2.5+
|
292 |
-
public static function rightnow_stats() {
|
293 |
-
if ( $count = get_option('akismet_spam_count') ) {
|
294 |
-
$intro = sprintf( _n(
|
295 |
-
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
|
296 |
-
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
|
297 |
-
$count
|
298 |
-
, 'akismet'), 'https://akismet.com/wordpress/', number_format_i18n( $count ) );
|
299 |
-
} else {
|
300 |
-
$intro = sprintf( __('<a href="%s">Akismet</a> blocks spam from getting to your blog. ', 'akismet'), 'https://akismet.com/wordpress/' );
|
301 |
-
}
|
302 |
-
|
303 |
-
$link = add_query_arg( array( 'comment_status' => 'spam' ), admin_url( 'edit-comments.php' ) );
|
304 |
-
|
305 |
-
if ( $queue_count = self::get_spam_count() ) {
|
306 |
-
$queue_text = sprintf( _n(
|
307 |
-
'There’s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
|
308 |
-
'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
|
309 |
-
$queue_count
|
310 |
-
, 'akismet'), number_format_i18n( $queue_count ), esc_url( $link ) );
|
311 |
-
} else {
|
312 |
-
$queue_text = sprintf( __( "There’s nothing in your <a href='%s'>spam queue</a> at the moment." , 'akismet'), esc_url( $link ) );
|
313 |
-
}
|
314 |
-
|
315 |
-
$text = $intro . '<br />' . $queue_text;
|
316 |
-
echo "<p class='akismet-right-now'>$text</p>\n";
|
317 |
-
}
|
318 |
-
|
319 |
-
public static function check_for_spam_button( $comment_status ) {
|
320 |
-
// The "Check for Spam" button should only appear when the page might be showing
|
321 |
-
// a comment with comment_approved=0, which means an un-trashed, un-spammed,
|
322 |
-
// not-yet-moderated comment.
|
323 |
-
if ( 'all' != $comment_status && 'moderated' != $comment_status ) {
|
324 |
-
return;
|
325 |
-
}
|
326 |
-
|
327 |
-
if ( function_exists('plugins_url') )
|
328 |
-
$link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
|
329 |
-
else
|
330 |
-
$link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
|
331 |
-
|
332 |
-
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>';
|
333 |
-
}
|
334 |
-
|
335 |
-
public static function recheck_queue() {
|
336 |
-
global $wpdb;
|
337 |
-
|
338 |
-
Akismet::fix_scheduled_recheck();
|
339 |
-
|
340 |
-
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
|
341 |
-
return;
|
342 |
-
|
343 |
-
$paginate = '';
|
344 |
-
if ( isset( $_POST['limit'] ) && isset( $_POST['offset'] ) ) {
|
345 |
-
$paginate = $wpdb->prepare( " LIMIT %d OFFSET %d", array( $_POST['limit'], $_POST['offset'] ) );
|
346 |
-
}
|
347 |
-
$moderation = $wpdb->get_results( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A );
|
348 |
-
|
349 |
-
foreach ( (array) $moderation as $c ) {
|
350 |
-
$c['user_ip'] = $c['comment_author_IP'];
|
351 |
-
$c['user_agent'] = $c['comment_agent'];
|
352 |
-
$c['referrer'] = '';
|
353 |
-
$c['blog'] = get_bloginfo('url');
|
354 |
-
$c['blog_lang'] = get_locale();
|
355 |
-
$c['blog_charset'] = get_option('blog_charset');
|
356 |
-
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
357 |
-
|
358 |
-
$c['user_role'] = '';
|
359 |
-
if ( isset( $c['user_ID'] ) )
|
360 |
-
$c['user_role'] = Akismet::get_user_roles($c['user_ID']);
|
361 |
-
|
362 |
-
if ( Akismet::is_test_mode() )
|
363 |
-
$c['is_test'] = 'true';
|
364 |
-
|
365 |
-
add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
|
366 |
-
|
367 |
-
$response = Akismet::http_post( Akismet::build_query( $c ), 'comment-check' );
|
368 |
-
|
369 |
-
if ( 'true' == $response[1] ) {
|
370 |
-
wp_set_comment_status( $c['comment_ID'], 'spam' );
|
371 |
-
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
|
372 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_error' );
|
373 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_delayed_moderation_email' );
|
374 |
-
Akismet::update_comment_history( $c['comment_ID'], '', 'recheck-spam' );
|
375 |
-
|
376 |
-
} elseif ( 'false' == $response[1] ) {
|
377 |
-
update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
|
378 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_error' );
|
379 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_delayed_moderation_email' );
|
380 |
-
Akismet::update_comment_history( $c['comment_ID'], '', 'recheck-ham' );
|
381 |
-
// abnormal result: error
|
382 |
-
} else {
|
383 |
-
update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
|
384 |
-
Akismet::update_comment_history(
|
385 |
-
$c['comment_ID'],
|
386 |
-
'',
|
387 |
-
'recheck-error',
|
388 |
-
array( 'response' => substr( $response[1], 0, 50 ) )
|
389 |
-
);
|
390 |
-
}
|
391 |
-
|
392 |
-
delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
|
393 |
-
}
|
394 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
395 |
-
wp_send_json( array(
|
396 |
-
'processed' => count((array) $moderation),
|
397 |
-
));
|
398 |
-
}
|
399 |
-
else {
|
400 |
-
$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
|
401 |
-
wp_safe_redirect( $redirect_to );
|
402 |
-
exit;
|
403 |
-
}
|
404 |
-
}
|
405 |
-
|
406 |
-
// Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
|
407 |
-
public static function remove_comment_author_url() {
|
408 |
-
if ( !empty( $_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
|
409 |
-
$comment = get_comment( intval( $_POST['id'] ), ARRAY_A );
|
410 |
-
if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
|
411 |
-
$comment['comment_author_url'] = '';
|
412 |
-
do_action( 'comment_remove_author_url' );
|
413 |
-
print( wp_update_comment( $comment ) );
|
414 |
-
die();
|
415 |
-
}
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
public static function add_comment_author_url() {
|
420 |
-
if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
|
421 |
-
$comment = get_comment( intval( $_POST['id'] ), ARRAY_A );
|
422 |
-
if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
|
423 |
-
$comment['comment_author_url'] = esc_url( $_POST['url'] );
|
424 |
-
do_action( 'comment_add_author_url' );
|
425 |
-
print( wp_update_comment( $comment ) );
|
426 |
-
die();
|
427 |
-
}
|
428 |
-
}
|
429 |
-
}
|
430 |
-
|
431 |
-
public static function comment_row_action( $a, $comment ) {
|
432 |
-
|
433 |
-
// failsafe for old WP versions
|
434 |
-
if ( !function_exists('add_comment_meta') )
|
435 |
-
return $a;
|
436 |
-
|
437 |
-
$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
|
438 |
-
$akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
|
439 |
-
$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
|
440 |
-
$comment_status = wp_get_comment_status( $comment->comment_ID );
|
441 |
-
$desc = null;
|
442 |
-
if ( $akismet_error ) {
|
443 |
-
$desc = __( 'Awaiting spam check' , 'akismet');
|
444 |
-
} elseif ( !$user_result || $user_result == $akismet_result ) {
|
445 |
-
// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
|
446 |
-
if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
|
447 |
-
$desc = __( 'Flagged as spam by Akismet' , 'akismet');
|
448 |
-
elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
|
449 |
-
$desc = __( 'Cleared by Akismet' , 'akismet');
|
450 |
-
} else {
|
451 |
-
$who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
|
452 |
-
if ( $user_result == 'true' )
|
453 |
-
$desc = sprintf( __('Flagged as spam by %s', 'akismet'), $who );
|
454 |
-
else
|
455 |
-
$desc = sprintf( __('Un-spammed by %s', 'akismet'), $who );
|
456 |
-
}
|
457 |
-
|
458 |
-
// add a History item to the hover links, just after Edit
|
459 |
-
if ( $akismet_result ) {
|
460 |
-
$b = array();
|
461 |
-
foreach ( $a as $k => $item ) {
|
462 |
-
$b[ $k ] = $item;
|
463 |
-
if (
|
464 |
-
$k == 'edit'
|
465 |
-
|| ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
|
466 |
-
) {
|
467 |
-
$b['history'] = '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' , 'akismet') . '"> '. esc_html__('History', 'akismet') . '</a>';
|
468 |
-
}
|
469 |
-
}
|
470 |
-
|
471 |
-
$a = $b;
|
472 |
-
}
|
473 |
-
|
474 |
-
if ( $desc )
|
475 |
-
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' , 'akismet') . '">'.esc_html( $desc ).'</a></span>';
|
476 |
-
|
477 |
-
$show_user_comments = apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') );
|
478 |
-
$show_user_comments = $show_user_comments === 'false' ? false : $show_user_comments; //option used to be saved as 'false' / 'true'
|
479 |
-
|
480 |
-
if ( $show_user_comments ) {
|
481 |
-
$comment_count = Akismet::get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
|
482 |
-
$comment_count = intval( $comment_count );
|
483 |
-
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>';
|
484 |
-
}
|
485 |
-
|
486 |
-
return $a;
|
487 |
-
}
|
488 |
-
|
489 |
-
public static function comment_status_meta_box( $comment ) {
|
490 |
-
$history = Akismet::get_comment_history( $comment->comment_ID );
|
491 |
-
|
492 |
-
if ( $history ) {
|
493 |
-
echo '<div class="akismet-history" style="margin: 13px;">';
|
494 |
-
|
495 |
-
foreach ( $history as $row ) {
|
496 |
-
$time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
|
497 |
-
|
498 |
-
$message = '';
|
499 |
-
|
500 |
-
if ( ! empty( $row['message'] ) ) {
|
501 |
-
// Old versions of Akismet stored the message as a literal string in the commentmeta.
|
502 |
-
// New versions don't do that for two reasons:
|
503 |
-
// 1) Save space.
|
504 |
-
// 2) The message can be translated into the current language of the blog, not stuck
|
505 |
-
// in the language of the blog when the comment was made.
|
506 |
-
$message = $row['message'];
|
507 |
-
}
|
508 |
-
|
509 |
-
// If possible, use a current translation.
|
510 |
-
switch ( $row['event'] ) {
|
511 |
-
case 'recheck-spam';
|
512 |
-
$message = __( 'Akismet re-checked and caught this comment as spam.', 'akismet' );
|
513 |
-
break;
|
514 |
-
case 'check-spam':
|
515 |
-
$message = __( 'Akismet caught this comment as spam.', 'akismet' );
|
516 |
-
break;
|
517 |
-
case 'recheck-ham':
|
518 |
-
$message = __( 'Akismet re-checked and cleared this comment.', 'akismet' );
|
519 |
-
break;
|
520 |
-
case 'check-ham':
|
521 |
-
$message = __( 'Akismet cleared this comment.', 'akismet' );
|
522 |
-
break;
|
523 |
-
case 'wp-blacklisted':
|
524 |
-
$message = __( 'Comment was caught by wp_blacklist_check.', 'akismet' );
|
525 |
-
break;
|
526 |
-
case 'report-spam':
|
527 |
-
if ( isset( $row['user'] ) ) {
|
528 |
-
$message = sprintf( __( '%s reported this comment as spam.', 'akismet' ), $row['user'] );
|
529 |
-
}
|
530 |
-
else if ( ! $message ) {
|
531 |
-
$message = __( 'This comment was reported as spam.', 'akismet' );
|
532 |
-
}
|
533 |
-
break;
|
534 |
-
case 'report-ham':
|
535 |
-
if ( isset( $row['user'] ) ) {
|
536 |
-
$message = sprintf( __( '%s reported this comment as not spam.', 'akismet' ), $row['user'] );
|
537 |
-
}
|
538 |
-
else if ( ! $message ) {
|
539 |
-
$message = __( 'This comment was reported as not spam.', 'akismet' );
|
540 |
-
}
|
541 |
-
break;
|
542 |
-
case 'cron-retry-spam':
|
543 |
-
$message = __( 'Akismet caught this comment as spam during an automatic retry.' , 'akismet');
|
544 |
-
break;
|
545 |
-
case 'cron-retry-ham':
|
546 |
-
$message = __( 'Akismet cleared this comment during an automatic retry.', 'akismet');
|
547 |
-
break;
|
548 |
-
case 'check-error':
|
549 |
-
if ( isset( $row['meta'], $row['meta']['response'] ) ) {
|
550 |
-
$message = sprintf( __( 'Akismet was unable to check this comment (response: %s) but will automatically retry later.', 'akismet'), $row['meta']['response'] );
|
551 |
-
}
|
552 |
-
break;
|
553 |
-
case 'recheck-error':
|
554 |
-
if ( isset( $row['meta'], $row['meta']['response'] ) ) {
|
555 |
-
$message = sprintf( __( 'Akismet was unable to recheck this comment (response: %s).', 'akismet'), $row['meta']['response'] );
|
556 |
-
}
|
557 |
-
break;
|
558 |
-
default:
|
559 |
-
if ( preg_match( '/^status-changed/', $row['event'] ) ) {
|
560 |
-
// Half of these used to be saved without the dash after 'status-changed'.
|
561 |
-
// See https://plugins.trac.wordpress.org/changeset/1150658/akismet/trunk
|
562 |
-
$new_status = preg_replace( '/^status-changed-?/', '', $row['event'] );
|
563 |
-
$message = sprintf( __( 'Comment status was changed to %s', 'akismet' ), $new_status );
|
564 |
-
}
|
565 |
-
else if ( preg_match( '/^status-/', $row['event'] ) ) {
|
566 |
-
$new_status = preg_replace( '/^status-/', '', $row['event'] );
|
567 |
-
|
568 |
-
if ( isset( $row['user'] ) ) {
|
569 |
-
$message = sprintf( __( '%1$s changed the comment status to %2$s.', 'akismet' ), $row['user'], $new_status );
|
570 |
-
}
|
571 |
-
}
|
572 |
-
break;
|
573 |
-
|
574 |
-
}
|
575 |
-
|
576 |
-
echo '<div style="margin-bottom: 13px;">';
|
577 |
-
echo '<span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( esc_html__('%s ago', 'akismet'), human_time_diff( $row['time'] ) ) . '</span>';
|
578 |
-
echo ' - ';
|
579 |
-
echo esc_html( $message );
|
580 |
-
echo '</div>';
|
581 |
-
}
|
582 |
-
|
583 |
-
echo '</div>';
|
584 |
-
}
|
585 |
-
}
|
586 |
-
|
587 |
-
public static function plugin_action_links( $links, $file ) {
|
588 |
-
if ( $file == plugin_basename( AKISMET__PLUGIN_URL . '/akismet.php' ) ) {
|
589 |
-
$links[] = '<a href="' . esc_url( self::get_page_url() ) . '">'.esc_html__( 'Settings' , 'akismet').'</a>';
|
590 |
-
}
|
591 |
-
|
592 |
-
return $links;
|
593 |
-
}
|
594 |
-
|
595 |
-
public static function text_add_link_callback( $m ) {
|
596 |
-
// bare link?
|
597 |
-
if ( $m[4] == $m[2] )
|
598 |
-
return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';
|
599 |
-
else
|
600 |
-
return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';
|
601 |
-
}
|
602 |
-
|
603 |
-
public static function text_add_link_class( $comment_text ) {
|
604 |
-
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', array( 'Akismet_Admin', 'text_add_link_callback' ), $comment_text );
|
605 |
-
}
|
606 |
-
|
607 |
-
// Total spam in queue
|
608 |
-
// get_option( 'akismet_spam_count' ) is the total caught ever
|
609 |
-
public static function get_spam_count( $type = false ) {
|
610 |
-
global $wpdb;
|
611 |
-
|
612 |
-
if ( !$type ) { // total
|
613 |
-
$count = wp_cache_get( 'akismet_spam_count', 'widget' );
|
614 |
-
if ( false === $count ) {
|
615 |
-
if ( function_exists('wp_count_comments') ) {
|
616 |
-
$count = wp_count_comments();
|
617 |
-
$count = $count->spam;
|
618 |
-
} else {
|
619 |
-
$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam'");
|
620 |
-
}
|
621 |
-
wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
|
622 |
-
}
|
623 |
-
return $count;
|
624 |
-
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
|
625 |
-
$type = '';
|
626 |
-
}
|
627 |
-
|
628 |
-
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam' AND comment_type = %s", $type ) );
|
629 |
-
}
|
630 |
-
|
631 |
-
// Check connectivity between the WordPress blog and Akismet's servers.
|
632 |
-
// 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).
|
633 |
-
public static function check_server_ip_connectivity() {
|
634 |
-
|
635 |
-
$servers = $ips = array();
|
636 |
-
|
637 |
-
// Some web hosts may disable this function
|
638 |
-
if ( function_exists('gethostbynamel') ) {
|
639 |
-
|
640 |
-
$ips = gethostbynamel( 'rest.akismet.com' );
|
641 |
-
if ( $ips && is_array($ips) && count($ips) ) {
|
642 |
-
$api_key = Akismet::get_api_key();
|
643 |
-
|
644 |
-
foreach ( $ips as $ip ) {
|
645 |
-
$response = Akismet::verify_key( $api_key, $ip );
|
646 |
-
// even if the key is invalid, at least we know we have connectivity
|
647 |
-
if ( $response == 'valid' || $response == 'invalid' )
|
648 |
-
$servers[$ip] = 'connected';
|
649 |
-
else
|
650 |
-
$servers[$ip] = $response ? $response : 'unable to connect';
|
651 |
-
}
|
652 |
-
}
|
653 |
-
}
|
654 |
-
|
655 |
-
return $servers;
|
656 |
-
}
|
657 |
-
|
658 |
-
// Simpler connectivity check
|
659 |
-
public static function check_server_connectivity($cache_timeout = 86400) {
|
660 |
-
|
661 |
-
$debug = array();
|
662 |
-
$debug[ 'PHP_VERSION' ] = PHP_VERSION;
|
663 |
-
$debug[ 'WORDPRESS_VERSION' ] = $GLOBALS['wp_version'];
|
664 |
-
$debug[ 'AKISMET_VERSION' ] = AKISMET_VERSION;
|
665 |
-
$debug[ 'AKISMET__PLUGIN_DIR' ] = AKISMET__PLUGIN_DIR;
|
666 |
-
$debug[ 'SITE_URL' ] = site_url();
|
667 |
-
$debug[ 'HOME_URL' ] = home_url();
|
668 |
-
|
669 |
-
$servers = get_option('akismet_available_servers');
|
670 |
-
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false ) {
|
671 |
-
$servers = self::check_server_ip_connectivity();
|
672 |
-
update_option('akismet_available_servers', $servers);
|
673 |
-
update_option('akismet_connectivity_time', time());
|
674 |
-
}
|
675 |
-
|
676 |
-
$response = wp_remote_get( 'http://rest.akismet.com/1.1/test' );
|
677 |
-
|
678 |
-
$debug[ 'gethostbynamel' ] = function_exists('gethostbynamel') ? 'exists' : 'not here';
|
679 |
-
$debug[ 'Servers' ] = $servers;
|
680 |
-
$debug[ 'Test Connection' ] = $response;
|
681 |
-
|
682 |
-
Akismet::log( $debug );
|
683 |
-
|
684 |
-
if ( $response && 'connected' == wp_remote_retrieve_body( $response ) )
|
685 |
-
return true;
|
686 |
-
|
687 |
-
return false;
|
688 |
-
}
|
689 |
-
|
690 |
-
// Check the server connectivity and store the available servers in an option.
|
691 |
-
public static function get_server_connectivity($cache_timeout = 86400) {
|
692 |
-
return self::check_server_connectivity( $cache_timeout );
|
693 |
-
}
|
694 |
-
|
695 |
-
public static function get_number_spam_waiting() {
|
696 |
-
global $wpdb;
|
697 |
-
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
|
698 |
-
}
|
699 |
-
|
700 |
-
public static function get_page_url( $page = 'config' ) {
|
701 |
-
|
702 |
-
$args = array( 'page' => 'akismet-key-config' );
|
703 |
-
|
704 |
-
if ( $page == 'stats' )
|
705 |
-
$args = array( 'page' => 'akismet-key-config', 'view' => 'stats' );
|
706 |
-
elseif ( $page == 'delete_key' )
|
707 |
-
$args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) );
|
708 |
-
|
709 |
-
$url = add_query_arg( $args, class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) );
|
710 |
-
|
711 |
-
return $url;
|
712 |
-
}
|
713 |
-
|
714 |
-
public static function get_akismet_user( $api_key ) {
|
715 |
-
$akismet_user = false;
|
716 |
-
|
717 |
-
$subscription_verification = Akismet::http_post( Akismet::build_query( array( 'key' => $api_key, 'blog' => get_bloginfo( 'url' ) ) ), 'get-subscription' );
|
718 |
-
|
719 |
-
if ( ! empty( $subscription_verification[1] ) ) {
|
720 |
-
if ( 'invalid' !== $subscription_verification[1] ) {
|
721 |
-
$akismet_user = json_decode( $subscription_verification[1] );
|
722 |
-
}
|
723 |
-
}
|
724 |
-
|
725 |
-
return $akismet_user;
|
726 |
-
}
|
727 |
-
|
728 |
-
public static function get_stats( $api_key ) {
|
729 |
-
$stat_totals = array();
|
730 |
-
|
731 |
-
foreach( array( '6-months', 'all' ) as $interval ) {
|
732 |
-
$response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_bloginfo( 'url' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
|
733 |
-
|
734 |
-
if ( ! empty( $response[1] ) ) {
|
735 |
-
$stat_totals[$interval] = json_decode( $response[1] );
|
736 |
-
}
|
737 |
-
}
|
738 |
-
|
739 |
-
return $stat_totals;
|
740 |
-
}
|
741 |
-
|
742 |
-
public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) {
|
743 |
-
$akismet_account = Akismet::http_post( Akismet::build_query( array_merge( array(
|
744 |
-
'user_id' => $user_id,
|
745 |
-
'api_key' => $api_key,
|
746 |
-
'get_account_type' => 'true'
|
747 |
-
), $extra ) ), 'verify-wpcom-key' );
|
748 |
-
|
749 |
-
if ( ! empty( $akismet_account[1] ) )
|
750 |
-
$akismet_account = json_decode( $akismet_account[1] );
|
751 |
-
|
752 |
-
Akismet::log( compact( 'akismet_account' ) );
|
753 |
-
|
754 |
-
return $akismet_account;
|
755 |
-
}
|
756 |
-
|
757 |
-
public static function connect_jetpack_user() {
|
758 |
-
|
759 |
-
if ( $jetpack_user = self::get_jetpack_user() ) {
|
760 |
-
if ( isset( $jetpack_user['user_id'] ) && isset( $jetpack_user['api_key'] ) ) {
|
761 |
-
$akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'], array( 'action' => 'connect_jetpack_user' ) );
|
762 |
-
|
763 |
-
if ( is_object( $akismet_user ) ) {
|
764 |
-
self::save_key( $akismet_user->api_key );
|
765 |
-
return in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) );
|
766 |
-
}
|
767 |
-
}
|
768 |
-
}
|
769 |
-
|
770 |
-
return false;
|
771 |
-
}
|
772 |
-
|
773 |
-
public static function display_alert() {
|
774 |
-
Akismet::view( 'notice', array(
|
775 |
-
'type' => 'alert',
|
776 |
-
'code' => (int) get_option( 'akismet_alert_code' ),
|
777 |
-
'msg' => get_option( 'akismet_alert_msg' )
|
778 |
-
) );
|
779 |
-
}
|
780 |
-
|
781 |
-
public static function display_spam_check_warning() {
|
782 |
-
Akismet::fix_scheduled_recheck();
|
783 |
-
|
784 |
-
if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::get_number_spam_waiting() > 0 ) {
|
785 |
-
$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() ) ) );
|
786 |
-
Akismet::view( 'notice', array( 'type' => 'spam-check', 'link_text' => $link_text ) );
|
787 |
-
}
|
788 |
-
}
|
789 |
-
|
790 |
-
public static function display_invalid_version() {
|
791 |
-
Akismet::view( 'notice', array( 'type' => 'version' ) );
|
792 |
-
}
|
793 |
-
|
794 |
-
public static function display_api_key_warning() {
|
795 |
-
Akismet::view( 'notice', array( 'type' => 'plugin' ) );
|
796 |
-
}
|
797 |
-
|
798 |
-
public static function display_page() {
|
799 |
-
if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) )
|
800 |
-
self::display_start_page();
|
801 |
-
elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' )
|
802 |
-
self::display_stats_page();
|
803 |
-
else
|
804 |
-
self::display_configuration_page();
|
805 |
-
}
|
806 |
-
|
807 |
-
public static function display_start_page() {
|
808 |
-
if ( isset( $_GET['action'] ) ) {
|
809 |
-
if ( $_GET['action'] == 'delete-key' ) {
|
810 |
-
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], self::NONCE ) )
|
811 |
-
delete_option( 'wordpress_api_key' );
|
812 |
-
}
|
813 |
-
}
|
814 |
-
|
815 |
-
if ( $api_key = Akismet::get_api_key() && ( empty( self::$notices['status'] ) || 'existing-key-invalid' != self::$notices['status'] ) ) {
|
816 |
-
self::display_configuration_page();
|
817 |
-
return;
|
818 |
-
}
|
819 |
-
|
820 |
-
//the user can choose to auto connect their API key by clicking a button on the akismet done page
|
821 |
-
//if jetpack, get verified api key by using connected wpcom user id
|
822 |
-
//if no jetpack, get verified api key by using an akismet token
|
823 |
-
|
824 |
-
$akismet_user = false;
|
825 |
-
|
826 |
-
if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) )
|
827 |
-
$akismet_user = self::verify_wpcom_key( '', '', array( 'token' => $_GET['token'] ) );
|
828 |
-
elseif ( $jetpack_user = self::get_jetpack_user() )
|
829 |
-
$akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] );
|
830 |
-
|
831 |
-
if ( isset( $_GET['action'] ) ) {
|
832 |
-
if ( $_GET['action'] == 'save-key' ) {
|
833 |
-
if ( is_object( $akismet_user ) ) {
|
834 |
-
self::save_key( $akismet_user->api_key );
|
835 |
-
self::display_notice();
|
836 |
-
self::display_configuration_page();
|
837 |
-
return;
|
838 |
-
}
|
839 |
-
}
|
840 |
-
}
|
841 |
-
|
842 |
-
echo '<h2 class="ak-header">'.esc_html__('Akismet', 'akismet').'</h2>';
|
843 |
-
|
844 |
-
self::display_status();
|
845 |
-
|
846 |
-
Akismet::view( 'start', compact( 'akismet_user' ) );
|
847 |
-
}
|
848 |
-
|
849 |
-
public static function display_stats_page() {
|
850 |
-
Akismet::view( 'stats' );
|
851 |
-
}
|
852 |
-
|
853 |
-
public static function display_configuration_page() {
|
854 |
-
$api_key = Akismet::get_api_key();
|
855 |
-
$akismet_user = self::get_akismet_user( $api_key );
|
856 |
-
|
857 |
-
if ( ! $akismet_user ) {
|
858 |
-
// This could happen if the user's key became invalid after it was previously valid and successfully set up.
|
859 |
-
self::$notices['status'] = 'existing-key-invalid';
|
860 |
-
self::display_start_page();
|
861 |
-
return;
|
862 |
-
}
|
863 |
-
|
864 |
-
$stat_totals = self::get_stats( $api_key );
|
865 |
-
|
866 |
-
// If unset, create the new strictness option using the old discard option to determine its default
|
867 |
-
if ( get_option( 'akismet_strictness' ) === false )
|
868 |
-
add_option( 'akismet_strictness', (get_option('akismet_discard_month') === 'true' ? '1' : '0') );
|
869 |
-
|
870 |
-
if ( empty( self::$notices ) ) {
|
871 |
-
//show status
|
872 |
-
if ( ! empty( $stat_totals['all'] ) && isset( $stat_totals['all']->time_saved ) && $akismet_user->status == 'active' && $akismet_user->account_type == 'free-api-key' ) {
|
873 |
-
|
874 |
-
$time_saved = false;
|
875 |
-
|
876 |
-
if ( $stat_totals['all']->time_saved > 1800 ) {
|
877 |
-
$total_in_minutes = round( $stat_totals['all']->time_saved / 60 );
|
878 |
-
$total_in_hours = round( $total_in_minutes / 60 );
|
879 |
-
$total_in_days = round( $total_in_hours / 8 );
|
880 |
-
$cleaning_up = __( 'Cleaning up spam takes time.' , 'akismet');
|
881 |
-
|
882 |
-
if ( $total_in_days > 1 )
|
883 |
-
$time_saved = $cleaning_up . ' ' . sprintf( __( 'Akismet has saved you %s days!' , 'akismet'), number_format_i18n( $total_in_days ) );
|
884 |
-
elseif ( $total_in_hours > 1 )
|
885 |
-
$time_saved = $cleaning_up . ' ' . sprintf( __( 'Akismet has saved you %d hours!' , 'akismet'), $total_in_hours );
|
886 |
-
elseif ( $total_in_minutes >= 30 )
|
887 |
-
$time_saved = $cleaning_up . ' ' . sprintf( __( 'Akismet has saved you %d minutes!' , 'akismet'), $total_in_minutes );
|
888 |
-
}
|
889 |
-
|
890 |
-
Akismet::view( 'notice', array( 'type' => 'active-notice', 'time_saved' => $time_saved ) );
|
891 |
-
}
|
892 |
-
|
893 |
-
if ( !empty( $akismet_user->limit_reached ) && in_array( $akismet_user->limit_reached, array( 'yellow', 'red' ) ) ) {
|
894 |
-
Akismet::view( 'notice', array( 'type' => 'limit-reached', 'level' => $akismet_user->limit_reached ) );
|
895 |
-
}
|
896 |
-
}
|
897 |
-
|
898 |
-
if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing', 'no-sub' ) ) )
|
899 |
-
Akismet::view( 'notice', array( 'type' => $akismet_user->status ) );
|
900 |
-
|
901 |
-
Akismet::log( compact( 'stat_totals', 'akismet_user' ) );
|
902 |
-
Akismet::view( 'config', compact( 'api_key', 'akismet_user', 'stat_totals' ) );
|
903 |
-
}
|
904 |
-
|
905 |
-
public static function display_notice() {
|
906 |
-
global $hook_suffix;
|
907 |
-
|
908 |
-
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 ) {
|
909 |
-
Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state
|
910 |
-
|
911 |
-
if ( get_option( 'akismet_alert_code' ) > 0 )
|
912 |
-
self::display_alert();
|
913 |
-
}
|
914 |
-
elseif ( $hook_suffix == 'plugins.php' && !Akismet::get_api_key() ) {
|
915 |
-
self::display_api_key_warning();
|
916 |
-
}
|
917 |
-
elseif ( $hook_suffix == 'edit-comments.php' && wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
|
918 |
-
self::display_spam_check_warning();
|
919 |
-
}
|
920 |
-
elseif ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config' ) ) && Akismet::get_api_key() ) {
|
921 |
-
self::display_status();
|
922 |
-
}
|
923 |
-
}
|
924 |
-
|
925 |
-
public static function display_status() {
|
926 |
-
$type = '';
|
927 |
-
|
928 |
-
if ( !self::get_server_connectivity() )
|
929 |
-
$type = 'servers-be-down';
|
930 |
-
|
931 |
-
if ( !empty( $type ) )
|
932 |
-
Akismet::view( 'notice', compact( 'type' ) );
|
933 |
-
elseif ( !empty( self::$notices ) ) {
|
934 |
-
foreach ( self::$notices as $type )
|
935 |
-
Akismet::view( 'notice', compact( 'type' ) );
|
936 |
-
}
|
937 |
-
}
|
938 |
-
|
939 |
-
private static function get_jetpack_user() {
|
940 |
-
if ( !class_exists('Jetpack') )
|
941 |
-
return false;
|
942 |
-
|
943 |
-
Jetpack::load_xml_rpc_client();
|
944 |
-
$xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) );
|
945 |
-
|
946 |
-
$xml->addCall( 'wpcom.getUserID' );
|
947 |
-
$xml->addCall( 'akismet.getAPIKey' );
|
948 |
-
$xml->query();
|
949 |
-
|
950 |
-
Akismet::log( compact( 'xml' ) );
|
951 |
-
|
952 |
-
if ( !$xml->isError() ) {
|
953 |
-
$responses = $xml->getResponse();
|
954 |
-
if ( count( $responses ) > 1 ) {
|
955 |
-
$api_key = array_shift( $responses[0] );
|
956 |
-
$user_id = (int) array_shift( $responses[1] );
|
957 |
-
return compact( 'api_key', 'user_id' );
|
958 |
-
}
|
959 |
-
}
|
960 |
-
return false;
|
961 |
-
}
|
962 |
-
|
963 |
-
/**
|
964 |
-
* Some commentmeta isn't useful in an export file. Suppress it (when supported).
|
965 |
-
*
|
966 |
-
* @param bool $exclude
|
967 |
-
* @param string $key The meta key
|
968 |
-
* @param object $meta The meta object
|
969 |
-
* @return bool Whether to exclude this meta entry from the export.
|
970 |
-
*/
|
971 |
-
public static function exclude_commentmeta_from_export( $exclude, $key, $meta ) {
|
972 |
-
if ( in_array( $key, array( 'akismet_as_submitted', 'akismet_rechecking', 'akismet_delayed_moderation_email' ) ) ) {
|
973 |
-
return true;
|
974 |
-
}
|
975 |
-
|
976 |
-
return $exclude;
|
977 |
-
}
|
978 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class.akismet.php
DELETED
@@ -1,1153 +0,0 @@
|
|
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 |
-
if ( '3.0.5' == $GLOBALS['wp_version'] ) {
|
50 |
-
remove_filter( 'comment_text', 'wp_kses_data' );
|
51 |
-
if ( is_admin() )
|
52 |
-
add_filter( 'comment_text', 'wp_kses_post' );
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
public static function get_api_key() {
|
57 |
-
return apply_filters( 'akismet_get_api_key', defined('WPCOM_API_KEY') ? constant('WPCOM_API_KEY') : get_option('wordpress_api_key') );
|
58 |
-
}
|
59 |
-
|
60 |
-
public static function check_key_status( $key, $ip = null ) {
|
61 |
-
return self::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option('home') ) ), 'verify-key', $ip );
|
62 |
-
}
|
63 |
-
|
64 |
-
public static function verify_key( $key, $ip = null ) {
|
65 |
-
$response = self::check_key_status( $key, $ip );
|
66 |
-
|
67 |
-
if ( $response[1] != 'valid' && $response[1] != 'invalid' )
|
68 |
-
return 'failed';
|
69 |
-
|
70 |
-
return $response[1];
|
71 |
-
}
|
72 |
-
|
73 |
-
public static function deactivate_key( $key ) {
|
74 |
-
$response = self::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option('home') ) ), 'deactivate' );
|
75 |
-
|
76 |
-
if ( $response[1] != 'deactivated' )
|
77 |
-
return 'failed';
|
78 |
-
|
79 |
-
return $response[1];
|
80 |
-
}
|
81 |
-
|
82 |
-
public static function auto_check_comment( $commentdata ) {
|
83 |
-
self::$last_comment_result = null;
|
84 |
-
|
85 |
-
$comment = $commentdata;
|
86 |
-
|
87 |
-
$comment['user_ip'] = self::get_ip_address();
|
88 |
-
$comment['user_agent'] = self::get_user_agent();
|
89 |
-
$comment['referrer'] = self::get_referer();
|
90 |
-
$comment['blog'] = get_option('home');
|
91 |
-
$comment['blog_lang'] = get_locale();
|
92 |
-
$comment['blog_charset'] = get_option('blog_charset');
|
93 |
-
$comment['permalink'] = get_permalink( $comment['comment_post_ID'] );
|
94 |
-
|
95 |
-
if ( !empty( $comment['user_ID'] ) )
|
96 |
-
$comment['user_role'] = Akismet::get_user_roles( $comment['user_ID'] );
|
97 |
-
|
98 |
-
$akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
99 |
-
$comment['akismet_comment_nonce'] = 'inactive';
|
100 |
-
if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
|
101 |
-
$comment['akismet_comment_nonce'] = 'failed';
|
102 |
-
if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
|
103 |
-
$comment['akismet_comment_nonce'] = 'passed';
|
104 |
-
|
105 |
-
// comment reply in wp-admin
|
106 |
-
if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
|
107 |
-
$comment['akismet_comment_nonce'] = 'passed';
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
if ( self::is_test_mode() )
|
112 |
-
$comment['is_test'] = 'true';
|
113 |
-
|
114 |
-
foreach( $_POST as $key => $value ) {
|
115 |
-
if ( is_string( $value ) )
|
116 |
-
$comment["POST_{$key}"] = $value;
|
117 |
-
}
|
118 |
-
|
119 |
-
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
|
120 |
-
|
121 |
-
foreach ( $_SERVER as $key => $value ) {
|
122 |
-
if ( !in_array( $key, $ignore ) && is_string($value) )
|
123 |
-
$comment["$key"] = $value;
|
124 |
-
else
|
125 |
-
$comment["$key"] = '';
|
126 |
-
}
|
127 |
-
|
128 |
-
$post = get_post( $comment['comment_post_ID'] );
|
129 |
-
$comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
|
130 |
-
|
131 |
-
$response = self::http_post( Akismet::build_query( $comment ), 'comment-check' );
|
132 |
-
|
133 |
-
do_action( 'akismet_comment_check_response', $response );
|
134 |
-
|
135 |
-
$commentdata['comment_as_submitted'] = array_intersect_key( $comment, self::$comment_as_submitted_allowed_keys );
|
136 |
-
$commentdata['akismet_result'] = $response[1];
|
137 |
-
|
138 |
-
if ( isset( $response[0]['x-akismet-pro-tip'] ) )
|
139 |
-
$commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
|
140 |
-
|
141 |
-
if ( isset( $response[0]['x-akismet-error'] ) ) {
|
142 |
-
// An error occurred that we anticipated (like a suspended key) and want the user to act on.
|
143 |
-
// Send to moderation.
|
144 |
-
self::$last_comment_result = '0';
|
145 |
-
}
|
146 |
-
else if ( 'true' == $response[1] ) {
|
147 |
-
// akismet_spam_count will be incremented later by comment_is_spam()
|
148 |
-
self::$last_comment_result = 'spam';
|
149 |
-
|
150 |
-
$discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard() );
|
151 |
-
|
152 |
-
do_action( 'akismet_spam_caught', $discard );
|
153 |
-
|
154 |
-
if ( $discard ) {
|
155 |
-
// akismet_result_spam() won't be called so bump the counter here
|
156 |
-
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
157 |
-
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
158 |
-
$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
|
159 |
-
wp_safe_redirect( esc_url_raw( $redirect_to ) );
|
160 |
-
die();
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
// if the response is neither true nor false, hold the comment for moderation and schedule a recheck
|
165 |
-
if ( 'true' != $response[1] && 'false' != $response[1] ) {
|
166 |
-
if ( !current_user_can('moderate_comments') ) {
|
167 |
-
// Comment status should be moderated
|
168 |
-
self::$last_comment_result = '0';
|
169 |
-
}
|
170 |
-
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_single_event') ) {
|
171 |
-
if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
|
172 |
-
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
173 |
-
do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
self::$prevent_moderation_email_for_these_comments[] = $commentdata;
|
178 |
-
}
|
179 |
-
|
180 |
-
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
|
181 |
-
// WP 2.1+: delete old comments daily
|
182 |
-
if ( !wp_next_scheduled( 'akismet_scheduled_delete' ) )
|
183 |
-
wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
|
184 |
-
}
|
185 |
-
elseif ( (mt_rand(1, 10) == 3) ) {
|
186 |
-
// WP 2.0: run this one time in ten
|
187 |
-
self::delete_old_comments();
|
188 |
-
}
|
189 |
-
|
190 |
-
self::set_last_comment( $commentdata );
|
191 |
-
self::fix_scheduled_recheck();
|
192 |
-
|
193 |
-
return $commentdata;
|
194 |
-
}
|
195 |
-
|
196 |
-
public static function get_last_comment() {
|
197 |
-
return self::$last_comment;
|
198 |
-
}
|
199 |
-
|
200 |
-
public static function set_last_comment( $comment ) {
|
201 |
-
if ( is_null( $comment ) ) {
|
202 |
-
self::$last_comment = null;
|
203 |
-
}
|
204 |
-
else {
|
205 |
-
// We filter it here so that it matches the filtered comment data that we'll have to compare against later.
|
206 |
-
// wp_filter_comment expects comment_author_IP
|
207 |
-
self::$last_comment = wp_filter_comment(
|
208 |
-
array_merge(
|
209 |
-
array( 'comment_author_IP' => self::get_ip_address() ),
|
210 |
-
$comment
|
211 |
-
)
|
212 |
-
);
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
// this fires on wp_insert_comment. we can't update comment_meta when auto_check_comment() runs
|
217 |
-
// because we don't know the comment ID at that point.
|
218 |
-
public static function auto_check_update_meta( $id, $comment ) {
|
219 |
-
|
220 |
-
// failsafe for old WP versions
|
221 |
-
if ( !function_exists('add_comment_meta') )
|
222 |
-
return false;
|
223 |
-
|
224 |
-
if ( !isset( self::$last_comment['comment_author_email'] ) )
|
225 |
-
self::$last_comment['comment_author_email'] = '';
|
226 |
-
|
227 |
-
// wp_insert_comment() might be called in other contexts, so make sure this is the same comment
|
228 |
-
// as was checked by auto_check_comment
|
229 |
-
if ( is_object( $comment ) && !empty( self::$last_comment ) && is_array( self::$last_comment ) ) {
|
230 |
-
if ( self::matches_last_comment( $comment ) ) {
|
231 |
-
|
232 |
-
load_plugin_textdomain( 'akismet' );
|
233 |
-
|
234 |
-
// normal result: true or false
|
235 |
-
if ( self::$last_comment['akismet_result'] == 'true' ) {
|
236 |
-
update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
|
237 |
-
self::update_comment_history( $comment->comment_ID, '', 'check-spam' );
|
238 |
-
if ( $comment->comment_approved != 'spam' )
|
239 |
-
self::update_comment_history(
|
240 |
-
$comment->comment_ID,
|
241 |
-
'',
|
242 |
-
'status-changed-'.$comment->comment_approved
|
243 |
-
);
|
244 |
-
}
|
245 |
-
elseif ( self::$last_comment['akismet_result'] == 'false' ) {
|
246 |
-
update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
|
247 |
-
self::update_comment_history( $comment->comment_ID, '', 'check-ham' );
|
248 |
-
if ( $comment->comment_approved == 'spam' ) {
|
249 |
-
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) )
|
250 |
-
self::update_comment_history( $comment->comment_ID, '', 'wp-blacklisted' );
|
251 |
-
else
|
252 |
-
self::update_comment_history( $comment->comment_ID, '', 'status-changed-'.$comment->comment_approved );
|
253 |
-
}
|
254 |
-
} // abnormal result: error
|
255 |
-
else {
|
256 |
-
update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
|
257 |
-
self::update_comment_history(
|
258 |
-
$comment->comment_ID,
|
259 |
-
'',
|
260 |
-
'check-error',
|
261 |
-
array( 'response' => substr( self::$last_comment['akismet_result'], 0, 50 ) )
|
262 |
-
);
|
263 |
-
}
|
264 |
-
|
265 |
-
// record the complete original data as submitted for checking
|
266 |
-
if ( isset( self::$last_comment['comment_as_submitted'] ) )
|
267 |
-
update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', self::$last_comment['comment_as_submitted'] );
|
268 |
-
|
269 |
-
if ( isset( self::$last_comment['akismet_pro_tip'] ) )
|
270 |
-
update_comment_meta( $comment->comment_ID, 'akismet_pro_tip', self::$last_comment['akismet_pro_tip'] );
|
271 |
-
}
|
272 |
-
}
|
273 |
-
}
|
274 |
-
|
275 |
-
public static function delete_old_comments() {
|
276 |
-
global $wpdb;
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Determines how many comments will be deleted in each batch.
|
280 |
-
*
|
281 |
-
* @param int The default, as defined by AKISMET_DELETE_LIMIT.
|
282 |
-
*/
|
283 |
-
$delete_limit = apply_filters( 'akismet_delete_comment_limit', defined( 'AKISMET_DELETE_LIMIT' ) ? AKISMET_DELETE_LIMIT : 10000 );
|
284 |
-
$delete_limit = max( 1, intval( $delete_limit ) );
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Determines how many days a comment will be left in the Spam queue before being deleted.
|
288 |
-
*
|
289 |
-
* @param int The default number of days.
|
290 |
-
*/
|
291 |
-
$delete_interval = apply_filters( 'akismet_delete_comment_interval', 15 );
|
292 |
-
$delete_interval = max( 1, intval( $delete_interval ) );
|
293 |
-
|
294 |
-
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 ) ) ) {
|
295 |
-
if ( empty( $comment_ids ) )
|
296 |
-
return;
|
297 |
-
|
298 |
-
$wpdb->queries = array();
|
299 |
-
|
300 |
-
foreach ( $comment_ids as $comment_id ) {
|
301 |
-
do_action( 'delete_comment', $comment_id );
|
302 |
-
}
|
303 |
-
|
304 |
-
$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
|
305 |
-
|
306 |
-
$wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( $comma_comment_ids )");
|
307 |
-
$wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( $comma_comment_ids )");
|
308 |
-
|
309 |
-
clean_comment_cache( $comment_ids );
|
310 |
-
}
|
311 |
-
|
312 |
-
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number
|
313 |
-
$wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
|
314 |
-
}
|
315 |
-
|
316 |
-
public static function delete_old_comments_meta() {
|
317 |
-
global $wpdb;
|
318 |
-
|
319 |
-
$interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
|
320 |
-
|
321 |
-
# enfore a minimum of 1 day
|
322 |
-
$interval = absint( $interval );
|
323 |
-
if ( $interval < 1 )
|
324 |
-
$interval = 1;
|
325 |
-
|
326 |
-
// akismet_as_submitted meta values are large, so expire them
|
327 |
-
// after $interval days regardless of the comment status
|
328 |
-
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 ) ) ) {
|
329 |
-
if ( empty( $comment_ids ) )
|
330 |
-
return;
|
331 |
-
|
332 |
-
$wpdb->queries = array();
|
333 |
-
|
334 |
-
foreach ( $comment_ids as $comment_id ) {
|
335 |
-
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
|
336 |
-
}
|
337 |
-
}
|
338 |
-
|
339 |
-
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
|
340 |
-
$wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
|
341 |
-
}
|
342 |
-
|
343 |
-
// how many approved comments does this author have?
|
344 |
-
public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
345 |
-
global $wpdb;
|
346 |
-
|
347 |
-
if ( !empty( $user_id ) )
|
348 |
-
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_approved = 1", $user_id ) );
|
349 |
-
|
350 |
-
if ( !empty( $comment_author_email ) )
|
351 |
-
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 ) );
|
352 |
-
|
353 |
-
return 0;
|
354 |
-
}
|
355 |
-
|
356 |
-
// get the full comment history for a given comment, as an array in reverse chronological order
|
357 |
-
public static function get_comment_history( $comment_id ) {
|
358 |
-
|
359 |
-
// failsafe for old WP versions
|
360 |
-
if ( !function_exists('add_comment_meta') )
|
361 |
-
return false;
|
362 |
-
|
363 |
-
$history = get_comment_meta( $comment_id, 'akismet_history', false );
|
364 |
-
usort( $history, array( 'Akismet', '_cmp_time' ) );
|
365 |
-
return $history;
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Log an event for a given comment, storing it in comment_meta.
|
370 |
-
*
|
371 |
-
* @param int $comment_id The ID of the relevant comment.
|
372 |
-
* @param string $message The string description of the event. No longer used.
|
373 |
-
* @param string $event The event code.
|
374 |
-
* @param array $meta Metadata about the history entry. e.g., the user that reported or changed the status of a given comment.
|
375 |
-
*/
|
376 |
-
public static function update_comment_history( $comment_id, $message, $event=null, $meta=null ) {
|
377 |
-
global $current_user;
|
378 |
-
|
379 |
-
// failsafe for old WP versions
|
380 |
-
if ( !function_exists('add_comment_meta') )
|
381 |
-
return false;
|
382 |
-
|
383 |
-
$user = '';
|
384 |
-
|
385 |
-
$event = array(
|
386 |
-
'time' => self::_get_microtime(),
|
387 |
-
'event' => $event,
|
388 |
-
);
|
389 |
-
|
390 |
-
if ( is_object( $current_user ) && isset( $current_user->user_login ) ) {
|
391 |
-
$event['user'] = $current_user->user_login;
|
392 |
-
}
|
393 |
-
|
394 |
-
if ( ! empty( $meta ) ) {
|
395 |
-
$event['meta'] = $meta;
|
396 |
-
}
|
397 |
-
|
398 |
-
// $unique = false so as to allow multiple values per comment
|
399 |
-
$r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
|
400 |
-
}
|
401 |
-
|
402 |
-
public static function check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
|
403 |
-
global $wpdb;
|
404 |
-
|
405 |
-
$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $id ), ARRAY_A );
|
406 |
-
if ( !$c )
|
407 |
-
return;
|
408 |
-
|
409 |
-
$c['user_ip'] = $c['comment_author_IP'];
|
410 |
-
$c['user_agent'] = $c['comment_agent'];
|
411 |
-
$c['referrer'] = '';
|
412 |
-
$c['blog'] = get_option('home');
|
413 |
-
$c['blog_lang'] = get_locale();
|
414 |
-
$c['blog_charset'] = get_option('blog_charset');
|
415 |
-
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
416 |
-
$c['recheck_reason'] = $recheck_reason;
|
417 |
-
|
418 |
-
if ( self::is_test_mode() )
|
419 |
-
$c['is_test'] = 'true';
|
420 |
-
|
421 |
-
$response = self::http_post( Akismet::build_query( $c ), 'comment-check' );
|
422 |
-
|
423 |
-
return ( is_array( $response ) && ! empty( $response[1] ) ) ? $response[1] : false;
|
424 |
-
}
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
public static function transition_comment_status( $new_status, $old_status, $comment ) {
|
429 |
-
|
430 |
-
if ( $new_status == $old_status )
|
431 |
-
return;
|
432 |
-
|
433 |
-
# we don't need to record a history item for deleted comments
|
434 |
-
if ( $new_status == 'delete' )
|
435 |
-
return;
|
436 |
-
|
437 |
-
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
|
438 |
-
return;
|
439 |
-
|
440 |
-
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
|
441 |
-
return;
|
442 |
-
|
443 |
-
// if this is present, it means the status has been changed by a re-check, not an explicit user action
|
444 |
-
if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
|
445 |
-
return;
|
446 |
-
|
447 |
-
global $current_user;
|
448 |
-
$reporter = '';
|
449 |
-
if ( is_object( $current_user ) )
|
450 |
-
$reporter = $current_user->user_login;
|
451 |
-
|
452 |
-
// Assumption alert:
|
453 |
-
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
|
454 |
-
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
|
455 |
-
// determine why the transition_comment_status action was triggered. And there are several different ways by which
|
456 |
-
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
|
457 |
-
// We'll assume that this is an explicit user action if certain POST/GET variables exist.
|
458 |
-
if ( ( isset( $_POST['status'] ) && in_array( $_POST['status'], array( 'spam', 'unspam' ) ) ) ||
|
459 |
-
( isset( $_POST['spam'] ) && (int) $_POST['spam'] == 1 ) ||
|
460 |
-
( isset( $_POST['unspam'] ) && (int) $_POST['unspam'] == 1 ) ||
|
461 |
-
( isset( $_POST['comment_status'] ) && in_array( $_POST['comment_status'], array( 'spam', 'unspam' ) ) ) ||
|
462 |
-
( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'spam', 'unspam' ) ) ) ||
|
463 |
-
( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) )
|
464 |
-
) {
|
465 |
-
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
|
466 |
-
return self::submit_spam_comment( $comment->comment_ID );
|
467 |
-
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
|
468 |
-
return self::submit_nonspam_comment( $comment->comment_ID );
|
469 |
-
}
|
470 |
-
}
|
471 |
-
|
472 |
-
self::update_comment_history( $comment->comment_ID, '', 'status-' . $new_status );
|
473 |
-
}
|
474 |
-
|
475 |
-
public static function submit_spam_comment( $comment_id ) {
|
476 |
-
global $wpdb, $current_user, $current_site;
|
477 |
-
|
478 |
-
$comment_id = (int) $comment_id;
|
479 |
-
|
480 |
-
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
481 |
-
|
482 |
-
if ( !$comment ) // it was deleted
|
483 |
-
return;
|
484 |
-
|
485 |
-
if ( 'spam' != $comment->comment_approved )
|
486 |
-
return;
|
487 |
-
|
488 |
-
// use the original version stored in comment_meta if available
|
489 |
-
$as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
|
490 |
-
|
491 |
-
if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) )
|
492 |
-
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
493 |
-
|
494 |
-
$comment->blog = get_bloginfo('url');
|
495 |
-
$comment->blog_lang = get_locale();
|
496 |
-
$comment->blog_charset = get_option('blog_charset');
|
497 |
-
$comment->permalink = get_permalink($comment->comment_post_ID);
|
498 |
-
|
499 |
-
if ( is_object($current_user) )
|
500 |
-
$comment->reporter = $current_user->user_login;
|
501 |
-
|
502 |
-
if ( is_object($current_site) )
|
503 |
-
$comment->site_domain = $current_site->domain;
|
504 |
-
|
505 |
-
$comment->user_role = '';
|
506 |
-
if ( isset( $comment->user_ID ) )
|
507 |
-
$comment->user_role = Akismet::get_user_roles( $comment->user_ID );
|
508 |
-
|
509 |
-
if ( self::is_test_mode() )
|
510 |
-
$comment->is_test = 'true';
|
511 |
-
|
512 |
-
$post = get_post( $comment->comment_post_ID );
|
513 |
-
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
514 |
-
|
515 |
-
$response = Akismet::http_post( Akismet::build_query( $comment ), 'submit-spam' );
|
516 |
-
if ( $comment->reporter ) {
|
517 |
-
self::update_comment_history( $comment_id, '', 'report-spam' );
|
518 |
-
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
|
519 |
-
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
520 |
-
}
|
521 |
-
|
522 |
-
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
|
523 |
-
}
|
524 |
-
|
525 |
-
public static function submit_nonspam_comment( $comment_id ) {
|
526 |
-
global $wpdb, $current_user, $current_site;
|
527 |
-
|
528 |
-
$comment_id = (int) $comment_id;
|
529 |
-
|
530 |
-
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
531 |
-
if ( !$comment ) // it was deleted
|
532 |
-
return;
|
533 |
-
|
534 |
-
// use the original version stored in comment_meta if available
|
535 |
-
$as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );
|
536 |
-
|
537 |
-
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
|
538 |
-
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
539 |
-
|
540 |
-
$comment->blog = get_bloginfo('url');
|
541 |
-
$comment->blog_lang = get_locale();
|
542 |
-
$comment->blog_charset = get_option('blog_charset');
|
543 |
-
$comment->permalink = get_permalink( $comment->comment_post_ID );
|
544 |
-
$comment->user_role = '';
|
545 |
-
|
546 |
-
if ( is_object($current_user) )
|
547 |
-
$comment->reporter = $current_user->user_login;
|
548 |
-
|
549 |
-
if ( is_object($current_site) )
|
550 |
-
$comment->site_domain = $current_site->domain;
|
551 |
-
|
552 |
-
if ( isset( $comment->user_ID ) )
|
553 |
-
$comment->user_role = Akismet::get_user_roles($comment->user_ID);
|
554 |
-
|
555 |
-
if ( Akismet::is_test_mode() )
|
556 |
-
$comment->is_test = 'true';
|
557 |
-
|
558 |
-
$post = get_post( $comment->comment_post_ID );
|
559 |
-
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
560 |
-
|
561 |
-
$response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );
|
562 |
-
if ( $comment->reporter ) {
|
563 |
-
self::update_comment_history( $comment_id, '', 'report-ham' );
|
564 |
-
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
|
565 |
-
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
566 |
-
}
|
567 |
-
|
568 |
-
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
|
569 |
-
}
|
570 |
-
|
571 |
-
public static function cron_recheck() {
|
572 |
-
global $wpdb;
|
573 |
-
|
574 |
-
$api_key = self::get_api_key();
|
575 |
-
|
576 |
-
$status = self::verify_key( $api_key );
|
577 |
-
if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
|
578 |
-
// since there is currently a problem with the key, reschedule a check for 6 hours hence
|
579 |
-
wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
|
580 |
-
do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status );
|
581 |
-
return false;
|
582 |
-
}
|
583 |
-
|
584 |
-
delete_option('akismet_available_servers');
|
585 |
-
|
586 |
-
$comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error' LIMIT 100" );
|
587 |
-
|
588 |
-
load_plugin_textdomain( 'akismet' );
|
589 |
-
|
590 |
-
foreach ( (array) $comment_errors as $comment_id ) {
|
591 |
-
// if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
|
592 |
-
$comment = get_comment( $comment_id );
|
593 |
-
if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
|
594 |
-
delete_comment_meta( $comment_id, 'akismet_error' );
|
595 |
-
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
|
596 |
-
continue;
|
597 |
-
}
|
598 |
-
|
599 |
-
add_comment_meta( $comment_id, 'akismet_rechecking', true );
|
600 |
-
$status = self::check_db_comment( $comment_id, 'retry' );
|
601 |
-
|
602 |
-
$event = '';
|
603 |
-
if ( $status == 'true' ) {
|
604 |
-
$event = 'cron-retry-spam';
|
605 |
-
} elseif ( $status == 'false' ) {
|
606 |
-
$event = 'cron-retry-ham';
|
607 |
-
}
|
608 |
-
|
609 |
-
// If we got back a legit response then update the comment history
|
610 |
-
// other wise just bail now and try again later. No point in
|
611 |
-
// re-trying all the comments once we hit one failure.
|
612 |
-
if ( !empty( $event ) ) {
|
613 |
-
delete_comment_meta( $comment_id, 'akismet_error' );
|
614 |
-
self::update_comment_history( $comment_id, '', $event );
|
615 |
-
update_comment_meta( $comment_id, 'akismet_result', $status );
|
616 |
-
// make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
|
617 |
-
$comment = get_comment( $comment_id );
|
618 |
-
if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
|
619 |
-
if ( $status == 'true' ) {
|
620 |
-
wp_spam_comment( $comment_id );
|
621 |
-
} elseif ( $status == 'false' ) {
|
622 |
-
// comment is good, but it's still in the pending queue. depending on the moderation settings
|
623 |
-
// we may need to change it to approved.
|
624 |
-
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) )
|
625 |
-
wp_set_comment_status( $comment_id, 1 );
|
626 |
-
else if ( get_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true ) )
|
627 |
-
wp_notify_moderator( $comment_id );
|
628 |
-
}
|
629 |
-
}
|
630 |
-
|
631 |
-
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
|
632 |
-
} else {
|
633 |
-
// If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
|
634 |
-
// send a moderation email now.
|
635 |
-
if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) {
|
636 |
-
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
|
637 |
-
wp_notify_moderator( $comment_id );
|
638 |
-
}
|
639 |
-
|
640 |
-
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
641 |
-
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
642 |
-
do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status );
|
643 |
-
return;
|
644 |
-
}
|
645 |
-
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
646 |
-
}
|
647 |
-
|
648 |
-
$remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
|
649 |
-
if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
|
650 |
-
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
651 |
-
do_action( 'akismet_scheduled_recheck', 'remaining' );
|
652 |
-
}
|
653 |
-
}
|
654 |
-
|
655 |
-
public static function fix_scheduled_recheck() {
|
656 |
-
$future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
|
657 |
-
if ( !$future_check ) {
|
658 |
-
return;
|
659 |
-
}
|
660 |
-
|
661 |
-
if ( get_option( 'akismet_alert_code' ) > 0 ) {
|
662 |
-
return;
|
663 |
-
}
|
664 |
-
|
665 |
-
$check_range = time() + 1200;
|
666 |
-
if ( $future_check > $check_range ) {
|
667 |
-
wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
|
668 |
-
wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
|
669 |
-
do_action( 'akismet_scheduled_recheck', 'fix-scheduled-recheck' );
|
670 |
-
}
|
671 |
-
}
|
672 |
-
|
673 |
-
public static function add_comment_nonce( $post_id ) {
|
674 |
-
echo '<p style="display: none;">';
|
675 |
-
wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
|
676 |
-
echo '</p>';
|
677 |
-
}
|
678 |
-
|
679 |
-
public static function is_test_mode() {
|
680 |
-
return defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE;
|
681 |
-
}
|
682 |
-
|
683 |
-
public static function allow_discard() {
|
684 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
|
685 |
-
return false;
|
686 |
-
if ( is_user_logged_in() )
|
687 |
-
return false;
|
688 |
-
|
689 |
-
return ( get_option( 'akismet_strictness' ) === '1' );
|
690 |
-
}
|
691 |
-
|
692 |
-
public static function get_ip_address() {
|
693 |
-
return isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null;
|
694 |
-
}
|
695 |
-
|
696 |
-
/**
|
697 |
-
* Do these two comments, without checking the comment_ID, "match"?
|
698 |
-
*
|
699 |
-
* @param mixed $comment1 A comment object or array.
|
700 |
-
* @param mixed $comment2 A comment object or array.
|
701 |
-
* @return bool Whether the two comments should be treated as the same comment.
|
702 |
-
*/
|
703 |
-
private static function comments_match( $comment1, $comment2 ) {
|
704 |
-
$comment1 = (array) $comment1;
|
705 |
-
$comment2 = (array) $comment2;
|
706 |
-
|
707 |
-
return (
|
708 |
-
isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] )
|
709 |
-
&& intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] )
|
710 |
-
&& (
|
711 |
-
// The comment author length max is 255 characters, limited by the TINYTEXT column type.
|
712 |
-
substr( $comment1['comment_author'], 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
|
713 |
-
|| substr( stripslashes( $comment1['comment_author'] ), 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
|
714 |
-
|| substr( $comment1['comment_author'], 0, 255 ) == substr( stripslashes( $comment2['comment_author'] ), 0, 255 )
|
715 |
-
)
|
716 |
-
&& (
|
717 |
-
// The email max length is 100 characters, limited by the VARCHAR(100) column type.
|
718 |
-
substr( $comment1['comment_author_email'], 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
|
719 |
-
|| substr( stripslashes( $comment1['comment_author_email'] ), 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
|
720 |
-
|| substr( $comment1['comment_author_email'], 0, 100 ) == substr( stripslashes( $comment2['comment_author_email'] ), 0, 100 )
|
721 |
-
// Very long emails can be truncated and then stripped if the [0:100] substring isn't a valid address.
|
722 |
-
|| ( ! $comment1['comment_author_email'] && strlen( $comment2['comment_author_email'] ) > 100 )
|
723 |
-
|| ( ! $comment2['comment_author_email'] && strlen( $comment1['comment_author_email'] ) > 100 )
|
724 |
-
)
|
725 |
-
);
|
726 |
-
}
|
727 |
-
|
728 |
-
// Does the supplied comment match the details of the one most recently stored in self::$last_comment?
|
729 |
-
public static function matches_last_comment( $comment ) {
|
730 |
-
if ( is_object( $comment ) )
|
731 |
-
$comment = (array) $comment;
|
732 |
-
|
733 |
-
return self::comments_match( self::$last_comment, $comment );
|
734 |
-
}
|
735 |
-
|
736 |
-
private static function get_user_agent() {
|
737 |
-
return isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
738 |
-
}
|
739 |
-
|
740 |
-
private static function get_referer() {
|
741 |
-
return isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
|
742 |
-
}
|
743 |
-
|
744 |
-
// return a comma-separated list of role names for the given user
|
745 |
-
public static function get_user_roles( $user_id ) {
|
746 |
-
$roles = false;
|
747 |
-
|
748 |
-
if ( !class_exists('WP_User') )
|
749 |
-
return false;
|
750 |
-
|
751 |
-
if ( $user_id > 0 ) {
|
752 |
-
$comment_user = new WP_User( $user_id );
|
753 |
-
if ( isset( $comment_user->roles ) )
|
754 |
-
$roles = join( ',', $comment_user->roles );
|
755 |
-
}
|
756 |
-
|
757 |
-
if ( is_multisite() && is_super_admin( $user_id ) ) {
|
758 |
-
if ( empty( $roles ) ) {
|
759 |
-
$roles = 'super_admin';
|
760 |
-
} else {
|
761 |
-
$comment_user->roles[] = 'super_admin';
|
762 |
-
$roles = join( ',', $comment_user->roles );
|
763 |
-
}
|
764 |
-
}
|
765 |
-
|
766 |
-
return $roles;
|
767 |
-
}
|
768 |
-
|
769 |
-
// filter handler used to return a spam result to pre_comment_approved
|
770 |
-
public static function last_comment_status( $approved, $comment ) {
|
771 |
-
// Only do this if it's the correct comment
|
772 |
-
if ( is_null(self::$last_comment_result) || ! self::matches_last_comment( $comment ) ) {
|
773 |
-
self::log( "comment_is_spam mismatched comment, returning unaltered $approved" );
|
774 |
-
return $approved;
|
775 |
-
}
|
776 |
-
|
777 |
-
// bump the counter here instead of when the filter is added to reduce the possibility of overcounting
|
778 |
-
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
779 |
-
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
780 |
-
|
781 |
-
return self::$last_comment_result;
|
782 |
-
}
|
783 |
-
|
784 |
-
/**
|
785 |
-
* If Akismet is temporarily unreachable, we don't want to "spam" the blogger with
|
786 |
-
* moderation emails for comments that will be automatically cleared or spammed on
|
787 |
-
* the next retry.
|
788 |
-
*
|
789 |
-
* For comments that will be rechecked later, empty the list of email addresses that
|
790 |
-
* the moderation email would be sent to.
|
791 |
-
*
|
792 |
-
* @param array $emails An array of email addresses that the moderation email will be sent to.
|
793 |
-
* @param int $comment_id The ID of the relevant comment.
|
794 |
-
* @return array An array of email addresses that the moderation email will be sent to.
|
795 |
-
*/
|
796 |
-
public static function disable_moderation_emails_if_unreachable( $emails, $comment_id ) {
|
797 |
-
if ( ! empty( self::$prevent_moderation_email_for_these_comments ) && ! empty( $emails ) ) {
|
798 |
-
$comment = get_comment( $comment_id );
|
799 |
-
|
800 |
-
foreach ( self::$prevent_moderation_email_for_these_comments as $possible_match ) {
|
801 |
-
if ( self::comments_match( $possible_match, $comment ) ) {
|
802 |
-
update_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true );
|
803 |
-
return array();
|
804 |
-
}
|
805 |
-
}
|
806 |
-
}
|
807 |
-
|
808 |
-
return $emails;
|
809 |
-
}
|
810 |
-
|
811 |
-
public static function _cmp_time( $a, $b ) {
|
812 |
-
return $a['time'] > $b['time'] ? -1 : 1;
|
813 |
-
}
|
814 |
-
|
815 |
-
public static function _get_microtime() {
|
816 |
-
$mtime = explode( ' ', microtime() );
|
817 |
-
return $mtime[1] + $mtime[0];
|
818 |
-
}
|
819 |
-
|
820 |
-
/**
|
821 |
-
* Make a POST request to the Akismet API.
|
822 |
-
*
|
823 |
-
* @param string $request The body of the request.
|
824 |
-
* @param string $path The path for the request.
|
825 |
-
* @param string $ip The specific IP address to hit.
|
826 |
-
* @return array A two-member array consisting of the headers and the response body, both empty in the case of a failure.
|
827 |
-
*/
|
828 |
-
public static function http_post( $request, $path, $ip=null ) {
|
829 |
-
|
830 |
-
$akismet_ua = sprintf( 'WordPress/%s | Akismet/%s', $GLOBALS['wp_version'], constant( 'AKISMET_VERSION' ) );
|
831 |
-
$akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
|
832 |
-
|
833 |
-
$content_length = strlen( $request );
|
834 |
-
|
835 |
-
$api_key = self::get_api_key();
|
836 |
-
$host = self::API_HOST;
|
837 |
-
|
838 |
-
if ( !empty( $api_key ) )
|
839 |
-
$host = $api_key.'.'.$host;
|
840 |
-
|
841 |
-
$http_host = $host;
|
842 |
-
// use a specific IP if provided
|
843 |
-
// needed by Akismet_Admin::check_server_connectivity()
|
844 |
-
if ( $ip && long2ip( ip2long( $ip ) ) ) {
|
845 |
-
$http_host = $ip;
|
846 |
-
}
|
847 |
-
|
848 |
-
$http_args = array(
|
849 |
-
'body' => $request,
|
850 |
-
'headers' => array(
|
851 |
-
'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),
|
852 |
-
'Host' => $host,
|
853 |
-
'User-Agent' => $akismet_ua,
|
854 |
-
),
|
855 |
-
'httpversion' => '1.0',
|
856 |
-
'timeout' => 15
|
857 |
-
);
|
858 |
-
|
859 |
-
$akismet_url = $http_akismet_url = "http://{$http_host}/1.1/{$path}";
|
860 |
-
|
861 |
-
/**
|
862 |
-
* Try SSL first; if that fails, try without it and don't try it again for a while.
|
863 |
-
*/
|
864 |
-
|
865 |
-
$ssl = $ssl_failed = false;
|
866 |
-
|
867 |
-
// Check if SSL requests were disabled fewer than X hours ago.
|
868 |
-
$ssl_disabled = get_option( 'akismet_ssl_disabled' );
|
869 |
-
|
870 |
-
if ( $ssl_disabled && $ssl_disabled < ( time() - 60 * 60 * 24 ) ) { // 24 hours
|
871 |
-
$ssl_disabled = false;
|
872 |
-
delete_option( 'akismet_ssl_disabled' );
|
873 |
-
}
|
874 |
-
else if ( $ssl_disabled ) {
|
875 |
-
do_action( 'akismet_ssl_disabled' );
|
876 |
-
}
|
877 |
-
|
878 |
-
if ( ! $ssl_disabled && function_exists( 'wp_http_supports') && ( $ssl = wp_http_supports( array( 'ssl' ) ) ) ) {
|
879 |
-
$akismet_url = set_url_scheme( $akismet_url, 'https' );
|
880 |
-
|
881 |
-
do_action( 'akismet_https_request_pre' );
|
882 |
-
}
|
883 |
-
|
884 |
-
$response = wp_remote_post( $akismet_url, $http_args );
|
885 |
-
|
886 |
-
Akismet::log( compact( 'akismet_url', 'http_args', 'response' ) );
|
887 |
-
|
888 |
-
if ( $ssl && is_wp_error( $response ) ) {
|
889 |
-
do_action( 'akismet_https_request_failure', $response );
|
890 |
-
|
891 |
-
// Intermittent connection problems may cause the first HTTPS
|
892 |
-
// request to fail and subsequent HTTP requests to succeed randomly.
|
893 |
-
// Retry the HTTPS request once before disabling SSL for a time.
|
894 |
-
$response = wp_remote_post( $akismet_url, $http_args );
|
895 |
-
|
896 |
-
Akismet::log( compact( 'akismet_url', 'http_args', 'response' ) );
|
897 |
-
|
898 |
-
if ( is_wp_error( $response ) ) {
|
899 |
-
$ssl_failed = true;
|
900 |
-
|
901 |
-
do_action( 'akismet_https_request_failure', $response );
|
902 |
-
|
903 |
-
do_action( 'akismet_http_request_pre' );
|
904 |
-
|
905 |
-
// Try the request again without SSL.
|
906 |
-
$response = wp_remote_post( $http_akismet_url, $http_args );
|
907 |
-
|
908 |
-
Akismet::log( compact( 'http_akismet_url', 'http_args', 'response' ) );
|
909 |
-
}
|
910 |
-
}
|
911 |
-
|
912 |
-
if ( is_wp_error( $response ) ) {
|
913 |
-
do_action( 'akismet_request_failure', $response );
|
914 |
-
|
915 |
-
return array( '', '' );
|
916 |
-
}
|
917 |
-
|
918 |
-
if ( $ssl_failed ) {
|
919 |
-
// The request failed when using SSL but succeeded without it. Disable SSL for future requests.
|
920 |
-
update_option( 'akismet_ssl_disabled', time() );
|
921 |
-
|
922 |
-
do_action( 'akismet_https_disabled' );
|
923 |
-
}
|
924 |
-
|
925 |
-
$simplified_response = array( $response['headers'], $response['body'] );
|
926 |
-
|
927 |
-
self::update_alert( $simplified_response );
|
928 |
-
|
929 |
-
return $simplified_response;
|
930 |
-
}
|
931 |
-
|
932 |
-
// given a response from an API call like check_key_status(), update the alert code options if an alert is present.
|
933 |
-
private static function update_alert( $response ) {
|
934 |
-
$code = $msg = null;
|
935 |
-
if ( isset( $response[0]['x-akismet-alert-code'] ) ) {
|
936 |
-
$code = $response[0]['x-akismet-alert-code'];
|
937 |
-
$msg = $response[0]['x-akismet-alert-msg'];
|
938 |
-
}
|
939 |
-
|
940 |
-
// only call update_option() if the value has changed
|
941 |
-
if ( $code != get_option( 'akismet_alert_code' ) ) {
|
942 |
-
if ( ! $code ) {
|
943 |
-
delete_option( 'akismet_alert_code' );
|
944 |
-
delete_option( 'akismet_alert_msg' );
|
945 |
-
}
|
946 |
-
else {
|
947 |
-
update_option( 'akismet_alert_code', $code );
|
948 |
-
update_option( 'akismet_alert_msg', $msg );
|
949 |
-
}
|
950 |
-
}
|
951 |
-
}
|
952 |
-
|
953 |
-
public static function load_form_js() {
|
954 |
-
// WP < 3.3 can't enqueue a script this late in the game and still have it appear in the footer.
|
955 |
-
// Once we drop support for everything pre-3.3, this can change back to a single enqueue call.
|
956 |
-
wp_register_script( 'akismet-form', AKISMET__PLUGIN_URL . '_inc/form.js', array(), AKISMET_VERSION, true );
|
957 |
-
add_action( 'wp_footer', array( 'Akismet', 'print_form_js' ) );
|
958 |
-
add_action( 'admin_footer', array( 'Akismet', 'print_form_js' ) );
|
959 |
-
}
|
960 |
-
|
961 |
-
public static function print_form_js() {
|
962 |
-
wp_print_scripts( 'akismet-form' );
|
963 |
-
}
|
964 |
-
|
965 |
-
public static function inject_ak_js( $fields ) {
|
966 |
-
echo '<p style="display: none;">';
|
967 |
-
echo '<input type="hidden" id="ak_js" name="ak_js" value="' . mt_rand( 0, 250 ) . '"/>';
|
968 |
-
echo '</p>';
|
969 |
-
}
|
970 |
-
|
971 |
-
private static function bail_on_activation( $message, $deactivate = true ) {
|
972 |
-
?>
|
973 |
-
<!doctype html>
|
974 |
-
<html>
|
975 |
-
<head>
|
976 |
-
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
977 |
-
<style>
|
978 |
-
* {
|
979 |
-
text-align: center;
|
980 |
-
margin: 0;
|
981 |
-
padding: 0;
|
982 |
-
font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
|
983 |
-
}
|
984 |
-
p {
|
985 |
-
margin-top: 1em;
|
986 |
-
font-size: 18px;
|
987 |
-
}
|
988 |
-
</style>
|
989 |
-
<body>
|
990 |
-
<p><?php echo esc_html( $message ); ?></p>
|
991 |
-
</body>
|
992 |
-
</html>
|
993 |
-
<?php
|
994 |
-
if ( $deactivate ) {
|
995 |
-
$plugins = get_option( 'active_plugins' );
|
996 |
-
$akismet = plugin_basename( AKISMET__PLUGIN_DIR . 'akismet.php' );
|
997 |
-
$update = false;
|
998 |
-
foreach ( $plugins as $i => $plugin ) {
|
999 |
-
if ( $plugin === $akismet ) {
|
1000 |
-
$plugins[$i] = false;
|
1001 |
-
$update = true;
|
1002 |
-
}
|
1003 |
-
}
|
1004 |
-
|
1005 |
-
if ( $update ) {
|
1006 |
-
update_option( 'active_plugins', array_filter( $plugins ) );
|
1007 |
-
}
|
1008 |
-
}
|
1009 |
-
exit;
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
public static function view( $name, array $args = array() ) {
|
1013 |
-
$args = apply_filters( 'akismet_view_arguments', $args, $name );
|
1014 |
-
|
1015 |
-
foreach ( $args AS $key => $val ) {
|
1016 |
-
$$key = $val;
|
1017 |
-
}
|
1018 |
-
|
1019 |
-
load_plugin_textdomain( 'akismet' );
|
1020 |
-
|
1021 |
-
$file = AKISMET__PLUGIN_DIR . 'views/'. $name . '.php';
|
1022 |
-
|
1023 |
-
include( $file );
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
/**
|
1027 |
-
* Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
|
1028 |
-
* @static
|
1029 |
-
*/
|
1030 |
-
public static function plugin_activation() {
|
1031 |
-
if ( version_compare( $GLOBALS['wp_version'], AKISMET__MINIMUM_WP_VERSION, '<' ) ) {
|
1032 |
-
load_plugin_textdomain( 'akismet' );
|
1033 |
-
|
1034 |
-
$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/');
|
1035 |
-
|
1036 |
-
Akismet::bail_on_activation( $message );
|
1037 |
-
}
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
/**
|
1041 |
-
* Removes all connection options
|
1042 |
-
* @static
|
1043 |
-
*/
|
1044 |
-
public static function plugin_deactivation( ) {
|
1045 |
-
return self::deactivate_key( self::get_api_key() );
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
/**
|
1049 |
-
* Essentially a copy of WP's build_query but one that doesn't expect pre-urlencoded values.
|
1050 |
-
*
|
1051 |
-
* @param array $args An array of key => value pairs
|
1052 |
-
* @return string A string ready for use as a URL query string.
|
1053 |
-
*/
|
1054 |
-
public static function build_query( $args ) {
|
1055 |
-
return _http_build_query( $args, '', '&' );
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
/**
|
1059 |
-
* Log debugging info to the error log.
|
1060 |
-
*
|
1061 |
-
* Enabled when WP_DEBUG_LOG is enabled, but can be disabled via the akismet_debug_log filter.
|
1062 |
-
*
|
1063 |
-
* @param mixed $akismet_debug The data to log.
|
1064 |
-
*/
|
1065 |
-
public static function log( $akismet_debug ) {
|
1066 |
-
if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) {
|
1067 |
-
error_log( print_r( compact( 'akismet_debug' ), true ) );
|
1068 |
-
}
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
public static function pre_check_pingback( $method ) {
|
1072 |
-
if ( $method !== 'pingback.ping' )
|
1073 |
-
return;
|
1074 |
-
|
1075 |
-
global $wp_xmlrpc_server;
|
1076 |
-
|
1077 |
-
if ( !is_object( $wp_xmlrpc_server ) )
|
1078 |
-
return false;
|
1079 |
-
|
1080 |
-
// Lame: tightly coupled with the IXR class.
|
1081 |
-
$args = $wp_xmlrpc_server->message->params;
|
1082 |
-
|
1083 |
-
if ( !empty( $args[1] ) ) {
|
1084 |
-
$post_id = url_to_postid( $args[1] );
|
1085 |
-
|
1086 |
-
// If this gets through the pre-check, make sure we properly identify the outbound request as a pingback verification
|
1087 |
-
Akismet::pingback_forwarded_for( null, $args[0] );
|
1088 |
-
add_filter( 'http_request_args', array( 'Akismet', 'pingback_forwarded_for' ), 10, 2 );
|
1089 |
-
|
1090 |
-
$comment = array(
|
1091 |
-
'comment_author_url' => $args[0],
|
1092 |
-
'comment_post_ID' => $post_id,
|
1093 |
-
'comment_author' => '',
|
1094 |
-
'comment_author_email' => '',
|
1095 |
-
'comment_content' => '',
|
1096 |
-
'comment_type' => 'pingback',
|
1097 |
-
'akismet_pre_check' => '1',
|
1098 |
-
'comment_pingback_target' => $args[1],
|
1099 |
-
);
|
1100 |
-
|
1101 |
-
$comment = Akismet::auto_check_comment( $comment );
|
1102 |
-
|
1103 |
-
if ( isset( $comment['akismet_result'] ) && 'true' == $comment['akismet_result'] ) {
|
1104 |
-
// Lame: tightly coupled with the IXR classes. Unfortunately the action provides no context and no way to return anything.
|
1105 |
-
$wp_xmlrpc_server->error( new IXR_Error( 0, 'Invalid discovery target' ) );
|
1106 |
-
}
|
1107 |
-
}
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
public static function pingback_forwarded_for( $r, $url ) {
|
1111 |
-
static $urls = array();
|
1112 |
-
|
1113 |
-
// Call this with $r == null to prime the callback to add headers on a specific URL
|
1114 |
-
if ( is_null( $r ) && !in_array( $url, $urls ) ) {
|
1115 |
-
$urls[] = $url;
|
1116 |
-
}
|
1117 |
-
|
1118 |
-
// Add X-Pingback-Forwarded-For header, but only for requests to a specific URL (the apparent pingback source)
|
1119 |
-
if ( is_array( $r ) && is_array( $r['headers'] ) && !isset( $r['headers']['X-Pingback-Forwarded-For'] ) && in_array( $url, $urls ) ) {
|
1120 |
-
$remote_ip = preg_replace( '/[^a-fx0-9:.,]/i', '', $_SERVER['REMOTE_ADDR'] );
|
1121 |
-
|
1122 |
-
// Note: this assumes REMOTE_ADDR is correct, and it may not be if a reverse proxy or CDN is in use
|
1123 |
-
$r['headers']['X-Pingback-Forwarded-For'] = $remote_ip;
|
1124 |
-
|
1125 |
-
// Also identify the request as a pingback verification in the UA string so it appears in logs
|
1126 |
-
$r['user-agent'] .= '; verifying pingback from ' . $remote_ip;
|
1127 |
-
}
|
1128 |
-
|
1129 |
-
return $r;
|
1130 |
-
}
|
1131 |
-
|
1132 |
-
/**
|
1133 |
-
* Ensure that we are loading expected scalar values from akismet_as_submitted commentmeta.
|
1134 |
-
*
|
1135 |
-
* @param mixed $meta_value
|
1136 |
-
* @return mixed
|
1137 |
-
*/
|
1138 |
-
private static function sanitize_comment_as_submitted( $meta_value ) {
|
1139 |
-
if ( empty( $meta_value ) ) {
|
1140 |
-
return $meta_value;
|
1141 |
-
}
|
1142 |
-
|
1143 |
-
$meta_value = (array) $meta_value;
|
1144 |
-
|
1145 |
-
foreach ( $meta_value as $key => $value ) {
|
1146 |
-
if ( ! isset( self::$comment_as_submitted_allowed_keys[$key] ) || ! is_scalar( $value ) ) {
|
1147 |
-
unset( $meta_value[$key] );
|
1148 |
-
}
|
1149 |
-
}
|
1150 |
-
|
1151 |
-
return $meta_value;
|
1152 |
-
}
|
1153 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img/logo.png
ADDED
Binary file
|
img/logo@2x.png
ADDED
Binary file
|
index.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?php
|
2 |
-
# Silence is golden.
|
1 |
<?php
|
2 |
+
# Silence is golden.
|
legacy.php
ADDED
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {
|
4 |
+
global $wpdb;
|
5 |
+
|
6 |
+
$page = (int) $page;
|
7 |
+
if ( $page < 2 )
|
8 |
+
$page = 1;
|
9 |
+
|
10 |
+
$per_page = (int) $per_page;
|
11 |
+
if ( $per_page < 1 )
|
12 |
+
$per_page = 50;
|
13 |
+
|
14 |
+
$start = ( $page - 1 ) * $per_page;
|
15 |
+
$end = $start + $per_page;
|
16 |
+
|
17 |
+
if ( $type ) {
|
18 |
+
if ( 'comments' == $type || 'comment' == $type )
|
19 |
+
$type = '';
|
20 |
+
else
|
21 |
+
$type = $wpdb->escape( $type );
|
22 |
+
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");
|
23 |
+
}
|
24 |
+
|
25 |
+
// All
|
26 |
+
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
|
27 |
+
}
|
28 |
+
|
29 |
+
// Totals for each comment type
|
30 |
+
// returns array( type => count, ... )
|
31 |
+
function akismet_spam_totals() {
|
32 |
+
global $wpdb;
|
33 |
+
$totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
|
34 |
+
$return = array();
|
35 |
+
foreach ( $totals as $total )
|
36 |
+
$return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;
|
37 |
+
return $return;
|
38 |
+
}
|
39 |
+
|
40 |
+
function akismet_manage_page() {
|
41 |
+
global $wpdb, $submenu, $wp_db_version;
|
42 |
+
|
43 |
+
// WP 2.7 has its own spam management page
|
44 |
+
if ( 8645 <= $wp_db_version )
|
45 |
+
return;
|
46 |
+
|
47 |
+
$count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());
|
48 |
+
if ( isset( $submenu['edit-comments.php'] ) )
|
49 |
+
add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );
|
50 |
+
elseif ( function_exists('add_management_page') )
|
51 |
+
add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');
|
52 |
+
}
|
53 |
+
|
54 |
+
function akismet_caught() {
|
55 |
+
global $wpdb, $comment, $akismet_caught, $akismet_nonce;
|
56 |
+
|
57 |
+
akismet_recheck_queue();
|
58 |
+
if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
|
59 |
+
check_admin_referer( $akismet_nonce );
|
60 |
+
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
|
61 |
+
die(__('You do not have sufficient permission to moderate comments.'));
|
62 |
+
|
63 |
+
$i = 0;
|
64 |
+
foreach ($_POST['not_spam'] as $comment):
|
65 |
+
$comment = (int) $comment;
|
66 |
+
if ( function_exists('wp_set_comment_status') )
|
67 |
+
wp_set_comment_status($comment, 'approve');
|
68 |
+
else
|
69 |
+
$wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
|
70 |
+
akismet_submit_nonspam_comment($comment);
|
71 |
+
++$i;
|
72 |
+
endforeach;
|
73 |
+
$to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
|
74 |
+
wp_safe_redirect( $to );
|
75 |
+
exit;
|
76 |
+
}
|
77 |
+
if ('delete' == $_POST['action']) {
|
78 |
+
check_admin_referer( $akismet_nonce );
|
79 |
+
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
|
80 |
+
die(__('You do not have sufficient permission to moderate comments.'));
|
81 |
+
|
82 |
+
$delete_time = $wpdb->escape( $_POST['display_time'] );
|
83 |
+
$comment_ids = $wpdb->get_col( "SELECT comment_id FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
|
84 |
+
if ( !empty( $comment_ids ) ) {
|
85 |
+
do_action( 'delete_comment', $comment_ids );
|
86 |
+
$wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
|
87 |
+
wp_cache_delete( 'akismet_spam_count', 'widget' );
|
88 |
+
}
|
89 |
+
$to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
|
90 |
+
wp_safe_redirect( $to );
|
91 |
+
exit;
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( isset( $_GET['recovered'] ) ) {
|
95 |
+
$i = (int) $_GET['recovered'];
|
96 |
+
echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";
|
97 |
+
}
|
98 |
+
|
99 |
+
if (isset( $_GET['deleted'] ) )
|
100 |
+
echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';
|
101 |
+
|
102 |
+
if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )
|
103 |
+
$link = 'edit-comments.php';
|
104 |
+
else
|
105 |
+
$link = 'edit.php';
|
106 |
+
?>
|
107 |
+
<style type="text/css">
|
108 |
+
.akismet-tabs {
|
109 |
+
list-style: none;
|
110 |
+
margin: 0;
|
111 |
+
padding: 0;
|
112 |
+
clear: both;
|
113 |
+
border-bottom: 1px solid #ccc;
|
114 |
+
height: 31px;
|
115 |
+
margin-bottom: 20px;
|
116 |
+
background: #ddd;
|
117 |
+
border-top: 1px solid #bdbdbd;
|
118 |
+
}
|
119 |
+
.akismet-tabs li {
|
120 |
+
float: left;
|
121 |
+
margin: 5px 0 0 20px;
|
122 |
+
}
|
123 |
+
.akismet-tabs a {
|
124 |
+
display: block;
|
125 |
+
padding: 4px .5em 3px;
|
126 |
+
border-bottom: none;
|
127 |
+
color: #036;
|
128 |
+
}
|
129 |
+
.akismet-tabs .active a {
|
130 |
+
background: #fff;
|
131 |
+
border: 1px solid #ccc;
|
132 |
+
border-bottom: none;
|
133 |
+
color: #000;
|
134 |
+
font-weight: bold;
|
135 |
+
padding-bottom: 4px;
|
136 |
+
}
|
137 |
+
#akismetsearch {
|
138 |
+
float: right;
|
139 |
+
margin-top: -.5em;
|
140 |
+
}
|
141 |
+
|
142 |
+
#akismetsearch p {
|
143 |
+
margin: 0;
|
144 |
+
padding: 0;
|
145 |
+
}
|
146 |
+
</style>
|
147 |
+
<div class="wrap">
|
148 |
+
<h2><?php _e('Caught Spam') ?></h2>
|
149 |
+
<?php
|
150 |
+
$count = get_option( 'akismet_spam_count' );
|
151 |
+
if ( $count ) {
|
152 |
+
?>
|
153 |
+
<p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p>
|
154 |
+
<?php
|
155 |
+
}
|
156 |
+
|
157 |
+
$spam_count = akismet_spam_count();
|
158 |
+
|
159 |
+
if ( 0 == $spam_count ) {
|
160 |
+
echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';
|
161 |
+
echo '</div>';
|
162 |
+
} else {
|
163 |
+
echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.').'</p>';
|
164 |
+
?>
|
165 |
+
<?php if ( !isset( $_POST['s'] ) ) { ?>
|
166 |
+
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
167 |
+
<?php akismet_nonce_field($akismet_nonce) ?>
|
168 |
+
<input type="hidden" name="action" value="delete" />
|
169 |
+
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?> <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" />
|
170 |
+
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
|
171 |
+
</form>
|
172 |
+
<?php } ?>
|
173 |
+
</div>
|
174 |
+
<div class="wrap">
|
175 |
+
<?php if ( isset( $_POST['s'] ) ) { ?>
|
176 |
+
<h2><?php _e('Search'); ?></h2>
|
177 |
+
<?php } else { ?>
|
178 |
+
<?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?>
|
179 |
+
<?php } ?>
|
180 |
+
<?php
|
181 |
+
if ( isset( $_POST['s'] ) ) {
|
182 |
+
$s = $wpdb->escape($_POST['s']);
|
183 |
+
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
|
184 |
+
(comment_author LIKE '%$s%' OR
|
185 |
+
comment_author_email LIKE '%$s%' OR
|
186 |
+
comment_author_url LIKE ('%$s%') OR
|
187 |
+
comment_author_IP LIKE ('%$s%') OR
|
188 |
+
comment_content LIKE ('%$s%') ) AND
|
189 |
+
comment_approved = 'spam'
|
190 |
+
ORDER BY comment_date DESC");
|
191 |
+
} else {
|
192 |
+
if ( isset( $_GET['apage'] ) )
|
193 |
+
$page = (int) $_GET['apage'];
|
194 |
+
else
|
195 |
+
$page = 1;
|
196 |
+
|
197 |
+
if ( $page < 2 )
|
198 |
+
$page = 1;
|
199 |
+
|
200 |
+
$current_type = false;
|
201 |
+
if ( isset( $_GET['ctype'] ) )
|
202 |
+
$current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
|
203 |
+
|
204 |
+
$comments = akismet_spam_comments( $current_type, $page );
|
205 |
+
$total = akismet_spam_count( $current_type );
|
206 |
+
$totals = akismet_spam_totals();
|
207 |
+
?>
|
208 |
+
<ul class="akismet-tabs">
|
209 |
+
<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
|
210 |
+
<?php
|
211 |
+
foreach ( $totals as $type => $type_count ) {
|
212 |
+
if ( 'comment' == $type ) {
|
213 |
+
$type = 'comments';
|
214 |
+
$show = __('Comments');
|
215 |
+
} else {
|
216 |
+
$show = ucwords( $type );
|
217 |
+
}
|
218 |
+
$type_count = number_format_i18n( $type_count );
|
219 |
+
$extra = $current_type === $type ? ' class="active"' : '';
|
220 |
+
echo "<li $extra><a href='edit-comments.php?page=akismet-admin&ctype=$type'>$show ($type_count)</a></li>";
|
221 |
+
}
|
222 |
+
do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
|
223 |
+
?>
|
224 |
+
</ul>
|
225 |
+
<?php
|
226 |
+
}
|
227 |
+
|
228 |
+
if ($comments) {
|
229 |
+
?>
|
230 |
+
<form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch">
|
231 |
+
<p> <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />
|
232 |
+
<input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam »')) ?>" /> </p>
|
233 |
+
</form>
|
234 |
+
<?php if ( $total > 50 ) {
|
235 |
+
$total_pages = ceil( $total / 50 );
|
236 |
+
$r = '';
|
237 |
+
if ( 1 < $page ) {
|
238 |
+
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
|
239 |
+
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('« Previous Page') .'</a>' . "\n";
|
240 |
+
}
|
241 |
+
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
|
242 |
+
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
|
243 |
+
if ( $page == $page_num ) :
|
244 |
+
$r .= "<strong>$page_num</strong>\n";
|
245 |
+
else :
|
246 |
+
$p = false;
|
247 |
+
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
|
248 |
+
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
|
249 |
+
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
|
250 |
+
$in = true;
|
251 |
+
elseif ( $in == true ) :
|
252 |
+
$r .= "...\n";
|
253 |
+
$in = false;
|
254 |
+
endif;
|
255 |
+
endif;
|
256 |
+
endfor;
|
257 |
+
}
|
258 |
+
if ( ( $page ) * 50 < $total || -1 == $total ) {
|
259 |
+
$args['apage'] = $page + 1;
|
260 |
+
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page »') .'</a>' . "\n";
|
261 |
+
}
|
262 |
+
echo "<p>$r</p>";
|
263 |
+
?>
|
264 |
+
|
265 |
+
<?php } ?>
|
266 |
+
<form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
267 |
+
<?php akismet_nonce_field($akismet_nonce) ?>
|
268 |
+
<input type="hidden" name="action" value="recover" />
|
269 |
+
<ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;">
|
270 |
+
<?php
|
271 |
+
$i = 0;
|
272 |
+
foreach($comments as $comment) {
|
273 |
+
$i++;
|
274 |
+
$comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
|
275 |
+
$post = get_post($comment->comment_post_ID);
|
276 |
+
$post_title = $post->post_title;
|
277 |
+
if ($i % 2) $class = 'class="alternate"';
|
278 |
+
else $class = '';
|
279 |
+
echo "\n\t<li id='comment-$comment->comment_ID' $class>";
|
280 |
+
?>
|
281 |
+
|
282 |
+
<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
|
283 |
+
|
284 |
+
<?php comment_text() ?>
|
285 |
+
|
286 |
+
<p><label for="spam-<?php echo $comment->comment_ID; ?>">
|
287 |
+
<input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" />
|
288 |
+
<?php _e('Not Spam') ?></label> — <?php comment_date('M j, g:i A'); ?> — [
|
289 |
+
<?php
|
290 |
+
$post = get_post($comment->comment_post_ID);
|
291 |
+
$post_title = wp_specialchars( $post->post_title, 'double' );
|
292 |
+
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
|
293 |
+
?>
|
294 |
+
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] </p>
|
295 |
+
|
296 |
+
|
297 |
+
<?php
|
298 |
+
}
|
299 |
+
?>
|
300 |
+
</ul>
|
301 |
+
<?php if ( $total > 50 ) {
|
302 |
+
$total_pages = ceil( $total / 50 );
|
303 |
+
$r = '';
|
304 |
+
if ( 1 < $page ) {
|
305 |
+
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
|
306 |
+
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('« Previous Page') .'</a>' . "\n";
|
307 |
+
}
|
308 |
+
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
|
309 |
+
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
|
310 |
+
if ( $page == $page_num ) :
|
311 |
+
$r .= "<strong>$page_num</strong>\n";
|
312 |
+
else :
|
313 |
+
$p = false;
|
314 |
+
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
|
315 |
+
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
|
316 |
+
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
|
317 |
+
$in = true;
|
318 |
+
elseif ( $in == true ) :
|
319 |
+
$r .= "...\n";
|
320 |
+
$in = false;
|
321 |
+
endif;
|
322 |
+
endif;
|
323 |
+
endfor;
|
324 |
+
}
|
325 |
+
if ( ( $page ) * 50 < $total || -1 == $total ) {
|
326 |
+
$args['apage'] = $page + 1;
|
327 |
+
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page »') .'</a>' . "\n";
|
328 |
+
}
|
329 |
+
echo "<p>$r</p>";
|
330 |
+
}
|
331 |
+
?>
|
332 |
+
<p class="submit">
|
333 |
+
<input type="submit" name="submit" value="<?php echo attribute_escape(__('De-spam marked comments »')); ?>" />
|
334 |
+
</p>
|
335 |
+
<p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.'); ?></p>
|
336 |
+
</form>
|
337 |
+
<?php
|
338 |
+
} else {
|
339 |
+
?>
|
340 |
+
<p><?php _e('No results found.'); ?></p>
|
341 |
+
<?php } ?>
|
342 |
+
|
343 |
+
<?php if ( !isset( $_POST['s'] ) ) { ?>
|
344 |
+
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
345 |
+
<?php akismet_nonce_field($akismet_nonce) ?>
|
346 |
+
<p><input type="hidden" name="action" value="delete" />
|
347 |
+
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?> <input type="submit" name="Submit" class="button" value="<?php echo attribute_escape(__('Delete all')); ?>" />
|
348 |
+
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
|
349 |
+
</form>
|
350 |
+
<?php } ?>
|
351 |
+
</div>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
add_action('admin_menu', 'akismet_manage_page');
|
357 |
+
|
358 |
+
function redirect_old_akismet_urls( ) {
|
359 |
+
global $wp_db_version;
|
360 |
+
$script_name = array_pop( split( '/', $_SERVER['PHP_SELF'] ) );
|
361 |
+
|
362 |
+
$page = '';
|
363 |
+
if ( !empty( $_GET['page'] ) )
|
364 |
+
$page = $_GET['page'];
|
365 |
+
|
366 |
+
// 2.7 redirect for people who might have bookmarked the old page
|
367 |
+
if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
|
368 |
+
$new_url = esc_url( 'edit-comments.php?comment_status=spam' );
|
369 |
+
wp_safe_redirect( $new_url, 301 );
|
370 |
+
exit;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
add_action( 'admin_init', 'redirect_old_akismet_urls' );
|
374 |
+
|
375 |
+
// For WP <= 2.3.x
|
376 |
+
global $pagenow;
|
377 |
+
|
378 |
+
if ( 'moderation.php' == $pagenow ) {
|
379 |
+
function akismet_recheck_button( $page ) {
|
380 |
+
global $submenu;
|
381 |
+
if ( isset( $submenu['edit-comments.php'] ) )
|
382 |
+
$link = 'edit-comments.php';
|
383 |
+
else
|
384 |
+
$link = 'edit.php';
|
385 |
+
$button = "<a href='$link?page=akismet-admin&recheckqueue=true&noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";
|
386 |
+
$page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );
|
387 |
+
return $page;
|
388 |
+
}
|
389 |
+
|
390 |
+
if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
|
391 |
+
ob_start( 'akismet_recheck_button' );
|
392 |
+
}
|
393 |
+
|
394 |
+
// This option causes tons of FPs, was removed in 2.1
|
395 |
+
function akismet_kill_proxy_check( $option ) { return 0; }
|
396 |
+
add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');
|
readme.txt
CHANGED
@@ -1,26 +1,27 @@
|
|
1 |
=== Akismet ===
|
2 |
-
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal,
|
3 |
-
Tags: akismet, comments, spam
|
4 |
-
Requires at least: 3.
|
5 |
-
Tested up to:
|
6 |
-
Stable tag:
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
-
Akismet checks your comments against the Akismet
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Akismet checks your comments against the Akismet
|
|
|
14 |
|
15 |
-
Major features in Akismet include:
|
16 |
|
17 |
-
*
|
18 |
-
*
|
19 |
-
*
|
20 |
-
* Moderators can see the number of approved comments for each user
|
21 |
-
*
|
22 |
|
23 |
-
PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs
|
24 |
|
25 |
== Installation ==
|
26 |
|
@@ -30,116 +31,20 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
30 |
|
31 |
== Changelog ==
|
32 |
|
33 |
-
=
|
34 |
-
*
|
35 |
-
|
36 |
-
* Fixed a bug that was preventing some users from automatically connecting using Jetpack if they didn't have a current Akismet subscription.
|
37 |
-
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
|
38 |
-
* Error messages and instructions have been simplified to be more understandable.
|
39 |
-
* Link previews are enabled for all links inside comments, not just the author's website link.
|
40 |
-
|
41 |
-
= 3.1.3 =
|
42 |
-
*Release Date - 6 July 2015*
|
43 |
-
|
44 |
-
* 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.
|
45 |
-
|
46 |
-
= 3.1.2 =
|
47 |
-
*Release Date - 7 June 2015*
|
48 |
-
|
49 |
-
* Reduced the amount of space Akismet uses in the commentmeta table.
|
50 |
-
* Fixed a bug where some comments with quotes in the author name weren't getting history entries
|
51 |
-
* Pre-emptive security improvements to ensure that the Akismet plugin can't be used by attackers to compromise a WordPress installation.
|
52 |
-
* 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.
|
53 |
-
* When deactivating the plugin, notify the Akismet API so the site can be marked as inactive.
|
54 |
-
* Clearer error messages.
|
55 |
-
|
56 |
-
= 3.1.1 =
|
57 |
-
*Release Date - 17th March, 2015*
|
58 |
-
|
59 |
-
* Improvements to the "Remove comment author URL" JavaScript
|
60 |
-
* Include the pingback pre-check from the 2.6 branch.
|
61 |
-
|
62 |
-
= 3.1 =
|
63 |
-
*Release Date - 11th March, 2015*
|
64 |
-
|
65 |
-
* Use HTTPS by default for all requests to Akismet.
|
66 |
-
* Fix for a situation where Akismet might strip HTML from a comment.
|
67 |
-
|
68 |
-
= 3.0.4 =
|
69 |
-
*Release Date - 11th December, 2014*
|
70 |
-
|
71 |
-
* Fix to make .htaccess compatible with Apache 2.4.
|
72 |
-
* Fix to allow removal of https author URLs.
|
73 |
-
* Fix to avoid stripping part of the author URL when removing and re-adding.
|
74 |
-
* Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect.
|
75 |
-
* Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account
|
76 |
-
|
77 |
-
= 3.0.3 =
|
78 |
-
*Release Date - 3rd November, 2014*
|
79 |
-
|
80 |
-
* Fix for sending the wrong data to delete_comment action that could have prevented old spam comments from being deleted.
|
81 |
-
* Added a filter to disable logging of Akismet debugging information.
|
82 |
-
* Added a filter for the maximum comment age when deleting old spam comments.
|
83 |
-
* Added a filter for the number per batch when deleting old spam comments.
|
84 |
-
* Removed the "Check for Spam" button from the Spam folder.
|
85 |
-
|
86 |
-
= 3.0.2 =
|
87 |
-
*Release Date - 18th August, 2014*
|
88 |
-
|
89 |
-
* Performance improvements.
|
90 |
-
* Fixed a bug that could truncate the comment data being sent to Akismet for checking.
|
91 |
-
|
92 |
-
= 3.0.1 =
|
93 |
-
*Release Date - 9th July, 2014*
|
94 |
-
|
95 |
-
* Removed dependency on PHP's fsockopen function
|
96 |
-
* Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app
|
97 |
-
* Remove jQuery dependency for comment form JavaScript
|
98 |
-
* Remove unnecessary data from some Akismet comment meta
|
99 |
-
* Suspended keys will now result in all comments being put in moderation, not spam.
|
100 |
-
|
101 |
-
= 3.0.0 =
|
102 |
-
*Release Date - 15th April, 2014*
|
103 |
-
|
104 |
-
* Move Akismet to Settings menu
|
105 |
-
* Drop Akismet Stats menu
|
106 |
-
* Add stats snapshot to Akismet settings
|
107 |
-
* Add Akismet subscription details and status to Akismet settings
|
108 |
-
* Add contextual help for each page
|
109 |
-
* Improve Akismet setup to use Jetpack to automate plugin setup
|
110 |
-
* Fix "Check for Spam" to use AJAX to avoid page timing out
|
111 |
-
* Fix Akismet settings page to be responsive
|
112 |
-
* Drop legacy code
|
113 |
-
* Tidy up CSS and Javascript
|
114 |
-
* Replace the old discard setting with a new "discard pervasive spam" feature.
|
115 |
-
|
116 |
-
= 2.6.0 =
|
117 |
-
*Release Date - 18th March, 2014*
|
118 |
-
|
119 |
-
* Add ajax paging to the check for spam button to handle large volumes of comments
|
120 |
-
* Optimize javascript and add localization support
|
121 |
-
* Fix bug in link to spam comments from right now dashboard widget
|
122 |
-
* Fix bug with deleting old comments to avoid timeouts dealing with large volumes of comments
|
123 |
-
* Include X-Pingback-Forwarded-For header in outbound WordPress pingback verifications
|
124 |
-
* Add pre-check for pingbacks, to stop spam before an outbound verification request is made
|
125 |
|
126 |
= 2.5.9 =
|
127 |
-
*Release Date - 1st August, 2013*
|
128 |
-
|
129 |
* Update 'Already have a key' link to redirect page rather than depend on javascript
|
130 |
* Fix some non-translatable strings to be translatable
|
131 |
* Update Activation banner in plugins page to redirect user to Akismet config page
|
132 |
|
133 |
= 2.5.8 =
|
134 |
-
*Release Date - 20th January, 2013*
|
135 |
-
|
136 |
* Simplify the activation process for new users
|
137 |
* Remove the reporter_ip parameter
|
138 |
* Minor preventative security improvements
|
139 |
|
140 |
= 2.5.7 =
|
141 |
-
*Release Date - 13th December, 2012*
|
142 |
-
|
143 |
* FireFox Stats iframe preview bug
|
144 |
* Fix mshots preview when using https
|
145 |
* Add .htaccess to block direct access to files
|
@@ -149,8 +54,6 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
149 |
* Fix prepare() warnings in WP 3.5
|
150 |
|
151 |
= 2.5.6 =
|
152 |
-
*Release Date - 26th April, 2012*
|
153 |
-
|
154 |
* Prevent retry scheduling problems on sites where wp_cron is misbehaving
|
155 |
* Preload mshot previews
|
156 |
* Modernize the widget code
|
@@ -162,14 +65,10 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
162 |
* Improve error messages when verifying an API key
|
163 |
|
164 |
= 2.5.5 =
|
165 |
-
*Release Date - 11th January, 2012*
|
166 |
-
|
167 |
* Add nonce check for comment author URL remove action
|
168 |
* Fix the settings link
|
169 |
|
170 |
= 2.5.4 =
|
171 |
-
*Release Date - 5th January, 2012*
|
172 |
-
|
173 |
* Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
|
174 |
* Added author URL quick removal functionality
|
175 |
* Added mShot preview on Author URL hover
|
@@ -178,14 +77,11 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
178 |
* Purge old Akismet comment meta data, default of 15 days
|
179 |
|
180 |
= 2.5.3 =
|
181 |
-
*Release Date - 8th Febuary, 2011*
|
182 |
-
|
183 |
* Specify the license is GPL v2 or later
|
184 |
* Fix a bug that could result in orphaned commentmeta entries
|
185 |
* Include hotfix for WordPress 3.0.5 filter issue
|
186 |
|
187 |
= 2.5.2 =
|
188 |
-
*Release Date - 14th January, 2011*
|
189 |
|
190 |
* Properly format the comment count for author counts
|
191 |
* Look for super admins on multisite installs when looking up user roles
|
@@ -195,7 +91,6 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
195 |
* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
|
196 |
|
197 |
= 2.5.1 =
|
198 |
-
*Release Date - 17th December, 2010*
|
199 |
|
200 |
* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
|
201 |
* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
|
@@ -214,7 +109,6 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
214 |
* Hid "flagged by..." notification while on dashboard
|
215 |
|
216 |
= 2.5.0 =
|
217 |
-
*Release Date - 7th December, 2010*
|
218 |
|
219 |
* Track comment actions under 'Akismet Status' on the edit comment screen
|
220 |
* Fix a few remaining deprecated function calls ( props Mike Glendinning )
|
@@ -230,7 +124,6 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
230 |
* New option, "Use a nonce on the comment form."
|
231 |
|
232 |
= 2.4.0 =
|
233 |
-
*Release Date - 23rd August, 2010*
|
234 |
|
235 |
* Spell out that the license is GPLv2
|
236 |
* Fix PHP warnings
|
@@ -240,7 +133,6 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
240 |
* General code clean up
|
241 |
|
242 |
= 2.3.0 =
|
243 |
-
*Release Date - 5th June, 2010*
|
244 |
|
245 |
* Fix "Are you sure" nonce message on config screen in WPMU
|
246 |
* Fix XHTML compliance issue in sidebar widget
|
@@ -248,12 +140,10 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
248 |
* Localize the widget title (core ticket #13879)
|
249 |
|
250 |
= 2.2.9 =
|
251 |
-
*Release Date - 2nd June, 2010*
|
252 |
|
253 |
* Eliminate a potential conflict with some plugins that may cause spurious reports
|
254 |
|
255 |
= 2.2.8 =
|
256 |
-
*Release Date - 27th May, 2010*
|
257 |
|
258 |
* Fix bug in initial comment check for ipv6 addresses
|
259 |
* Report comments as ham when they are moved from spam to moderation
|
@@ -263,14 +153,12 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
263 |
* Better handling of comments by logged-in users
|
264 |
|
265 |
= 2.2.7 =
|
266 |
-
*Release Date - 17th December, 2009*
|
267 |
|
268 |
* Add a new AKISMET_VERSION constant
|
269 |
* Reduce the possibility of over-counting spam when another spam filter plugin is in use
|
270 |
* Disable the connectivity check when the API key is hard-coded for WPMU
|
271 |
|
272 |
= 2.2.6 =
|
273 |
-
*Release Date - 20th July, 2009*
|
274 |
|
275 |
* Fix a global warning introduced in 2.2.5
|
276 |
* Add changelog and additional readme.txt tags
|
@@ -278,12 +166,10 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
278 |
* Support a new WPCOM_API_KEY constant for easier use with WordPress MU
|
279 |
|
280 |
= 2.2.5 =
|
281 |
-
*Release Date - 13th July, 2009*
|
282 |
|
283 |
* Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
|
284 |
|
285 |
= 2.2.4 =
|
286 |
-
*Release Date - 3rd June, 2009*
|
287 |
|
288 |
* Fixed a key problem affecting the stats feature in WordPress MU
|
289 |
* Provide additional blog information in Akismet API calls
|
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 |
|
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 |
* 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 |
* 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 |
* 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 |
* 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 |
* 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 |
* 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 |
* 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 |
* 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 |
* 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 |
* 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
|
views/config.php
DELETED
@@ -1,220 +0,0 @@
|
|
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 esc_html_e( 'Spam blocked' , 'akismet');?>
|
21 |
-
</li>
|
22 |
-
<li>
|
23 |
-
<h3><?php esc_html_e( 'All time' , 'akismet');?></h3>
|
24 |
-
<span><?php echo number_format( $stat_totals['all']->spam );?></span>
|
25 |
-
<?php esc_html_e( 'Spam blocked' , 'akismet');?>
|
26 |
-
</li>
|
27 |
-
<li>
|
28 |
-
<h3><?php esc_html_e( 'Accuracy' , 'akismet');?></h3>
|
29 |
-
<span><?php echo $stat_totals['all']->accuracy; ?>%</span>
|
30 |
-
<?php printf(
|
31 |
-
esc_html(
|
32 |
-
_n( '%s missed spam, %s false positive', '%s missed spam, %s false positives', $stat_totals['all']->false_positives , 'akismet')
|
33 |
-
),
|
34 |
-
number_format( $stat_totals['all']->missed_spam ),
|
35 |
-
number_format( $stat_totals['all']->false_positives )
|
36 |
-
); ?>
|
37 |
-
</li>
|
38 |
-
</ul>
|
39 |
-
<div class="clearfix"></div>
|
40 |
-
</div>
|
41 |
-
<?php endif;?>
|
42 |
-
|
43 |
-
<?php if ( $akismet_user ):?>
|
44 |
-
|
45 |
-
<div id="wpcom-stats-meta-box-container" class="metabox-holder"><?php
|
46 |
-
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
47 |
-
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
48 |
-
?>
|
49 |
-
<script type="text/javascript">
|
50 |
-
jQuery(document).ready( function($) {
|
51 |
-
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
52 |
-
if(typeof postboxes !== 'undefined')
|
53 |
-
postboxes.add_postbox_toggles( 'plugins_page_akismet-key-config' );
|
54 |
-
});
|
55 |
-
</script>
|
56 |
-
<div class="postbox-container" style="width: 55%;margin-right: 10px;">
|
57 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
58 |
-
<div id="referrers" class="postbox ">
|
59 |
-
<div class="handlediv" title="Click to toggle"><br></div>
|
60 |
-
<h3 class="hndle"><span><?php esc_html_e( 'Settings' , 'akismet');?></span></h3>
|
61 |
-
<form name="akismet_conf" id="akismet-conf" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
|
62 |
-
<div class="inside">
|
63 |
-
<table cellspacing="0" class="akismet-settings">
|
64 |
-
<tbody>
|
65 |
-
<?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
|
66 |
-
<tr>
|
67 |
-
<th class="akismet-api-key" width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th>
|
68 |
-
<td width="5%"/>
|
69 |
-
<td align="left">
|
70 |
-
<span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="regular-text code <?php echo $akismet_user->status;?>"></span>
|
71 |
-
</td>
|
72 |
-
</tr>
|
73 |
-
<?php endif; ?>
|
74 |
-
<?php if ( isset( $_GET['ssl_status'] ) ) { ?>
|
75 |
-
<tr>
|
76 |
-
<th align="left" scope="row"><?php esc_html_e( 'SSL Status', 'akismet' ); ?></th>
|
77 |
-
<td></td>
|
78 |
-
<td align="left">
|
79 |
-
<p>
|
80 |
-
<?php
|
81 |
-
|
82 |
-
if ( ! function_exists( 'wp_http_supports' ) ) {
|
83 |
-
?><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
|
84 |
-
}
|
85 |
-
else if ( ! wp_http_supports( array( 'ssl' ) ) ) {
|
86 |
-
?><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
|
87 |
-
}
|
88 |
-
else {
|
89 |
-
$ssl_disabled = get_option( 'akismet_ssl_disabled' );
|
90 |
-
|
91 |
-
if ( $ssl_disabled ) {
|
92 |
-
?><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
|
93 |
-
}
|
94 |
-
else {
|
95 |
-
?><b><?php esc_html_e( 'Enabled.', 'akismet' ); ?></b> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?><?php
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
?>
|
100 |
-
</p>
|
101 |
-
</td>
|
102 |
-
</tr>
|
103 |
-
<?php } ?>
|
104 |
-
<tr>
|
105 |
-
<th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th>
|
106 |
-
<td></td>
|
107 |
-
<td align="left">
|
108 |
-
<p>
|
109 |
-
<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>
|
110 |
-
</p>
|
111 |
-
</td>
|
112 |
-
</tr>
|
113 |
-
<tr>
|
114 |
-
<th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th>
|
115 |
-
<td></td>
|
116 |
-
<td align="left">
|
117 |
-
<fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
|
118 |
-
<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>
|
119 |
-
<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>
|
120 |
-
</fieldset>
|
121 |
-
<span class="note"><strong><?php esc_html_e('Note:', 'akismet');?></strong>
|
122 |
-
<?php
|
123 |
-
|
124 |
-
$delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
|
125 |
-
|
126 |
-
printf(
|
127 |
-
_n(
|
128 |
-
'Spam in the <a href="%1$s">spam folder</a> older than 1 day is deleted automatically.',
|
129 |
-
'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.',
|
130 |
-
$delete_interval,
|
131 |
-
'akismet'
|
132 |
-
),
|
133 |
-
admin_url( 'edit-comments.php?comment_status=spam' ),
|
134 |
-
$delete_interval
|
135 |
-
);
|
136 |
-
|
137 |
-
?>
|
138 |
-
</td>
|
139 |
-
</tr>
|
140 |
-
</tbody>
|
141 |
-
</table>
|
142 |
-
</div>
|
143 |
-
<div id="major-publishing-actions">
|
144 |
-
<?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
|
145 |
-
<div id="delete-action">
|
146 |
-
<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>
|
147 |
-
</div>
|
148 |
-
<?php endif; ?>
|
149 |
-
<?php wp_nonce_field(Akismet_Admin::NONCE) ?>
|
150 |
-
<div id="publishing-action">
|
151 |
-
<input type="hidden" name="action" value="enter-key">
|
152 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>">
|
153 |
-
|
154 |
-
</div>
|
155 |
-
<div class="clear"></div>
|
156 |
-
</div>
|
157 |
-
</form>
|
158 |
-
</div>
|
159 |
-
</div>
|
160 |
-
</div>
|
161 |
-
<div class="postbox-container" style="width:44%;">
|
162 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
163 |
-
<div id="referrers" class="postbox ">
|
164 |
-
<div class="handlediv" title="Click to toggle"><br></div>
|
165 |
-
<h3 class="hndle"><span><?php esc_html_e( 'Account' , 'akismet');?></span></h3>
|
166 |
-
<div class="inside">
|
167 |
-
<table cellspacing="0">
|
168 |
-
<tbody>
|
169 |
-
<tr>
|
170 |
-
<th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th>
|
171 |
-
<td width="5%"/>
|
172 |
-
<td align="left">
|
173 |
-
<span><?php echo $akismet_user->account_name; ?></span>
|
174 |
-
</td>
|
175 |
-
</tr>
|
176 |
-
<tr>
|
177 |
-
<th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th>
|
178 |
-
<td width="5%"/>
|
179 |
-
<td align="left">
|
180 |
-
<span><?php
|
181 |
-
if ( 'cancelled' == $akismet_user->status ) :
|
182 |
-
esc_html_e( 'Cancelled', 'akismet' );
|
183 |
-
elseif ( 'suspended' == $akismet_user->status ) :
|
184 |
-
esc_html_e( 'Suspended', 'akismet' );
|
185 |
-
elseif ( 'missing' == $akismet_user->status ) :
|
186 |
-
esc_html_e( 'Missing', 'akismet' );
|
187 |
-
elseif ( 'no-sub' == $akismet_user->status ) :
|
188 |
-
esc_html_e( 'No Subscription Found', 'akismet' );
|
189 |
-
else :
|
190 |
-
esc_html_e( 'Active', 'akismet' );
|
191 |
-
endif; ?></span>
|
192 |
-
</td>
|
193 |
-
</tr>
|
194 |
-
<?php if ( $akismet_user->next_billing_date ) : ?>
|
195 |
-
<tr>
|
196 |
-
<th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th>
|
197 |
-
<td width="5%"/>
|
198 |
-
<td align="left">
|
199 |
-
<span><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></span>
|
200 |
-
</td>
|
201 |
-
</tr>
|
202 |
-
<?php endif; ?>
|
203 |
-
</tbody>
|
204 |
-
</table>
|
205 |
-
</div>
|
206 |
-
<div id="major-publishing-actions">
|
207 |
-
<div id="publishing-action">
|
208 |
-
<?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?>
|
209 |
-
</div>
|
210 |
-
<div class="clear"></div>
|
211 |
-
</div>
|
212 |
-
</div>
|
213 |
-
</div>
|
214 |
-
</div>
|
215 |
-
</div>
|
216 |
-
|
217 |
-
<?php endif;?>
|
218 |
-
|
219 |
-
</div>
|
220 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/get.php
DELETED
@@ -1,6 +0,0 @@
|
|
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
DELETED
@@ -1,119 +0,0 @@
|
|
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 == 'missing-functions' ) :?>
|
41 |
-
<div class="wrap alert critical">
|
42 |
-
<h3 class="key-status failed"><?php esc_html_e('Network functions are disabled.', 'akismet'); ?></h3>
|
43 |
-
<p class="description"><?php printf( __('Your web host or server administrator has disabled PHP’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’s system requirements</a>.', 'akismet'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
44 |
-
</div>
|
45 |
-
<?php elseif ( $type == 'servers-be-down' ) :?>
|
46 |
-
<div class="wrap alert critical">
|
47 |
-
<h3 class="key-status failed"><?php esc_html_e("Akismet can’t connect to your site.", 'akismet'); ?></h3>
|
48 |
-
<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>
|
49 |
-
</div>
|
50 |
-
<?php elseif ( $type == 'active-dunning' ) :?>
|
51 |
-
<div class="wrap alert critical">
|
52 |
-
<h3 class="key-status"><?php esc_html_e("Please update your payment information.", 'akismet'); ?></h3>
|
53 |
-
<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>
|
54 |
-
</div>
|
55 |
-
<?php elseif ( $type == 'cancelled' ) :?>
|
56 |
-
<div class="wrap alert critical">
|
57 |
-
<h3 class="key-status"><?php esc_html_e("Your Akismet plan has been cancelled.", 'akismet'); ?></h3>
|
58 |
-
<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>
|
59 |
-
</div>
|
60 |
-
<?php elseif ( $type == 'suspended' ) :?>
|
61 |
-
<div class="wrap alert critical">
|
62 |
-
<h3 class="key-status failed"><?php esc_html_e("Your Akismet subscription is suspended.", 'akismet'); ?></h3>
|
63 |
-
<p class="description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
|
64 |
-
</div>
|
65 |
-
<?php elseif ( $type == 'active-notice' && $time_saved ) :?>
|
66 |
-
<div class="wrap alert active">
|
67 |
-
<h3 class="key-status"><?php echo esc_html( $time_saved ); ?></h3>
|
68 |
-
<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>
|
69 |
-
</div>
|
70 |
-
<?php elseif ( $type == 'missing' ) :?>
|
71 |
-
<div class="wrap alert critical">
|
72 |
-
<h3 class="key-status failed"><?php esc_html_e( 'There is a problem with your API key.', 'akismet'); ?></h3>
|
73 |
-
<p class="description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
|
74 |
-
</div>
|
75 |
-
<?php elseif ( $type == 'no-sub' ) :?>
|
76 |
-
<div class="wrap alert critical">
|
77 |
-
<h3 class="key-status failed"><?php esc_html_e( 'You don’t have an Akismet plan.', 'akismet'); ?></h3>
|
78 |
-
<p class="description">
|
79 |
-
<?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’d appreciate it if you’d <a href="%s" target="_blank">sign into your account</a> and choose one.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?>
|
80 |
-
<br /><br />
|
81 |
-
<?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/' ); ?>
|
82 |
-
</p>
|
83 |
-
</div>
|
84 |
-
<?php elseif ( $type == 'new-key-valid' ) :?>
|
85 |
-
<div class="wrap alert active">
|
86 |
-
<h3 class="key-status"><?php esc_html_e('Akismet is now activated. Happy blogging!', 'akismet'); ?></h3>
|
87 |
-
</div>
|
88 |
-
<?php elseif ( $type == 'new-key-invalid' ) :?>
|
89 |
-
<div class="wrap alert critical">
|
90 |
-
<h3 class="key-status"><?php esc_html_e( 'The key you entered is invalid. Please double-check it.' , 'akismet'); ?></h3>
|
91 |
-
</div>
|
92 |
-
<?php elseif ( $type == 'existing-key-invalid' ) :?>
|
93 |
-
<div class="wrap alert critical">
|
94 |
-
<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>
|
95 |
-
</div>
|
96 |
-
<?php elseif ( $type == 'new-key-failed' ) :?>
|
97 |
-
<div class="wrap alert critical">
|
98 |
-
<h3 class="key-status"><?php esc_html_e( 'The API key you entered could not be verified.' , 'akismet'); ?></h3>
|
99 |
-
<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>
|
100 |
-
</div>
|
101 |
-
<?php elseif ( $type == 'limit-reached' && in_array( $level, array( 'yellow', 'red' ) ) ) :?>
|
102 |
-
<div class="wrap alert critical">
|
103 |
-
<?php if ( $level == 'yellow' ): ?>
|
104 |
-
<h3 class="key-status failed"><?php esc_html_e( 'You’re using your Akismet key on more sites than your Pro subscription allows.', 'akismet' ); ?></h3>
|
105 |
-
<p class="description">
|
106 |
-
<?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/' ); ?>
|
107 |
-
<br /><br />
|
108 |
-
<?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?>
|
109 |
-
</p>
|
110 |
-
<?php elseif ( $level == 'red' ): ?>
|
111 |
-
<h3 class="key-status failed"><?php esc_html_e( 'You’re using Akismet on far too many sites for your Pro subscription.', 'akismet' ); ?></h3>
|
112 |
-
<p class="description">
|
113 |
-
<?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>
|
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/'); ?></p>
|
116 |
-
</p>
|
117 |
-
<?php endif; ?>
|
118 |
-
</div>
|
119 |
-
<?php endif;?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/start.php
DELETED
@@ -1,97 +0,0 @@
|
|
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’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
DELETED
@@ -1,4 +0,0 @@
|
|
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
DELETED
@@ -1,17 +0,0 @@
|
|
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class.akismet-widget.php → widget.php
RENAMED
@@ -5,12 +5,10 @@
|
|
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'
|
13 |
-
array( 'description' => __( 'Display the number of spam comments Akismet has caught'
|
14 |
);
|
15 |
|
16 |
if ( is_active_widget( false, false, $this->id_base ) ) {
|
@@ -25,7 +23,7 @@ class Akismet_Widget extends WP_Widget {
|
|
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,7 +41,7 @@ class Akismet_Widget extends WP_Widget {
|
|
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,19 +61,19 @@ class Akismet_Widget extends WP_Widget {
|
|
63 |
|
64 |
function form( $instance ) {
|
65 |
if ( $instance ) {
|
66 |
-
$title = $instance['title'];
|
67 |
}
|
68 |
else {
|
69 |
-
$title = __( 'Spam Blocked'
|
70 |
}
|
71 |
?>
|
72 |
|
73 |
<p>
|
74 |
-
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php
|
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
|
76 |
</p>
|
77 |
|
78 |
-
<?php
|
79 |
}
|
80 |
|
81 |
function update( $new_instance, $old_instance ) {
|
@@ -95,7 +93,7 @@ class Akismet_Widget extends WP_Widget {
|
|
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
|
99 |
</div>
|
100 |
|
101 |
<?php
|
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 |
.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 |
-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 |
|
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 |
?>
|
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
|
wrapper.php
DELETED
@@ -1,213 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|