@@ -136,6 +136,7 @@ discard block |
||
136 | 136 | * @param mixed Name of the PHP variable to bind to the SQL statement parameter |
137 | 137 | * @param int SQL data type of the parameter |
138 | 138 | * @param int length of the data type |
139 | + * @param string $name |
|
139 | 140 | * @see http://www.php.net/manual/en/function.PDOStatement-bindParam.php |
140 | 141 | */ |
141 | 142 | public function bindParameter($name, &$value, $dataType=null, $length=null) |
@@ -157,6 +158,7 @@ discard block |
||
157 | 158 | * placeholders, this will be the 1-indexed position of the parameter. |
158 | 159 | * @param mixed The value to bind to the parameter |
159 | 160 | * @param int SQL data type of the parameter |
161 | + * @param string $name |
|
160 | 162 | * @see http://www.php.net/manual/en/function.PDOStatement-bindValue.php |
161 | 163 | */ |
162 | 164 | public function bindValue($name, $value, $dataType=null) |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param TDbConnection the database connection |
46 | 46 | * @param string the SQL statement to be executed |
47 | 47 | */ |
48 | - public function __construct(TDbConnection $connection,$text) |
|
48 | + public function __construct(TDbConnection $connection, $text) |
|
49 | 49 | { |
50 | 50 | $this->_connection=$connection; |
51 | 51 | $this->setText($text); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __sleep() |
58 | 58 | { |
59 | - return array_diff(parent::__sleep(),array("\0TDbCommand\0_statement")); |
|
59 | + return array_diff(parent::__sleep(), array("\0TDbCommand\0_statement")); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | catch(Exception $e) |
114 | 114 | { |
115 | - throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText()); |
|
115 | + throw new TDbException('dbcommand_prepare_failed', $e->getMessage(), $this->getText()); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | { |
143 | 143 | $this->prepare(); |
144 | 144 | if($dataType===null) |
145 | - $this->_statement->bindParam($name,$value); |
|
145 | + $this->_statement->bindParam($name, $value); |
|
146 | 146 | else if($length===null) |
147 | - $this->_statement->bindParam($name,$value,$dataType); |
|
147 | + $this->_statement->bindParam($name, $value, $dataType); |
|
148 | 148 | else |
149 | - $this->_statement->bindParam($name,$value,$dataType,$length); |
|
149 | + $this->_statement->bindParam($name, $value, $dataType, $length); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | { |
164 | 164 | $this->prepare(); |
165 | 165 | if($dataType===null) |
166 | - $this->_statement->bindValue($name,$value); |
|
166 | + $this->_statement->bindValue($name, $value); |
|
167 | 167 | else |
168 | - $this->_statement->bindValue($name,$value,$dataType); |
|
168 | + $this->_statement->bindValue($name, $value, $dataType); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | catch(Exception $e) |
194 | 194 | { |
195 | - throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
195 | + throw new TDbException('dbcommand_execute_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getDebugStatementText() |
203 | 203 | { |
204 | - if(Prado::getApplication()->getMode() === TApplicationMode::Debug) |
|
204 | + if(Prado::getApplication()->getMode()===TApplicationMode::Debug) |
|
205 | 205 | return $this->_statement instanceof PDOStatement ? |
206 | 206 | $this->_statement->queryString |
207 | 207 | : $this->getText(); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | catch(Exception $e) |
228 | 228 | { |
229 | - throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
229 | + throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | } |
254 | 254 | catch(Exception $e) |
255 | 255 | { |
256 | - throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
256 | + throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | catch(Exception $e) |
284 | 284 | { |
285 | - throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
285 | + throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 |
@@ -109,8 +109,7 @@ discard block |
||
109 | 109 | try |
110 | 110 | { |
111 | 111 | $this->_statement=$this->getConnection()->getPdoInstance()->prepare($this->getText()); |
112 | - } |
|
113 | - catch(Exception $e) |
|
112 | + } catch(Exception $e) |
|
114 | 113 | { |
115 | 114 | throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText()); |
116 | 115 | } |
@@ -186,11 +185,9 @@ discard block |
||
186 | 185 | { |
187 | 186 | $this->_statement->execute(); |
188 | 187 | return $this->_statement->rowCount(); |
189 | - } |
|
190 | - else |
|
188 | + } else |
|
191 | 189 | return $this->getConnection()->getPdoInstance()->exec($this->getText()); |
192 | - } |
|
193 | - catch(Exception $e) |
|
190 | + } catch(Exception $e) |
|
194 | 191 | { |
195 | 192 | throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText()); |
196 | 193 | } |
@@ -223,8 +220,7 @@ discard block |
||
223 | 220 | else |
224 | 221 | $this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText()); |
225 | 222 | return new TDbDataReader($this); |
226 | - } |
|
227 | - catch(Exception $e) |
|
223 | + } catch(Exception $e) |
|
228 | 224 | { |
229 | 225 | throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
230 | 226 | } |
@@ -250,8 +246,7 @@ discard block |
||
250 | 246 | $result=$this->_statement->fetch($fetchAssociative ? PDO::FETCH_ASSOC : PDO::FETCH_NUM); |
251 | 247 | $this->_statement->closeCursor(); |
252 | 248 | return $result; |
253 | - } |
|
254 | - catch(Exception $e) |
|
249 | + } catch(Exception $e) |
|
255 | 250 | { |
256 | 251 | throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
257 | 252 | } |
@@ -279,8 +274,7 @@ discard block |
||
279 | 274 | return stream_get_contents($result); |
280 | 275 | else |
281 | 276 | return $result; |
282 | - } |
|
283 | - catch(Exception $e) |
|
277 | + } catch(Exception $e) |
|
284 | 278 | { |
285 | 279 | throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
286 | 280 | } |
@@ -58,6 +58,7 @@ |
||
58 | 58 | * should match the case of the column, as returned by the driver. |
59 | 59 | * @param mixed Name of the PHP variable to which the column will be bound. |
60 | 60 | * @param int Data type of the parameter |
61 | + * @param integer $column |
|
61 | 62 | * @see http://www.php.net/manual/en/function.PDOStatement-bindColumn.php |
62 | 63 | */ |
63 | 64 | public function bindColumn($column, &$value, $dataType=null) |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TDbDataReader class file |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Data |
|
10 | - */ |
|
3 | + * TDbDataReader class file |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Data |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * TDbDataReader class. |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | public function bindColumn($column, &$value, $dataType=null) |
64 | 64 | { |
65 | 65 | if($dataType===null) |
66 | - $this->_statement->bindColumn($column,$value); |
|
66 | + $this->_statement->bindColumn($column, $value); |
|
67 | 67 | else |
68 | - $this->_statement->bindColumn($column,$value,$dataType); |
|
68 | + $this->_statement->bindColumn($column, $value, $dataType); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function setFetchMode($mode) |
75 | 75 | { |
76 | 76 | $params=func_get_args(); |
77 | - call_user_func_array(array($this->_statement,'setFetchMode'),$params); |
|
77 | + call_user_func_array(array($this->_statement, 'setFetchMode'), $params); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created |
103 | 103 | * @return mixed|false the populated object, false if no more row of data available |
104 | 104 | */ |
105 | - public function readObject($className,$fields) |
|
105 | + public function readObject($className, $fields) |
|
106 | 106 | { |
107 | - return $this->_statement->fetchObject($className,$fields); |
|
107 | + return $this->_statement->fetchObject($className, $fields); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function rewind() |
173 | 173 | { |
174 | - if($this->_index<0) |
|
174 | + if($this->_index < 0) |
|
175 | 175 | { |
176 | 176 | $this->_row=$this->_statement->fetch(); |
177 | 177 | $this->_index=0; |
@@ -109,6 +109,7 @@ discard block |
||
109 | 109 | * It terminates the application immediately after the error is displayed. |
110 | 110 | * @param mixed sender of the event |
111 | 111 | * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance) |
112 | + * @param null|TApplication $sender |
|
112 | 113 | */ |
113 | 114 | public function handleError($sender,$param) |
114 | 115 | { |
@@ -171,6 +172,7 @@ discard block |
||
171 | 172 | * mode will be displayed to the client user. |
172 | 173 | * @param integer response status code |
173 | 174 | * @param Exception exception instance |
175 | + * @param integer $statusCode |
|
174 | 176 | */ |
175 | 177 | protected function handleExternalError($statusCode,$exception) |
176 | 178 | { |
@@ -363,6 +365,9 @@ discard block |
||
363 | 365 | return $result; |
364 | 366 | } |
365 | 367 | |
368 | + /** |
|
369 | + * @param string $pattern |
|
370 | + */ |
|
366 | 371 | private function getPropertyAccessTrace($trace,$pattern) |
367 | 372 | { |
368 | 373 | $result=null; |
@@ -395,6 +400,9 @@ discard block |
||
395 | 400 | return $source; |
396 | 401 | } |
397 | 402 | |
403 | + /** |
|
404 | + * @param string $message |
|
405 | + */ |
|
398 | 406 | private function addLink($message) |
399 | 407 | { |
400 | 408 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
@@ -219,8 +219,7 @@ discard block |
||
219 | 219 | echo "<body><h1>Recursive Error</h1>\n"; |
220 | 220 | echo "<pre>".$exception->__toString()."</pre>\n"; |
221 | 221 | echo "</body></html>"; |
222 | - } |
|
223 | - else |
|
222 | + } else |
|
224 | 223 | { |
225 | 224 | error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
226 | 225 | header('HTTP/1.0 500 Internal Error'); |
@@ -251,15 +250,13 @@ discard block |
||
251 | 250 | if($fileName==='') |
252 | 251 | $fileName='---embedded template---'; |
253 | 252 | $errorLine=$exception->getLineNumber(); |
254 | - } |
|
255 | - else |
|
253 | + } else |
|
256 | 254 | { |
257 | 255 | if(($trace=$this->getExactTrace($exception))!==null) |
258 | 256 | { |
259 | 257 | $fileName=$trace['file']; |
260 | 258 | $errorLine=$trace['line']; |
261 | - } |
|
262 | - else |
|
259 | + } else |
|
263 | 260 | { |
264 | 261 | $fileName=$exception->getFile(); |
265 | 262 | $errorLine=$exception->getLine(); |
@@ -350,8 +347,7 @@ discard block |
||
350 | 347 | $result=$trace[0]; |
351 | 348 | elseif(isset($trace[1])) |
352 | 349 | $result=$trace[1]; |
353 | - } |
|
354 | - else if($exception instanceof TInvalidOperationException) |
|
350 | + } else if($exception instanceof TInvalidOperationException) |
|
355 | 351 | { |
356 | 352 | // in case of getter or setter error, find out the exact file and row |
357 | 353 | if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
@@ -388,8 +384,7 @@ discard block |
||
388 | 384 | { |
389 | 385 | $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
390 | 386 | $source.="<div class=\"error\">".$line."</div>"; |
391 | - } |
|
392 | - else |
|
387 | + } else |
|
393 | 388 | $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
394 | 389 | } |
395 | 390 | return $source; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
99 | 99 | $this->_templatePath=$templatePath; |
100 | 100 | else |
101 | - throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
|
101 | + throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param mixed sender of the event |
111 | 111 | * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance) |
112 | 112 | */ |
113 | - public function handleError($sender,$param) |
|
113 | + public function handleError($sender, $param) |
|
114 | 114 | { |
115 | 115 | static $handling=false; |
116 | 116 | // We need to restore error and exception handlers, |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | if(!headers_sent()) |
130 | 130 | header('Content-Type: text/html; charset=UTF-8'); |
131 | 131 | if($param instanceof THttpException) |
132 | - $this->handleExternalError($param->getStatusCode(),$param); |
|
132 | + $this->handleExternalError($param->getStatusCode(), $param); |
|
133 | 133 | else if($this->getApplication()->getMode()===TApplicationMode::Debug) |
134 | 134 | $this->displayException($param); |
135 | 135 | else |
136 | - $this->handleExternalError(500,$param); |
|
136 | + $this->handleExternalError(500, $param); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -146,21 +146,21 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected static function hideSecurityRelated($value, $exception=null) |
148 | 148 | { |
149 | - $aRpl = array(); |
|
150 | - if($exception !== null && $exception instanceof Exception) |
|
149 | + $aRpl=array(); |
|
150 | + if($exception!==null && $exception instanceof Exception) |
|
151 | 151 | { |
152 | - $aTrace = $exception->getTrace(); |
|
152 | + $aTrace=$exception->getTrace(); |
|
153 | 153 | foreach($aTrace as $item) |
154 | 154 | { |
155 | 155 | if(isset($item['file'])) |
156 | - $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
|
156 | + $aRpl[dirname($item['file']).DIRECTORY_SEPARATOR]='<hidden>'.DIRECTORY_SEPARATOR; |
|
157 | 157 | } |
158 | 158 | } |
159 | - $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
|
160 | - $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
|
161 | - $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
|
159 | + $aRpl[$_SERVER['DOCUMENT_ROOT']]='${DocumentRoot}'; |
|
160 | + $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])]='${DocumentRoot}'; |
|
161 | + $aRpl[PRADO_DIR.DIRECTORY_SEPARATOR]='${PradoFramework}'.DIRECTORY_SEPARATOR; |
|
162 | 162 | if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
163 | - $aRpl = array_reverse($aRpl, true); |
|
163 | + $aRpl=array_reverse($aRpl, true); |
|
164 | 164 | |
165 | 165 | return str_replace(array_keys($aRpl), $aRpl, $value); |
166 | 166 | } |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | * @param integer response status code |
173 | 173 | * @param Exception exception instance |
174 | 174 | */ |
175 | - protected function handleExternalError($statusCode,$exception) |
|
175 | + protected function handleExternalError($statusCode, $exception) |
|
176 | 176 | { |
177 | 177 | if(!($exception instanceof THttpException)) |
178 | 178 | error_log($exception->__toString()); |
179 | 179 | |
180 | - $content=$this->getErrorTemplate($statusCode,$exception); |
|
180 | + $content=$this->getErrorTemplate($statusCode, $exception); |
|
181 | 181 | |
182 | - $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
182 | + $serverAdmin=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
183 | 183 | |
184 | - $isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug; |
|
184 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
185 | 185 | |
186 | - $errorMessage = $exception->getMessage(); |
|
186 | + $errorMessage=$exception->getMessage(); |
|
187 | 187 | if($isDebug) |
188 | 188 | $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
189 | 189 | else |
190 | 190 | { |
191 | 191 | $version=''; |
192 | - $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
|
192 | + $errorMessage=self::hideSecurityRelated($errorMessage, $exception); |
|
193 | 193 | } |
194 | 194 | $tokens=array( |
195 | 195 | '%%StatusCode%%' => "$statusCode", |
196 | 196 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
197 | 197 | '%%ServerAdmin%%' => $serverAdmin, |
198 | 198 | '%%Version%%' => $version, |
199 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
199 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
200 | 200 | ); |
201 | 201 | |
202 | 202 | $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null); |
203 | 203 | |
204 | - echo strtr($content,$tokens); |
|
204 | + echo strtr($content, $tokens); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | if($exception instanceof TTemplateException) |
247 | 247 | { |
248 | 248 | $fileName=$exception->getTemplateFile(); |
249 | - $lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName); |
|
250 | - $source=$this->getSourceCode($lines,$exception->getLineNumber()); |
|
249 | + $lines=empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
250 | + $source=$this->getSourceCode($lines, $exception->getLineNumber()); |
|
251 | 251 | if($fileName==='') |
252 | 252 | $fileName='---embedded template---'; |
253 | 253 | $errorLine=$exception->getLineNumber(); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $fileName=$exception->getFile(); |
265 | 265 | $errorLine=$exception->getLine(); |
266 | 266 | } |
267 | - $source=$this->getSourceCode(@file($fileName),$errorLine); |
|
267 | + $source=$this->getSourceCode(@file($fileName), $errorLine); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | '%%SourceCode%%' => $source, |
280 | 280 | '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), |
281 | 281 | '%%Version%%' => $version, |
282 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
282 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
283 | 283 | ); |
284 | 284 | |
285 | 285 | $content=$this->getExceptionTemplate($exception); |
286 | 286 | |
287 | - echo strtr($content,$tokens); |
|
287 | + echo strtr($content, $tokens); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param Exception the exception to be displayed |
322 | 322 | * @return string the template content |
323 | 323 | */ |
324 | - protected function getErrorTemplate($statusCode,$exception) |
|
324 | + protected function getErrorTemplate($statusCode, $exception) |
|
325 | 325 | { |
326 | 326 | $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
327 | 327 | $lang=Prado::getPreferredLanguage(); |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | else if($exception instanceof TInvalidOperationException) |
355 | 355 | { |
356 | 356 | // in case of getter or setter error, find out the exact file and row |
357 | - if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
|
358 | - $result=$this->getPropertyAccessTrace($trace,'__set'); |
|
357 | + if(($result=$this->getPropertyAccessTrace($trace, '__get'))===null) |
|
358 | + $result=$this->getPropertyAccessTrace($trace, '__set'); |
|
359 | 359 | } |
360 | - if($result!==null && strpos($result['file'],': eval()\'d code')!==false) |
|
360 | + if($result!==null && strpos($result['file'], ': eval()\'d code')!==false) |
|
361 | 361 | return null; |
362 | 362 | |
363 | 363 | return $result; |
364 | 364 | } |
365 | 365 | |
366 | - private function getPropertyAccessTrace($trace,$pattern) |
|
366 | + private function getPropertyAccessTrace($trace, $pattern) |
|
367 | 367 | { |
368 | 368 | $result=null; |
369 | 369 | foreach($trace as $t) |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | return $result; |
377 | 377 | } |
378 | 378 | |
379 | - private function getSourceCode($lines,$errorLine) |
|
379 | + private function getSourceCode($lines, $errorLine) |
|
380 | 380 | { |
381 | - $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; |
|
382 | - $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); |
|
381 | + $beginLine=$errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
382 | + $endLine=$errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
383 | 383 | |
384 | 384 | $source=''; |
385 | - for($i=$beginLine;$i<$endLine;++$i) |
|
385 | + for($i=$beginLine; $i < $endLine; ++$i) |
|
386 | 386 | { |
387 | - if($i===$errorLine-1) |
|
387 | + if($i===$errorLine - 1) |
|
388 | 388 | { |
389 | - $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
389 | + $line=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
390 | 390 | $source.="<div class=\"error\">".$line."</div>"; |
391 | 391 | } |
392 | 392 | else |
393 | - $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
393 | + $source.=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
394 | 394 | } |
395 | 395 | return $source; |
396 | 396 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | private function addLink($message) |
399 | 399 | { |
400 | 400 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
401 | - return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message); |
|
401 | + return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 |
@@ -393,6 +393,8 @@ |
||
393 | 393 | * in the message file. If so, the message in the preferred language |
394 | 394 | * will be used as the error message. Any rest parameters will be used |
395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
396 | + * @param integer $statusCode |
|
397 | + * @param string $errorMessage |
|
396 | 398 | */ |
397 | 399 | public function __construct($statusCode,$errorMessage) |
398 | 400 | { |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | array_shift($args); |
51 | 51 | $n=count($args); |
52 | 52 | $tokens=array(); |
53 | - for($i=0;$i<$n;++$i) |
|
53 | + for($i=0; $i < $n; ++$i) |
|
54 | 54 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
55 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
55 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | $msgFile=$this->getErrorMessageFile(); |
66 | 66 | |
67 | 67 | // Cache messages |
68 | - if (!isset(self::$_messageCache[$msgFile])) |
|
68 | + if(!isset(self::$_messageCache[$msgFile])) |
|
69 | 69 | { |
70 | 70 | if(($entries=@file($msgFile))!==false) |
71 | 71 | { |
72 | 72 | foreach($entries as $entry) |
73 | 73 | { |
74 | - @list($code,$message)=explode('=',$entry,2); |
|
74 | + @list($code, $message)=explode('=', $entry, 2); |
|
75 | 75 | self::$_messageCache[$msgFile][trim($code)]=trim($message); |
76 | 76 | } |
77 | 77 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param string error file |
339 | 339 | * @param integer error line number |
340 | 340 | */ |
341 | - public function __construct($errno,$errstr,$errfile,$errline) |
|
341 | + public function __construct($errno, $errstr, $errfile, $errline) |
|
342 | 342 | { |
343 | 343 | static $errorTypes=array( |
344 | 344 | E_ERROR => "Error", |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | E_USER_NOTICE => "User Notice", |
355 | 355 | E_STRICT => "Runtime Notice" |
356 | 356 | ); |
357 | - $errorType=isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; |
|
357 | + $errorType=isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error'; |
|
358 | 358 | parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); |
359 | 359 | } |
360 | 360 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * will be used as the error message. Any rest parameters will be used |
395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
396 | 396 | */ |
397 | - public function __construct($statusCode,$errorMessage) |
|
397 | + public function __construct($statusCode, $errorMessage) |
|
398 | 398 | { |
399 | 399 | $this->_statusCode=$statusCode; |
400 | 400 | $this->setErrorCode($errorMessage); |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | array_shift($args); |
405 | 405 | $n=count($args); |
406 | 406 | $tokens=array(); |
407 | - for($i=0;$i<$n;++$i) |
|
407 | + for($i=0; $i < $n; ++$i) |
|
408 | 408 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
409 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
409 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -165,6 +165,9 @@ discard block |
||
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | + /** |
|
169 | + * @param string $set |
|
170 | + */ |
|
168 | 171 | protected function isValidSetNotation($number, $set) |
169 | 172 | { |
170 | 173 | $str = '$result = '.str_replace('n', '$number', $set).';'; |
@@ -208,6 +211,7 @@ discard block |
||
208 | 211 | * string that satisfied the set within the choices. |
209 | 212 | * @param string the choices string. |
210 | 213 | * @param float the number to test. |
214 | + * @param double $number |
|
211 | 215 | * @return string the choosen string. |
212 | 216 | */ |
213 | 217 | public function format($string, $number) |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | * The pattern to validate a set notation |
83 | 83 | * @var string |
84 | 84 | */ |
85 | - protected $validate = '/[\(\[\{]|[-Inf\d:\s]+|,|[\+Inf\d\s:\?\-=!><%\|&\(\)]+|[\)\]\}]/ms'; |
|
85 | + protected $validate='/[\(\[\{]|[-Inf\d:\s]+|,|[\+Inf\d\s:\?\-=!><%\|&\(\)]+|[\)\]\}]/ms'; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * The pattern to parse the formatting string. |
89 | 89 | * @var string |
90 | 90 | */ |
91 | - protected $parse = '/\s*\|?([\(\[\{]([-Inf\d:\s]+,?[\+Inf\d\s:\?\-=!><%\|&\(\)]*)+[\)\]\}])\s*/'; |
|
91 | + protected $parse='/\s*\|?([\(\[\{]([-Inf\d:\s]+,?[\+Inf\d\s:\?\-=!><%\|&\(\)]*)+[\)\]\}])\s*/'; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * The value for positive infinity. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function __construct() |
104 | 104 | { |
105 | - $this->inf = -log(0); |
|
105 | + $this->inf=-log(0); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | function isValid($number, $set) |
116 | 116 | { |
117 | - $n = preg_match_all($this->validate,$set,$matches,PREG_SET_ORDER); |
|
117 | + $n=preg_match_all($this->validate, $set, $matches, PREG_SET_ORDER); |
|
118 | 118 | |
119 | 119 | if($n < 3) throw new Exception("Invalid set \"{$set}\""); |
120 | 120 | |
@@ -123,42 +123,42 @@ discard block |
||
123 | 123 | return $this->isValidSetNotation($number, $def[1]); |
124 | 124 | } |
125 | 125 | |
126 | - $leftBracket = $matches[0][0]; |
|
127 | - $rightBracket = $matches[$n-1][0]; |
|
126 | + $leftBracket=$matches[0][0]; |
|
127 | + $rightBracket=$matches[$n - 1][0]; |
|
128 | 128 | |
129 | - $i = 0; |
|
130 | - $elements = array(); |
|
129 | + $i=0; |
|
130 | + $elements=array(); |
|
131 | 131 | foreach($matches as $match) |
132 | 132 | { |
133 | - $string = $match[0]; |
|
134 | - if($i != 0 && $i != $n-1 && $string !== ',') |
|
133 | + $string=$match[0]; |
|
134 | + if($i!=0 && $i!=$n - 1 && $string!==',') |
|
135 | 135 | { |
136 | - if($string == '-Inf') |
|
137 | - $elements[] = -1*$this->inf; |
|
138 | - else if ($string == '+Inf' || $string == 'Inf') |
|
139 | - $elements[] = $this->inf; |
|
136 | + if($string=='-Inf') |
|
137 | + $elements[]=-1 * $this->inf; |
|
138 | + else if($string=='+Inf' || $string=='Inf') |
|
139 | + $elements[]=$this->inf; |
|
140 | 140 | else |
141 | - $elements[] = floatval($string); |
|
141 | + $elements[]=floatval($string); |
|
142 | 142 | } |
143 | 143 | $i++; |
144 | 144 | } |
145 | - $total = count($elements); |
|
146 | - $number = floatval($number); |
|
145 | + $total=count($elements); |
|
146 | + $number=floatval($number); |
|
147 | 147 | |
148 | - if($leftBracket == '{' && $rightBracket == '}') |
|
148 | + if($leftBracket=='{' && $rightBracket=='}') |
|
149 | 149 | return in_array($number, $elements); |
150 | 150 | |
151 | - $left = false; |
|
152 | - if($leftBracket == '[') |
|
153 | - $left = $number >= $elements[0]; |
|
154 | - else if ($leftBracket == '(') |
|
155 | - $left = $number > $elements[0]; |
|
151 | + $left=false; |
|
152 | + if($leftBracket=='[') |
|
153 | + $left=$number >= $elements[0]; |
|
154 | + else if($leftBracket=='(') |
|
155 | + $left=$number > $elements[0]; |
|
156 | 156 | |
157 | - $right = false; |
|
157 | + $right=false; |
|
158 | 158 | if($rightBracket==']') |
159 | - $right = $number <= $elements[$total-1]; |
|
160 | - else if($rightBracket == ')') |
|
161 | - $right = $number < $elements[$total-1]; |
|
159 | + $right=$number <= $elements[$total - 1]; |
|
160 | + else if($rightBracket==')') |
|
161 | + $right=$number < $elements[$total - 1]; |
|
162 | 162 | |
163 | 163 | if($left && $right) return true; |
164 | 164 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | protected function isValidSetNotation($number, $set) |
169 | 169 | { |
170 | - $str = '$result = '.str_replace('n', '$number', $set).';'; |
|
170 | + $str='$result = '.str_replace('n', '$number', $set).';'; |
|
171 | 171 | try |
172 | 172 | { |
173 | 173 | eval($str); |
@@ -187,18 +187,18 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function parse($string) |
189 | 189 | { |
190 | - $n = preg_match_all($this->parse,$string,$matches, PREG_OFFSET_CAPTURE); |
|
191 | - $sets = array(); |
|
190 | + $n=preg_match_all($this->parse, $string, $matches, PREG_OFFSET_CAPTURE); |
|
191 | + $sets=array(); |
|
192 | 192 | foreach($matches[1] as $match) |
193 | - $sets[] = $match[0]; |
|
194 | - $offset = $matches[0]; |
|
195 | - $strings = array(); |
|
196 | - for($i = 0; $i < $n; $i++) |
|
193 | + $sets[]=$match[0]; |
|
194 | + $offset=$matches[0]; |
|
195 | + $strings=array(); |
|
196 | + for($i=0; $i < $n; $i++) |
|
197 | 197 | { |
198 | - $len = strlen($offset[$i][0]); |
|
199 | - $begin = $i == 0? $len : $offset[$i][1] + $len; |
|
200 | - $end = $i == $n-1 ? strlen($string) : $offset[$i+1][1]; |
|
201 | - $strings[] = substr($string, $begin, $end - $begin); |
|
198 | + $len=strlen($offset[$i][0]); |
|
199 | + $begin=$i==0 ? $len : $offset[$i][1] + $len; |
|
200 | + $end=$i==$n - 1 ? strlen($string) : $offset[$i + 1][1]; |
|
201 | + $strings[]=substr($string, $begin, $end - $begin); |
|
202 | 202 | } |
203 | 203 | return array($sets, $strings); |
204 | 204 | } |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function format($string, $number) |
214 | 214 | { |
215 | - list($sets, $strings) = $this->parse($string); |
|
216 | - $total = count($sets); |
|
217 | - for($i = 0; $i < $total; $i++) |
|
215 | + list($sets, $strings)=$this->parse($string); |
|
216 | + $total=count($sets); |
|
217 | + for($i=0; $i < $total; $i++) |
|
218 | 218 | { |
219 | 219 | if($this->isValid($number, $sets[$i])) |
220 | 220 | return $strings[$i]; |
@@ -164,8 +164,7 @@ |
||
164 | 164 | try |
165 | 165 | { |
166 | 166 | $highlighter=Text_Highlighter::factory($this->getLanguage()); |
167 | - } |
|
168 | - catch(Exception $e) |
|
167 | + } catch(Exception $e) |
|
169 | 168 | { |
170 | 169 | $highlighter=false; |
171 | 170 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * @return mixed the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'. |
|
185 | + * @return string the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'. |
|
186 | 186 | */ |
187 | 187 | public function getCryptAlgorithm() |
188 | 188 | { |
@@ -201,6 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Encrypts data with {@link getEncryptionKey EncryptionKey}. |
203 | 203 | * @param string data to be encrypted. |
204 | + * @param string $data |
|
204 | 205 | * @return string the encrypted data |
205 | 206 | * @throws TNotSupportedException if PHP Mcrypt extension is not loaded |
206 | 207 | */ |
@@ -220,6 +221,7 @@ discard block |
||
220 | 221 | /** |
221 | 222 | * Decrypts data with {@link getEncryptionKey EncryptionKey}. |
222 | 223 | * @param string data to be decrypted. |
224 | + * @param string $data |
|
223 | 225 | * @return string the decrypted data |
224 | 226 | * @throws TNotSupportedException if PHP Mcrypt extension is not loaded |
225 | 227 | */ |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class TSecurityManager extends TModule |
42 | 42 | { |
43 | - const STATE_VALIDATION_KEY = 'prado:securitymanager:validationkey'; |
|
44 | - const STATE_ENCRYPTION_KEY = 'prado:securitymanager:encryptionkey'; |
|
43 | + const STATE_VALIDATION_KEY='prado:securitymanager:validationkey'; |
|
44 | + const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey'; |
|
45 | 45 | |
46 | - private $_validationKey = null; |
|
47 | - private $_encryptionKey = null; |
|
48 | - private $_hashAlgorithm = 'sha1'; |
|
49 | - private $_cryptAlgorithm = 'rijndael-256'; |
|
46 | + private $_validationKey=null; |
|
47 | + private $_encryptionKey=null; |
|
48 | + private $_hashAlgorithm='sha1'; |
|
49 | + private $_cryptAlgorithm='rijndael-256'; |
|
50 | 50 | private $_mbstring; |
51 | 51 | |
52 | 52 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function generateRandomKey() |
67 | 67 | { |
68 | - return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand()); |
|
68 | + return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getValidationKey() |
76 | 76 | { |
77 | - if(null === $this->_validationKey) { |
|
78 | - if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
79 | - $this->_validationKey = $this->generateRandomKey(); |
|
77 | + if(null===$this->_validationKey) { |
|
78 | + if(null===($this->_validationKey=$this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
79 | + $this->_validationKey=$this->generateRandomKey(); |
|
80 | 80 | $this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true); |
81 | 81 | } |
82 | 82 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setValidationKey($value) |
91 | 91 | { |
92 | - if('' === $value) |
|
92 | + if(''===$value) |
|
93 | 93 | throw new TInvalidDataValueException('securitymanager_validationkey_invalid'); |
94 | 94 | |
95 | - $this->_validationKey = $value; |
|
95 | + $this->_validationKey=$value; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function getEncryptionKey() |
103 | 103 | { |
104 | - if(null === $this->_encryptionKey) { |
|
105 | - if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
106 | - $this->_encryptionKey = $this->generateRandomKey(); |
|
104 | + if(null===$this->_encryptionKey) { |
|
105 | + if(null===($this->_encryptionKey=$this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
106 | + $this->_encryptionKey=$this->generateRandomKey(); |
|
107 | 107 | $this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true); |
108 | 108 | } |
109 | 109 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function setEncryptionKey($value) |
118 | 118 | { |
119 | - if('' === $value) |
|
119 | + if(''===$value) |
|
120 | 120 | throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid'); |
121 | 121 | |
122 | - $this->_encryptionKey = $value; |
|
122 | + $this->_encryptionKey=$value; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function setValidation($value) |
149 | 149 | { |
150 | - $this->_hashAlgorithm = TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode'); |
|
150 | + $this->_hashAlgorithm=TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function setHashAlgorithm($value) |
157 | 157 | { |
158 | - $this->_hashAlgorithm = TPropertyValue::ensureString($value); |
|
158 | + $this->_hashAlgorithm=TPropertyValue::ensureString($value); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function setEncryption($value) |
180 | 180 | { |
181 | - $this->_cryptAlgorithm = $value; |
|
181 | + $this->_cryptAlgorithm=$value; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function setCryptAlgorithm($value) |
197 | 197 | { |
198 | - $this->_cryptAlgorithm = $value; |
|
198 | + $this->_cryptAlgorithm=$value; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | public function encrypt($data) |
208 | 208 | { |
209 | 209 | $module=$this->openCryptModule(); |
210 | - $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
210 | + $key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
211 | 211 | srand(); |
212 | - $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
|
212 | + $iv=mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
|
213 | 213 | mcrypt_generic_init($module, $key, $iv); |
214 | - $encrypted = $iv.mcrypt_generic($module, $data); |
|
214 | + $encrypted=$iv.mcrypt_generic($module, $data); |
|
215 | 215 | mcrypt_generic_deinit($module); |
216 | 216 | mcrypt_module_close($module); |
217 | 217 | return $encrypted; |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | public function decrypt($data) |
227 | 227 | { |
228 | 228 | $module=$this->openCryptModule(); |
229 | - $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
230 | - $ivSize = mcrypt_enc_get_iv_size($module); |
|
231 | - $iv = $this->substr($data, 0, $ivSize); |
|
229 | + $key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
230 | + $ivSize=mcrypt_enc_get_iv_size($module); |
|
231 | + $iv=$this->substr($data, 0, $ivSize); |
|
232 | 232 | mcrypt_generic_init($module, $key, $iv); |
233 | - $decrypted = mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data))); |
|
233 | + $decrypted=mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data))); |
|
234 | 234 | mcrypt_generic_deinit($module); |
235 | 235 | mcrypt_module_close($module); |
236 | 236 | return $decrypted; |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | if(extension_loaded('mcrypt')) |
247 | 247 | { |
248 | 248 | if(is_array($this->_cryptAlgorithm)) |
249 | - $module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm); |
|
249 | + $module=@call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm); |
|
250 | 250 | else |
251 | - $module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,''); |
|
251 | + $module=@mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, ''); |
|
252 | 252 | |
253 | 253 | if($module===false) |
254 | 254 | throw new TNotSupportedException('securitymanager_mcryptextension_initfailed'); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function hashData($data) |
268 | 268 | { |
269 | - $hmac = $this->computeHMAC($data); |
|
269 | + $hmac=$this->computeHMAC($data); |
|
270 | 270 | return $hmac.$data; |
271 | 271 | } |
272 | 272 | |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | if($this->strlen($data) < $len) |
285 | 285 | return false; |
286 | 286 | |
287 | - $hmac = $this->substr($data, 0, $len); |
|
287 | + $hmac=$this->substr($data, 0, $len); |
|
288 | 288 | $data2=$this->substr($data, $len, $this->strlen($data)); |
289 | - return $hmac === $this->computeHMAC($data2) ? $data2 : false; |
|
289 | + return $hmac===$this->computeHMAC($data2) ? $data2 : false; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,22 +296,22 @@ discard block |
||
296 | 296 | */ |
297 | 297 | protected function computeHMAC($data) |
298 | 298 | { |
299 | - $key = $this->getValidationKey(); |
|
299 | + $key=$this->getValidationKey(); |
|
300 | 300 | |
301 | 301 | if(function_exists('hash_hmac')) |
302 | 302 | return hash_hmac($this->_hashAlgorithm, $data, $key); |
303 | 303 | |
304 | - if(!strcasecmp($this->_hashAlgorithm,'sha1')) |
|
304 | + if(!strcasecmp($this->_hashAlgorithm, 'sha1')) |
|
305 | 305 | { |
306 | - $pack = 'H40'; |
|
307 | - $func = 'sha1'; |
|
306 | + $pack='H40'; |
|
307 | + $func='sha1'; |
|
308 | 308 | } else { |
309 | - $pack = 'H32'; |
|
310 | - $func = 'md5'; |
|
309 | + $pack='H32'; |
|
310 | + $func='md5'; |
|
311 | 311 | } |
312 | 312 | |
313 | - $key = str_pad($func($key), 64, chr(0)); |
|
314 | - return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)) . pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)) . $data))); |
|
313 | + $key=str_pad($func($key), 64, chr(0)); |
|
314 | + return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)).pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)).$data))); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | private function strlen($string) |
324 | 324 | { |
325 | - return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string); |
|
325 | + return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * @param int $length the desired portion length |
334 | 334 | * @return string the extracted part of string, or FALSE on failure or an empty string. |
335 | 335 | */ |
336 | - private function substr($string,$start,$length) |
|
336 | + private function substr($string, $start, $length) |
|
337 | 337 | { |
338 | - return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length); |
|
338 | + return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
@@ -357,6 +357,6 @@ discard block |
||
357 | 357 | */ |
358 | 358 | class TSecurityManagerValidationMode extends TEnumerable |
359 | 359 | { |
360 | - const MD5 = 'MD5'; |
|
361 | - const SHA1 = 'SHA1'; |
|
360 | + const MD5='MD5'; |
|
361 | + const SHA1='SHA1'; |
|
362 | 362 | } |
@@ -73,6 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string username |
76 | + * @param string $value |
|
76 | 77 | */ |
77 | 78 | public function setName($value) |
78 | 79 | { |
@@ -89,6 +90,7 @@ discard block |
||
89 | 90 | |
90 | 91 | /** |
91 | 92 | * @param boolean if the user is a guest |
93 | + * @param boolean $value |
|
92 | 94 | */ |
93 | 95 | public function setIsGuest($value) |
94 | 96 | { |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | * |
171 | 173 | * @param string variable name |
172 | 174 | * @param mixed default value |
175 | + * @param string $key |
|
173 | 176 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 177 | * @see setState |
175 | 178 | */ |
@@ -190,6 +193,7 @@ discard block |
||
190 | 193 | * @param string variable name |
191 | 194 | * @param mixed variable value |
192 | 195 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
196 | + * @param string $key |
|
193 | 197 | * @see getState |
194 | 198 | */ |
195 | 199 | protected function setState($key,$value,$defaultValue=null) |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getName() |
70 | 70 | { |
71 | - return $this->getState('Name',''); |
|
71 | + return $this->getState('Name', ''); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setName($value) |
78 | 78 | { |
79 | - $this->setState('Name',$value,''); |
|
79 | + $this->setState('Name', $value, ''); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getIsGuest() |
86 | 86 | { |
87 | - return $this->getState('IsGuest',true); |
|
87 | + return $this->getState('IsGuest', true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->setName($this->_manager->getGuestName()); |
98 | 98 | $this->setRoles(array()); |
99 | 99 | } |
100 | - $this->setState('IsGuest',$isGuest); |
|
100 | + $this->setState('IsGuest', $isGuest); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getRoles() |
107 | 107 | { |
108 | - return $this->getState('Roles',array()); |
|
108 | + return $this->getState('Roles', array()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function setRoles($value) |
115 | 115 | { |
116 | 116 | if(is_array($value)) |
117 | - $this->setState('Roles',$value,array()); |
|
117 | + $this->setState('Roles', $value, array()); |
|
118 | 118 | else |
119 | 119 | { |
120 | 120 | $roles=array(); |
121 | - foreach(explode(',',$value) as $role) |
|
121 | + foreach(explode(',', $value) as $role) |
|
122 | 122 | { |
123 | 123 | if(($role=trim($role))!=='') |
124 | 124 | $roles[]=$role; |
125 | 125 | } |
126 | - $this->setState('Roles',$roles,array()); |
|
126 | + $this->setState('Roles', $roles, array()); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function isInRole($role) |
135 | 135 | { |
136 | 136 | foreach($this->getRoles() as $r) |
137 | - if(strcasecmp($role,$r)===0) |
|
137 | + if(strcasecmp($role, $r)===0) |
|
138 | 138 | return true; |
139 | 139 | return false; |
140 | 140 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 174 | * @see setState |
175 | 175 | */ |
176 | - protected function getState($key,$defaultValue=null) |
|
176 | + protected function getState($key, $defaultValue=null) |
|
177 | 177 | { |
178 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
178 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
193 | 193 | * @see getState |
194 | 194 | */ |
195 | - protected function setState($key,$value,$defaultValue=null) |
|
195 | + protected function setState($key, $value, $defaultValue=null) |
|
196 | 196 | { |
197 | 197 | if($value===$defaultValue) |
198 | 198 | unset($this->_state[$key]); |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param string path of the asset that is relative to the directory containing the specified class file. |
94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
95 | + * @param string $assetPath |
|
95 | 96 | * @return string URL to the asset path. |
96 | 97 | */ |
97 | 98 | public function publishAsset($assetPath,$className=null) |
@@ -106,6 +107,7 @@ discard block |
||
106 | 107 | /** |
107 | 108 | * Publishes a file or directory and returns its URL. |
108 | 109 | * @param string absolute path of the file or directory to be published |
110 | + * @param string $fullPath |
|
109 | 111 | * @return string URL to the published file or directory |
110 | 112 | */ |
111 | 113 | public function publishFilePath($fullPath, $checkTimestamp=false) |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TApplicationComponent class |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System |
|
10 | - */ |
|
3 | + * TApplicationComponent class |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * TApplicationComponent class |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
95 | 95 | * @return string URL to the asset path. |
96 | 96 | */ |
97 | - public function publishAsset($assetPath,$className=null) |
|
97 | + public function publishAsset($assetPath, $className=null) |
|
98 | 98 | { |
99 | 99 | if($className===null) |
100 | 100 | $className=get_class($this); |
@@ -258,6 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Saves the current UrlManager instance to cache. |
261 | + * @param TUrlManager $manager |
|
261 | 262 | * @return boolean true if UrlManager instance was cached, false otherwise. |
262 | 263 | */ |
263 | 264 | protected function cacheUrlManager($manager) |
@@ -349,7 +350,7 @@ discard block |
||
349 | 350 | } |
350 | 351 | |
351 | 352 | /** |
352 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
353 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
353 | 354 | */ |
354 | 355 | public function getUrlFormat() |
355 | 356 | { |
@@ -710,6 +711,7 @@ discard block |
||
710 | 711 | * @param array GET parameters, null if not needed |
711 | 712 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
712 | 713 | * @param boolean whether to encode the GET parameters (their names and values), defaults to false. |
714 | + * @param string $serviceID |
|
713 | 715 | * @return string URL |
714 | 716 | * @see TUrlManager::constructUrl |
715 | 717 | */ |
@@ -980,6 +982,7 @@ discard block |
||
980 | 982 | /** |
981 | 983 | * Constructor. |
982 | 984 | * @param mixed owner of this collection. |
985 | + * @param THttpResponse $owner |
|
983 | 986 | */ |
984 | 987 | public function __construct($owner=null) |
985 | 988 | { |
@@ -1125,6 +1128,7 @@ discard block |
||
1125 | 1128 | |
1126 | 1129 | /** |
1127 | 1130 | * @param integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. |
1131 | + * @param integer $value |
|
1128 | 1132 | */ |
1129 | 1133 | public function setExpire($value) |
1130 | 1134 | { |
@@ -1287,6 +1291,7 @@ discard block |
||
1287 | 1291 | * Constructor. |
1288 | 1292 | * Decomposes the specified URI into parts. |
1289 | 1293 | * @param string URI to be represented |
1294 | + * @param string $uri |
|
1290 | 1295 | * @throws TInvalidDataValueException if URI is of bad format |
1291 | 1296 | */ |
1292 | 1297 | public function __construct($uri) |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @package System.Web |
67 | 67 | * @since 3.0 |
68 | 68 | */ |
69 | -class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
69 | +class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
70 | 70 | { |
71 | - const CGIFIX__PATH_INFO = 1; |
|
72 | - const CGIFIX__SCRIPT_NAME = 2; |
|
71 | + const CGIFIX__PATH_INFO=1; |
|
72 | + const CGIFIX__SCRIPT_NAME=2; |
|
73 | 73 | /** |
74 | 74 | * @var TUrlManager the URL manager module |
75 | 75 | */ |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | if(isset($_SERVER['REQUEST_URI'])) |
173 | 173 | $this->_requestUri=$_SERVER['REQUEST_URI']; |
174 | 174 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
175 | - $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
175 | + $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
176 | 176 | |
177 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
177 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
178 | 178 | $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
179 | 179 | elseif(isset($_SERVER['PATH_INFO'])) |
180 | 180 | $this->_pathInfo=$_SERVER['PATH_INFO']; |
181 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
181 | + else if(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | + $this->_pathInfo=substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
183 | 183 | else |
184 | 184 | $this->_pathInfo=''; |
185 | 185 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function stripSlashes(&$data) |
208 | 208 | { |
209 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
209 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if($this->_url===null) |
218 | 218 | { |
219 | 219 | $secure=$this->getIsSecureConnection(); |
220 | - $url=$secure?'https://':'http://'; |
|
220 | + $url=$secure ? 'https://' : 'http://'; |
|
221 | 221 | if(empty($_SERVER['HTTP_HOST'])) |
222 | 222 | { |
223 | 223 | $url.=$_SERVER['SERVER_NAME']; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function setEnableCache($value) |
242 | 242 | { |
243 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
243 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | { |
265 | 265 | if($this->getEnableCache()) |
266 | 266 | { |
267 | - $cache = $this->getApplication()->getCache(); |
|
268 | - if($cache !== null) |
|
267 | + $cache=$this->getApplication()->getCache(); |
|
268 | + if($cache!==null) |
|
269 | 269 | { |
270 | - $dependencies = null; |
|
271 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
272 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
270 | + $dependencies=null; |
|
271 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
272 | + if($manager instanceof TUrlMapping && $fn=$manager->getConfigFile()) |
|
273 | 273 | { |
274 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
275 | - $dependencies = new TFileCacheDependency($fn); |
|
274 | + $fn=Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
275 | + $dependencies=new TFileCacheDependency($fn); |
|
276 | 276 | } |
277 | 277 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
278 | 278 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | { |
289 | 289 | if($this->getEnableCache()) |
290 | 290 | { |
291 | - $cache = $this->getApplication()->getCache(); |
|
292 | - if($cache !== null) |
|
291 | + $cache=$this->getApplication()->getCache(); |
|
292 | + if($cache!==null) |
|
293 | 293 | { |
294 | - $manager = $cache->get($this->getCacheKey()); |
|
294 | + $manager=$cache->get($this->getCacheKey()); |
|
295 | 295 | if($manager instanceof TUrlManager) |
296 | 296 | return $manager; |
297 | 297 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | { |
328 | 328 | if($this->_urlManager===null) |
329 | 329 | { |
330 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
330 | + if(($this->_urlManager=$this->loadCachedUrlManager())===null) |
|
331 | 331 | { |
332 | 332 | if(empty($this->_urlManagerID)) |
333 | 333 | { |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | { |
339 | 339 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 340 | if($this->_urlManager===null) |
341 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
341 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
342 | 342 | if(!($this->_urlManager instanceof TUrlManager)) |
343 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
343 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
344 | 344 | } |
345 | 345 | $this->cacheUrlManager($this->_urlManager); |
346 | 346 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setUrlFormat($value) |
368 | 368 | { |
369 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
369 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -394,19 +394,19 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function getRequestType() |
396 | 396 | { |
397 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
397 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @param boolean $mimetypeOnly whether to return only the mimetype (default: true) |
402 | 402 | * @return string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified |
403 | 403 | */ |
404 | - public function getContentType($mimetypeOnly = true) |
|
404 | + public function getContentType($mimetypeOnly=true) |
|
405 | 405 | { |
406 | 406 | if(!isset($_SERVER['CONTENT_TYPE'])) |
407 | 407 | return null; |
408 | 408 | |
409 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
409 | + if($mimetypeOnly===true && ($_pos=strpos(';', $_SERVER['CONTENT_TYPE']))!==false) |
|
410 | 410 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
411 | 411 | |
412 | 412 | return $_SERVER['CONTENT_TYPE']; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function getIsSecureConnection() |
419 | 419 | { |
420 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
420 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function getQueryString() |
435 | 435 | { |
436 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
436 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getHttpProtocolVersion() |
443 | 443 | { |
444 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
444 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -452,19 +452,19 @@ discard block |
||
452 | 452 | { |
453 | 453 | static $result; |
454 | 454 | |
455 | - if($result === null && function_exists('apache_request_headers')) { |
|
456 | - $result = apache_request_headers(); |
|
455 | + if($result===null && function_exists('apache_request_headers')) { |
|
456 | + $result=apache_request_headers(); |
|
457 | 457 | } |
458 | - elseif($result === null) { |
|
459 | - $result = array(); |
|
458 | + elseif($result===null) { |
|
459 | + $result=array(); |
|
460 | 460 | foreach($_SERVER as $key=>$value) { |
461 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
462 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
463 | - $result[$key] = $value; |
|
461 | + if(strncasecmp($key, 'HTTP_', 5)!==0) continue; |
|
462 | + $key=str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
463 | + $result[$key]=$value; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if($case !== null) |
|
467 | + if($case!==null) |
|
468 | 468 | return array_change_key_case($result, $case); |
469 | 469 | |
470 | 470 | return $result; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | public function getBaseUrl($forceSecureConnection=null) |
489 | 489 | { |
490 | 490 | $url=$this->getUrl(); |
491 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
491 | + $scheme=($forceSecureConnection) ? "https" : (($forceSecureConnection===null) ? $url->getScheme() : 'http'); |
|
492 | 492 | $host=$url->getHost(); |
493 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
493 | + if(($port=$url->getPort())) $host.=':'.$port; |
|
494 | 494 | return $scheme.'://'.$host; |
495 | 495 | } |
496 | 496 | |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | */ |
500 | 500 | public function getApplicationUrl() |
501 | 501 | { |
502 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
502 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
503 | 503 | return $_SERVER['ORIG_SCRIPT_NAME']; |
504 | 504 | |
505 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
505 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
516 | 516 | { |
517 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
517 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function getApplicationFilePath() |
524 | 524 | { |
525 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
525 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getServerName() |
532 | 532 | { |
533 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
533 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function getServerPort() |
540 | 540 | { |
541 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
541 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public function getUrlReferrer() |
548 | 548 | { |
549 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
549 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | public function getUserAgent() |
572 | 572 | { |
573 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
573 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | */ |
579 | 579 | public function getUserHostAddress() |
580 | 580 | { |
581 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
581 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | */ |
587 | 587 | public function getUserHost() |
588 | 588 | { |
589 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
589 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public function getAcceptTypes() |
596 | 596 | { |
597 | 597 | // TBD: break it into array?? |
598 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
598 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | foreach($_COOKIE as $key=>$value) |
661 | 661 | { |
662 | 662 | if(($value=$sm->validateData($value))!==false) |
663 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
663 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
667 | 667 | { |
668 | 668 | foreach($_COOKIE as $key=>$value) |
669 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
669 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | return $this->_cookies; |
@@ -713,13 +713,13 @@ discard block |
||
713 | 713 | * @return string URL |
714 | 714 | * @see TUrlManager::constructUrl |
715 | 715 | */ |
716 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
716 | + public function constructUrl($serviceID, $serviceParam, $getItems=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
717 | 717 | { |
718 | - if ($this->_cookieOnly===null) |
|
719 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
720 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
721 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
722 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
718 | + if($this->_cookieOnly===null) |
|
719 | + $this->_cookieOnly=(int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
720 | + $url=$this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
721 | + if(defined('SID') && SID!='' && !$this->_cookieOnly) |
|
722 | + return $url.(strpos($url, '?')===false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
723 | 723 | else |
724 | 724 | return $url; |
725 | 725 | } |
@@ -747,11 +747,11 @@ discard block |
||
747 | 747 | */ |
748 | 748 | public function resolveRequest($serviceIDs) |
749 | 749 | { |
750 | - Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'],'System.Web.THttpRequest'); |
|
750 | + Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'], 'System.Web.THttpRequest'); |
|
751 | 751 | $getParams=$this->parseUrl(); |
752 | 752 | foreach($getParams as $name=>$value) |
753 | 753 | $_GET[$name]=$value; |
754 | - $this->_items=array_merge($_GET,$_POST); |
|
754 | + $this->_items=array_merge($_GET, $_POST); |
|
755 | 755 | $this->_requestResolved=true; |
756 | 756 | foreach($serviceIDs as $serviceID) |
757 | 757 | { |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @param mixed key |
863 | 863 | * @param mixed value |
864 | 864 | */ |
865 | - public function add($key,$value) |
|
865 | + public function add($key, $value) |
|
866 | 866 | { |
867 | 867 | $this->_items[$key]=$value; |
868 | 868 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | */ |
876 | 876 | public function remove($key) |
877 | 877 | { |
878 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
878 | + if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
879 | 879 | { |
880 | 880 | $value=$this->_items[$key]; |
881 | 881 | unset($this->_items[$key]); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | */ |
901 | 901 | public function contains($key) |
902 | 902 | { |
903 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
903 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
@@ -939,9 +939,9 @@ discard block |
||
939 | 939 | * @param integer the offset to set element |
940 | 940 | * @param mixed the element value |
941 | 941 | */ |
942 | - public function offsetSet($offset,$item) |
|
942 | + public function offsetSet($offset, $item) |
|
943 | 943 | { |
944 | - $this->add($offset,$item); |
|
944 | + $this->add($offset, $item); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | /** |
@@ -994,11 +994,11 @@ discard block |
||
994 | 994 | * @param mixed new item |
995 | 995 | * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object. |
996 | 996 | */ |
997 | - public function insertAt($index,$item) |
|
997 | + public function insertAt($index, $item) |
|
998 | 998 | { |
999 | 999 | if($item instanceof THttpCookie) |
1000 | 1000 | { |
1001 | - parent::insertAt($index,$item); |
|
1001 | + parent::insertAt($index, $item); |
|
1002 | 1002 | if($this->_o instanceof THttpResponse) |
1003 | 1003 | $this->_o->addCookie($item); |
1004 | 1004 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @param string name of this cookie |
1094 | 1094 | * @param string value of this cookie |
1095 | 1095 | */ |
1096 | - public function __construct($name,$value) |
|
1096 | + public function __construct($name, $value) |
|
1097 | 1097 | { |
1098 | 1098 | $this->_name=$name; |
1099 | 1099 | $this->_value=$value; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | public function setHttpOnly($value) |
1146 | 1146 | { |
1147 | - $this->_httpOnly = TPropertyValue::ensureBoolean($value); |
|
1147 | + $this->_httpOnly=TPropertyValue::ensureBoolean($value); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
@@ -1294,19 +1294,19 @@ discard block |
||
1294 | 1294 | if(($ret=@parse_url($uri))!==false) |
1295 | 1295 | { |
1296 | 1296 | // decoding??? |
1297 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
1298 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
1299 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
1300 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
1301 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
1302 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
1303 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
1304 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
1297 | + $this->_scheme=isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
1298 | + $this->_host=isset($ret['host']) ? $ret['host'] : ''; |
|
1299 | + $this->_port=isset($ret['port']) ? $ret['port'] : ''; |
|
1300 | + $this->_user=isset($ret['user']) ? $ret['user'] : ''; |
|
1301 | + $this->_pass=isset($ret['pass']) ? $ret['pass'] : ''; |
|
1302 | + $this->_path=isset($ret['path']) ? $ret['path'] : ''; |
|
1303 | + $this->_query=isset($ret['query']) ? $ret['query'] : ''; |
|
1304 | + $this->_fragment=isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
1305 | 1305 | $this->_uri=$uri; |
1306 | 1306 | } |
1307 | 1307 | else |
1308 | 1308 | { |
1309 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
1309 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
1310 | 1310 | } |
1311 | 1311 | } |
1312 | 1312 |
@@ -224,8 +224,7 @@ discard block |
||
224 | 224 | $port=$_SERVER['SERVER_PORT']; |
225 | 225 | if(($port!=80 && !$secure) || ($port!=443 && $secure)) |
226 | 226 | $url.=':'.$port; |
227 | - } |
|
228 | - else |
|
227 | + } else |
|
229 | 228 | $url.=$_SERVER['HTTP_HOST']; |
230 | 229 | $url.=$this->getRequestUri(); |
231 | 230 | $this->_url=new TUri($url); |
@@ -333,8 +332,7 @@ discard block |
||
333 | 332 | { |
334 | 333 | $this->_urlManager=new TUrlManager; |
335 | 334 | $this->_urlManager->init(null); |
336 | - } |
|
337 | - else |
|
335 | + } else |
|
338 | 336 | { |
339 | 337 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 338 | if($this->_urlManager===null) |
@@ -454,8 +452,7 @@ discard block |
||
454 | 452 | |
455 | 453 | if($result === null && function_exists('apache_request_headers')) { |
456 | 454 | $result = apache_request_headers(); |
457 | - } |
|
458 | - elseif($result === null) { |
|
455 | + } elseif($result === null) { |
|
459 | 456 | $result = array(); |
460 | 457 | foreach($_SERVER as $key=>$value) { |
461 | 458 | if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
@@ -558,8 +555,7 @@ discard block |
||
558 | 555 | try |
559 | 556 | { |
560 | 557 | return get_browser(); |
561 | - } |
|
562 | - catch(TPhpErrorException $e) |
|
558 | + } catch(TPhpErrorException $e) |
|
563 | 559 | { |
564 | 560 | throw new TConfigurationException('httprequest_browscap_required'); |
565 | 561 | } |
@@ -662,8 +658,7 @@ discard block |
||
662 | 658 | if(($value=$sm->validateData($value))!==false) |
663 | 659 | $this->_cookies->add(new THttpCookie($key,$value)); |
664 | 660 | } |
665 | - } |
|
666 | - else |
|
661 | + } else |
|
667 | 662 | { |
668 | 663 | foreach($_COOKIE as $key=>$value) |
669 | 664 | $this->_cookies->add(new THttpCookie($key,$value)); |
@@ -880,8 +875,7 @@ discard block |
||
880 | 875 | $value=$this->_items[$key]; |
881 | 876 | unset($this->_items[$key]); |
882 | 877 | return $value; |
883 | - } |
|
884 | - else |
|
878 | + } else |
|
885 | 879 | return null; |
886 | 880 | } |
887 | 881 | |
@@ -1001,8 +995,7 @@ discard block |
||
1001 | 995 | parent::insertAt($index,$item); |
1002 | 996 | if($this->_o instanceof THttpResponse) |
1003 | 997 | $this->_o->addCookie($item); |
1004 | - } |
|
1005 | - else |
|
998 | + } else |
|
1006 | 999 | throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required'); |
1007 | 1000 | } |
1008 | 1001 | |
@@ -1303,8 +1296,7 @@ discard block |
||
1303 | 1296 | $this->_query=isset($ret['query'])?$ret['query']:''; |
1304 | 1297 | $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
1305 | 1298 | $this->_uri=$uri; |
1306 | - } |
|
1307 | - else |
|
1299 | + } else |
|
1308 | 1300 | { |
1309 | 1301 | throw new TInvalidDataValueException('uri_format_invalid',$uri); |
1310 | 1302 | } |