Passed
Push — master ( 47aa65...ade1c9 )
by kill
02:28
created
core/helpers/Chaos.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -139,6 +139,10 @@
 block discarded – undo
139 139
 	}
140 140
 	
141 141
 	//随机重复一个字符
142
+
143
+	/**
144
+	 * @param string $str
145
+	 */
142 146
 	function setRepeat($str) {
143 147
 		$len = iconv_strlen( $str, 'UTF-8' );
144 148
 		$action = 0;
Please login to merge, or discard this patch.
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -1,195 +1,195 @@
 block discarded – undo
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
-	/**
61
-	 * @param string $url
62
-	 */
63
-	function setChacha($url ){
64
-		$url = strtolower($url);
65
-		$arr = array(
66
-			'a' => array('a','A','a','A','Α','А','α'),
67
-			'b' => array('b','B','b','B','Β','В','Ь'),
68
-			'c' => array('c','C','c','C','С','с'),
69
-			'd' => array('d','D','d','D'),
70
-			'e' => array('e','E','e','E','Ε','Е','е'),
71
-			'f' => array('f','F','f','F'),
72
-			'g' => array('g','G','g','G'),
73
-			'h' => array('h','H','h','H','Η','Н','н'),
74
-			'i' => array('i','I','i','I','Ι','Ⅰ'),
75
-			'j' => array('j','J','j','J'),
76
-			'k' => array('k','K','k','K','Κ','κ','к','К'),
77
-			'l' => array('l','L','l','L','︱','︳','|'),
78
-			'm' => array('m','M','m','M','Μ','М','м'),
79
-			'n' => array('n','N','n','N','Ν','∩'),
80
-			'o' => array('o','O','o','O','Ο','О'),
81
-			'p' => array('p','P','p','P','Ρ','Р','р'),
82
-			'q' => array('q','Q','q','Q'),
83
-			'r' => array('r','R','r','R'),
84
-			's' => array('s','S','s','S'),
85
-			't' => array('t','T','t','T','Τ','Т','ㄒ'),
86
-			'u' => array('u','U','u','U','∪'),
87
-			'v' => array('v','V','v','V','∨','ν'),
88
-			'w' => array('w','W','w','W'),
89
-			'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'),
90
-			'y' => array('y','Y','y','Y','У'),
91
-			'z' => array('z','Z','z','Z','Ζ'),
60
+    /**
61
+     * @param string $url
62
+     */
63
+    function setChacha($url ){
64
+        $url = strtolower($url);
65
+        $arr = array(
66
+            'a' => array('a','A','a','A','Α','А','α'),
67
+            'b' => array('b','B','b','B','Β','В','Ь'),
68
+            'c' => array('c','C','c','C','С','с'),
69
+            'd' => array('d','D','d','D'),
70
+            'e' => array('e','E','e','E','Ε','Е','е'),
71
+            'f' => array('f','F','f','F'),
72
+            'g' => array('g','G','g','G'),
73
+            'h' => array('h','H','h','H','Η','Н','н'),
74
+            'i' => array('i','I','i','I','Ι','Ⅰ'),
75
+            'j' => array('j','J','j','J'),
76
+            'k' => array('k','K','k','K','Κ','κ','к','К'),
77
+            'l' => array('l','L','l','L','︱','︳','|'),
78
+            'm' => array('m','M','m','M','Μ','М','м'),
79
+            'n' => array('n','N','n','N','Ν','∩'),
80
+            'o' => array('o','O','o','O','Ο','О'),
81
+            'p' => array('p','P','p','P','Ρ','Р','р'),
82
+            'q' => array('q','Q','q','Q'),
83
+            'r' => array('r','R','r','R'),
84
+            's' => array('s','S','s','S'),
85
+            't' => array('t','T','t','T','Τ','Т','ㄒ'),
86
+            'u' => array('u','U','u','U','∪'),
87
+            'v' => array('v','V','v','V','∨','ν'),
88
+            'w' => array('w','W','w','W'),
89
+            'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'),
90
+            'y' => array('y','Y','y','Y','У'),
91
+            'z' => array('z','Z','z','Z','Ζ'),
92 92
 			
93
-			'1' => array('1','1'),
94
-			'2' => array('2','2'),
95
-			'3' => array('3','3'),
96
-			'4' => array('4','4'),
97
-			'5' => array('5','5'),
98
-			'6' => array('6','6'),
99
-			'7' => array('7','7'),
100
-			'8' => array('8','8'),
101
-			'9' => array('9','9'),
102
-			'0' => array('0','0'),
93
+            '1' => array('1','1'),
94
+            '2' => array('2','2'),
95
+            '3' => array('3','3'),
96
+            '4' => array('4','4'),
97
+            '5' => array('5','5'),
98
+            '6' => array('6','6'),
99
+            '7' => array('7','7'),
100
+            '8' => array('8','8'),
101
+            '9' => array('9','9'),
102
+            '0' => array('0','0'),
103 103
 			
104
-			':' => array(':',':','∶'),
105
-			'/' => array('/','/'),
106
-			'.' => array('。','·','.','、','﹒',',','丶')
104
+            ':' => array(':',':','∶'),
105
+            '/' => array('/','/'),
106
+            '.' => array('。','·','.','、','﹒',',','丶')
107 107
 		
108
-		);
109
-		$len = strlen( $url );
110
-		$temp = "\n\n";
111
-		for( $i=0; $i<$len; $i++){
112
-			$t_str = substr( $url, $i, 1 );
113
-			$sj = mt_rand( 0, count($arr[$t_str])-1 );
114
-			$temp .= $arr[$t_str][$sj];
115
-		}
116
-		return $temp;
117
-	}
108
+        );
109
+        $len = strlen( $url );
110
+        $temp = "\n\n";
111
+        for( $i=0; $i<$len; $i++){
112
+            $t_str = substr( $url, $i, 1 );
113
+            $sj = mt_rand( 0, count($arr[$t_str])-1 );
114
+            $temp .= $arr[$t_str][$sj];
115
+        }
116
+        return $temp;
117
+    }
118 118
 
119
-	//随机把一个字符转为拼音
119
+    //随机把一个字符转为拼音
120 120
 
121
-	/**
122
-	 * @param string $str
123
-	 */
124
-	function setPinyin($str) {
125
-		$py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1);
126
-		$t_str = iconv_substr( $str, $py, 1, 'UTF-8');
127
-		if(mt_rand(0,10) > 5) {
128
-		    $pinyin = " ";
129
-		}
130
-		$pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE);
121
+    /**
122
+     * @param string $str
123
+     */
124
+    function setPinyin($str) {
125
+        $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1);
126
+        $t_str = iconv_substr( $str, $py, 1, 'UTF-8');
127
+        if(mt_rand(0,10) > 5) {
128
+            $pinyin = " ";
129
+        }
130
+        $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE);
131 131
         $pinyin=implode(" ",$pinyin);
132
-		if(mt_rand(0,10) > 5) {
133
-		    $pinyin .= " ";
134
-		}
135
-		if($t_str != "%"){
136
-			$str = preg_replace("'$t_str'", $pinyin, $str, 1);
137
-		}
138
-		return $str;
139
-	}
132
+        if(mt_rand(0,10) > 5) {
133
+            $pinyin .= " ";
134
+        }
135
+        if($t_str != "%"){
136
+            $str = preg_replace("'$t_str'", $pinyin, $str, 1);
137
+        }
138
+        return $str;
139
+    }
140 140
 	
141
-	//随机重复一个字符
142
-	function setRepeat($str) {
143
-		$len = iconv_strlen( $str, 'UTF-8' );
144
-		$action = 0;
145
-		$temp = '';
146
-		for( $i=0;  $i<$len; $i++ ){
147
-			$t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
148
-			if( mt_rand( 1, 50 ) > 48 && $action == 0) {
149
-				if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
150
-					$temp .= $t_str;
151
-					$action = 1;
152
-				}
153
-			}
154
-			$temp .= $t_str;
155
-		}
156
-		return $temp;
157
-	}
141
+    //随机重复一个字符
142
+    function setRepeat($str) {
143
+        $len = iconv_strlen( $str, 'UTF-8' );
144
+        $action = 0;
145
+        $temp = '';
146
+        for( $i=0;  $i<$len; $i++ ){
147
+            $t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
148
+            if( mt_rand( 1, 50 ) > 48 && $action == 0) {
149
+                if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
150
+                    $temp .= $t_str;
151
+                    $action = 1;
152
+                }
153
+            }
154
+            $temp .= $t_str;
155
+        }
156
+        return $temp;
157
+    }
158 158
 	
159
-	//随机插入不影响阅读的字符
159
+    //随机插入不影响阅读的字符
160 160
 
161
-	/**
162
-	 * @param string $str
163
-	 */
164
-	function setBlankness($str) {
165
-		$blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅');
166
-		$len = iconv_strlen( $str, 'UTF-8' );
167
-		$temp = '';
168
-		for( $i=0;  $i<$len; $i++ ){
169
-			$t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
170
-			if( mt_rand( 1, 50 ) > 48 ) {
171
-				if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
172
-					$temp .= $blankness[mt_rand(0, 7)];
173
-				}
174
-			}
175
-			$temp .= $t_str;
176
-		}
177
-		return $temp;
178
-	}
161
+    /**
162
+     * @param string $str
163
+     */
164
+    function setBlankness($str) {
165
+        $blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅');
166
+        $len = iconv_strlen( $str, 'UTF-8' );
167
+        $temp = '';
168
+        for( $i=0;  $i<$len; $i++ ){
169
+            $t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
170
+            if( mt_rand( 1, 50 ) > 48 ) {
171
+                if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
172
+                    $temp .= $blankness[mt_rand(0, 7)];
173
+                }
174
+            }
175
+            $temp .= $t_str;
176
+        }
177
+        return $temp;
178
+    }
179 179
 	
180
-	//随机进行繁体中文转换
181
-	function GbToBig( $str ){
182
-		$len = iconv_strlen( $str, 'UTF-8' );
183
-		$temp = '';
184
-		for( $i=0;  $i<$len; $i++ ){
185
-			$t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
186
-			if( mt_rand( 1, 50 ) > 48 ) {
187
-				$t_str = strtr( $t_str, $this->GbToBigArray );
188
-			}
189
-			$temp .= $t_str;
190
-		}
191
-		return $temp;
192
-	}
180
+    //随机进行繁体中文转换
181
+    function GbToBig( $str ){
182
+        $len = iconv_strlen( $str, 'UTF-8' );
183
+        $temp = '';
184
+        for( $i=0;  $i<$len; $i++ ){
185
+            $t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
186
+            if( mt_rand( 1, 50 ) > 48 ) {
187
+                $t_str = strtr( $t_str, $this->GbToBigArray );
188
+            }
189
+            $temp .= $t_str;
190
+        }
191
+        return $temp;
192
+    }
193 193
 }
194 194
 
195 195
 
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -31,87 +31,87 @@  discard block
 block discarded – undo
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 60
 	/**
61 61
 	 * @param string $url
62 62
 	 */
63
-	function setChacha($url ){
64
-		$url = strtolower($url);
65
-		$arr = array(
66
-			'a' => array('a','A','a','A','Α','А','α'),
67
-			'b' => array('b','B','b','B','Β','В','Ь'),
68
-			'c' => array('c','C','c','C','С','с'),
69
-			'd' => array('d','D','d','D'),
70
-			'e' => array('e','E','e','E','Ε','Е','е'),
71
-			'f' => array('f','F','f','F'),
72
-			'g' => array('g','G','g','G'),
73
-			'h' => array('h','H','h','H','Η','Н','н'),
74
-			'i' => array('i','I','i','I','Ι','Ⅰ'),
75
-			'j' => array('j','J','j','J'),
76
-			'k' => array('k','K','k','K','Κ','κ','к','К'),
77
-			'l' => array('l','L','l','L','︱','︳','|'),
78
-			'm' => array('m','M','m','M','Μ','М','м'),
79
-			'n' => array('n','N','n','N','Ν','∩'),
80
-			'o' => array('o','O','o','O','Ο','О'),
81
-			'p' => array('p','P','p','P','Ρ','Р','р'),
82
-			'q' => array('q','Q','q','Q'),
83
-			'r' => array('r','R','r','R'),
84
-			's' => array('s','S','s','S'),
85
-			't' => array('t','T','t','T','Τ','Т','ㄒ'),
86
-			'u' => array('u','U','u','U','∪'),
87
-			'v' => array('v','V','v','V','∨','ν'),
88
-			'w' => array('w','W','w','W'),
89
-			'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'),
90
-			'y' => array('y','Y','y','Y','У'),
91
-			'z' => array('z','Z','z','Z','Ζ'),
63
+	function setChacha($url) {
64
+		$url=strtolower($url);
65
+		$arr=array(
66
+			'a' => array('a', 'A', 'a', 'A', 'Α', 'А', 'α'),
67
+			'b' => array('b', 'B', 'b', 'B', 'Β', 'В', 'Ь'),
68
+			'c' => array('c', 'C', 'c', 'C', 'С', 'с'),
69
+			'd' => array('d', 'D', 'd', 'D'),
70
+			'e' => array('e', 'E', 'e', 'E', 'Ε', 'Е', 'е'),
71
+			'f' => array('f', 'F', 'f', 'F'),
72
+			'g' => array('g', 'G', 'g', 'G'),
73
+			'h' => array('h', 'H', 'h', 'H', 'Η', 'Н', 'н'),
74
+			'i' => array('i', 'I', 'i', 'I', 'Ι', 'Ⅰ'),
75
+			'j' => array('j', 'J', 'j', 'J'),
76
+			'k' => array('k', 'K', 'k', 'K', 'Κ', 'κ', 'к', 'К'),
77
+			'l' => array('l', 'L', 'l', 'L', '︱', '︳', '|'),
78
+			'm' => array('m', 'M', 'm', 'M', 'Μ', 'М', 'м'),
79
+			'n' => array('n', 'N', 'n', 'N', 'Ν', '∩'),
80
+			'o' => array('o', 'O', 'o', 'O', 'Ο', 'О'),
81
+			'p' => array('p', 'P', 'p', 'P', 'Ρ', 'Р', 'р'),
82
+			'q' => array('q', 'Q', 'q', 'Q'),
83
+			'r' => array('r', 'R', 'r', 'R'),
84
+			's' => array('s', 'S', 's', 'S'),
85
+			't' => array('t', 'T', 't', 'T', 'Τ', 'Т', 'ㄒ'),
86
+			'u' => array('u', 'U', 'u', 'U', '∪'),
87
+			'v' => array('v', 'V', 'v', 'V', '∨', 'ν'),
88
+			'w' => array('w', 'W', 'w', 'W'),
89
+			'x' => array('x', 'X', 'x', 'X', 'Χ', 'χ', 'Х', 'х', 'Ⅹ', '×'),
90
+			'y' => array('y', 'Y', 'y', 'Y', 'У'),
91
+			'z' => array('z', 'Z', 'z', 'Z', 'Ζ'),
92 92
 			
93
-			'1' => array('1','1'),
94
-			'2' => array('2','2'),
95
-			'3' => array('3','3'),
96
-			'4' => array('4','4'),
97
-			'5' => array('5','5'),
98
-			'6' => array('6','6'),
99
-			'7' => array('7','7'),
100
-			'8' => array('8','8'),
101
-			'9' => array('9','9'),
102
-			'0' => array('0','0'),
93
+			'1' => array('1', '1'),
94
+			'2' => array('2', '2'),
95
+			'3' => array('3', '3'),
96
+			'4' => array('4', '4'),
97
+			'5' => array('5', '5'),
98
+			'6' => array('6', '6'),
99
+			'7' => array('7', '7'),
100
+			'8' => array('8', '8'),
101
+			'9' => array('9', '9'),
102
+			'0' => array('0', '0'),
103 103
 			
104
-			':' => array(':',':','∶'),
105
-			'/' => array('/','/'),
106
-			'.' => array('。','·','.','、','﹒',',','丶')
104
+			':' => array(':', ':', '∶'),
105
+			'/' => array('/', '/'),
106
+			'.' => array('。', '·', '.', '、', '﹒', ',', '丶')
107 107
 		
108 108
 		);
109
-		$len = strlen( $url );
110
-		$temp = "\n\n";
111
-		for( $i=0; $i<$len; $i++){
112
-			$t_str = substr( $url, $i, 1 );
113
-			$sj = mt_rand( 0, count($arr[$t_str])-1 );
114
-			$temp .= $arr[$t_str][$sj];
109
+		$len=strlen($url);
110
+		$temp="\n\n";
111
+		for ($i=0; $i < $len; $i++) {
112
+			$t_str=substr($url, $i, 1);
113
+			$sj=mt_rand(0, count($arr[$t_str]) - 1);
114
+			$temp.=$arr[$t_str][$sj];
115 115
 		}
116 116
 		return $temp;
117 117
 	}
@@ -122,36 +122,36 @@  discard block
 block discarded – undo
122 122
 	 * @param string $str
123 123
 	 */
124 124
 	function setPinyin($str) {
125
-		$py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1);
126
-		$t_str = iconv_substr( $str, $py, 1, 'UTF-8');
127
-		if(mt_rand(0,10) > 5) {
128
-		    $pinyin = " ";
125
+		$py=mt_rand(0, iconv_strlen($str, 'UTF-8') - 1);
126
+		$t_str=iconv_substr($str, $py, 1, 'UTF-8');
127
+		if (mt_rand(0, 10) > 5) {
128
+		    $pinyin=" ";
129 129
 		}
130
-		$pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE);
131
-        $pinyin=implode(" ",$pinyin);
132
-		if(mt_rand(0,10) > 5) {
133
-		    $pinyin .= " ";
130
+		$pinyin=$this->_pinyin->convert($t_str, PINYIN_UNICODE);
131
+        $pinyin=implode(" ", $pinyin);
132
+		if (mt_rand(0, 10) > 5) {
133
+		    $pinyin.=" ";
134 134
 		}
135
-		if($t_str != "%"){
136
-			$str = preg_replace("'$t_str'", $pinyin, $str, 1);
135
+		if ($t_str != "%") {
136
+			$str=preg_replace("'$t_str'", $pinyin, $str, 1);
137 137
 		}
138 138
 		return $str;
139 139
 	}
140 140
 	
141 141
 	//随机重复一个字符
142 142
 	function setRepeat($str) {
143
-		$len = iconv_strlen( $str, 'UTF-8' );
144
-		$action = 0;
145
-		$temp = '';
146
-		for( $i=0;  $i<$len; $i++ ){
147
-			$t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
148
-			if( mt_rand( 1, 50 ) > 48 && $action == 0) {
149
-				if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
150
-					$temp .= $t_str;
151
-					$action = 1;
143
+		$len=iconv_strlen($str, 'UTF-8');
144
+		$action=0;
145
+		$temp='';
146
+		for ($i=0; $i < $len; $i++) {
147
+			$t_str=iconv_substr($str, $i, 1, 'UTF-8');
148
+			if (mt_rand(1, 50) > 48 && $action == 0) {
149
+				if (!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
150
+					$temp.=$t_str;
151
+					$action=1;
152 152
 				}
153 153
 			}
154
-			$temp .= $t_str;
154
+			$temp.=$t_str;
155 155
 		}
156 156
 		return $temp;
157 157
 	}
@@ -162,31 +162,31 @@  discard block
 block discarded – undo
162 162
 	 * @param string $str
163 163
 	 */
164 164
 	function setBlankness($str) {
165
-		$blankness = array(" ", ' ', '҉','̅̅','̲','̲̲','̅','̲̲̅̅');
166
-		$len = iconv_strlen( $str, 'UTF-8' );
167
-		$temp = '';
168
-		for( $i=0;  $i<$len; $i++ ){
169
-			$t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
170
-			if( mt_rand( 1, 50 ) > 48 ) {
171
-				if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
172
-					$temp .= $blankness[mt_rand(0, 7)];
165
+		$blankness=array(" ", ' ', '҉', '̅̅', '̲', '̲̲', '̅', '̲̲̅̅');
166
+		$len=iconv_strlen($str, 'UTF-8');
167
+		$temp='';
168
+		for ($i=0; $i < $len; $i++) {
169
+			$t_str=iconv_substr($str, $i, 1, 'UTF-8');
170
+			if (mt_rand(1, 50) > 48) {
171
+				if (!preg_match("@[a-z0-9%\\s]+@i", $t_str)) {
172
+					$temp.=$blankness[mt_rand(0, 7)];
173 173
 				}
174 174
 			}
175
-			$temp .= $t_str;
175
+			$temp.=$t_str;
176 176
 		}
177 177
 		return $temp;
178 178
 	}
179 179
 	
180 180
 	//随机进行繁体中文转换
181
-	function GbToBig( $str ){
182
-		$len = iconv_strlen( $str, 'UTF-8' );
183
-		$temp = '';
184
-		for( $i=0;  $i<$len; $i++ ){
185
-			$t_str = iconv_substr( $str, $i, 1 ,'UTF-8');
186
-			if( mt_rand( 1, 50 ) > 48 ) {
187
-				$t_str = strtr( $t_str, $this->GbToBigArray );
181
+	function GbToBig($str) {
182
+		$len=iconv_strlen($str, 'UTF-8');
183
+		$temp='';
184
+		for ($i=0; $i < $len; $i++) {
185
+			$t_str=iconv_substr($str, $i, 1, 'UTF-8');
186
+			if (mt_rand(1, 50) > 48) {
187
+				$t_str=strtr($t_str, $this->GbToBigArray);
188 188
 			}
189
-			$temp .= $t_str;
189
+			$temp.=$t_str;
190 190
 		}
191 191
 		return $temp;
192 192
 	}
Please login to merge, or discard this patch.
function.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
     // 过滤查询特殊字符
405 405
     if (preg_match('/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOTIN|NOT IN|IN)$/i', $value)) {
406
-        $value .= ' ';
406
+        $value.=' ';
407 407
     }
408 408
 }
409 409
 /**
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @return string|null
413 413
  */
414
-function config($name=null,$value=null,$default=null){
414
+function config($name=null, $value=null, $default=null) {
415 415
     $config=\puck\Conf::load();
416
-    if ($name===null){
416
+    if ($name === null) {
417 417
         return $config->all();
418 418
     }
419
-    if ($value===null){
420
-        return $config->get($name,$default);
419
+    if ($value === null) {
420
+        return $config->get($name, $default);
421 421
     }
422
-    $config->set($name,$value);
422
+    $config->set($name, $value);
423 423
 }
424 424
 /**
425 425
  * 字符串命名风格转换
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@
 block discarded – undo
39 39
 {
40 40
     if (isset($arr['status']) && $type == 2) {
41 41
         $ret=$arr;
42
-    }
43
-    else {
42
+    } else {
44 43
         $ret['status']=$type;
45 44
         $ret['data']=$arr;
46 45
     }
Please login to merge, or discard this patch.
core/Model.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -15,64 +15,64 @@
 block discarded – undo
15 15
     protected $limitCount=null;
16 16
     public function __construct()
17 17
     {
18
-        if(!$this->dbConn){
18
+        if (!$this->dbConn) {
19 19
             $this->dbConn='main';
20 20
         }
21
-        $this->db = Mysql::getDb($this->dbConn);
21
+        $this->db=Mysql::getDb($this->dbConn);
22 22
     }
23
-    public function __call($method,$arg){
23
+    public function __call($method, $arg) {
24 24
         $ret=$this;
25
-        if(method_exists ($this->db, $method)){
26
-            $ret=call_user_func_array(array($this->db,$method),$arg);
25
+        if (method_exists($this->db, $method)) {
26
+            $ret=call_user_func_array(array($this->db, $method), $arg);
27 27
         }
28
-        return $ret==$this->db? $this: $ret;
28
+        return $ret == $this->db ? $this : $ret;
29 29
     }
30
-    public function __get($name){
31
-        if(property_exists($this->db, $name)){
30
+    public function __get($name) {
31
+        if (property_exists($this->db, $name)) {
32 32
             return $this->db->$name;
33 33
         }
34
-        throw new MemberAccessException('model Property ' . $name . ' not exists');
34
+        throw new MemberAccessException('model Property '.$name.' not exists');
35 35
     }
36
-    public function limit($limit){
36
+    public function limit($limit) {
37 37
         $this->limitCount=$limit;
38 38
         return $this;
39 39
     }
40
-    public function find(){
41
-        return $this->db->getOne($this->table,$this->field);
40
+    public function find() {
41
+        return $this->db->getOne($this->table, $this->field);
42 42
     }
43
-    public function select(){
44
-        return $this->db->get($this->table,$this->limitCount?$this->limitCount:null,$this->field);
43
+    public function select() {
44
+        return $this->db->get($this->table, $this->limitCount ? $this->limitCount : null, $this->field);
45 45
     }
46
-    public function count(){
46
+    public function count() {
47 47
         return $this->field("count(*) as count")->find()['count'];
48 48
     }
49
-    public function table($table){
49
+    public function table($table) {
50 50
         $this->table=$table;
51 51
         return $this;
52 52
     }
53
-    public function add($data){
54
-        return $this->db->insert($this->table,$data);
53
+    public function add($data) {
54
+        return $this->db->insert($this->table, $data);
55 55
     }
56
-    public function replace($data){
57
-        return $this->db->replace($this->table,$data);
56
+    public function replace($data) {
57
+        return $this->db->replace($this->table, $data);
58 58
     }
59
-    public function update($data){
60
-        return $this->db->update($this->table,$data);
59
+    public function update($data) {
60
+        return $this->db->update($this->table, $data);
61 61
     }
62 62
 
63 63
     /**
64 64
      * @param string $field
65 65
      */
66
-    public function field($field){
66
+    public function field($field) {
67 67
         $this->field=$field;
68 68
         return $this;
69 69
     }
70
-    public function delete(){
70
+    public function delete() {
71 71
         return $this->db->delete($this->table);
72 72
     }
73
-    public function page($page,$pageLimit='10'){
73
+    public function page($page, $pageLimit='10') {
74 74
         $this->db->pageLimit=$pageLimit;
75
-        $info= $this->db->paginate($this->table,$page,$this->field);
75
+        $info=$this->db->paginate($this->table, $page, $this->field);
76 76
         return $info;
77 77
     }
78 78
 }
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
core/Controller.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,48 +4,48 @@
 block discarded – undo
4 4
 class Controller
5 5
 {
6 6
 
7
-    protected $viewPath = '';
7
+    protected $viewPath='';
8 8
     private $twig;
9
-    private $tVar = array();
9
+    private $tVar=array();
10 10
     protected $title='';
11 11
     public function __construct()
12 12
     {
13
-        $loader = new \Twig_Loader_Filesystem(BASE_PATH . $this->viewPath);
14
-        $twig = new \Twig_Environment($loader, array(
13
+        $loader=new \Twig_Loader_Filesystem(BASE_PATH.$this->viewPath);
14
+        $twig=new \Twig_Environment($loader, array(
15 15
             'debug' => DEBUG,
16
-            'cache' => BASE_PATH . '/cache',
16
+            'cache' => BASE_PATH.'/cache',
17 17
         ));
18
-        $this->twig = $twig;
18
+        $this->twig=$twig;
19 19
         $this->initTwigFilter();
20 20
         $this->initTwigFunction();
21
-        $this->db = \MysqliDb::getInstance();
21
+        $this->db=\MysqliDb::getInstance();
22 22
     }
23
-    private function initTwigFilter(){
24
-        $filter = new \Twig_SimpleFilter('long2ip', 'long2ip');
23
+    private function initTwigFilter() {
24
+        $filter=new \Twig_SimpleFilter('long2ip', 'long2ip');
25 25
         $this->twig->addFilter($filter);
26 26
     }
27
-    private function initTwigFunction(){
28
-        $function = new \Twig_SimpleFunction('I','I');
27
+    private function initTwigFunction() {
28
+        $function=new \Twig_SimpleFunction('I', 'I');
29 29
         $this->twig->addFunction($function);
30 30
     }
31 31
 
32 32
     /**
33 33
      * @param string $name
34 34
      */
35
-    protected function assign($name, $value = '')
35
+    protected function assign($name, $value='')
36 36
     {
37 37
         if (is_array($name)) {
38
-            $this->tVar = array_merge($this->tVar, $name);
38
+            $this->tVar=array_merge($this->tVar, $name);
39 39
         } else {
40
-            $this->tVar[$name] = $value;
40
+            $this->tVar[$name]=$value;
41 41
         }
42 42
     }
43 43
 
44
-    protected function show($tmpPath = '')
44
+    protected function show($tmpPath='')
45 45
     {
46 46
         if ($tmpPath == '') {
47 47
             if (defined("CONTROLLER_NAME") && defined("ACTION_NAME")) {
48
-                $tmpPath = parse_name(CONTROLLER_NAME) . '/' . parse_name(ACTION_NAME);
48
+                $tmpPath=parse_name(CONTROLLER_NAME).'/'.parse_name(ACTION_NAME);
49 49
             } else {
50 50
                 show_json($this->tVar);
51 51
             }
Please login to merge, or discard this patch.
core/helpers/TimeAgo.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -54,84 +54,84 @@
 block discarded – undo
54 54
      * @param integer $past
55 55
      * @param integer $now
56 56
      */
57
-    public function inStamp($past, $now = null) {
58
-        if($now==null){
57
+    public function inStamp($past, $now=null) {
58
+        if ($now == null) {
59 59
             $now=time();
60 60
         }
61 61
         // creates the "time ago" string. This always starts with an "about..."
62
-        $timeAgo = "";
62
+        $timeAgo="";
63 63
 
64 64
         // finds the time difference
65
-        $timeDifference = $now - $past;
65
+        $timeDifference=$now - $past;
66 66
         // rule 0
67 67
         // $past is null or empty or ''
68
-        if ($past==0) {
69
-            $timeAgo = $this->translate('never');
68
+        if ($past == 0) {
69
+            $timeAgo=$this->translate('never');
70 70
         }
71 71
         // rule 1
72 72
         // less than 29secs
73 73
         else if ($this->isLessThan29Seconds($timeDifference)) {
74
-            $timeAgo = $this->translate('lessThanAMinute');
74
+            $timeAgo=$this->translate('lessThanAMinute');
75 75
         }
76 76
         // rule 2
77 77
         // more than 29secs and less than 1min29secss
78 78
         else if ($this->isLessThan1Min29Seconds($timeDifference)) {
79
-            $timeAgo = $this->translate('oneMinute');
79
+            $timeAgo=$this->translate('oneMinute');
80 80
         }
81 81
         // rule 3
82 82
         // between 1min30secs and 44mins29secs
83 83
         else if ($this->isLessThan44Min29Secs($timeDifference)) {
84
-            $minutes = round($timeDifference / $this->secondsPerMinute);
85
-            $timeAgo = $this->translate('lessThanOneHour', $minutes);
84
+            $minutes=round($timeDifference / $this->secondsPerMinute);
85
+            $timeAgo=$this->translate('lessThanOneHour', $minutes);
86 86
         }
87 87
         // rule 4
88 88
         // between 44mins30secs and 1hour29mins59secs
89 89
         else if ($this->isLessThan1Hour29Mins59Seconds($timeDifference)) {
90
-            $timeAgo = $this->translate('aboutOneHour');
90
+            $timeAgo=$this->translate('aboutOneHour');
91 91
         }
92 92
         // rule 5
93 93
         // between 1hour29mins59secs and 23hours59mins29secs
94 94
         else if ($this->isLessThan23Hours59Mins29Seconds($timeDifference)) {
95
-            $hours = round($timeDifference / $this->secondsPerHour);
96
-            $timeAgo = $this->translate('hours', $hours);
95
+            $hours=round($timeDifference / $this->secondsPerHour);
96
+            $timeAgo=$this->translate('hours', $hours);
97 97
         }
98 98
         // rule 6
99 99
         // between 23hours59mins30secs and 47hours59mins29secs
100 100
         else if ($this->isLessThan47Hours59Mins29Seconds($timeDifference)) {
101
-            $timeAgo = $this->translate('aboutOneDay');
101
+            $timeAgo=$this->translate('aboutOneDay');
102 102
         }
103 103
         // rule 7
104 104
         // between 47hours59mins30secs and 29days23hours59mins29secs
105 105
         else if ($this->isLessThan29Days23Hours59Mins29Seconds($timeDifference)) {
106
-            $days = round($timeDifference / $this->secondsPerDay);
107
-            $timeAgo = $this->translate('days', $days);
106
+            $days=round($timeDifference / $this->secondsPerDay);
107
+            $timeAgo=$this->translate('days', $days);
108 108
         }
109 109
         // rule 8
110 110
         // between 29days23hours59mins30secs and 59days23hours59mins29secs
111 111
         else if ($this->isLessThan59Days23Hours59Mins29Secs($timeDifference)) {
112
-            $timeAgo = $this->translate('aboutOneMonth');
112
+            $timeAgo=$this->translate('aboutOneMonth');
113 113
         }
114 114
         // rule 9
115 115
         // between 59days23hours59mins30secs and 1year (minus 1sec)
116 116
         else if ($this->isLessThan1Year($timeDifference)) {
117
-            $months = round($timeDifference / $this->secondsPerMonth);
117
+            $months=round($timeDifference / $this->secondsPerMonth);
118 118
             // if months is 1, then set it to 2, because we are "past" 1 month
119 119
             if ($months == 1) {
120
-                $months = 2;
120
+                $months=2;
121 121
             }
122 122
 
123
-            $timeAgo = $this->translate('months', $months);
123
+            $timeAgo=$this->translate('months', $months);
124 124
         }
125 125
         // rule 10
126 126
         // between 1year and 2years (minus 1sec)
127 127
         else if ($this->isLessThan2Years($timeDifference)) {
128
-            $timeAgo = $this->translate('aboutOneYear');
128
+            $timeAgo=$this->translate('aboutOneYear');
129 129
         }
130 130
         // rule 11
131 131
         // 2years or more
132 132
         else {
133
-            $years = floor($timeDifference / $this->secondsPerYear);
134
-            $timeAgo = $this->translate('years', $years);
133
+            $years=floor($timeDifference / $this->secondsPerYear);
134
+            $timeAgo=$this->translate('years', $years);
135 135
         }
136 136
 
137 137
         return $timeAgo;
Please login to merge, or discard this patch.
core/helpers/Page.php 1 patch
Braces   +33 added lines, -30 removed lines patch added patch discarded remove patch
@@ -133,71 +133,74 @@
 block discarded – undo
133 133
                 $ext=$this->getParam();
134 134
             }
135 135
             $pagination.="<ul class='pager'>";
136
-            if ($this->_page > 1)
137
-                $pagination.="<li class='previous'><a href='".$path."$this->_instance=$prev"."$ext'><<</a></li>";
138
-            else
139
-                $pagination.="<li class='disabled previous'><span class='disabled'><<</span></li>";
136
+            if ($this->_page > 1) {
137
+                            $pagination.="<li class='previous'><a href='".$path."$this->_instance=$prev"."$ext'><<</a></li>";
138
+            } else {
139
+                            $pagination.="<li class='disabled previous'><span class='disabled'><<</span></li>";
140
+            }
140 141
 
141 142
             if ($lastpage < 7 + ($adjacents * 2))
142 143
             {
143 144
                 for ($counter=1; $counter <= $lastpage; $counter++)
144 145
                 {
145
-                    if ($counter == $this->_page)
146
-                        $pagination.="<li class='current'><span>$counter</span></li>";
147
-                    else
148
-                        $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
146
+                    if ($counter == $this->_page) {
147
+                                            $pagination.="<li class='current'><span>$counter</span></li>";
148
+                    } else {
149
+                                            $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
150
+                    }
149 151
                 }
150
-            }
151
-            elseif ($lastpage > 5 + ($adjacents * 2))
152
+            } elseif ($lastpage > 5 + ($adjacents * 2))
152 153
             {
153 154
                 if ($this->_page < 1 + ($adjacents * 2))
154 155
                 {
155 156
                     for ($counter=1; $counter < 4 + ($adjacents * 2); $counter++)
156 157
                     {
157
-                        if ($counter == $this->_page)
158
-                            $pagination.="<li class='current'><span>$counter</span></li>";
159
-                        else
160
-                            $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
158
+                        if ($counter == $this->_page) {
159
+                                                    $pagination.="<li class='current'><span>$counter</span></li>";
160
+                        } else {
161
+                                                    $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
162
+                        }
161 163
                     }
162 164
                     $pagination.="...";
163 165
                     $pagination.="<li><a href='".$path."$this->_instance=$lpm1"."$ext'>$lpm1</a></li>";
164 166
                     $pagination.="<li><a href='".$path."$this->_instance=$lastpage"."$ext'>$lastpage</a></li>";
165
-                }
166
-                elseif ($lastpage - ($adjacents * 2) > $this->_page && $this->_page > ($adjacents * 2))
167
+                } elseif ($lastpage - ($adjacents * 2) > $this->_page && $this->_page > ($adjacents * 2))
167 168
                 {
168 169
                     $pagination.="<li><a href='".$path."$this->_instance=1"."$ext'>1</a></li>";
169 170
                     $pagination.="<li><a href='".$path."$this->_instance=2"."$ext'>2</a></li>";
170 171
                     $pagination.="...";
171 172
                     for ($counter=$this->_page - $adjacents; $counter <= $this->_page + $adjacents; $counter++)
172 173
                     {
173
-                        if ($counter == $this->_page)
174
-                            $pagination.="<li class='current'><span>$counter</span></li>";
175
-                        else
176
-                            $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
174
+                        if ($counter == $this->_page) {
175
+                                                    $pagination.="<li class='current'><span>$counter</span></li>";
176
+                        } else {
177
+                                                    $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
178
+                        }
177 179
                     }
178 180
                     $pagination.="..";
179 181
                     $pagination.="<li><a href='".$path."$this->_instance=$lpm1"."$ext'>$lpm1</a></li>";
180 182
                     $pagination.="<li><a href='".$path."$this->_instance=$lastpage"."$ext'>$lastpage</a></li>";
181
-                }
182
-                else
183
+                } else
183 184
                 {
184 185
                     $pagination.="<li><a href='".$path."$this->_instance=1"."$ext'>1</a></li>";
185 186
                     $pagination.="<li><a href='".$path."$this->_instance=2"."$ext'>2</a></li>";
186 187
                     $pagination.="..";
187 188
                     for ($counter=$lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
188 189
                     {
189
-                        if ($counter == $this->_page)
190
-                            $pagination.="<li class='current'><span>$counter</span></li>";
191
-                        else
192
-                            $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
190
+                        if ($counter == $this->_page) {
191
+                                                    $pagination.="<li class='current'><span>$counter</span></li>";
192
+                        } else {
193
+                                                    $pagination.="<li><a href='".$path."$this->_instance=$counter"."$ext'>$counter</a></li>";
194
+                        }
193 195
                     }
194 196
                 }
195 197
             }
196 198
 
197
-            if ($this->_page < $counter - 1)
198
-                $pagination.="<li class='next'><a href='".$path."$this->_instance=$next"."$ext'>>></a></li>";
199
-            else
200
-                $pagination.="<li class='next disabled'><span class='disabled'>>></span></li>";
199
+            if ($this->_page < $counter - 1) {
200
+                            $pagination.="<li class='next'><a href='".$path."$this->_instance=$next"."$ext'>>></a></li>";
201
+            } else {
202
+                            $pagination.="<li class='next disabled'><span class='disabled'>>></span></li>";
203
+            }
201 204
             $pagination.="</ul>\n";
202 205
         }
203 206
 
Please login to merge, or discard this patch.
core/helpers/Dispatch.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,49 +6,49 @@  discard block
 block discarded – undo
6 6
 
7 7
 class Dispatch
8 8
 {
9
-    static public function init(){
10
-        if(!IS_CLI){
9
+    static public function init() {
10
+        if (!IS_CLI) {
11 11
             define('NOW_TIME', $_SERVER['REQUEST_TIME']);
12 12
             define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
13 13
             define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
14 14
             define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
15 15
             define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
16 16
             define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
17
-            define('IS_AJAX', ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ) ? true : false);
17
+            define('IS_AJAX', ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) ? true : false);
18 18
             define('__SELF__', strip_tags($_SERVER['REQUEST_URI']));
19 19
         }
20 20
     }
21
-    static public function dispatch($path='',$app='\\admin') {
21
+    static public function dispatch($path='', $app='\\admin') {
22 22
         self::init();
23
-        if($path==''){
23
+        if ($path == '') {
24 24
             $path=array();
25
-        } else{
26
-            $path=str_replace('-','_',$path);
27
-            $path   = explode('/',$path);
25
+        } else {
26
+            $path=str_replace('-', '_', $path);
27
+            $path=explode('/', $path);
28 28
         }
29 29
 
30
-        if(count($path)==0){
31
-            array_push($path,'home');
32
-            array_push($path,'index');
33
-        } elseif (count($path)==1){
34
-            array_push($path,'index');
30
+        if (count($path) == 0) {
31
+            array_push($path, 'home');
32
+            array_push($path, 'index');
33
+        } elseif (count($path) == 1) {
34
+            array_push($path, 'index');
35 35
         }
36
-        if(!empty($path)){
36
+        if (!empty($path)) {
37 37
             $tmpAction=array_pop($path);
38 38
             $tmpAction=preg_replace('/\.(html|aspx|do|php|htm|h5|api)$/i', '', $tmpAction);
39
-            $tmpAction=parse_name($tmpAction,1);
39
+            $tmpAction=parse_name($tmpAction, 1);
40 40
             $var['a']=$tmpAction;
41 41
         }
42
-        define('ACTION_NAME',$var['a']);
42
+        define('ACTION_NAME', $var['a']);
43 43
         if (!preg_match('/^[A-Za-z](\w)*$/', ACTION_NAME)) {
44 44
             die("error action");
45 45
         }
46
-        if(!empty($path)){
46
+        if (!empty($path)) {
47 47
             $tmpController=array_pop($path);
48
-            $tmpController=parse_name($tmpController,1);
48
+            $tmpController=parse_name($tmpController, 1);
49 49
             $var['c']=$tmpController;
50 50
         }
51
-        define('CONTROLLER_NAME',$var['c']);
51
+        define('CONTROLLER_NAME', $var['c']);
52 52
         if (!preg_match('/^[A-Za-z](\/|\w)*$/', CONTROLLER_NAME)) {
53 53
             die("error controller");
54 54
         }
@@ -56,24 +56,24 @@  discard block
 block discarded – undo
56 56
         if (!class_exists($class)) {
57 57
             not_found('this controller is can not work now!');
58 58
         }
59
-        $class= new $class();
60
-        if (!method_exists($class,ACTION_NAME)) {
59
+        $class=new $class();
60
+        if (!method_exists($class, ACTION_NAME)) {
61 61
             not_found();
62 62
         }
63 63
         self::param();
64
-        self::exec($class,ACTION_NAME);
64
+        self::exec($class, ACTION_NAME);
65 65
     }
66 66
 
67 67
     /**
68 68
      * @param string $function
69 69
      */
70
-    static public function exec($class,$function){
71
-        $method = new \ReflectionMethod($class, $function);
70
+    static public function exec($class, $function) {
71
+        $method=new \ReflectionMethod($class, $function);
72 72
         if ($method->isPublic() && !$method->isStatic()) {
73
-            $refClass = new \ReflectionClass($class);
73
+            $refClass=new \ReflectionClass($class);
74 74
             //前置方法
75
-            if ($refClass->hasMethod('_before_' . $function)) {
76
-                $before = $refClass->getMethod('_before_' . $function);
75
+            if ($refClass->hasMethod('_before_'.$function)) {
76
+                $before=$refClass->getMethod('_before_'.$function);
77 77
                 if ($before->isPublic()) {
78 78
                     $before->invoke($class);
79 79
                 }
Please login to merge, or discard this patch.