XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
postcommon_post_need_multibyte.php
Go to the documentation of this file.
1 <?php
2 
3 // Don't enable this for site using single-byte
4 // Perhaps, japanese, schinese, tchinese, and korean can use it
5 
7 
8  function execute()
9  {
10  global $xoopsUser ;
11 
12  if( ! function_exists( 'mb_strlen' ) ) return true ;
13 
14  // registered users always pass this plugin
15  if( is_object( $xoopsUser ) ) return true ;
16 
17  $lengths = array(
18  0 => 100 , // default value
19  'message' => 2 ,
20  'com_text' => 2 ,
21  'excerpt' => 2 ,
22  ) ;
23 
24  foreach( $_POST as $key => $data ) {
25  // dare to ignore arrays/objects
26  if( ! is_string( $data ) ) continue ;
27 
28  $check_length = isset( $lengths[ $key ] ) ? $lengths[ $key ] : $lengths[ 0 ] ;
29  if( strlen( $data ) > $check_length ) {
30  if( strlen( $data ) == mb_strlen( $data ) ) {
31  $this->protector->message .= "No multibyte character was found ($data)\n" ;
32  $this->protector->output_log( 'Singlebyte SPAM' , 0 , false , 128 ) ;
33  die( 'Protector rejects your post, because your post looks like SPAM' ) ;
34  }
35  }
36  }
37 
38  return true ;
39  }
40 
41 }
42 
43 ?>