@@ -57,6 +57,9 @@ discard block |
||
57 | 57 | $this->msg=$this->prefix.str_replace( '%%%%', $this->url, $this->msg); |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param string $url |
|
62 | + */ |
|
60 | 63 | function setChacha($url ){ |
61 | 64 | $url = strtolower($url); |
62 | 65 | $arr = array( |
@@ -114,6 +117,10 @@ discard block |
||
114 | 117 | } |
115 | 118 | |
116 | 119 | //随机把一个字符转为拼音 |
120 | + |
|
121 | + /** |
|
122 | + * @param string $str |
|
123 | + */ |
|
117 | 124 | function setPinyin($str) { |
118 | 125 | $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
119 | 126 | $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
@@ -146,6 +153,10 @@ discard block |
||
146 | 153 | } |
147 | 154 | |
148 | 155 | //随机插入不影响阅读的字符 |
156 | + |
|
157 | + /** |
|
158 | + * @param string $str |
|
159 | + */ |
|
149 | 160 | function setBlankness($str) { |
150 | 161 | $blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅'); |
151 | 162 | $len = iconv_strlen( $str, 'UTF-8' ); |
@@ -1,180 +1,180 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace puck\helpers; |
3 | 3 | class Chaos { |
4 | - public $GbToBigArray; |
|
5 | - public $_pinyin; |
|
6 | - public $string; |
|
7 | - public $url = ''; |
|
8 | - public $msg = ''; |
|
9 | - public $action; |
|
10 | - private $prefix; |
|
4 | + public $GbToBigArray; |
|
5 | + public $_pinyin; |
|
6 | + public $string; |
|
7 | + public $url = ''; |
|
8 | + public $msg = ''; |
|
9 | + public $action; |
|
10 | + private $prefix; |
|
11 | 11 | |
12 | 12 | function __construct(){ |
13 | - $this->_pinyin = new PinYin(); |
|
14 | - } |
|
13 | + $this->_pinyin = new PinYin(); |
|
14 | + } |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $prefix |
18 | 18 | */ |
19 | 19 | public function addPrefix(array $prefix) { |
20 | 20 | $this->prefix=$prefix[array_rand($prefix)]; |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | 23 | public function clearPrefix() { |
24 | 24 | $this->prefix=''; |
25 | - } |
|
25 | + } |
|
26 | 26 | public function get($str) { |
27 | 27 | $this->cutting($str); |
28 | 28 | $this->convert(); |
29 | 29 | $this->clearPrefix(); |
30 | 30 | return $this->msg; |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - //分离URL |
|
34 | - private function cutting($str){ |
|
33 | + //分离URL |
|
34 | + private function cutting($str){ |
|
35 | 35 | |
36 | - if(preg_match("@(http://[^\\s]+)@i", $str, $result)) { |
|
37 | - $this->url = $result[1]; |
|
38 | - $this->msg = $str = str_replace($this->url, '%%%%', $str); |
|
39 | - } else { |
|
40 | - $this->msg = $str; |
|
41 | - } |
|
42 | - } |
|
36 | + if(preg_match("@(http://[^\\s]+)@i", $str, $result)) { |
|
37 | + $this->url = $result[1]; |
|
38 | + $this->msg = $str = str_replace($this->url, '%%%%', $str); |
|
39 | + } else { |
|
40 | + $this->msg = $str; |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - private function convert( $method = 'msg' ){ |
|
47 | - if( $method == 'msg' || $method == 'all') { |
|
48 | - $this->msg = $this->setPinyin($this->msg); |
|
49 | - $this->msg = $this->setRepeat($this->msg); |
|
50 | - //$this->msg = $this->GbToBig($this->msg); |
|
51 | - $this->msg = $this->setBlankness($this->msg); |
|
46 | + private function convert( $method = 'msg' ){ |
|
47 | + if( $method == 'msg' || $method == 'all') { |
|
48 | + $this->msg = $this->setPinyin($this->msg); |
|
49 | + $this->msg = $this->setRepeat($this->msg); |
|
50 | + //$this->msg = $this->GbToBig($this->msg); |
|
51 | + $this->msg = $this->setBlankness($this->msg); |
|
52 | 52 | |
53 | - } |
|
54 | - if( $method == 'url' || $method == 'all') { |
|
55 | - $this->url = $this->setChacha($this->url); |
|
56 | - } |
|
57 | - $this->msg=$this->prefix.str_replace( '%%%%', $this->url, $this->msg); |
|
58 | - } |
|
53 | + } |
|
54 | + if( $method == 'url' || $method == 'all') { |
|
55 | + $this->url = $this->setChacha($this->url); |
|
56 | + } |
|
57 | + $this->msg=$this->prefix.str_replace( '%%%%', $this->url, $this->msg); |
|
58 | + } |
|
59 | 59 | |
60 | - function setChacha($url ){ |
|
61 | - $url = strtolower($url); |
|
62 | - $arr = array( |
|
63 | - 'a' => array('a','A','a','A','Α','А','α'), |
|
64 | - 'b' => array('b','B','b','B','Β','В','Ь'), |
|
65 | - 'c' => array('c','C','c','C','С','с'), |
|
66 | - 'd' => array('d','D','d','D'), |
|
67 | - 'e' => array('e','E','e','E','Ε','Е','е'), |
|
68 | - 'f' => array('f','F','f','F'), |
|
69 | - 'g' => array('g','G','g','G'), |
|
70 | - 'h' => array('h','H','h','H','Η','Н','н'), |
|
71 | - 'i' => array('i','I','i','I','Ι','Ⅰ'), |
|
72 | - 'j' => array('j','J','j','J'), |
|
73 | - 'k' => array('k','K','k','K','Κ','κ','к','К'), |
|
74 | - 'l' => array('l','L','l','L','︱','︳','|'), |
|
75 | - 'm' => array('m','M','m','M','Μ','М','м'), |
|
76 | - 'n' => array('n','N','n','N','Ν','∩'), |
|
77 | - 'o' => array('o','O','o','O','Ο','О'), |
|
78 | - 'p' => array('p','P','p','P','Ρ','Р','р'), |
|
79 | - 'q' => array('q','Q','q','Q'), |
|
80 | - 'r' => array('r','R','r','R'), |
|
81 | - 's' => array('s','S','s','S'), |
|
82 | - 't' => array('t','T','t','T','Τ','Т','ㄒ'), |
|
83 | - 'u' => array('u','U','u','U','∪'), |
|
84 | - 'v' => array('v','V','v','V','∨','ν'), |
|
85 | - 'w' => array('w','W','w','W'), |
|
86 | - 'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'), |
|
87 | - 'y' => array('y','Y','y','Y','У'), |
|
88 | - 'z' => array('z','Z','z','Z','Ζ'), |
|
60 | + function setChacha($url ){ |
|
61 | + $url = strtolower($url); |
|
62 | + $arr = array( |
|
63 | + 'a' => array('a','A','a','A','Α','А','α'), |
|
64 | + 'b' => array('b','B','b','B','Β','В','Ь'), |
|
65 | + 'c' => array('c','C','c','C','С','с'), |
|
66 | + 'd' => array('d','D','d','D'), |
|
67 | + 'e' => array('e','E','e','E','Ε','Е','е'), |
|
68 | + 'f' => array('f','F','f','F'), |
|
69 | + 'g' => array('g','G','g','G'), |
|
70 | + 'h' => array('h','H','h','H','Η','Н','н'), |
|
71 | + 'i' => array('i','I','i','I','Ι','Ⅰ'), |
|
72 | + 'j' => array('j','J','j','J'), |
|
73 | + 'k' => array('k','K','k','K','Κ','κ','к','К'), |
|
74 | + 'l' => array('l','L','l','L','︱','︳','|'), |
|
75 | + 'm' => array('m','M','m','M','Μ','М','м'), |
|
76 | + 'n' => array('n','N','n','N','Ν','∩'), |
|
77 | + 'o' => array('o','O','o','O','Ο','О'), |
|
78 | + 'p' => array('p','P','p','P','Ρ','Р','р'), |
|
79 | + 'q' => array('q','Q','q','Q'), |
|
80 | + 'r' => array('r','R','r','R'), |
|
81 | + 's' => array('s','S','s','S'), |
|
82 | + 't' => array('t','T','t','T','Τ','Т','ㄒ'), |
|
83 | + 'u' => array('u','U','u','U','∪'), |
|
84 | + 'v' => array('v','V','v','V','∨','ν'), |
|
85 | + 'w' => array('w','W','w','W'), |
|
86 | + 'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'), |
|
87 | + 'y' => array('y','Y','y','Y','У'), |
|
88 | + 'z' => array('z','Z','z','Z','Ζ'), |
|
89 | 89 | |
90 | - '1' => array('1','1'), |
|
91 | - '2' => array('2','2'), |
|
92 | - '3' => array('3','3'), |
|
93 | - '4' => array('4','4'), |
|
94 | - '5' => array('5','5'), |
|
95 | - '6' => array('6','6'), |
|
96 | - '7' => array('7','7'), |
|
97 | - '8' => array('8','8'), |
|
98 | - '9' => array('9','9'), |
|
99 | - '0' => array('0','0'), |
|
90 | + '1' => array('1','1'), |
|
91 | + '2' => array('2','2'), |
|
92 | + '3' => array('3','3'), |
|
93 | + '4' => array('4','4'), |
|
94 | + '5' => array('5','5'), |
|
95 | + '6' => array('6','6'), |
|
96 | + '7' => array('7','7'), |
|
97 | + '8' => array('8','8'), |
|
98 | + '9' => array('9','9'), |
|
99 | + '0' => array('0','0'), |
|
100 | 100 | |
101 | - ':' => array(':',':','∶'), |
|
102 | - '/' => array('/','/'), |
|
103 | - '.' => array('。','·','.','、','﹒',',','丶') |
|
101 | + ':' => array(':',':','∶'), |
|
102 | + '/' => array('/','/'), |
|
103 | + '.' => array('。','·','.','、','﹒',',','丶') |
|
104 | 104 | |
105 | - ); |
|
106 | - $len = strlen( $url ); |
|
107 | - $temp = "\n\n"; |
|
108 | - for( $i=0; $i<$len; $i++){ |
|
109 | - $t_str = substr( $url, $i, 1 ); |
|
110 | - $sj = mt_rand( 0, count($arr[$t_str])-1 ); |
|
111 | - $temp .= $arr[$t_str][$sj]; |
|
112 | - } |
|
113 | - return $temp; |
|
114 | - } |
|
105 | + ); |
|
106 | + $len = strlen( $url ); |
|
107 | + $temp = "\n\n"; |
|
108 | + for( $i=0; $i<$len; $i++){ |
|
109 | + $t_str = substr( $url, $i, 1 ); |
|
110 | + $sj = mt_rand( 0, count($arr[$t_str])-1 ); |
|
111 | + $temp .= $arr[$t_str][$sj]; |
|
112 | + } |
|
113 | + return $temp; |
|
114 | + } |
|
115 | 115 | |
116 | - //随机把一个字符转为拼音 |
|
117 | - function setPinyin($str) { |
|
118 | - $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
|
119 | - $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
|
120 | - if(mt_rand(0,10) > 5) $pinyin = " "; |
|
121 | - $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE); |
|
116 | + //随机把一个字符转为拼音 |
|
117 | + function setPinyin($str) { |
|
118 | + $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
|
119 | + $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
|
120 | + if(mt_rand(0,10) > 5) $pinyin = " "; |
|
121 | + $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE); |
|
122 | 122 | $pinyin=implode(" ",$pinyin); |
123 | - if(mt_rand(0,10) > 5) $pinyin .= " "; |
|
124 | - if($t_str != "%"){ |
|
125 | - $str = preg_replace("'$t_str'", $pinyin, $str, 1); |
|
126 | - } |
|
127 | - return $str; |
|
128 | - } |
|
123 | + if(mt_rand(0,10) > 5) $pinyin .= " "; |
|
124 | + if($t_str != "%"){ |
|
125 | + $str = preg_replace("'$t_str'", $pinyin, $str, 1); |
|
126 | + } |
|
127 | + return $str; |
|
128 | + } |
|
129 | 129 | |
130 | - //随机重复一个字符 |
|
131 | - function setRepeat($str) { |
|
132 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
133 | - $action = 0; |
|
134 | - $temp = ''; |
|
135 | - for( $i=0; $i<$len; $i++ ){ |
|
136 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
137 | - if( mt_rand( 1, 50 ) > 48 && $action == 0) { |
|
138 | - if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
139 | - $temp .= $t_str; |
|
140 | - $action = 1; |
|
141 | - } |
|
142 | - } |
|
143 | - $temp .= $t_str; |
|
144 | - } |
|
145 | - return $temp; |
|
146 | - } |
|
130 | + //随机重复一个字符 |
|
131 | + function setRepeat($str) { |
|
132 | + $len = iconv_strlen( $str, 'UTF-8' ); |
|
133 | + $action = 0; |
|
134 | + $temp = ''; |
|
135 | + for( $i=0; $i<$len; $i++ ){ |
|
136 | + $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
137 | + if( mt_rand( 1, 50 ) > 48 && $action == 0) { |
|
138 | + if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
139 | + $temp .= $t_str; |
|
140 | + $action = 1; |
|
141 | + } |
|
142 | + } |
|
143 | + $temp .= $t_str; |
|
144 | + } |
|
145 | + return $temp; |
|
146 | + } |
|
147 | 147 | |
148 | - //随机插入不影响阅读的字符 |
|
149 | - function setBlankness($str) { |
|
150 | - $blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅'); |
|
151 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
152 | - $temp = ''; |
|
153 | - for( $i=0; $i<$len; $i++ ){ |
|
154 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
155 | - if( mt_rand( 1, 50 ) > 48 ) { |
|
156 | - if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
157 | - $temp .= $blankness[mt_rand(0, 7)]; |
|
158 | - } |
|
159 | - } |
|
160 | - $temp .= $t_str; |
|
161 | - } |
|
162 | - return $temp; |
|
163 | - } |
|
148 | + //随机插入不影响阅读的字符 |
|
149 | + function setBlankness($str) { |
|
150 | + $blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅'); |
|
151 | + $len = iconv_strlen( $str, 'UTF-8' ); |
|
152 | + $temp = ''; |
|
153 | + for( $i=0; $i<$len; $i++ ){ |
|
154 | + $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
155 | + if( mt_rand( 1, 50 ) > 48 ) { |
|
156 | + if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
157 | + $temp .= $blankness[mt_rand(0, 7)]; |
|
158 | + } |
|
159 | + } |
|
160 | + $temp .= $t_str; |
|
161 | + } |
|
162 | + return $temp; |
|
163 | + } |
|
164 | 164 | |
165 | - //随机进行繁体中文转换 |
|
166 | - function GbToBig( $str ){ |
|
167 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
168 | - $temp = ''; |
|
169 | - for( $i=0; $i<$len; $i++ ){ |
|
170 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
171 | - if( mt_rand( 1, 50 ) > 48 ) { |
|
172 | - $t_str = strtr( $t_str, $this->GbToBigArray ); |
|
173 | - } |
|
174 | - $temp .= $t_str; |
|
175 | - } |
|
176 | - return $temp; |
|
177 | - } |
|
165 | + //随机进行繁体中文转换 |
|
166 | + function GbToBig( $str ){ |
|
167 | + $len = iconv_strlen( $str, 'UTF-8' ); |
|
168 | + $temp = ''; |
|
169 | + for( $i=0; $i<$len; $i++ ){ |
|
170 | + $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
171 | + if( mt_rand( 1, 50 ) > 48 ) { |
|
172 | + $t_str = strtr( $t_str, $this->GbToBigArray ); |
|
173 | + } |
|
174 | + $temp .= $t_str; |
|
175 | + } |
|
176 | + return $temp; |
|
177 | + } |
|
178 | 178 | } |
179 | 179 | |
180 | 180 |
@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | public $GbToBigArray; |
5 | 5 | public $_pinyin; |
6 | 6 | public $string; |
7 | - public $url = ''; |
|
8 | - public $msg = ''; |
|
7 | + public $url=''; |
|
8 | + public $msg=''; |
|
9 | 9 | public $action; |
10 | 10 | private $prefix; |
11 | 11 | |
12 | - function __construct(){ |
|
13 | - $this->_pinyin = new PinYin(); |
|
12 | + function __construct() { |
|
13 | + $this->_pinyin=new PinYin(); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
@@ -31,147 +31,147 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | //分离URL |
34 | - private function cutting($str){ |
|
34 | + private function cutting($str) { |
|
35 | 35 | |
36 | - if(preg_match("@(http://[^\\s]+)@i", $str, $result)) { |
|
37 | - $this->url = $result[1]; |
|
38 | - $this->msg = $str = str_replace($this->url, '%%%%', $str); |
|
36 | + if (preg_match("@(http://[^\\s]+)@i", $str, $result)) { |
|
37 | + $this->url=$result[1]; |
|
38 | + $this->msg=$str=str_replace($this->url, '%%%%', $str); |
|
39 | 39 | } else { |
40 | - $this->msg = $str; |
|
40 | + $this->msg=$str; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - private function convert( $method = 'msg' ){ |
|
47 | - if( $method == 'msg' || $method == 'all') { |
|
48 | - $this->msg = $this->setPinyin($this->msg); |
|
49 | - $this->msg = $this->setRepeat($this->msg); |
|
46 | + private function convert($method='msg') { |
|
47 | + if ($method == 'msg' || $method == 'all') { |
|
48 | + $this->msg=$this->setPinyin($this->msg); |
|
49 | + $this->msg=$this->setRepeat($this->msg); |
|
50 | 50 | //$this->msg = $this->GbToBig($this->msg); |
51 | - $this->msg = $this->setBlankness($this->msg); |
|
51 | + $this->msg=$this->setBlankness($this->msg); |
|
52 | 52 | |
53 | 53 | } |
54 | - if( $method == 'url' || $method == 'all') { |
|
55 | - $this->url = $this->setChacha($this->url); |
|
54 | + if ($method == 'url' || $method == 'all') { |
|
55 | + $this->url=$this->setChacha($this->url); |
|
56 | 56 | } |
57 | - $this->msg=$this->prefix.str_replace( '%%%%', $this->url, $this->msg); |
|
57 | + $this->msg=$this->prefix.str_replace('%%%%', $this->url, $this->msg); |
|
58 | 58 | } |
59 | 59 | |
60 | - function setChacha($url ){ |
|
61 | - $url = strtolower($url); |
|
62 | - $arr = array( |
|
63 | - 'a' => array('a','A','a','A','Α','А','α'), |
|
64 | - 'b' => array('b','B','b','B','Β','В','Ь'), |
|
65 | - 'c' => array('c','C','c','C','С','с'), |
|
66 | - 'd' => array('d','D','d','D'), |
|
67 | - 'e' => array('e','E','e','E','Ε','Е','е'), |
|
68 | - 'f' => array('f','F','f','F'), |
|
69 | - 'g' => array('g','G','g','G'), |
|
70 | - 'h' => array('h','H','h','H','Η','Н','н'), |
|
71 | - 'i' => array('i','I','i','I','Ι','Ⅰ'), |
|
72 | - 'j' => array('j','J','j','J'), |
|
73 | - 'k' => array('k','K','k','K','Κ','κ','к','К'), |
|
74 | - 'l' => array('l','L','l','L','︱','︳','|'), |
|
75 | - 'm' => array('m','M','m','M','Μ','М','м'), |
|
76 | - 'n' => array('n','N','n','N','Ν','∩'), |
|
77 | - 'o' => array('o','O','o','O','Ο','О'), |
|
78 | - 'p' => array('p','P','p','P','Ρ','Р','р'), |
|
79 | - 'q' => array('q','Q','q','Q'), |
|
80 | - 'r' => array('r','R','r','R'), |
|
81 | - 's' => array('s','S','s','S'), |
|
82 | - 't' => array('t','T','t','T','Τ','Т','ㄒ'), |
|
83 | - 'u' => array('u','U','u','U','∪'), |
|
84 | - 'v' => array('v','V','v','V','∨','ν'), |
|
85 | - 'w' => array('w','W','w','W'), |
|
86 | - 'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'), |
|
87 | - 'y' => array('y','Y','y','Y','У'), |
|
88 | - 'z' => array('z','Z','z','Z','Ζ'), |
|
60 | + function setChacha($url) { |
|
61 | + $url=strtolower($url); |
|
62 | + $arr=array( |
|
63 | + 'a' => array('a', 'A', 'a', 'A', 'Α', 'А', 'α'), |
|
64 | + 'b' => array('b', 'B', 'b', 'B', 'Β', 'В', 'Ь'), |
|
65 | + 'c' => array('c', 'C', 'c', 'C', 'С', 'с'), |
|
66 | + 'd' => array('d', 'D', 'd', 'D'), |
|
67 | + 'e' => array('e', 'E', 'e', 'E', 'Ε', 'Е', 'е'), |
|
68 | + 'f' => array('f', 'F', 'f', 'F'), |
|
69 | + 'g' => array('g', 'G', 'g', 'G'), |
|
70 | + 'h' => array('h', 'H', 'h', 'H', 'Η', 'Н', 'н'), |
|
71 | + 'i' => array('i', 'I', 'i', 'I', 'Ι', 'Ⅰ'), |
|
72 | + 'j' => array('j', 'J', 'j', 'J'), |
|
73 | + 'k' => array('k', 'K', 'k', 'K', 'Κ', 'κ', 'к', 'К'), |
|
74 | + 'l' => array('l', 'L', 'l', 'L', '︱', '︳', '|'), |
|
75 | + 'm' => array('m', 'M', 'm', 'M', 'Μ', 'М', 'м'), |
|
76 | + 'n' => array('n', 'N', 'n', 'N', 'Ν', '∩'), |
|
77 | + 'o' => array('o', 'O', 'o', 'O', 'Ο', 'О'), |
|
78 | + 'p' => array('p', 'P', 'p', 'P', 'Ρ', 'Р', 'р'), |
|
79 | + 'q' => array('q', 'Q', 'q', 'Q'), |
|
80 | + 'r' => array('r', 'R', 'r', 'R'), |
|
81 | + 's' => array('s', 'S', 's', 'S'), |
|
82 | + 't' => array('t', 'T', 't', 'T', 'Τ', 'Т', 'ㄒ'), |
|
83 | + 'u' => array('u', 'U', 'u', 'U', '∪'), |
|
84 | + 'v' => array('v', 'V', 'v', 'V', '∨', 'ν'), |
|
85 | + 'w' => array('w', 'W', 'w', 'W'), |
|
86 | + 'x' => array('x', 'X', 'x', 'X', 'Χ', 'χ', 'Х', 'х', 'Ⅹ', '×'), |
|
87 | + 'y' => array('y', 'Y', 'y', 'Y', 'У'), |
|
88 | + 'z' => array('z', 'Z', 'z', 'Z', 'Ζ'), |
|
89 | 89 | |
90 | - '1' => array('1','1'), |
|
91 | - '2' => array('2','2'), |
|
92 | - '3' => array('3','3'), |
|
93 | - '4' => array('4','4'), |
|
94 | - '5' => array('5','5'), |
|
95 | - '6' => array('6','6'), |
|
96 | - '7' => array('7','7'), |
|
97 | - '8' => array('8','8'), |
|
98 | - '9' => array('9','9'), |
|
99 | - '0' => array('0','0'), |
|
90 | + '1' => array('1', '1'), |
|
91 | + '2' => array('2', '2'), |
|
92 | + '3' => array('3', '3'), |
|
93 | + '4' => array('4', '4'), |
|
94 | + '5' => array('5', '5'), |
|
95 | + '6' => array('6', '6'), |
|
96 | + '7' => array('7', '7'), |
|
97 | + '8' => array('8', '8'), |
|
98 | + '9' => array('9', '9'), |
|
99 | + '0' => array('0', '0'), |
|
100 | 100 | |
101 | - ':' => array(':',':','∶'), |
|
102 | - '/' => array('/','/'), |
|
103 | - '.' => array('。','·','.','、','﹒',',','丶') |
|
101 | + ':' => array(':', ':', '∶'), |
|
102 | + '/' => array('/', '/'), |
|
103 | + '.' => array('。', '·', '.', '、', '﹒', ',', '丶') |
|
104 | 104 | |
105 | 105 | ); |
106 | - $len = strlen( $url ); |
|
107 | - $temp = "\n\n"; |
|
108 | - for( $i=0; $i<$len; $i++){ |
|
109 | - $t_str = substr( $url, $i, 1 ); |
|
110 | - $sj = mt_rand( 0, count($arr[$t_str])-1 ); |
|
111 | - $temp .= $arr[$t_str][$sj]; |
|
106 | + $len=strlen($url); |
|
107 | + $temp="\n\n"; |
|
108 | + for ($i=0; $i < $len; $i++) { |
|
109 | + $t_str=substr($url, $i, 1); |
|
110 | + $sj=mt_rand(0, count($arr[$t_str]) - 1); |
|
111 | + $temp.=$arr[$t_str][$sj]; |
|
112 | 112 | } |
113 | 113 | return $temp; |
114 | 114 | } |
115 | 115 | |
116 | 116 | //随机把一个字符转为拼音 |
117 | 117 | function setPinyin($str) { |
118 | - $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
|
119 | - $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
|
120 | - if(mt_rand(0,10) > 5) $pinyin = " "; |
|
121 | - $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE); |
|
122 | - $pinyin=implode(" ",$pinyin); |
|
123 | - if(mt_rand(0,10) > 5) $pinyin .= " "; |
|
124 | - if($t_str != "%"){ |
|
125 | - $str = preg_replace("'$t_str'", $pinyin, $str, 1); |
|
118 | + $py=mt_rand(0, iconv_strlen($str, 'UTF-8') - 1); |
|
119 | + $t_str=iconv_substr($str, $py, 1, 'UTF-8'); |
|
120 | + if (mt_rand(0, 10) > 5) $pinyin=" "; |
|
121 | + $pinyin=$this->_pinyin->convert($t_str, PINYIN_UNICODE); |
|
122 | + $pinyin=implode(" ", $pinyin); |
|
123 | + if (mt_rand(0, 10) > 5) $pinyin.=" "; |
|
124 | + if ($t_str != "%") { |
|
125 | + $str=preg_replace("'$t_str'", $pinyin, $str, 1); |
|
126 | 126 | } |
127 | 127 | return $str; |
128 | 128 | } |
129 | 129 | |
130 | 130 | //随机重复一个字符 |
131 | 131 | function setRepeat($str) { |
132 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
133 | - $action = 0; |
|
134 | - $temp = ''; |
|
135 | - for( $i=0; $i<$len; $i++ ){ |
|
136 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
137 | - if( mt_rand( 1, 50 ) > 48 && $action == 0) { |
|
138 | - if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
139 | - $temp .= $t_str; |
|
140 | - $action = 1; |
|
132 | + $len=iconv_strlen($str, 'UTF-8'); |
|
133 | + $action=0; |
|
134 | + $temp=''; |
|
135 | + for ($i=0; $i < $len; $i++) { |
|
136 | + $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
137 | + if (mt_rand(1, 50) > 48 && $action == 0) { |
|
138 | + if (!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
139 | + $temp.=$t_str; |
|
140 | + $action=1; |
|
141 | 141 | } |
142 | 142 | } |
143 | - $temp .= $t_str; |
|
143 | + $temp.=$t_str; |
|
144 | 144 | } |
145 | 145 | return $temp; |
146 | 146 | } |
147 | 147 | |
148 | 148 | //随机插入不影响阅读的字符 |
149 | 149 | function setBlankness($str) { |
150 | - $blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅'); |
|
151 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
152 | - $temp = ''; |
|
153 | - for( $i=0; $i<$len; $i++ ){ |
|
154 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
155 | - if( mt_rand( 1, 50 ) > 48 ) { |
|
156 | - if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
157 | - $temp .= $blankness[mt_rand(0, 7)]; |
|
150 | + $blankness=array(" ", ' ', '҉', '̅̅', '̲', '̲̲', '̅', '̲̲̅̅'); |
|
151 | + $len=iconv_strlen($str, 'UTF-8'); |
|
152 | + $temp=''; |
|
153 | + for ($i=0; $i < $len; $i++) { |
|
154 | + $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
155 | + if (mt_rand(1, 50) > 48) { |
|
156 | + if (!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
157 | + $temp.=$blankness[mt_rand(0, 7)]; |
|
158 | 158 | } |
159 | 159 | } |
160 | - $temp .= $t_str; |
|
160 | + $temp.=$t_str; |
|
161 | 161 | } |
162 | 162 | return $temp; |
163 | 163 | } |
164 | 164 | |
165 | 165 | //随机进行繁体中文转换 |
166 | - function GbToBig( $str ){ |
|
167 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
168 | - $temp = ''; |
|
169 | - for( $i=0; $i<$len; $i++ ){ |
|
170 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
171 | - if( mt_rand( 1, 50 ) > 48 ) { |
|
172 | - $t_str = strtr( $t_str, $this->GbToBigArray ); |
|
166 | + function GbToBig($str) { |
|
167 | + $len=iconv_strlen($str, 'UTF-8'); |
|
168 | + $temp=''; |
|
169 | + for ($i=0; $i < $len; $i++) { |
|
170 | + $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
171 | + if (mt_rand(1, 50) > 48) { |
|
172 | + $t_str=strtr($t_str, $this->GbToBigArray); |
|
173 | 173 | } |
174 | - $temp .= $t_str; |
|
174 | + $temp.=$t_str; |
|
175 | 175 | } |
176 | 176 | return $temp; |
177 | 177 | } |
@@ -117,10 +117,14 @@ |
||
117 | 117 | function setPinyin($str) { |
118 | 118 | $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
119 | 119 | $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
120 | - if(mt_rand(0,10) > 5) $pinyin = " "; |
|
120 | + if(mt_rand(0,10) > 5) { |
|
121 | + $pinyin = " "; |
|
122 | + } |
|
121 | 123 | $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE); |
122 | 124 | $pinyin=implode(" ",$pinyin); |
123 | - if(mt_rand(0,10) > 5) $pinyin .= " "; |
|
125 | + if(mt_rand(0,10) > 5) { |
|
126 | + $pinyin .= " "; |
|
127 | + } |
|
124 | 128 | if($t_str != "%"){ |
125 | 129 | $str = preg_replace("'$t_str'", $pinyin, $str, 1); |
126 | 130 | } |