Version Description
2013-09-26 = * Fixed: Bug with mass comments deletion * Changed: Russian localization for admin panel * Tested with mulitsite setup (WordPress network or WPMU)
Download this release
Release Info
Developer | shagimuratov |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 2.4.15 |
Comparing to | |
See all releases |
Code changes from version 2.4.14 to 2.4.15
- cleantalk.class.php +897 -857
- cleantalk.php +3 -12
- i18n/cleantalk-ru_RU.mo +0 -0
- readme.txt +26 -5
cleantalk.class.php
CHANGED
@@ -1,857 +1,897 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Cleantalk base class
|
4 |
-
*
|
5 |
-
* @version
|
6 |
-
* @package Cleantalk
|
7 |
-
* @subpackage Base
|
8 |
-
* @author Сleantalk team (welcome@cleantalk.ru)
|
9 |
-
* @copyright (C) 2013 СleanTalk team (http://cleantalk.org)
|
10 |
-
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
11 |
-
* @see http://cleantalk.ru/wiki/doku.php/api
|
12 |
-
*
|
13 |
-
*/
|
14 |
-
|
15 |
-
/**
|
16 |
-
*
|
17 |
-
*/
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
$this->
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
*
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
*
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
*
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
*
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
*
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
*
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
*
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
*
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
*
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
*
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
*
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
*
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
*
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
*
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
*
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
*
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
*
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
*
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
*
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
*
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
*
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
*
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
*
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
*
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
*
|
391 |
-
* @
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
'
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
*
|
413 |
-
* @param CleantalkRequest $request
|
414 |
-
* @return type
|
415 |
-
*/
|
416 |
-
public function
|
417 |
-
$error_params = $this->filterRequest('
|
418 |
-
|
419 |
-
if (!empty($error_params)) {
|
420 |
-
$response = new CleantalkResponse(
|
421 |
-
array(
|
422 |
-
'allow' => 0,
|
423 |
-
'comment' => '
|
424 |
-
), null);
|
425 |
-
|
426 |
-
return $response;
|
427 |
-
}
|
428 |
-
|
429 |
-
$msg = $this->createMsg('
|
430 |
-
return $this->
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
*
|
435 |
-
*
|
436 |
-
* @
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
if (!is_string($value)) {
|
470 |
-
$error_params[] = $param;
|
471 |
-
}
|
472 |
-
}
|
473 |
-
|
474 |
-
if ($param
|
475 |
-
if (!
|
476 |
-
$error_params[] = $param;
|
477 |
-
}
|
478 |
-
}
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
if (
|
515 |
-
$
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
*
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
*
|
556 |
-
* @
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
'
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
$
|
607 |
-
|
608 |
-
$
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
$
|
827 |
-
|
828 |
-
$
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cleantalk base class
|
4 |
+
*
|
5 |
+
* @version 1.21.9
|
6 |
+
* @package Cleantalk
|
7 |
+
* @subpackage Base
|
8 |
+
* @author Сleantalk team (welcome@cleantalk.ru)
|
9 |
+
* @copyright (C) 2013 СleanTalk team (http://cleantalk.org)
|
10 |
+
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
11 |
+
* @see http://cleantalk.ru/wiki/doku.php/api
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Load JSON functions if they are not exists
|
17 |
+
*/
|
18 |
+
if(!function_exists('json_encode')) {
|
19 |
+
require_once 'JSON.php';
|
20 |
+
|
21 |
+
function json_encode($data) {
|
22 |
+
$json = new Services_JSON();
|
23 |
+
return( $json->encode($data) );
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
27 |
+
if(!function_exists('json_decode')) {
|
28 |
+
require_once 'JSON.php';
|
29 |
+
|
30 |
+
function json_decode($data) {
|
31 |
+
$json = new Services_JSON();
|
32 |
+
return( $json->decode($data) );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Response class
|
38 |
+
*/
|
39 |
+
class CleantalkResponse {
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Is stop words
|
43 |
+
* @var int
|
44 |
+
*/
|
45 |
+
public $stop_words = null;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Cleantalk comment
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
public $comment = null;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Is blacklisted
|
55 |
+
* @var int
|
56 |
+
*/
|
57 |
+
public $blacklisted = null;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Is allow, 1|0
|
61 |
+
* @var int
|
62 |
+
*/
|
63 |
+
public $allow = null;
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Request ID
|
67 |
+
* @var int
|
68 |
+
*/
|
69 |
+
public $id = null;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Request errno
|
73 |
+
* @var int
|
74 |
+
*/
|
75 |
+
public $errno = null;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Error string
|
79 |
+
* @var string
|
80 |
+
*/
|
81 |
+
public $errstr = null;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Is fast submit, 1|0
|
85 |
+
* @var string
|
86 |
+
*/
|
87 |
+
public $fast_submit = null;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Is spam comment
|
91 |
+
* @var string
|
92 |
+
*/
|
93 |
+
public $spam = null;
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Is JS
|
97 |
+
* @var type
|
98 |
+
*/
|
99 |
+
public $js_disabled = null;
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Sms check
|
103 |
+
* @var type
|
104 |
+
*/
|
105 |
+
public $sms_allow = null;
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Sms code result
|
109 |
+
* @var type
|
110 |
+
*/
|
111 |
+
public $sms = null;
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Sms error code
|
115 |
+
* @var type
|
116 |
+
*/
|
117 |
+
public $sms_error_code = null;
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Sms error code
|
121 |
+
* @var type
|
122 |
+
*/
|
123 |
+
public $sms_error_text = null;
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Stop queue message, 1|0
|
127 |
+
* @var int
|
128 |
+
*/
|
129 |
+
public $stop_queue = null;
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Account shuld by deactivated after registration, 1|0
|
133 |
+
* @var int
|
134 |
+
*/
|
135 |
+
public $inactive = null;
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Create server response
|
139 |
+
*
|
140 |
+
* @param type $response
|
141 |
+
* @param type $obj
|
142 |
+
*/
|
143 |
+
function __construct($response = null, $obj = null) {
|
144 |
+
if ($response && is_array($response) && count($response) > 0) {
|
145 |
+
foreach ($response as $param => $value) {
|
146 |
+
$this->{$param} = $value;
|
147 |
+
}
|
148 |
+
} else {
|
149 |
+
$this->errno = $obj->errno;
|
150 |
+
$this->errstr = $obj->errstr;
|
151 |
+
|
152 |
+
$this->errstr = preg_replace("/.+(\*\*\*.+\*\*\*).+/", "$1", $this->errstr);
|
153 |
+
// Разбираем ответ с клинтолка
|
154 |
+
$this->stop_words = isset($obj->stop_words) ? $obj->stop_words : null;
|
155 |
+
$this->comment = isset($obj->comment) ? utf8_decode($obj->comment) : null;
|
156 |
+
$this->blacklisted = (isset($obj->blacklisted)) ? $obj->blacklisted : null;
|
157 |
+
$this->allow = (isset($obj->allow)) ? $obj->allow : null;
|
158 |
+
$this->id = (isset($obj->id)) ? $obj->id : null;
|
159 |
+
$this->fast_submit = (isset($obj->fast_submit)) ? $obj->fast_submit : 0;
|
160 |
+
$this->spam = (isset($obj->spam)) ? $obj->spam : 0;
|
161 |
+
$this->js_disabled = (isset($obj->js_disabled)) ? $obj->js_disabled : 0;
|
162 |
+
$this->sms_allow = (isset($obj->sms_allow)) ? $obj->sms_allow : null;
|
163 |
+
$this->sms = (isset($obj->sms)) ? $obj->sms : null;
|
164 |
+
$this->sms_error_code = (isset($obj->sms_error_code)) ? $obj->sms_error_code : null;
|
165 |
+
$this->sms_error_text = (isset($obj->sms_error_text)) ? $obj->sms_error_text : null;
|
166 |
+
$this->stop_queue = (isset($obj->stop_queue)) ? $obj->stop_queue : 0;
|
167 |
+
$this->inactive = (isset($obj->inactive)) ? $obj->inactive : 0;
|
168 |
+
|
169 |
+
if ($this->errno !== 0 && $this->errstr !== null && $this->comment === null)
|
170 |
+
$this->comment = '*** ' . $this->errstr . ' Automoderator cleantalk.org ***';
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Request class
|
178 |
+
*/
|
179 |
+
class CleantalkRequest {
|
180 |
+
|
181 |
+
/**
|
182 |
+
* User message
|
183 |
+
* @var string
|
184 |
+
*/
|
185 |
+
public $message = null;
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Post example with last comments
|
189 |
+
* @var string
|
190 |
+
*/
|
191 |
+
public $example = null;
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Auth key
|
195 |
+
* @var string
|
196 |
+
*/
|
197 |
+
public $auth_key = null;
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Engine
|
201 |
+
* @var string
|
202 |
+
*/
|
203 |
+
public $agent = null;
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Is check for stoplist,
|
207 |
+
* valid are 0|1
|
208 |
+
* @var int
|
209 |
+
*/
|
210 |
+
public $stoplist_check = null;
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Language server response,
|
214 |
+
* valid are 'en' or 'ru'
|
215 |
+
* @var string
|
216 |
+
*/
|
217 |
+
public $response_lang = null;
|
218 |
+
|
219 |
+
/**
|
220 |
+
* User IP
|
221 |
+
* @var strings
|
222 |
+
*/
|
223 |
+
public $sender_ip = null;
|
224 |
+
|
225 |
+
/**
|
226 |
+
* User email
|
227 |
+
* @var strings
|
228 |
+
*/
|
229 |
+
public $sender_email = null;
|
230 |
+
|
231 |
+
/**
|
232 |
+
* User nickname
|
233 |
+
* @var string
|
234 |
+
*/
|
235 |
+
public $sender_nickname = null;
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Sender info JSON string
|
239 |
+
* @var string
|
240 |
+
*/
|
241 |
+
public $sender_info = null;
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Post info JSON string
|
245 |
+
* @var string
|
246 |
+
*/
|
247 |
+
public $post_info = null;
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Is allow links, email and icq,
|
251 |
+
* valid are 1|0
|
252 |
+
* @var int
|
253 |
+
*/
|
254 |
+
public $allow_links = null;
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Time form filling
|
258 |
+
* @var int
|
259 |
+
*/
|
260 |
+
public $submit_time = null;
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Is enable Java Script,
|
264 |
+
* valid are 0|1|2
|
265 |
+
* Status:
|
266 |
+
* null - JS html code not inserted into phpBB templates
|
267 |
+
* 0 - JS disabled at the client browser
|
268 |
+
* 1 - JS enabled at the client broswer
|
269 |
+
* @var int
|
270 |
+
*/
|
271 |
+
public $js_on = null;
|
272 |
+
|
273 |
+
/**
|
274 |
+
* user time zone
|
275 |
+
* @var string
|
276 |
+
*/
|
277 |
+
public $tz = null;
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Feedback string,
|
281 |
+
* valid are 'requset_id:(1|0)'
|
282 |
+
* @var string
|
283 |
+
*/
|
284 |
+
public $feedback = null;
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Phone number
|
288 |
+
* @var type
|
289 |
+
*/
|
290 |
+
public $phone = null;
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Method name
|
294 |
+
* @var string
|
295 |
+
*/
|
296 |
+
public $method_name = 'check_message';
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Fill params with constructor
|
300 |
+
* @param type $params
|
301 |
+
*/
|
302 |
+
public function __construct($params = null) {
|
303 |
+
if (is_array($params) && count($params) > 0) {
|
304 |
+
foreach ($params as $param => $value) {
|
305 |
+
$this->{$param} = $value;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Cleantalk class create request
|
314 |
+
*/
|
315 |
+
class Cleantalk {
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Debug level
|
319 |
+
* @var int
|
320 |
+
*/
|
321 |
+
public $debug = 0;
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Maximum data size in bytes
|
325 |
+
* @var int
|
326 |
+
*/
|
327 |
+
private $dataMaxSise = 32768;
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Data compression rate
|
331 |
+
* @var int
|
332 |
+
*/
|
333 |
+
private $compressRate = 6;
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Server connection timeout in seconds
|
337 |
+
* @var int
|
338 |
+
*/
|
339 |
+
private $server_timeout = 5;
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Cleantalk server url
|
343 |
+
* @var string
|
344 |
+
*/
|
345 |
+
public $server_url = null;
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Last work url
|
349 |
+
* @var string
|
350 |
+
*/
|
351 |
+
public $work_url = null;
|
352 |
+
|
353 |
+
/**
|
354 |
+
* WOrk url ttl
|
355 |
+
* @var int
|
356 |
+
*/
|
357 |
+
public $server_ttl = null;
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Time wotk_url changer
|
361 |
+
* @var int
|
362 |
+
*/
|
363 |
+
public $server_changed = null;
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Flag is change server url
|
367 |
+
* @var bool
|
368 |
+
*/
|
369 |
+
public $server_change = false;
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Use TRUE when need stay on server. Example: send feedback
|
373 |
+
* @var bool
|
374 |
+
*/
|
375 |
+
public $stay_on_server = false;
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Codepage of the data
|
379 |
+
* @var bool
|
380 |
+
*/
|
381 |
+
public $data_codepage = null;
|
382 |
+
|
383 |
+
/**
|
384 |
+
* API version to use
|
385 |
+
* @var string
|
386 |
+
*/
|
387 |
+
public $api_version = '/api2.0';
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Function checks whether it is possible to publish the message
|
391 |
+
* @param CleantalkRequest $request
|
392 |
+
* @return type
|
393 |
+
*/
|
394 |
+
public function isAllowMessage(CleantalkRequest $request) {
|
395 |
+
$error_params = $this->filterRequest('check_message', $request);
|
396 |
+
|
397 |
+
if (!empty($error_params)) {
|
398 |
+
$response = new CleantalkResponse(
|
399 |
+
array(
|
400 |
+
'allow' => 0,
|
401 |
+
'comment' => 'CleanTalk. Request params error: ' . implode(', ', $error_params)
|
402 |
+
), null);
|
403 |
+
|
404 |
+
return $response;
|
405 |
+
}
|
406 |
+
|
407 |
+
$msg = $this->createMsg('check_message', $request);
|
408 |
+
return $this->httpRequest($msg);
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Function checks whether it is possible to publish the message
|
413 |
+
* @param CleantalkRequest $request
|
414 |
+
* @return type
|
415 |
+
*/
|
416 |
+
public function isAllowUser(CleantalkRequest $request) {
|
417 |
+
$error_params = $this->filterRequest('check_newuser', $request);
|
418 |
+
|
419 |
+
if (!empty($error_params)) {
|
420 |
+
$response = new CleantalkResponse(
|
421 |
+
array(
|
422 |
+
'allow' => 0,
|
423 |
+
'comment' => 'CleanTalk. Request params error: ' . implode(', ', $error_params)
|
424 |
+
), null);
|
425 |
+
|
426 |
+
return $response;
|
427 |
+
}
|
428 |
+
|
429 |
+
$msg = $this->createMsg('check_newuser', $request);
|
430 |
+
return $this->httpRequest($msg);
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Function sends the results of manual moderation
|
435 |
+
*
|
436 |
+
* @param CleantalkRequest $request
|
437 |
+
* @return type
|
438 |
+
*/
|
439 |
+
public function sendFeedback(CleantalkRequest $request) {
|
440 |
+
$error_params = $this->filterRequest('send_feedback', $request);
|
441 |
+
|
442 |
+
if (!empty($error_params)) {
|
443 |
+
$response = new CleantalkResponse(
|
444 |
+
array(
|
445 |
+
'allow' => 0,
|
446 |
+
'comment' => 'Cleantalk. Spam protect. Request params error: ' . implode(', ', $error_params)
|
447 |
+
), null);
|
448 |
+
|
449 |
+
return $response;
|
450 |
+
}
|
451 |
+
|
452 |
+
$msg = $this->createMsg('send_feedback', $request);
|
453 |
+
|
454 |
+
return $this->httpRequest($msg);
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Filter request params
|
459 |
+
* @param CleantalkRequest $request
|
460 |
+
* @return type
|
461 |
+
*/
|
462 |
+
private function filterRequest($method, CleantalkRequest $request) {
|
463 |
+
$error_params = array();
|
464 |
+
|
465 |
+
// general and optional
|
466 |
+
foreach ($request as $param => $value) {
|
467 |
+
if (in_array($param, array('message', 'example', 'agent',
|
468 |
+
'sender_info', 'sender_nickname', 'post_info', 'phone')) && !empty($value)) {
|
469 |
+
if (!is_string($value) && !is_integer($value)) {
|
470 |
+
$error_params[] = $param;
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
if (in_array($param, array('stoplist_check', 'allow_links')) && !empty($value)) {
|
475 |
+
if (!in_array($value, array(1, 2))) {
|
476 |
+
$error_params[] = $param;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
if (in_array($param, array('js_on')) && !empty($value)) {
|
481 |
+
if (!is_integer($value)) {
|
482 |
+
$error_params[] = $param;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
if ($param == 'sender_ip' && !empty($value)) {
|
487 |
+
if (!is_string($value)) {
|
488 |
+
$error_params[] = $param;
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
if ($param == 'sender_email' && !empty($value)) {
|
493 |
+
if (!is_string($value)) {
|
494 |
+
$error_params[] = $param;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
if ($param == 'submit_time' && !empty($value)) {
|
499 |
+
if (!is_int($value)) {
|
500 |
+
$error_params[] = $param;
|
501 |
+
}
|
502 |
+
}
|
503 |
+
}
|
504 |
+
|
505 |
+
// special and must be
|
506 |
+
switch ($method) {
|
507 |
+
case 'check_message':
|
508 |
+
break;
|
509 |
+
|
510 |
+
case 'check_newuser':
|
511 |
+
if (empty($request->sender_nickname)) {
|
512 |
+
$error_params[] = 'sender_nickname';
|
513 |
+
}
|
514 |
+
if (empty($request->sender_email)) {
|
515 |
+
$error_params[] = 'sender_email';
|
516 |
+
}
|
517 |
+
break;
|
518 |
+
|
519 |
+
case 'send_feedback':
|
520 |
+
if (empty($request->feedback)) {
|
521 |
+
$error_params[] = 'feedback';
|
522 |
+
}
|
523 |
+
break;
|
524 |
+
}
|
525 |
+
|
526 |
+
return $error_params;
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Compress data and encode to base64
|
531 |
+
* @param type string
|
532 |
+
* @return string
|
533 |
+
*/
|
534 |
+
private function compressData($data = null){
|
535 |
+
|
536 |
+
if (strlen($data) > $this->dataMaxSise && function_exists('gzencode') && function_exists('base64_encode')){
|
537 |
+
|
538 |
+
$localData = gzencode($data, $this->compressRate, FORCE_GZIP);
|
539 |
+
|
540 |
+
if ($localData === false)
|
541 |
+
return $data;
|
542 |
+
|
543 |
+
$localData = base64_encode($localData);
|
544 |
+
|
545 |
+
if ($localData === false)
|
546 |
+
return $data;
|
547 |
+
|
548 |
+
return $localData;
|
549 |
+
}
|
550 |
+
|
551 |
+
return $data;
|
552 |
+
}
|
553 |
+
|
554 |
+
/**
|
555 |
+
* Create msg for cleantalk server
|
556 |
+
* @param type $method
|
557 |
+
* @param CleantalkRequest $request
|
558 |
+
* @return \xmlrpcmsg
|
559 |
+
*/
|
560 |
+
private function createMsg($method, CleantalkRequest $request) {
|
561 |
+
switch ($method) {
|
562 |
+
case 'check_message':
|
563 |
+
// Convert strings to UTF8
|
564 |
+
$request->message = $this->stringToUTF8($request->message, $this->data_codepage);
|
565 |
+
$request->example = $this->stringToUTF8($request->example, $this->data_codepage);
|
566 |
+
$request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
|
567 |
+
$request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
|
568 |
+
|
569 |
+
$request->message = $this->compressData($request->message);
|
570 |
+
$request->example = $this->compressData($request->example);
|
571 |
+
break;
|
572 |
+
|
573 |
+
case 'check_newuser':
|
574 |
+
// Convert strings to UTF8
|
575 |
+
$request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
|
576 |
+
$request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
|
577 |
+
break;
|
578 |
+
|
579 |
+
case 'send_feedback':
|
580 |
+
if (is_array($request->feedback)) {
|
581 |
+
$request->feedback = implode(';', $request->feedback);
|
582 |
+
}
|
583 |
+
break;
|
584 |
+
}
|
585 |
+
|
586 |
+
$request->method_name = $method;
|
587 |
+
|
588 |
+
return $request;
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Send JSON request to servers
|
593 |
+
* @param $msg
|
594 |
+
* @return boolean|\CleantalkResponse
|
595 |
+
*/
|
596 |
+
private function sendRequest($data = null, $url, $server_timeout = 3) {
|
597 |
+
// Convert to array
|
598 |
+
$data = json_decode(json_encode($data), true);
|
599 |
+
|
600 |
+
// Convert to JSON
|
601 |
+
$data = json_encode($data);
|
602 |
+
|
603 |
+
if (isset($this->api_version))
|
604 |
+
$url = $url . $this->api_version;
|
605 |
+
|
606 |
+
$result = false;
|
607 |
+
if(function_exists('curl_init')) {
|
608 |
+
$ch = curl_init();
|
609 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
610 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, $server_timeout);
|
611 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
612 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
613 |
+
// receive server response ...
|
614 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
615 |
+
|
616 |
+
$result = curl_exec($ch);
|
617 |
+
curl_close($ch);
|
618 |
+
} else {
|
619 |
+
$allow_url_fopen = ini_get('allow_url_fopen');
|
620 |
+
if (function_exists('file_get_contents') && isset($allow_url_fopen) && $allow_url_fopen == '1') {
|
621 |
+
$opts = array('http' =>
|
622 |
+
array(
|
623 |
+
'method' => 'POST',
|
624 |
+
'header' => "Content-Type: text/html\r\n",
|
625 |
+
'content' => $data,
|
626 |
+
'timeout' => $server_timeout
|
627 |
+
)
|
628 |
+
);
|
629 |
+
|
630 |
+
$context = stream_context_create($opts);
|
631 |
+
$result = @file_get_contents($url, false, $context);
|
632 |
+
} else {
|
633 |
+
$response = null;
|
634 |
+
$response['errno'] = 1;
|
635 |
+
$response['errstr'] = 'No CURL support compiled in. Disabled allow_url_fopen in php.ini.';
|
636 |
+
$response = json_decode(json_encode($response));
|
637 |
+
|
638 |
+
return $response;
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
$errstr = null;
|
643 |
+
$response = json_decode($result);
|
644 |
+
if ($result !== false && is_object($response)) {
|
645 |
+
$response->errno = 0;
|
646 |
+
$response->errstr = $errstr;
|
647 |
+
} else {
|
648 |
+
if ($result === false)
|
649 |
+
$errstr = 'Failed connect to ' . $url . '.';
|
650 |
+
else
|
651 |
+
$errstr = $result;
|
652 |
+
|
653 |
+
$response = null;
|
654 |
+
$response['errno'] = 1;
|
655 |
+
$response['errstr'] = $errstr;
|
656 |
+
$response = json_decode(json_encode($response));
|
657 |
+
}
|
658 |
+
|
659 |
+
return $response;
|
660 |
+
}
|
661 |
+
|
662 |
+
/**
|
663 |
+
* httpRequest
|
664 |
+
* @param $msg
|
665 |
+
* @return boolean|\CleantalkResponse
|
666 |
+
*/
|
667 |
+
private function httpRequest($msg) {
|
668 |
+
$result = false;
|
669 |
+
if (((isset($this->work_url) && $this->work_url !== '') && ($this->server_changed + $this->server_ttl > time()))
|
670 |
+
|| $this->stay_on_server == true) {
|
671 |
+
|
672 |
+
$url = (!empty($this->work_url)) ? $this->work_url : $this->server_url;
|
673 |
+
|
674 |
+
$result = $this->sendRequest($msg, $url, $this->server_timeout);
|
675 |
+
}
|
676 |
+
|
677 |
+
if (($result === false || $result->errno != 0) && $this->stay_on_server == false) {
|
678 |
+
|
679 |
+
// Split server url to parts
|
680 |
+
preg_match("@^(https?://)([^/:]+)(.*)@i", $this->server_url, $matches);
|
681 |
+
$url_prefix = '';
|
682 |
+
if (isset($matches[1]))
|
683 |
+
$url_prefix = $matches[1];
|
684 |
+
|
685 |
+
$pool = null;
|
686 |
+
if (isset($matches[2]))
|
687 |
+
$pool = $matches[2];
|
688 |
+
|
689 |
+
$url_suffix = '';
|
690 |
+
if (isset($matches[3]))
|
691 |
+
$url_suffix = $matches[3];
|
692 |
+
|
693 |
+
if ($url_prefix === '')
|
694 |
+
$url_prefix = 'http://';
|
695 |
+
|
696 |
+
if (empty($pool)) {
|
697 |
+
return false;
|
698 |
+
} else {
|
699 |
+
|
700 |
+
// Loop until find work server
|
701 |
+
foreach ($this->get_servers_ip($pool) as $server) {
|
702 |
+
if ($server['host'] === 'localhost' || $server['ip'] === null) {
|
703 |
+
$work_url = $server['host'];
|
704 |
+
} else {
|
705 |
+
$server_host = gethostbyaddr($server['ip']);
|
706 |
+
$work_url = $server_host;
|
707 |
+
}
|
708 |
+
$work_url = $url_prefix . $work_url;
|
709 |
+
if (isset($url_suffix))
|
710 |
+
$work_url = $work_url . $url_suffix;
|
711 |
+
|
712 |
+
$this->work_url = $work_url;
|
713 |
+
$this->server_ttl = $server['ttl'];
|
714 |
+
|
715 |
+
$result = $this->sendRequest($msg, $this->work_url, $this->server_timeout);
|
716 |
+
|
717 |
+
if ($result !== false && $result->errno === 0) {
|
718 |
+
$this->server_change = true;
|
719 |
+
break;
|
720 |
+
}
|
721 |
+
}
|
722 |
+
}
|
723 |
+
}
|
724 |
+
|
725 |
+
$response = new CleantalkResponse(null, $result);
|
726 |
+
|
727 |
+
return $response;
|
728 |
+
}
|
729 |
+
|
730 |
+
/**
|
731 |
+
* Function DNS request
|
732 |
+
* @param $host
|
733 |
+
* @return array
|
734 |
+
*/
|
735 |
+
public function get_servers_ip($host) {
|
736 |
+
$response = null;
|
737 |
+
if (!isset($host))
|
738 |
+
return $response;
|
739 |
+
|
740 |
+
if (function_exists('dns_get_record')) {
|
741 |
+
$records = dns_get_record($host, DNS_A);
|
742 |
+
|
743 |
+
if ($records !== FALSE) {
|
744 |
+
foreach ($records as $server) {
|
745 |
+
$response[] = $server;
|
746 |
+
}
|
747 |
+
}
|
748 |
+
}
|
749 |
+
|
750 |
+
if (count($response) == 0 && function_exists('gethostbynamel')) {
|
751 |
+
$records = gethostbynamel($host);
|
752 |
+
|
753 |
+
if ($records !== FALSE) {
|
754 |
+
foreach ($records as $server) {
|
755 |
+
$response[] = array("ip" => $server,
|
756 |
+
"host" => $host,
|
757 |
+
"ttl" => $this->server_ttl
|
758 |
+
);
|
759 |
+
}
|
760 |
+
}
|
761 |
+
}
|
762 |
+
|
763 |
+
if (count($response) == 0) {
|
764 |
+
$response[] = array("ip" => null,
|
765 |
+
"host" => $host,
|
766 |
+
"ttl" => $this->server_ttl
|
767 |
+
);
|
768 |
+
} else {
|
769 |
+
|
770 |
+
// $i - to resolve collisions with localhost and
|
771 |
+
$i = 0;
|
772 |
+
$r_temp = null;
|
773 |
+
foreach ($response as $server) {
|
774 |
+
$ping = $this->httpPing($server['ip']);
|
775 |
+
|
776 |
+
// -1 server is down, skips not reachable server
|
777 |
+
if ($ping != -1)
|
778 |
+
$r_temp[$ping * 10000 + $i] = $server;
|
779 |
+
|
780 |
+
$i++;
|
781 |
+
}
|
782 |
+
if (count($r_temp)){
|
783 |
+
ksort($r_temp);
|
784 |
+
$response = $r_temp;
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
return $response;
|
789 |
+
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Function to get the message hash from Cleantalk.ru comment
|
793 |
+
* @param $message
|
794 |
+
* @return null
|
795 |
+
*/
|
796 |
+
public function getCleantalkCommentHash($message) {
|
797 |
+
$matches = array();
|
798 |
+
if (preg_match('/\n\n\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
|
799 |
+
return $matches[1];
|
800 |
+
else if (preg_match('/\<br.*\>[\n]{0,1}\<br.*\>[\n]{0,1}\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
|
801 |
+
return $matches[1];
|
802 |
+
|
803 |
+
return NULL;
|
804 |
+
}
|
805 |
+
|
806 |
+
/**
|
807 |
+
* Function adds to the post comment Cleantalk.ru
|
808 |
+
* @param $message
|
809 |
+
* @param $comment
|
810 |
+
* @return string
|
811 |
+
*/
|
812 |
+
public function addCleantalkComment($message, $comment) {
|
813 |
+
$comment = preg_match('/\*\*\*(.+)\*\*\*/', $comment, $matches) ? $comment : '*** ' . $comment . ' ***';
|
814 |
+
return $message . "\n\n" . $comment;
|
815 |
+
}
|
816 |
+
|
817 |
+
/**
|
818 |
+
* Function deletes the comment Cleantalk.ru
|
819 |
+
* @param $message
|
820 |
+
* @return mixed
|
821 |
+
*/
|
822 |
+
public function delCleantalkComment($message) {
|
823 |
+
$message = preg_replace('/\n\n\*\*\*.+\*\*\*$/', '', $message);
|
824 |
+
|
825 |
+
// DLE sign cut
|
826 |
+
$message = preg_replace('/<br\s?\/><br\s?\/>\*\*\*.+\*\*\*$/', '', $message);
|
827 |
+
|
828 |
+
$message = preg_replace('/\<br.*\>[\n]{0,1}\<br.*\>[\n]{0,1}\*\*\*.+\*\*\*$/', '', $message);
|
829 |
+
|
830 |
+
return $message;
|
831 |
+
}
|
832 |
+
|
833 |
+
/*
|
834 |
+
Get user IP
|
835 |
+
*/
|
836 |
+
public function ct_session_ip( $data_ip )
|
837 |
+
{
|
838 |
+
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
839 |
+
{
|
840 |
+
$forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? htmlentities($_SERVER['HTTP_X_FORWARDED_FOR']) : '';
|
841 |
+
}
|
842 |
+
|
843 |
+
// 127.0.0.1 usually used at reverse proxy
|
844 |
+
$session_ip = ($data_ip == '127.0.0.1' && !empty($forwarded_for)) ? $forwarded_for : $data_ip;
|
845 |
+
|
846 |
+
return $session_ip;
|
847 |
+
}
|
848 |
+
|
849 |
+
/**
|
850 |
+
* Function to check response time
|
851 |
+
* param string
|
852 |
+
* @return int
|
853 |
+
*/
|
854 |
+
function httpPing($host){
|
855 |
+
|
856 |
+
// Skip localhost ping cause it raise error at fsockopen.
|
857 |
+
// And return minimun value
|
858 |
+
if ($host == 'localhost')
|
859 |
+
return 0.001;
|
860 |
+
|
861 |
+
$starttime = microtime(true);
|
862 |
+
$file = @fsockopen ($host, 80, $errno, $errstr, $this->server_timeout);
|
863 |
+
$stoptime = microtime(true);
|
864 |
+
$status = 0;
|
865 |
+
|
866 |
+
if (!$file) {
|
867 |
+
$status = -1; // Site is down
|
868 |
+
} else {
|
869 |
+
fclose($file);
|
870 |
+
$status = ($stoptime - $starttime);
|
871 |
+
$status = round($status, 4);
|
872 |
+
}
|
873 |
+
|
874 |
+
return $status;
|
875 |
+
}
|
876 |
+
|
877 |
+
/**
|
878 |
+
* Function convert string to UTF8 and removes non UTF8 characters
|
879 |
+
* param string
|
880 |
+
* param string
|
881 |
+
* @return string
|
882 |
+
*/
|
883 |
+
function stringToUTF8($str, $data_codepage = null){
|
884 |
+
if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
|
885 |
+
|
886 |
+
if ($data_codepage !== null)
|
887 |
+
return mb_convert_encoding($str, 'UTF-8', $data_codepage);
|
888 |
+
|
889 |
+
$encoding = mb_detect_encoding($str);
|
890 |
+
return mb_convert_encoding($str, 'UTF-8', $encoding);
|
891 |
+
}
|
892 |
+
|
893 |
+
return $str;
|
894 |
+
}
|
895 |
+
}
|
896 |
+
|
897 |
+
?>
|
cleantalk.php
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: CleanTalk
|
4 |
Plugin URI: http://cleantalk.org/wordpress
|
5 |
Description: It's cloud, invisible, smart antispam for your blog. The plugin doesn't use CAPTCHA, Q&A, math to stop spam bots.
|
6 |
-
Version: 2.4.
|
7 |
Author: СleanTalk team <welcome@cleantalk.ru>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
|
11 |
-
$ct_agent_version = 'wordpress-
|
12 |
|
13 |
add_action('init', 'ct_init_locale');
|
14 |
-
add_action('delete_comment', 'ct_delete_comment_meta'); // param - comment ID
|
15 |
add_action('comment_form', 'ct_add_hidden_fields');
|
16 |
add_action('parse_request', 'ct_set_session');
|
17 |
add_action('admin_notices', 'admin_notice_message');
|
@@ -160,14 +159,6 @@ function ct_init_locale() {
|
|
160 |
}
|
161 |
}
|
162 |
|
163 |
-
/**
|
164 |
-
* Public action 'delete_comment' - Deletes comment's meta before deleting comment
|
165 |
-
* @param int $post_id Post ID, not used
|
166 |
-
*/
|
167 |
-
function ct_delete_comment_meta($comment_id) {
|
168 |
-
delete_comment_meta($comment_id, 'ct_hash');
|
169 |
-
}
|
170 |
-
|
171 |
/**
|
172 |
* Public action 'comment_form' - Adds hidden filed to define avaialbility of client's JavaScript
|
173 |
* @param int $post_id Post ID, not used
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Anti-spam by CleanTalk
|
4 |
Plugin URI: http://cleantalk.org/wordpress
|
5 |
Description: It's cloud, invisible, smart antispam for your blog. The plugin doesn't use CAPTCHA, Q&A, math to stop spam bots.
|
6 |
+
Version: 2.4.15
|
7 |
Author: СleanTalk team <welcome@cleantalk.ru>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
|
11 |
+
$ct_agent_version = 'wordpress-2415';
|
12 |
|
13 |
add_action('init', 'ct_init_locale');
|
|
|
14 |
add_action('comment_form', 'ct_add_hidden_fields');
|
15 |
add_action('parse_request', 'ct_set_session');
|
16 |
add_action('admin_notices', 'admin_notice_message');
|
159 |
}
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
/**
|
163 |
* Public action 'comment_form' - Adds hidden filed to define avaialbility of client's JavaScript
|
164 |
* @param int $post_id Post ID, not used
|
i18n/cleantalk-ru_RU.mo
CHANGED
Binary file
|
readme.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
=== Anti-spam by CleanTalk ===
|
2 |
Contributors: znaeff, default.asp, shagimuratov, aleontiev
|
3 |
-
Tags: spam, antispam, anti-spam, spambot, spam-bot, stop spam, spammers, spamfree, captcha, capcha, captha, catcha, recaptcha, comment, comments, math, cloud, blacklist, puzzle
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 2.4.
|
7 |
License: GPLv2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -19,7 +19,9 @@ Plugin filters spam bots in the comments, spam moves to trash. The plugin is not
|
|
19 |
|
20 |
Also every new comment plugin compares with post and previous comments. If the relevance of the comment is good enough it gets approval at the blog without manual approval. This feature works for English, Russian laguages.
|
21 |
|
22 |
-
|
|
|
|
|
23 |
|
24 |
= Requirements =
|
25 |
WordPress 3.0 at least. PHP 4, 5 with CURL or file_get_contents() function and enabled 'allow_url_fopen' setting.
|
@@ -54,12 +56,21 @@ Plugin works with all WordPress themes. With some themes may not works JavaScrip
|
|
54 |
|
55 |
Please use test email stop_email@example.com for comments. Also you can see comments proccessed by plugin for last 7 days at <a href="http://cleantalk.org/my/show_requests">Control panel</a> or look at folder "Spam" for banned comments.
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
= Why do I need one more anti-spam plugin? =
|
58 |
|
59 |
1. The plugin is more effective than CAPTCHA because use several methods to stop spammers.
|
60 |
1. This plugin stops spam bots automatically, plugin invisible for blog visitors and admins.
|
61 |
1. CleanTalk automatically approves relevant, not spam comments.
|
62 |
|
|
|
|
|
|
|
63 |
== Screenshots ==
|
64 |
|
65 |
1. The comment from spammer (sender blacklisted by IP/Email, comment text not relevant for the post) prohibited to place in the queue WordPress
|
@@ -68,6 +79,11 @@ Please use test email stop_email@example.com for comments. Also you can see comm
|
|
68 |
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
|
|
71 |
= 2.4.14 2013-08-29 =
|
72 |
* Changed: Removed feedback requests to the servers for banned (spam) comments.
|
73 |
|
@@ -167,6 +183,11 @@ Please use test email stop_email@example.com for comments. Also you can see comm
|
|
167 |
* First version
|
168 |
|
169 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
170 |
= 2.4.14 2013-08-29 =
|
171 |
* Changed: Removed feedback requests to the servers for banned (spam) comments.
|
172 |
|
1 |
=== Anti-spam by CleanTalk ===
|
2 |
Contributors: znaeff, default.asp, shagimuratov, aleontiev
|
3 |
+
Tags: spam, antispam, anti-spam, spambot, spam-bot, stop spam, spammers, spamfree, captcha, capcha, captha, catcha, recaptcha, comment, comments, math, cloud, blacklist, puzzle, wpmu, network, multisite, akismet, спам, 垃圾邮件, correo no deseado,
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 3.7
|
6 |
+
Stable tag: 2.4.15
|
7 |
License: GPLv2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
Cloud, smart, invisible anti-spam without CAPTCHA. No spam in the comments.
|
11 |
|
12 |
== Description ==
|
13 |
|
19 |
|
20 |
Also every new comment plugin compares with post and previous comments. If the relevance of the comment is good enough it gets approval at the blog without manual approval. This feature works for English, Russian laguages.
|
21 |
|
22 |
+
The plugin is a client application for anti-spam cloud service <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>. CleanTalk.org daily prevents from spam 3 000 blogs, blocks up to 300 000 spam bots attacks and approves up to 2 000 not spam comments.
|
23 |
+
|
24 |
+
The plugin is WordPress MultiUser (WPMU or WordPress network) compatible. Each blog in multisite environment has individual anitspam options for spam bots protection.
|
25 |
|
26 |
= Requirements =
|
27 |
WordPress 3.0 at least. PHP 4, 5 with CURL or file_get_contents() function and enabled 'allow_url_fopen' setting.
|
56 |
|
57 |
Please use test email stop_email@example.com for comments. Also you can see comments proccessed by plugin for last 7 days at <a href="http://cleantalk.org/my/show_requests">Control panel</a> or look at folder "Spam" for banned comments.
|
58 |
|
59 |
+
= How the plugin is effective against spam bots? =
|
60 |
+
Plugin Antispam by CleanTalk stops about 99.99% of spam comments by spam bots. More over, by determining the relevance of the comment text, the plugin stops about 96% spam comments submitted manually via browser.
|
61 |
+
|
62 |
+
= What about pingback, trackback spam? =
|
63 |
+
Plugin by default pass not spam pingbacks/trackbacks (sender host clear at <a href="http://cleantalk.org/blacklists">Blacklists IP</a> database) from third-party sites to the blog. If the pingback has more then 3 records in the Blacklists and not relevant to the blog the pingback will be stopped by CleanTalk.
|
64 |
+
|
65 |
= Why do I need one more anti-spam plugin? =
|
66 |
|
67 |
1. The plugin is more effective than CAPTCHA because use several methods to stop spammers.
|
68 |
1. This plugin stops spam bots automatically, plugin invisible for blog visitors and admins.
|
69 |
1. CleanTalk automatically approves relevant, not spam comments.
|
70 |
|
71 |
+
= Should I use another antispam plugins? =
|
72 |
+
Use other antispam plugins not necessarily, because CleanTalk stops 99.99% of spam comments. But if necessary, the plugin can work together with Akismet, Captcha and etc.
|
73 |
+
|
74 |
== Screenshots ==
|
75 |
|
76 |
1. The comment from spammer (sender blacklisted by IP/Email, comment text not relevant for the post) prohibited to place in the queue WordPress
|
79 |
|
80 |
== Changelog ==
|
81 |
|
82 |
+
= 2.4.15 2013-09-26 =
|
83 |
+
* Fixed: Bug with mass comments deletion
|
84 |
+
* Changed: Russian localization for admin panel
|
85 |
+
* Tested with mulitsite setup (WordPress network or WPMU)
|
86 |
+
|
87 |
= 2.4.14 2013-08-29 =
|
88 |
* Changed: Removed feedback requests to the servers for banned (spam) comments.
|
89 |
|
183 |
* First version
|
184 |
|
185 |
== Upgrade Notice ==
|
186 |
+
= 2.4.15 2013-09-26 =
|
187 |
+
* Fixed: Bug with mass comments deletion
|
188 |
+
* Changed: Russian localization for admin panel
|
189 |
+
* Tested with mulitsite setup (WordPress network or WPMU)
|
190 |
+
|
191 |
= 2.4.14 2013-08-29 =
|
192 |
* Changed: Removed feedback requests to the servers for banned (spam) comments.
|
193 |
|