1: <?php
2:
3: // Don't enable this for site using single-byte
4: // Perhaps, japanese, schinese, tchinese, and korean can use it
5:
6: /**
7: * Class protector_postcommon_post_need_multibyte
8: */
9: class Protector_postcommon_post_need_multibyte extends ProtectorFilterAbstract
10: {
11: /**
12: * @return bool
13: */
14: public function execute()
15: {
16: global $xoopsUser;
17:
18: if (!function_exists('mb_strlen')) {
19: return true;
20: }
21:
22: // registered users always pass this plugin
23: if (is_object($xoopsUser)) {
24: return true;
25: }
26:
27: $lengths = array(
28: 0 => 100, // default value
29: 'message' => 2,
30: 'com_text' => 2,
31: 'excerpt' => 2);
32:
33: foreach ($_POST as $key => $data) {
34: // dare to ignore arrays/objects
35: if (!is_string($data)) {
36: continue;
37: }
38:
39: $check_length = isset($lengths[$key]) ? $lengths[$key] : $lengths[0];
40: if (strlen($data) > $check_length) {
41: if (strlen($data) == mb_strlen($data)) {
42: $this->protector->message .= "No multibyte character was found ($data)\n";
43: $this->protector->output_log('Singlebyte SPAM', 0, false, 128);
44: die('Protector rejects your post, because your post looks like SPAM');
45: }
46: }
47: }
48:
49: return true;
50: }
51: }
52: