@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, |
491 | 491 | * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. |
492 | 492 | * |
493 | - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter |
|
493 | + * @param integer|null $options If $mode is PEAR_ERROR_TRIGGER, this parameter |
|
494 | 494 | * specifies the PHP-internal error level (one of |
495 | 495 | * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). |
496 | 496 | * If $mode is PEAR_ERROR_CALLBACK, this |
@@ -581,6 +581,7 @@ discard block |
||
581 | 581 | * message, code and userinfo are enough. |
582 | 582 | * |
583 | 583 | * @param string $message |
584 | + * @param integer $code |
|
584 | 585 | * |
585 | 586 | */ |
586 | 587 | function &throwError($message = null, |
@@ -864,7 +865,7 @@ discard block |
||
864 | 865 | * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, |
865 | 866 | * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION |
866 | 867 | * |
867 | - * @param mixed $options (optional) error level, _OR_ in the case of |
|
868 | + * @param integer $options (optional) error level, _OR_ in the case of |
|
868 | 869 | * PEAR_ERROR_CALLBACK, the callback function or object/method |
869 | 870 | * tuple. |
870 | 871 | * |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PEAR, the PHP Extension and Application Repository |
|
4 | - * |
|
5 | - * PEAR class and PEAR_Error class |
|
6 | - * |
|
7 | - * PHP versions 4 and 5 |
|
8 | - * |
|
9 | - * @category pear |
|
10 | - * @package PEAR |
|
11 | - * @author Sterling Hughes <[email protected]> |
|
12 | - * @author Stig Bakken <[email protected]> |
|
13 | - * @author Tomas V.V.Cox <[email protected]> |
|
14 | - * @author Greg Beaver <[email protected]> |
|
15 | - * @copyright 1997-2009 The Authors |
|
16 | - * @license http://opensource.org/licenses/bsd-license.php New BSD License |
|
17 | - * @version CVS: $Id: PEAR.php 286670 2009-08-02 14:16:06Z dufuz $ |
|
18 | - * @link http://pear.php.net/package/PEAR |
|
19 | - * @since File available since Release 0.1 |
|
20 | - */ |
|
3 | + * PEAR, the PHP Extension and Application Repository |
|
4 | + * |
|
5 | + * PEAR class and PEAR_Error class |
|
6 | + * |
|
7 | + * PHP versions 4 and 5 |
|
8 | + * |
|
9 | + * @category pear |
|
10 | + * @package PEAR |
|
11 | + * @author Sterling Hughes <[email protected]> |
|
12 | + * @author Stig Bakken <[email protected]> |
|
13 | + * @author Tomas V.V.Cox <[email protected]> |
|
14 | + * @author Greg Beaver <[email protected]> |
|
15 | + * @copyright 1997-2009 The Authors |
|
16 | + * @license http://opensource.org/licenses/bsd-license.php New BSD License |
|
17 | + * @version CVS: $Id: PEAR.php 286670 2009-08-02 14:16:06Z dufuz $ |
|
18 | + * @link http://pear.php.net/package/PEAR |
|
19 | + * @since File available since Release 0.1 |
|
20 | + */ |
|
21 | 21 | |
22 | 22 | // Added by Chamilo team, 16-MAR-2010 |
23 | 23 | if (class_exists('pear')) { return; } |
@@ -205,17 +205,17 @@ discard block |
||
205 | 205 | // {{{ getStaticProperty() |
206 | 206 | |
207 | 207 | /** |
208 | - * If you have a class that's mostly/entirely static, and you need static |
|
209 | - * properties, you can use this method to simulate them. Eg. in your method(s) |
|
210 | - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); |
|
211 | - * You MUST use a reference, or they will not persist! |
|
212 | - * |
|
213 | - * @access public |
|
214 | - * @param string $class The calling classname, to prevent clashes |
|
215 | - * @param string $var The variable to retrieve. |
|
216 | - * @return mixed A reference to the variable. If not set it will be |
|
217 | - * auto initialised to NULL. |
|
218 | - */ |
|
208 | + * If you have a class that's mostly/entirely static, and you need static |
|
209 | + * properties, you can use this method to simulate them. Eg. in your method(s) |
|
210 | + * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); |
|
211 | + * You MUST use a reference, or they will not persist! |
|
212 | + * |
|
213 | + * @access public |
|
214 | + * @param string $class The calling classname, to prevent clashes |
|
215 | + * @param string $var The variable to retrieve. |
|
216 | + * @return mixed A reference to the variable. If not set it will be |
|
217 | + * auto initialised to NULL. |
|
218 | + */ |
|
219 | 219 | function &getStaticProperty($class, $var) |
220 | 220 | { |
221 | 221 | static $properties; |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | // {{{ registerShutdownFunc() |
235 | 235 | |
236 | 236 | /** |
237 | - * Use this function to register a shutdown method for static |
|
238 | - * classes. |
|
239 | - * |
|
240 | - * @access public |
|
241 | - * @param mixed $func The function name (or array of class/method) to call |
|
242 | - * @param mixed $args The arguments to pass to the function |
|
243 | - * @return void |
|
244 | - */ |
|
237 | + * Use this function to register a shutdown method for static |
|
238 | + * classes. |
|
239 | + * |
|
240 | + * @access public |
|
241 | + * @param mixed $func The function name (or array of class/method) to call |
|
242 | + * @param mixed $args The arguments to pass to the function |
|
243 | + * @return void |
|
244 | + */ |
|
245 | 245 | function registerShutdownFunc($func, $args = array()) |
246 | 246 | { |
247 | 247 | // if we are called statically, there is a potential |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | * @since PHP 4.0.5 |
514 | 514 | */ |
515 | 515 | function &raiseError($message = null, |
516 | - $code = null, |
|
517 | - $mode = null, |
|
518 | - $options = null, |
|
519 | - $userinfo = null, |
|
520 | - $error_class = null, |
|
521 | - $skipmsg = false) |
|
516 | + $code = null, |
|
517 | + $mode = null, |
|
518 | + $options = null, |
|
519 | + $userinfo = null, |
|
520 | + $error_class = null, |
|
521 | + $skipmsg = false) |
|
522 | 522 | { |
523 | 523 | // The error is yet a PEAR error object |
524 | 524 | if (is_object($message)) { |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * |
585 | 585 | */ |
586 | 586 | function &throwError($message = null, |
587 | - $code = null, |
|
588 | - $userinfo = null) |
|
587 | + $code = null, |
|
588 | + $userinfo = null) |
|
589 | 589 | { |
590 | 590 | if (isset($this) && is_a($this, 'PEAR')) { |
591 | 591 | $a = &$this->raiseError($message, $code, null, null, $userinfo); |
@@ -707,12 +707,12 @@ discard block |
||
707 | 707 | // {{{ popErrorHandling() |
708 | 708 | |
709 | 709 | /** |
710 | - * Pop the last error handler used |
|
711 | - * |
|
712 | - * @return bool Always true |
|
713 | - * |
|
714 | - * @see PEAR::pushErrorHandling |
|
715 | - */ |
|
710 | + * Pop the last error handler used |
|
711 | + * |
|
712 | + * @return bool Always true |
|
713 | + * |
|
714 | + * @see PEAR::pushErrorHandling |
|
715 | + */ |
|
716 | 716 | function popErrorHandling() |
717 | 717 | { |
718 | 718 | $stack = &$GLOBALS['_PEAR_error_handler_stack']; |
@@ -731,12 +731,12 @@ discard block |
||
731 | 731 | // {{{ loadExtension() |
732 | 732 | |
733 | 733 | /** |
734 | - * OS independant PHP extension load. Remember to take care |
|
735 | - * on the correct extension name for case sensitive OSes. |
|
736 | - * |
|
737 | - * @param string $ext The extension name |
|
738 | - * @return bool Success or not on the dl() call |
|
739 | - */ |
|
734 | + * OS independant PHP extension load. Remember to take care |
|
735 | + * on the correct extension name for case sensitive OSes. |
|
736 | + * |
|
737 | + * @param string $ext The extension name |
|
738 | + * @return bool Success or not on the dl() call |
|
739 | + */ |
|
740 | 740 | function loadExtension($ext) |
741 | 741 | { |
742 | 742 | if (!extension_loaded($ext)) { |
@@ -999,10 +999,10 @@ discard block |
||
999 | 999 | * @return int error code |
1000 | 1000 | * @access public |
1001 | 1001 | */ |
1002 | - function getCode() |
|
1003 | - { |
|
1002 | + function getCode() |
|
1003 | + { |
|
1004 | 1004 | return $this->code; |
1005 | - } |
|
1005 | + } |
|
1006 | 1006 | |
1007 | 1007 | // }}} |
1008 | 1008 | // {{{ getType() |
@@ -1110,10 +1110,10 @@ discard block |
||
1110 | 1110 | $callback = $this->callback; |
1111 | 1111 | } |
1112 | 1112 | return sprintf('[%s: message="%s" code=%d mode=callback '. |
1113 | - 'callback=%s prefix="%s" info="%s"]', |
|
1114 | - strtolower(get_class($this)), $this->message, $this->code, |
|
1115 | - $callback, $this->error_message_prefix, |
|
1116 | - $this->userinfo); |
|
1113 | + 'callback=%s prefix="%s" info="%s"]', |
|
1114 | + strtolower(get_class($this)), $this->message, $this->code, |
|
1115 | + $callback, $this->error_message_prefix, |
|
1116 | + $this->userinfo); |
|
1117 | 1117 | } |
1118 | 1118 | if ($this->mode & PEAR_ERROR_PRINT) { |
1119 | 1119 | $modes[] = 'print'; |
@@ -1128,11 +1128,11 @@ discard block |
||
1128 | 1128 | $modes[] = 'return'; |
1129 | 1129 | } |
1130 | 1130 | return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. |
1131 | - 'prefix="%s" info="%s"]', |
|
1132 | - strtolower(get_class($this)), $this->message, $this->code, |
|
1133 | - implode("|", $modes), $levels[$this->level], |
|
1134 | - $this->error_message_prefix, |
|
1135 | - $this->userinfo); |
|
1131 | + 'prefix="%s" info="%s"]', |
|
1132 | + strtolower(get_class($this)), $this->message, $this->code, |
|
1133 | + implode("|", $modes), $levels[$this->level], |
|
1134 | + $this->error_message_prefix, |
|
1135 | + $this->userinfo); |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | // }}} |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | /**#@+ |
27 | 27 | * ERROR constants |
28 | 28 | */ |
29 | -define('PEAR_ERROR_RETURN', 1); |
|
30 | -define('PEAR_ERROR_PRINT', 2); |
|
31 | -define('PEAR_ERROR_TRIGGER', 4); |
|
32 | -define('PEAR_ERROR_DIE', 8); |
|
33 | -define('PEAR_ERROR_CALLBACK', 16); |
|
29 | +define('PEAR_ERROR_RETURN', 1); |
|
30 | +define('PEAR_ERROR_PRINT', 2); |
|
31 | +define('PEAR_ERROR_TRIGGER', 4); |
|
32 | +define('PEAR_ERROR_DIE', 8); |
|
33 | +define('PEAR_ERROR_CALLBACK', 16); |
|
34 | 34 | /** |
35 | 35 | * WARNING: obsolete |
36 | 36 | * @deprecated |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | if (substr(PHP_OS, 0, 3) == 'WIN') { |
44 | 44 | define('OS_WINDOWS', true); |
45 | - define('OS_UNIX', false); |
|
46 | - define('PEAR_OS', 'Windows'); |
|
45 | + define('OS_UNIX', false); |
|
46 | + define('PEAR_OS', 'Windows'); |
|
47 | 47 | } else { |
48 | 48 | define('OS_WINDOWS', false); |
49 | - define('OS_UNIX', true); |
|
50 | - define('PEAR_OS', 'Unix'); // blatant assumption |
|
49 | + define('OS_UNIX', true); |
|
50 | + define('PEAR_OS', 'Unix'); // blatant assumption |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | // $error_code is a non-empty array here; |
452 | 452 | // we walk through it trying to unset all |
453 | 453 | // values |
454 | - foreach($error_code as $key => $error) { |
|
454 | + foreach ($error_code as $key => $error) { |
|
455 | 455 | if ($this->_checkDelExpect($error)) { |
456 | - $deleted = true; |
|
456 | + $deleted = true; |
|
457 | 457 | } else { |
458 | 458 | $deleted = false; |
459 | 459 | } |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | */ |
987 | 987 | function getMessage() |
988 | 988 | { |
989 | - return ($this->error_message_prefix . $this->message); |
|
989 | + return ($this->error_message_prefix.$this->message); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | |
@@ -1103,8 +1103,7 @@ discard block |
||
1103 | 1103 | if ($this->mode & PEAR_ERROR_CALLBACK) { |
1104 | 1104 | if (is_array($this->callback)) { |
1105 | 1105 | $callback = (is_object($this->callback[0]) ? |
1106 | - strtolower(get_class($this->callback[0])) : |
|
1107 | - $this->callback[0]) . '::' . |
|
1106 | + strtolower(get_class($this->callback[0])) : $this->callback[0]).'::'. |
|
1108 | 1107 | $this->callback[1]; |
1109 | 1108 | } else { |
1110 | 1109 | $callback = $this->callback; |
@@ -147,6 +147,7 @@ discard block |
||
147 | 147 | * the two files do not match, and likewise that the last lines do not |
148 | 148 | * match. The caller must trim matching lines from the beginning and end |
149 | 149 | * of the portions it is going to specify. |
150 | + * @param double $nchunks |
|
150 | 151 | */ |
151 | 152 | function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) |
152 | 153 | { |
@@ -267,6 +268,10 @@ discard block |
||
267 | 268 | * |
268 | 269 | * Note that XLIM, YLIM are exclusive bounds. All line numbers are |
269 | 270 | * origin-0 and discarded lines are not counted. |
271 | + * @param integer $xoff |
|
272 | + * @param integer $xlim |
|
273 | + * @param integer $yoff |
|
274 | + * @param integer $ylim |
|
270 | 275 | */ |
271 | 276 | function _compareseq ($xoff, $xlim, $yoff, $ylim) |
272 | 277 | { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * match. The caller must trim matching lines from the beginning and end |
149 | 149 | * of the portions it is going to specify. |
150 | 150 | */ |
151 | - function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) |
|
151 | + function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) |
|
152 | 152 | { |
153 | 153 | $flip = false; |
154 | 154 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | $this->lcs = 0; |
174 | - $this->seq[0]= $yoff - 1; |
|
174 | + $this->seq[0] = $yoff - 1; |
|
175 | 175 | $this->in_seq = array(); |
176 | 176 | $ymids[0] = array(); |
177 | 177 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); |
|
187 | + $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $chunk) / $nchunks); |
|
188 | 188 | for (; $x < $x1; $x++) { |
189 | 189 | $line = $flip ? $this->yv[$x] : $this->xv[$x]; |
190 | 190 | if (empty($ymatches[$line])) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); |
221 | 221 | $ymid = $ymids[$this->lcs]; |
222 | 222 | for ($n = 0; $n < $nchunks - 1; $n++) { |
223 | - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); |
|
223 | + $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $n) / $nchunks); |
|
224 | 224 | $y1 = $ymid[$n] + 1; |
225 | 225 | $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); |
226 | 226 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | $beg = 1; |
242 | 242 | while ($beg < $end) { |
243 | - $mid = (int)(($beg + $end) / 2); |
|
243 | + $mid = (int) (($beg + $end) / 2); |
|
244 | 244 | if ($ypos > $this->seq[$mid]) { |
245 | 245 | $beg = $mid + 1; |
246 | 246 | } else { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * Note that XLIM, YLIM are exclusive bounds. All line numbers are |
269 | 269 | * origin-0 and discarded lines are not counted. |
270 | 270 | */ |
271 | - function _compareseq ($xoff, $xlim, $yoff, $ylim) |
|
271 | + function _compareseq($xoff, $xlim, $yoff, $ylim) |
|
272 | 272 | { |
273 | 273 | /* Slide down the bottom initial diagonal. */ |
274 | 274 | while ($xoff < $xlim && $yoff < $ylim |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | reset($seps); |
310 | 310 | $pt1 = $seps[0]; |
311 | 311 | while ($pt2 = next($seps)) { |
312 | - $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); |
|
312 | + $this->_compareseq($pt1[0], $pt2[0], $pt1[1], $pt2[1]); |
|
313 | 313 | $pt1 = $pt2; |
314 | 314 | } |
315 | 315 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $j++; |
353 | 353 | } |
354 | 354 | |
355 | - while ($i < $len && ! $changed[$i]) { |
|
355 | + while ($i < $len && !$changed[$i]) { |
|
356 | 356 | assert('$j < $other_len && ! $other_changed[$j]'); |
357 | 357 | $i++; $j++; |
358 | 358 | while ($j < $other_len && $other_changed[$j]) { |
@@ -143,6 +143,12 @@ discard block |
||
143 | 143 | return $output . $this->_endDiff(); |
144 | 144 | } |
145 | 145 | |
146 | + /** |
|
147 | + * @param integer $xbeg |
|
148 | + * @param integer $xlen |
|
149 | + * @param integer $ybeg |
|
150 | + * @param integer $ylen |
|
151 | + */ |
|
146 | 152 | function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) |
147 | 153 | { |
148 | 154 | $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen)); |
@@ -199,6 +205,9 @@ discard block |
||
199 | 205 | return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg; |
200 | 206 | } |
201 | 207 | |
208 | + /** |
|
209 | + * @param string $header |
|
210 | + */ |
|
202 | 211 | function _startBlock($header) |
203 | 212 | { |
204 | 213 | return $header . "\n"; |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | } |
105 | 105 | /* @todo */ |
106 | 106 | $output .= $this->_block($x0, $ntrail + $xi - $x0, |
107 | - $y0, $ntrail + $yi - $y0, |
|
108 | - $block); |
|
107 | + $y0, $ntrail + $yi - $y0, |
|
108 | + $block); |
|
109 | 109 | $block = false; |
110 | 110 | } |
111 | 111 | } |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | |
137 | 137 | if (is_array($block)) { |
138 | 138 | $output .= $this->_block($x0, $xi - $x0, |
139 | - $y0, $yi - $y0, |
|
140 | - $block); |
|
139 | + $y0, $yi - $y0, |
|
140 | + $block); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return $output . $this->_endDiff(); |
@@ -149,21 +149,21 @@ |
||
149 | 149 | |
150 | 150 | foreach ($edits as $edit) { |
151 | 151 | switch (strtolower(get_class($edit))) { |
152 | - case 'text_diff_op_copy': |
|
153 | - $output .= $this->_context($edit->orig); |
|
154 | - break; |
|
152 | + case 'text_diff_op_copy': |
|
153 | + $output .= $this->_context($edit->orig); |
|
154 | + break; |
|
155 | 155 | |
156 | - case 'text_diff_op_add': |
|
157 | - $output .= $this->_added($edit->final); |
|
158 | - break; |
|
156 | + case 'text_diff_op_add': |
|
157 | + $output .= $this->_added($edit->final); |
|
158 | + break; |
|
159 | 159 | |
160 | - case 'text_diff_op_delete': |
|
161 | - $output .= $this->_deleted($edit->orig); |
|
162 | - break; |
|
160 | + case 'text_diff_op_delete': |
|
161 | + $output .= $this->_deleted($edit->orig); |
|
162 | + break; |
|
163 | 163 | |
164 | - case 'text_diff_op_change': |
|
165 | - $output .= $this->_changed($edit->orig, $edit->final); |
|
166 | - break; |
|
164 | + case 'text_diff_op_change': |
|
165 | + $output .= $this->_changed($edit->orig, $edit->final); |
|
166 | + break; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | function Text_Diff_Renderer($params = array()) |
39 | 39 | { |
40 | 40 | foreach ($params as $param => $value) { |
41 | - $v = '_' . $param; |
|
41 | + $v = '_'.$param; |
|
42 | 42 | if (isset($this->$v)) { |
43 | 43 | $this->$v = $value; |
44 | 44 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $block); |
141 | 141 | } |
142 | 142 | |
143 | - return $output . $this->_endDiff(); |
|
143 | + return $output.$this->_endDiff(); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - return $output . $this->_endBlock(); |
|
170 | + return $output.$this->_endBlock(); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function _startDiff() |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | function _blockHeader($xbeg, $xlen, $ybeg, $ylen) |
184 | 184 | { |
185 | 185 | if ($xlen > 1) { |
186 | - $xbeg .= ',' . ($xbeg + $xlen - 1); |
|
186 | + $xbeg .= ','.($xbeg + $xlen - 1); |
|
187 | 187 | } |
188 | 188 | if ($ylen > 1) { |
189 | - $ybeg .= ',' . ($ybeg + $ylen - 1); |
|
189 | + $ybeg .= ','.($ybeg + $ylen - 1); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // this matches the GNU Diff behaviour |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | $xbeg--; |
197 | 197 | } |
198 | 198 | |
199 | - return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg; |
|
199 | + return $xbeg.($xlen ? ($ylen ? 'c' : 'd') : 'a').$ybeg; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | function _startBlock($header) |
203 | 203 | { |
204 | - return $header . "\n"; |
|
204 | + return $header."\n"; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | function _endBlock() |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | |
212 | 212 | function _lines($lines, $prefix = ' ') |
213 | 213 | { |
214 | - return $prefix . implode("\n$prefix", $lines) . "\n"; |
|
214 | + return $prefix.implode("\n$prefix", $lines)."\n"; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | function _context($lines) |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | function _changed($orig, $final) |
233 | 233 | { |
234 | - return $this->_deleted($orig) . "---\n" . $this->_added($final); |
|
234 | + return $this->_deleted($orig)."---\n".$this->_added($final); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | } |
@@ -74,6 +74,9 @@ discard block |
||
74 | 74 | return $header; |
75 | 75 | } |
76 | 76 | |
77 | + /** |
|
78 | + * @param string[] $lines |
|
79 | + */ |
|
77 | 80 | function _lines($lines, $prefix = ' ', $encode = true) |
78 | 81 | { |
79 | 82 | if ($encode) { |
@@ -141,6 +144,9 @@ discard block |
||
141 | 144 | return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; |
142 | 145 | } |
143 | 146 | |
147 | + /** |
|
148 | + * @param string $string |
|
149 | + */ |
|
144 | 150 | function _splitOnWords($string, $newlineEscape = "\n") |
145 | 151 | { |
146 | 152 | // Ignore \0; otherwise the while loop will never finish. |
@@ -129,13 +129,13 @@ |
||
129 | 129 | * preserve whitespace as well. Therefore we split on words, |
130 | 130 | * but include all blocks of whitespace in the wordlist. */ |
131 | 131 | $diff = new Text_Diff('native', |
132 | - array($this->_splitOnWords($text1, $nl), |
|
132 | + array($this->_splitOnWords($text1, $nl), |
|
133 | 133 | $this->_splitOnWords($text2, $nl))); |
134 | 134 | |
135 | 135 | /* Get the diff in inline format. */ |
136 | 136 | $renderer = new Text_Diff_Renderer_inline |
137 | 137 | (array_merge($this->getParams(), |
138 | - array('split_level' => 'words'))); |
|
138 | + array('split_level' => 'words'))); |
|
139 | 139 | |
140 | 140 | /* Run the diff and get the output. */ |
141 | 141 | return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | if ($this->_split_level == 'words') { |
84 | 84 | return implode('', $lines); |
85 | 85 | } else { |
86 | - return implode("\n", $lines) . "\n"; |
|
86 | + return implode("\n", $lines)."\n"; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | function _added($lines) |
91 | 91 | { |
92 | 92 | array_walk($lines, array(&$this, '_encode')); |
93 | - $lines[0] = $this->_ins_prefix . $lines[0]; |
|
93 | + $lines[0] = $this->_ins_prefix.$lines[0]; |
|
94 | 94 | $lines[count($lines) - 1] .= $this->_ins_suffix; |
95 | 95 | return $this->_lines($lines, ' ', false); |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function _deleted($lines, $words = false) |
99 | 99 | { |
100 | 100 | array_walk($lines, array(&$this, '_encode')); |
101 | - $lines[0] = $this->_del_prefix . $lines[0]; |
|
101 | + $lines[0] = $this->_del_prefix.$lines[0]; |
|
102 | 102 | $lines[count($lines) - 1] .= $this->_del_suffix; |
103 | 103 | return $this->_lines($lines, ' ', false); |
104 | 104 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $orig[0] = substr($orig[0], 1); |
117 | 117 | $final[0] = substr($final[0], 1); |
118 | 118 | } |
119 | - return $prefix . $this->_deleted($orig) . $this->_added($final); |
|
119 | + return $prefix.$this->_deleted($orig).$this->_added($final); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $text1 = implode("\n", $orig); |
@@ -133,12 +133,11 @@ discard block |
||
133 | 133 | $this->_splitOnWords($text2, $nl))); |
134 | 134 | |
135 | 135 | /* Get the diff in inline format. */ |
136 | - $renderer = new Text_Diff_Renderer_inline |
|
137 | - (array_merge($this->getParams(), |
|
136 | + $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(), |
|
138 | 137 | array('split_level' => 'words'))); |
139 | 138 | |
140 | 139 | /* Run the diff and get the output. */ |
141 | - return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; |
|
140 | + return str_replace($nl, "\n", $renderer->render($diff))."\n"; |
|
142 | 141 | } |
143 | 142 | |
144 | 143 | function _splitOnWords($string, $newlineEscape = "\n") |
@@ -180,6 +180,7 @@ discard block |
||
180 | 180 | * @access private |
181 | 181 | * @param string Login |
182 | 182 | * @param integer Key |
183 | + * @param integer $key |
|
183 | 184 | * @return string |
184 | 185 | */ |
185 | 186 | function _xor($login, $key) |
@@ -208,6 +209,7 @@ discard block |
||
208 | 209 | * @access private |
209 | 210 | * @param string Login |
210 | 211 | * @param integer Key |
212 | + * @param integer $key |
|
211 | 213 | * @return string |
212 | 214 | */ |
213 | 215 | function _rotx($login, $key) |
@@ -241,6 +243,7 @@ discard block |
||
241 | 243 | * @access private |
242 | 244 | * @param string Login |
243 | 245 | * @param integer Key |
246 | + * @param integer $key |
|
244 | 247 | * @return string |
245 | 248 | */ |
246 | 249 | function _rotxpp($login, $key) |
@@ -274,6 +277,7 @@ discard block |
||
274 | 277 | * @access private |
275 | 278 | * @param string Login |
276 | 279 | * @param integer Key |
280 | + * @param integer $key |
|
277 | 281 | * @return string |
278 | 282 | */ |
279 | 283 | function _rotxmm($login, $key) |
@@ -306,6 +310,7 @@ discard block |
||
306 | 310 | * @access private |
307 | 311 | * @param string Login |
308 | 312 | * @param integer Key |
313 | + * @param integer $key |
|
309 | 314 | * @return string |
310 | 315 | */ |
311 | 316 | function _asciiRotx($login, $key) |
@@ -340,6 +345,7 @@ discard block |
||
340 | 345 | * @access private |
341 | 346 | * @param string Login |
342 | 347 | * @param integer Key |
348 | + * @param integer $key |
|
343 | 349 | * @return string |
344 | 350 | */ |
345 | 351 | function _asciiRotxpp($login, $key) |
@@ -374,6 +380,7 @@ discard block |
||
374 | 380 | * @access private |
375 | 381 | * @param string Login |
376 | 382 | * @param integer Key |
383 | + * @param integer $key |
|
377 | 384 | * @return string |
378 | 385 | */ |
379 | 386 | function _asciiRotxmm($login, $key) |
@@ -430,6 +437,7 @@ discard block |
||
430 | 437 | * |
431 | 438 | * @access private |
432 | 439 | * @param integer Length of the password |
440 | + * @param integer $length |
|
433 | 441 | * @return string Returns the password |
434 | 442 | */ |
435 | 443 | function _createPronounceable($length) |
@@ -475,6 +483,8 @@ discard block |
||
475 | 483 | * @param string Character which could be use in the |
476 | 484 | * unpronounceable password ex : 'ABCDEFG' |
477 | 485 | * or numeric, alphabetical or alphanumeric. |
486 | + * @param integer $length |
|
487 | + * @param string $chars |
|
478 | 488 | * @return string Returns the password |
479 | 489 | */ |
480 | 490 | function _createUnpronounceable($length, $chars) |
@@ -441,17 +441,17 @@ discard block |
||
441 | 441 | * List of vowels and vowel sounds |
442 | 442 | */ |
443 | 443 | $v = array('a', 'e', 'i', 'o', 'u', 'ae', 'ou', 'io', |
444 | - 'ea', 'ou', 'ia', 'ai' |
|
445 | - ); |
|
444 | + 'ea', 'ou', 'ia', 'ai' |
|
445 | + ); |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * List of consonants and consonant sounds |
449 | 449 | */ |
450 | 450 | $c = array('b', 'c', 'd', 'g', 'h', 'j', 'k', 'l', 'm', |
451 | - 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', |
|
452 | - 'tr', 'cr', 'fr', 'dr', 'wr', 'pr', 'th', |
|
453 | - 'ch', 'ph', 'st', 'sl', 'cl' |
|
454 | - ); |
|
451 | + 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', |
|
452 | + 'tr', 'cr', 'fr', 'dr', 'wr', 'pr', 'th', |
|
453 | + 'ch', 'ph', 'st', 'sl', 'cl' |
|
454 | + ); |
|
455 | 455 | |
456 | 456 | $v_count = 12; |
457 | 457 | $c_count = 29; |
@@ -484,50 +484,50 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * List of character which could be use in the password |
486 | 486 | */ |
487 | - switch($chars) { |
|
487 | + switch($chars) { |
|
488 | 488 | |
489 | - case 'alphanumeric': |
|
489 | + case 'alphanumeric': |
|
490 | 490 | $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
491 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
492 | - break; |
|
491 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
492 | + break; |
|
493 | 493 | |
494 | - case 'alphabetical': |
|
494 | + case 'alphabetical': |
|
495 | 495 | $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
496 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
497 | - break; |
|
496 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
497 | + break; |
|
498 | 498 | |
499 | - case 'numeric': |
|
499 | + case 'numeric': |
|
500 | 500 | $chars = '0123456789'; |
501 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
502 | - break; |
|
501 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
502 | + break; |
|
503 | 503 | |
504 | - case '': |
|
504 | + case '': |
|
505 | 505 | $chars = '_#@%&ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
506 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
507 | - break; |
|
506 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
507 | + break; |
|
508 | 508 | |
509 | - default: |
|
509 | + default: |
|
510 | 510 | /** |
511 | 511 | * Some characters shouldn't be used |
512 | 512 | */ |
513 | 513 | $chars = trim($chars); |
514 | - $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
515 | - |
|
516 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * Generate password |
|
521 | - */ |
|
522 | - for ($i = 0; $i < $length; $i++) { |
|
523 | - $num = mt_rand(0, $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] - 1); |
|
524 | - $password .= $chars{$num}; |
|
525 | - } |
|
526 | - |
|
527 | - /** |
|
528 | - * Return password |
|
529 | - */ |
|
530 | - return $password; |
|
514 | + $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
515 | + |
|
516 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * Generate password |
|
521 | + */ |
|
522 | + for ($i = 0; $i < $length; $i++) { |
|
523 | + $num = mt_rand(0, $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] - 1); |
|
524 | + $password .= $chars{$num}; |
|
525 | + } |
|
526 | + |
|
527 | + /** |
|
528 | + * Return password |
|
529 | + */ |
|
530 | + return $password; |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | ?> |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | function create($length = 10, $type = 'pronounceable', $chars = '') |
56 | 56 | { |
57 | 57 | switch ($type) { |
58 | - case 'unpronounceable' : |
|
59 | - return Text_Password::_createUnpronounceable($length, $chars); |
|
58 | + case 'unpronounceable' : |
|
59 | + return Text_Password::_createUnpronounceable($length, $chars); |
|
60 | 60 | |
61 | - case 'pronounceable' : |
|
62 | - default : |
|
63 | - return Text_Password::_createPronounceable($length); |
|
61 | + case 'pronounceable' : |
|
62 | + default : |
|
63 | + return Text_Password::_createPronounceable($length); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -110,35 +110,35 @@ discard block |
||
110 | 110 | function createFromLogin($login, $type, $key = 0) |
111 | 111 | { |
112 | 112 | switch ($type) { |
113 | - case 'reverse': |
|
114 | - return strrev($login); |
|
113 | + case 'reverse': |
|
114 | + return strrev($login); |
|
115 | 115 | |
116 | - case 'shuffle': |
|
117 | - return Text_Password::_shuffle($login); |
|
116 | + case 'shuffle': |
|
117 | + return Text_Password::_shuffle($login); |
|
118 | 118 | |
119 | - case 'xor': |
|
120 | - return Text_Password::_xor($login, $key); |
|
119 | + case 'xor': |
|
120 | + return Text_Password::_xor($login, $key); |
|
121 | 121 | |
122 | - case 'rot13': |
|
123 | - return str_rot13($login); |
|
122 | + case 'rot13': |
|
123 | + return str_rot13($login); |
|
124 | 124 | |
125 | - case 'rotx': |
|
126 | - return Text_Password::_rotx($login, $key); |
|
125 | + case 'rotx': |
|
126 | + return Text_Password::_rotx($login, $key); |
|
127 | 127 | |
128 | - case 'rotx++': |
|
129 | - return Text_Password::_rotxpp($login, $key); |
|
128 | + case 'rotx++': |
|
129 | + return Text_Password::_rotxpp($login, $key); |
|
130 | 130 | |
131 | - case 'rotx--': |
|
132 | - return Text_Password::_rotxmm($login, $key); |
|
131 | + case 'rotx--': |
|
132 | + return Text_Password::_rotxmm($login, $key); |
|
133 | 133 | |
134 | - case 'ascii_rotx': |
|
135 | - return Text_Password::_asciiRotx($login, $key); |
|
134 | + case 'ascii_rotx': |
|
135 | + return Text_Password::_asciiRotx($login, $key); |
|
136 | 136 | |
137 | - case 'ascii_rotx++': |
|
138 | - return Text_Password::_asciiRotxpp($login, $key); |
|
137 | + case 'ascii_rotx++': |
|
138 | + return Text_Password::_asciiRotxpp($login, $key); |
|
139 | 139 | |
140 | - case 'ascii_rotx--': |
|
141 | - return Text_Password::_asciiRotxmm($login, $key); |
|
140 | + case 'ascii_rotx--': |
|
141 | + return Text_Password::_asciiRotxmm($login, $key); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | $next += 255; |
321 | 321 | } |
322 | 322 | switch ($next) { // delete white space |
323 | - case 0x09: |
|
324 | - case 0x20: |
|
325 | - case 0x0A: |
|
326 | - case 0x0D: |
|
327 | - $next++; |
|
323 | + case 0x09: |
|
324 | + case 0x20: |
|
325 | + case 0x0A: |
|
326 | + case 0x0D: |
|
327 | + $next++; |
|
328 | 328 | } |
329 | 329 | $tmp .= chr($next); |
330 | 330 | } |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | $next += 255; |
355 | 355 | } |
356 | 356 | switch ($next) { // delete white space |
357 | - case 0x09: |
|
358 | - case 0x20: |
|
359 | - case 0x0A: |
|
360 | - case 0x0D: |
|
361 | - $next++; |
|
357 | + case 0x09: |
|
358 | + case 0x20: |
|
359 | + case 0x0A: |
|
360 | + case 0x0D: |
|
361 | + $next++; |
|
362 | 362 | } |
363 | 363 | $tmp .= chr($next); |
364 | 364 | } |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | $next += 255; |
389 | 389 | } |
390 | 390 | switch ($next) { // delete white space |
391 | - case 0x09: |
|
392 | - case 0x20: |
|
393 | - case 0x0A: |
|
394 | - case 0x0D: |
|
395 | - $next++; |
|
391 | + case 0x09: |
|
392 | + case 0x20: |
|
393 | + case 0x0A: |
|
394 | + case 0x0D: |
|
395 | + $next++; |
|
396 | 396 | } |
397 | 397 | $tmp .= chr($next); |
398 | 398 | } |
@@ -486,34 +486,34 @@ discard block |
||
486 | 486 | */ |
487 | 487 | switch($chars) { |
488 | 488 | |
489 | - case 'alphanumeric': |
|
490 | - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
491 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
492 | - break; |
|
489 | + case 'alphanumeric': |
|
490 | + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
491 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
492 | + break; |
|
493 | 493 | |
494 | - case 'alphabetical': |
|
495 | - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
496 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
497 | - break; |
|
494 | + case 'alphabetical': |
|
495 | + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
496 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
497 | + break; |
|
498 | 498 | |
499 | - case 'numeric': |
|
500 | - $chars = '0123456789'; |
|
501 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
502 | - break; |
|
499 | + case 'numeric': |
|
500 | + $chars = '0123456789'; |
|
501 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
502 | + break; |
|
503 | 503 | |
504 | - case '': |
|
505 | - $chars = '_#@%&ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
506 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
507 | - break; |
|
504 | + case '': |
|
505 | + $chars = '_#@%&ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
506 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
507 | + break; |
|
508 | 508 | |
509 | - default: |
|
510 | - /** |
|
509 | + default: |
|
510 | + /** |
|
511 | 511 | * Some characters shouldn't be used |
512 | 512 | */ |
513 | - $chars = trim($chars); |
|
514 | - $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
513 | + $chars = trim($chars); |
|
514 | + $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
515 | 515 | |
516 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
516 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = $v_count + $c_count; |
460 | 460 | |
461 | 461 | for ($i = 0; $i < $length; $i++) { |
462 | - $retVal .= $c[mt_rand(0, $c_count-1)] . $v[mt_rand(0, $v_count-1)]; |
|
462 | + $retVal .= $c[mt_rand(0, $c_count - 1)].$v[mt_rand(0, $v_count - 1)]; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | return substr($retVal, 0, $length); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * List of character which could be use in the password |
486 | 486 | */ |
487 | - switch($chars) { |
|
487 | + switch ($chars) { |
|
488 | 488 | |
489 | 489 | case 'alphanumeric': |
490 | 490 | $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
@@ -115,7 +115,7 @@ |
||
115 | 115 | * Setup db connection. |
116 | 116 | * Based on defined options, this method connects to db defined in {@link $dsn} |
117 | 117 | * and creates a {@link $table} table if {@link $createTable} is true. |
118 | - * @return boolean true if all ok. |
|
118 | + * @return boolean|null true if all ok. |
|
119 | 119 | */ |
120 | 120 | function activateOptions() |
121 | 121 | { |
@@ -121,10 +121,10 @@ |
||
121 | 121 | { |
122 | 122 | $this->db = &ADONewConnection($this->type); |
123 | 123 | if (! $this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
124 | - $this->db = null; |
|
125 | - $this->closed = true; |
|
126 | - $this->canAppend = false; |
|
127 | - return; |
|
124 | + $this->db = null; |
|
125 | + $this->closed = true; |
|
126 | + $this->canAppend = false; |
|
127 | + return; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $this->layout = LoggerReflectionUtils::createObject('LoggerLayoutPattern'); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | |
21 | 21 | /** A docblok to make phpdoc happy */ |
22 | -require_once(ADODB_DIR . '/adodb.inc.php'); |
|
22 | +require_once(ADODB_DIR.'/adodb.inc.php'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Appends log events to a db table using adodb class. |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | function activateOptions() |
121 | 121 | { |
122 | 122 | $this->db = &ADONewConnection($this->type); |
123 | - if (! $this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
|
123 | + if (!$this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
|
124 | 124 | $this->db = null; |
125 | 125 | $this->closed = true; |
126 | 126 | $this->canAppend = false; |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | $this->layout->setConversionPattern($this->getSql()); |
132 | 132 | |
133 | 133 | // test if log table exists |
134 | - $sql = 'select * from ' . $this->table . ' where 1 = 0'; |
|
134 | + $sql = 'select * from '.$this->table.' where 1 = 0'; |
|
135 | 135 | $dbrs = $this->db->Execute($sql); |
136 | 136 | if ($dbrs == false and $this->getCreateTable()) { |
137 | 137 | $query = "CREATE TABLE {$this->table} (timestamp varchar(32),logger varchar(32),level varchar(32),message varchar(64),thread varchar(32),file varchar(64),line varchar(4) );"; |
138 | 138 | |
139 | 139 | |
140 | 140 | $result = $this->db->Execute($query); |
141 | - if (! $result) { |
|
141 | + if (!$result) { |
|
142 | 142 | $this->canAppend = false; |
143 | 143 | return; |
144 | 144 | } |
@@ -155,8 +155,9 @@ |
||
155 | 155 | |
156 | 156 | function close() |
157 | 157 | { |
158 | - if ($this->db !== null) |
|
159 | - $this->db->Close(); |
|
158 | + if ($this->db !== null) { |
|
159 | + $this->db->Close(); |
|
160 | + } |
|
160 | 161 | $this->closed = true; |
161 | 162 | } |
162 | 163 |
@@ -151,10 +151,16 @@ |
||
151 | 151 | return $this->append; |
152 | 152 | } |
153 | 153 | |
154 | + /** |
|
155 | + * @param boolean $flag |
|
156 | + */ |
|
154 | 157 | public function setAppend($flag) { |
155 | 158 | $this->append = LoggerOptionConverter::toBoolean($flag, true); |
156 | 159 | } |
157 | 160 | |
161 | + /** |
|
162 | + * @param string $fileName |
|
163 | + */ |
|
158 | 164 | public function setFileName($fileName) { |
159 | 165 | $this->fileName = $fileName; |
160 | 166 | } |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | public function activateOptions() { |
68 | 68 | $fileName = $this->getFile(); |
69 | 69 | |
70 | - if(!is_file($fileName)) { |
|
70 | + if (!is_file($fileName)) { |
|
71 | 71 | $dir = dirname($fileName); |
72 | - if(!is_dir($dir)) { |
|
72 | + if (!is_dir($dir)) { |
|
73 | 73 | mkdir($dir, 0777, true); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
78 | - if($this->fp) { |
|
79 | - if(flock($this->fp, LOCK_EX)) { |
|
80 | - if($this->getAppend()) { |
|
77 | + $this->fp = fopen($fileName, ($this->getAppend() ? 'a' : 'w')); |
|
78 | + if ($this->fp) { |
|
79 | + if (flock($this->fp, LOCK_EX)) { |
|
80 | + if ($this->getAppend()) { |
|
81 | 81 | fseek($this->fp, 0, SEEK_END); |
82 | 82 | } |
83 | 83 | fwrite($this->fp, $this->layout->getHeader()); |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | public function close() { |
96 | - if($this->closed != true) { |
|
97 | - if($this->fp and $this->layout !== null) { |
|
98 | - if(flock($this->fp, LOCK_EX)) { |
|
96 | + if ($this->closed != true) { |
|
97 | + if ($this->fp and $this->layout !== null) { |
|
98 | + if (flock($this->fp, LOCK_EX)) { |
|
99 | 99 | fwrite($this->fp, $this->layout->getFooter()); |
100 | 100 | flock($this->fp, LOCK_UN); |
101 | 101 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | public function append(LoggerLoggingEvent $event) { |
109 | - if($this->fp and $this->layout !== null) { |
|
110 | - if(flock($this->fp, LOCK_EX)) { |
|
109 | + if ($this->fp and $this->layout !== null) { |
|
110 | + if (flock($this->fp, LOCK_EX)) { |
|
111 | 111 | fwrite($this->fp, $this->layout->format($event)); |
112 | 112 | flock($this->fp, LOCK_UN); |
113 | 113 | } else { |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function setFile() { |
129 | 129 | $numargs = func_num_args(); |
130 | - $args = func_get_args(); |
|
130 | + $args = func_get_args(); |
|
131 | 131 | |
132 | - if($numargs == 1 and is_string($args[0])) { |
|
132 | + if ($numargs == 1 and is_string($args[0])) { |
|
133 | 133 | $this->setFileName($args[0]); |
134 | - } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
134 | + } else if ($numargs >= 2 and is_string($args[0]) and is_bool($args[1])) { |
|
135 | 135 | $this->setFile($args[0]); |
136 | 136 | $this->setAppend($args[1]); |
137 | 137 | } |
@@ -42,129 +42,129 @@ |
||
42 | 42 | */ |
43 | 43 | class LoggerAppenderFile extends LoggerAppender { |
44 | 44 | |
45 | - /** |
|
46 | - * @var boolean if {@link $file} exists, appends events. |
|
47 | - */ |
|
48 | - private $append = true; |
|
49 | - /** |
|
50 | - * @var string the file name used to append events |
|
51 | - */ |
|
52 | - protected $fileName; |
|
53 | - /** |
|
54 | - * @var mixed file resource |
|
55 | - */ |
|
56 | - protected $fp = false; |
|
45 | + /** |
|
46 | + * @var boolean if {@link $file} exists, appends events. |
|
47 | + */ |
|
48 | + private $append = true; |
|
49 | + /** |
|
50 | + * @var string the file name used to append events |
|
51 | + */ |
|
52 | + protected $fileName; |
|
53 | + /** |
|
54 | + * @var mixed file resource |
|
55 | + */ |
|
56 | + protected $fp = false; |
|
57 | 57 | |
58 | - public function __construct($name = '') { |
|
59 | - parent::__construct($name); |
|
60 | - $this->requiresLayout = true; |
|
61 | - } |
|
58 | + public function __construct($name = '') { |
|
59 | + parent::__construct($name); |
|
60 | + $this->requiresLayout = true; |
|
61 | + } |
|
62 | 62 | |
63 | - public function __destruct() { |
|
64 | - $this->close(); |
|
65 | - } |
|
63 | + public function __destruct() { |
|
64 | + $this->close(); |
|
65 | + } |
|
66 | 66 | |
67 | - public function activateOptions() { |
|
68 | - $fileName = $this->getFile(); |
|
67 | + public function activateOptions() { |
|
68 | + $fileName = $this->getFile(); |
|
69 | 69 | |
70 | - if(!is_file($fileName)) { |
|
71 | - $dir = dirname($fileName); |
|
72 | - if(!is_dir($dir)) { |
|
73 | - mkdir($dir, 0777, true); |
|
74 | - } |
|
75 | - } |
|
70 | + if(!is_file($fileName)) { |
|
71 | + $dir = dirname($fileName); |
|
72 | + if(!is_dir($dir)) { |
|
73 | + mkdir($dir, 0777, true); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
78 | - if($this->fp) { |
|
79 | - if(flock($this->fp, LOCK_EX)) { |
|
80 | - if($this->getAppend()) { |
|
81 | - fseek($this->fp, 0, SEEK_END); |
|
82 | - } |
|
83 | - fwrite($this->fp, $this->layout->getHeader()); |
|
84 | - flock($this->fp, LOCK_UN); |
|
85 | - $this->closed = false; |
|
86 | - } else { |
|
87 | - // TODO: should we take some action in this case? |
|
88 | - $this->closed = true; |
|
89 | - } |
|
90 | - } else { |
|
91 | - $this->closed = true; |
|
92 | - } |
|
93 | - } |
|
77 | + $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
78 | + if($this->fp) { |
|
79 | + if(flock($this->fp, LOCK_EX)) { |
|
80 | + if($this->getAppend()) { |
|
81 | + fseek($this->fp, 0, SEEK_END); |
|
82 | + } |
|
83 | + fwrite($this->fp, $this->layout->getHeader()); |
|
84 | + flock($this->fp, LOCK_UN); |
|
85 | + $this->closed = false; |
|
86 | + } else { |
|
87 | + // TODO: should we take some action in this case? |
|
88 | + $this->closed = true; |
|
89 | + } |
|
90 | + } else { |
|
91 | + $this->closed = true; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - public function close() { |
|
96 | - if($this->closed != true) { |
|
97 | - if($this->fp and $this->layout !== null) { |
|
98 | - if(flock($this->fp, LOCK_EX)) { |
|
99 | - fwrite($this->fp, $this->layout->getFooter()); |
|
100 | - flock($this->fp, LOCK_UN); |
|
101 | - } |
|
102 | - fclose($this->fp); |
|
103 | - } |
|
104 | - $this->closed = true; |
|
105 | - } |
|
106 | - } |
|
95 | + public function close() { |
|
96 | + if($this->closed != true) { |
|
97 | + if($this->fp and $this->layout !== null) { |
|
98 | + if(flock($this->fp, LOCK_EX)) { |
|
99 | + fwrite($this->fp, $this->layout->getFooter()); |
|
100 | + flock($this->fp, LOCK_UN); |
|
101 | + } |
|
102 | + fclose($this->fp); |
|
103 | + } |
|
104 | + $this->closed = true; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - public function append(LoggerLoggingEvent $event) { |
|
109 | - if($this->fp and $this->layout !== null) { |
|
110 | - if(flock($this->fp, LOCK_EX)) { |
|
111 | - fwrite($this->fp, $this->layout->format($event)); |
|
112 | - flock($this->fp, LOCK_UN); |
|
113 | - } else { |
|
114 | - $this->closed = true; |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
108 | + public function append(LoggerLoggingEvent $event) { |
|
109 | + if($this->fp and $this->layout !== null) { |
|
110 | + if(flock($this->fp, LOCK_EX)) { |
|
111 | + fwrite($this->fp, $this->layout->format($event)); |
|
112 | + flock($this->fp, LOCK_UN); |
|
113 | + } else { |
|
114 | + $this->closed = true; |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Sets and opens the file where the log output will go. |
|
121 | - * |
|
122 | - * This is an overloaded method. It can be called with: |
|
123 | - * - setFile(string $fileName) to set filename. |
|
124 | - * - setFile(string $fileName, boolean $append) to set filename and append. |
|
125 | - * |
|
126 | - * TODO: remove overloading. Use only file as alias to filename |
|
127 | - */ |
|
128 | - public function setFile() { |
|
129 | - $numargs = func_num_args(); |
|
130 | - $args = func_get_args(); |
|
119 | + /** |
|
120 | + * Sets and opens the file where the log output will go. |
|
121 | + * |
|
122 | + * This is an overloaded method. It can be called with: |
|
123 | + * - setFile(string $fileName) to set filename. |
|
124 | + * - setFile(string $fileName, boolean $append) to set filename and append. |
|
125 | + * |
|
126 | + * TODO: remove overloading. Use only file as alias to filename |
|
127 | + */ |
|
128 | + public function setFile() { |
|
129 | + $numargs = func_num_args(); |
|
130 | + $args = func_get_args(); |
|
131 | 131 | |
132 | - if($numargs == 1 and is_string($args[0])) { |
|
133 | - $this->setFileName($args[0]); |
|
134 | - } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
135 | - $this->setFile($args[0]); |
|
136 | - $this->setAppend($args[1]); |
|
137 | - } |
|
138 | - } |
|
132 | + if($numargs == 1 and is_string($args[0])) { |
|
133 | + $this->setFileName($args[0]); |
|
134 | + } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
135 | + $this->setFile($args[0]); |
|
136 | + $this->setAppend($args[1]); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function getFile() { |
|
144 | - return $this->getFileName(); |
|
145 | - } |
|
140 | + /** |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function getFile() { |
|
144 | + return $this->getFileName(); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @return boolean |
|
149 | - */ |
|
150 | - public function getAppend() { |
|
151 | - return $this->append; |
|
152 | - } |
|
147 | + /** |
|
148 | + * @return boolean |
|
149 | + */ |
|
150 | + public function getAppend() { |
|
151 | + return $this->append; |
|
152 | + } |
|
153 | 153 | |
154 | - public function setAppend($flag) { |
|
155 | - $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
156 | - } |
|
154 | + public function setAppend($flag) { |
|
155 | + $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
156 | + } |
|
157 | 157 | |
158 | - public function setFileName($fileName) { |
|
159 | - $this->fileName = $fileName; |
|
160 | - } |
|
158 | + public function setFileName($fileName) { |
|
159 | + $this->fileName = $fileName; |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function getFileName() { |
|
166 | - return $this->fileName; |
|
167 | - } |
|
162 | + /** |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function getFileName() { |
|
166 | + return $this->fileName; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | |
170 | 170 | } |
@@ -92,7 +92,7 @@ |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Returns the value of the MaxBackupIndex option. |
95 | - * @return integer |
|
95 | + * @return string |
|
96 | 96 | */ |
97 | 97 | private function getExpandedFileName() { |
98 | 98 | return $this->expandedFileName; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @var integer |
80 | 80 | */ |
81 | - private $maxBackupIndex = 1; |
|
81 | + private $maxBackupIndex = 1; |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @var string the filename expanded |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function rollOver() { |
119 | 119 | // If maxBackups <= 0, then there is no file renaming to be done. |
120 | - if($this->maxBackupIndex > 0) { |
|
120 | + if ($this->maxBackupIndex > 0) { |
|
121 | 121 | $fileName = $this->getExpandedFileName(); |
122 | 122 | // Delete the oldest file, to keep Windows happy. |
123 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
124 | - if(is_writable($file)) |
|
123 | + $file = $fileName.'.'.$this->maxBackupIndex; |
|
124 | + if (is_writable($file)) |
|
125 | 125 | unlink($file); |
126 | 126 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
127 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | - $file = $fileName . "." . $i; |
|
129 | - if(is_readable($file)) { |
|
130 | - $target = $fileName . '.' . ($i + 1); |
|
127 | + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | + $file = $fileName.".".$i; |
|
129 | + if (is_readable($file)) { |
|
130 | + $target = $fileName.'.'.($i + 1); |
|
131 | 131 | rename($file, $target); |
132 | 132 | } |
133 | 133 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $this->close(); |
136 | 136 | |
137 | 137 | // Rename fileName to fileName.1 |
138 | - $target = $fileName . ".1"; |
|
138 | + $target = $fileName.".1"; |
|
139 | 139 | $file = $fileName; |
140 | 140 | rename($file, $target); |
141 | 141 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param mixed $maxBackups |
168 | 168 | */ |
169 | 169 | public function setMaxBackupIndex($maxBackups) { |
170 | - if(is_numeric($maxBackups)) { |
|
171 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
170 | + if (is_numeric($maxBackups)) { |
|
171 | + $this->maxBackupIndex = abs((int) $maxBackups); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -199,20 +199,20 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function setMaxFileSize($value) { |
201 | 201 | $maxFileSize = null; |
202 | - $numpart = substr($value,0, strlen($value) -2); |
|
202 | + $numpart = substr($value, 0, strlen($value) - 2); |
|
203 | 203 | $suffix = strtoupper(substr($value, -2)); |
204 | 204 | |
205 | - switch($suffix) { |
|
206 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
207 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
208 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
205 | + switch ($suffix) { |
|
206 | + case 'KB': $maxFileSize = (int) ((int) $numpart * 1024); break; |
|
207 | + case 'MB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024); break; |
|
208 | + case 'GB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024 * 1024); break; |
|
209 | 209 | default: |
210 | - if(is_numeric($value)) { |
|
211 | - $maxFileSize = (int)$value; |
|
210 | + if (is_numeric($value)) { |
|
211 | + $maxFileSize = (int) $value; |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if($maxFileSize !== null) { |
|
215 | + if ($maxFileSize !== null) { |
|
216 | 216 | $this->maxFileSize = abs($maxFileSize); |
217 | 217 | } |
218 | 218 | return $this->maxFileSize; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function append(LoggerLoggingEvent $event) { |
225 | 225 | parent::append($event); |
226 | - if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
226 | + if (ftell($this->fp) > $this->getMaximumFileSize()) { |
|
227 | 227 | $this->rollOver(); |
228 | 228 | } |
229 | 229 | } |
@@ -121,8 +121,9 @@ discard block |
||
121 | 121 | $fileName = $this->getExpandedFileName(); |
122 | 122 | // Delete the oldest file, to keep Windows happy. |
123 | 123 | $file = $fileName . '.' . $this->maxBackupIndex; |
124 | - if(is_writable($file)) |
|
125 | - unlink($file); |
|
124 | + if(is_writable($file)) { |
|
125 | + unlink($file); |
|
126 | + } |
|
126 | 127 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
127 | 128 | for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
128 | 129 | $file = $fileName . "." . $i; |
@@ -150,7 +151,9 @@ discard block |
||
150 | 151 | // As LoggerAppenderFile does not create the directory, it has to exist. |
151 | 152 | // realpath() fails if the argument does not exist so the filename is separated. |
152 | 153 | $this->expandedFileName = realpath(dirname($fileName)); |
153 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
154 | + if ($this->expandedFileName === false) { |
|
155 | + throw new Exception("Directory of $fileName does not exist!"); |
|
156 | + } |
|
154 | 157 | $this->expandedFileName .= '/'.basename($fileName); |
155 | 158 | } |
156 | 159 |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * LoggerAppenderRollingFile extends LoggerAppenderFile to backup the log files |
@@ -48,183 +48,183 @@ discard block |
||
48 | 48 | */ |
49 | 49 | class LoggerAppenderRollingFile extends LoggerAppenderFile { |
50 | 50 | |
51 | - /** |
|
52 | - * Set the maximum size that the output file is allowed to reach |
|
53 | - * before being rolled over to backup files. |
|
54 | - * |
|
55 | - * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
56 | - * long integer in the range 0 - 2^63. You can specify the value |
|
57 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
58 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
59 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
60 | - * as 10240.</p> |
|
61 | - * <p>The default maximum file size is 10MB.</p> |
|
62 | - * |
|
63 | - * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
64 | - * |
|
65 | - * @var integer |
|
66 | - */ |
|
67 | - private $maxFileSize = 10485760; |
|
51 | + /** |
|
52 | + * Set the maximum size that the output file is allowed to reach |
|
53 | + * before being rolled over to backup files. |
|
54 | + * |
|
55 | + * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
56 | + * long integer in the range 0 - 2^63. You can specify the value |
|
57 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
58 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
59 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
60 | + * as 10240.</p> |
|
61 | + * <p>The default maximum file size is 10MB.</p> |
|
62 | + * |
|
63 | + * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
64 | + * |
|
65 | + * @var integer |
|
66 | + */ |
|
67 | + private $maxFileSize = 10485760; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Set the maximum number of backup files to keep around. |
|
71 | - * |
|
72 | - * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
73 | - * files are kept before the oldest is erased. This option takes |
|
74 | - * a positive integer value. If set to zero, then there will be no |
|
75 | - * backup files and the log file will be truncated when it reaches |
|
76 | - * MaxFileSize.</p> |
|
77 | - * <p>There is one backup file by default.</p> |
|
78 | - * |
|
79 | - * @var integer |
|
80 | - */ |
|
81 | - private $maxBackupIndex = 1; |
|
69 | + /** |
|
70 | + * Set the maximum number of backup files to keep around. |
|
71 | + * |
|
72 | + * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
73 | + * files are kept before the oldest is erased. This option takes |
|
74 | + * a positive integer value. If set to zero, then there will be no |
|
75 | + * backup files and the log file will be truncated when it reaches |
|
76 | + * MaxFileSize.</p> |
|
77 | + * <p>There is one backup file by default.</p> |
|
78 | + * |
|
79 | + * @var integer |
|
80 | + */ |
|
81 | + private $maxBackupIndex = 1; |
|
82 | 82 | |
83 | - /** |
|
84 | - * @var string the filename expanded |
|
85 | - * @access private |
|
86 | - */ |
|
87 | - private $expandedFileName = null; |
|
83 | + /** |
|
84 | + * @var string the filename expanded |
|
85 | + * @access private |
|
86 | + */ |
|
87 | + private $expandedFileName = null; |
|
88 | 88 | |
89 | - public function __destruct() { |
|
90 | - parent::__destruct(); |
|
91 | - } |
|
89 | + public function __destruct() { |
|
90 | + parent::__destruct(); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Returns the value of the MaxBackupIndex option. |
|
95 | - * @return integer |
|
96 | - */ |
|
97 | - private function getExpandedFileName() { |
|
98 | - return $this->expandedFileName; |
|
99 | - } |
|
93 | + /** |
|
94 | + * Returns the value of the MaxBackupIndex option. |
|
95 | + * @return integer |
|
96 | + */ |
|
97 | + private function getExpandedFileName() { |
|
98 | + return $this->expandedFileName; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get the maximum size that the output file is allowed to reach |
|
103 | - * before being rolled over to backup files. |
|
104 | - * @return integer |
|
105 | - */ |
|
106 | - private function getMaximumFileSize() { |
|
107 | - return $this->maxFileSize; |
|
108 | - } |
|
101 | + /** |
|
102 | + * Get the maximum size that the output file is allowed to reach |
|
103 | + * before being rolled over to backup files. |
|
104 | + * @return integer |
|
105 | + */ |
|
106 | + private function getMaximumFileSize() { |
|
107 | + return $this->maxFileSize; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Implements the usual roll over behaviour. |
|
112 | - * |
|
113 | - * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
114 | - * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
115 | - * |
|
116 | - * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
117 | - */ |
|
118 | - private function rollOver() { |
|
119 | - // If maxBackups <= 0, then there is no file renaming to be done. |
|
120 | - if($this->maxBackupIndex > 0) { |
|
121 | - $fileName = $this->getExpandedFileName(); |
|
122 | - // Delete the oldest file, to keep Windows happy. |
|
123 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
124 | - if(is_writable($file)) |
|
125 | - unlink($file); |
|
126 | - // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
127 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | - $file = $fileName . "." . $i; |
|
129 | - if(is_readable($file)) { |
|
130 | - $target = $fileName . '.' . ($i + 1); |
|
131 | - rename($file, $target); |
|
132 | - } |
|
133 | - } |
|
110 | + /** |
|
111 | + * Implements the usual roll over behaviour. |
|
112 | + * |
|
113 | + * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
114 | + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
115 | + * |
|
116 | + * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
117 | + */ |
|
118 | + private function rollOver() { |
|
119 | + // If maxBackups <= 0, then there is no file renaming to be done. |
|
120 | + if($this->maxBackupIndex > 0) { |
|
121 | + $fileName = $this->getExpandedFileName(); |
|
122 | + // Delete the oldest file, to keep Windows happy. |
|
123 | + $file = $fileName . '.' . $this->maxBackupIndex; |
|
124 | + if(is_writable($file)) |
|
125 | + unlink($file); |
|
126 | + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
127 | + for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | + $file = $fileName . "." . $i; |
|
129 | + if(is_readable($file)) { |
|
130 | + $target = $fileName . '.' . ($i + 1); |
|
131 | + rename($file, $target); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | |
135 | - $this->close(); |
|
135 | + $this->close(); |
|
136 | 136 | |
137 | - // Rename fileName to fileName.1 |
|
138 | - $target = $fileName . ".1"; |
|
139 | - $file = $fileName; |
|
140 | - rename($file, $target); |
|
141 | - } |
|
137 | + // Rename fileName to fileName.1 |
|
138 | + $target = $fileName . ".1"; |
|
139 | + $file = $fileName; |
|
140 | + rename($file, $target); |
|
141 | + } |
|
142 | 142 | |
143 | - //unset($this->fp); |
|
144 | - $this->activateOptions(); |
|
145 | - $this->setFile($fileName, false); |
|
146 | - } |
|
143 | + //unset($this->fp); |
|
144 | + $this->activateOptions(); |
|
145 | + $this->setFile($fileName, false); |
|
146 | + } |
|
147 | 147 | |
148 | - public function setFileName($fileName) { |
|
149 | - $this->fileName = $fileName; |
|
150 | - // As LoggerAppenderFile does not create the directory, it has to exist. |
|
151 | - // realpath() fails if the argument does not exist so the filename is separated. |
|
152 | - $this->expandedFileName = realpath(dirname($fileName)); |
|
153 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
154 | - $this->expandedFileName .= '/'.basename($fileName); |
|
155 | - } |
|
148 | + public function setFileName($fileName) { |
|
149 | + $this->fileName = $fileName; |
|
150 | + // As LoggerAppenderFile does not create the directory, it has to exist. |
|
151 | + // realpath() fails if the argument does not exist so the filename is separated. |
|
152 | + $this->expandedFileName = realpath(dirname($fileName)); |
|
153 | + if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
154 | + $this->expandedFileName .= '/'.basename($fileName); |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | - /** |
|
159 | - * Set the maximum number of backup files to keep around. |
|
160 | - * |
|
161 | - * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
162 | - * files are kept before the oldest is erased. This option takes |
|
163 | - * a positive integer value. If set to zero, then there will be no |
|
164 | - * backup files and the log file will be truncated when it reaches |
|
165 | - * MaxFileSize. |
|
166 | - * |
|
167 | - * @param mixed $maxBackups |
|
168 | - */ |
|
169 | - public function setMaxBackupIndex($maxBackups) { |
|
170 | - if(is_numeric($maxBackups)) { |
|
171 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
172 | - } |
|
173 | - } |
|
158 | + /** |
|
159 | + * Set the maximum number of backup files to keep around. |
|
160 | + * |
|
161 | + * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
162 | + * files are kept before the oldest is erased. This option takes |
|
163 | + * a positive integer value. If set to zero, then there will be no |
|
164 | + * backup files and the log file will be truncated when it reaches |
|
165 | + * MaxFileSize. |
|
166 | + * |
|
167 | + * @param mixed $maxBackups |
|
168 | + */ |
|
169 | + public function setMaxBackupIndex($maxBackups) { |
|
170 | + if(is_numeric($maxBackups)) { |
|
171 | + $this->maxBackupIndex = abs((int)$maxBackups); |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Set the maximum size that the output file is allowed to reach |
|
177 | - * before being rolled over to backup files. |
|
178 | - * |
|
179 | - * @param mixed $maxFileSize |
|
180 | - * @see setMaxFileSize() |
|
181 | - * @deprecated |
|
182 | - */ |
|
183 | - public function setMaximumFileSize($maxFileSize) { |
|
184 | - return $this->setMaxFileSize($maxFileSize); |
|
185 | - } |
|
175 | + /** |
|
176 | + * Set the maximum size that the output file is allowed to reach |
|
177 | + * before being rolled over to backup files. |
|
178 | + * |
|
179 | + * @param mixed $maxFileSize |
|
180 | + * @see setMaxFileSize() |
|
181 | + * @deprecated |
|
182 | + */ |
|
183 | + public function setMaximumFileSize($maxFileSize) { |
|
184 | + return $this->setMaxFileSize($maxFileSize); |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Set the maximum size that the output file is allowed to reach |
|
189 | - * before being rolled over to backup files. |
|
190 | - * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
191 | - * long integer in the range 0 - 2^63. You can specify the value |
|
192 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
193 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
194 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
195 | - * as 10240. |
|
196 | - * |
|
197 | - * @param mixed $value |
|
198 | - * @return the actual file size set |
|
199 | - */ |
|
200 | - public function setMaxFileSize($value) { |
|
201 | - $maxFileSize = null; |
|
202 | - $numpart = substr($value,0, strlen($value) -2); |
|
203 | - $suffix = strtoupper(substr($value, -2)); |
|
187 | + /** |
|
188 | + * Set the maximum size that the output file is allowed to reach |
|
189 | + * before being rolled over to backup files. |
|
190 | + * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
191 | + * long integer in the range 0 - 2^63. You can specify the value |
|
192 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
193 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
194 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
195 | + * as 10240. |
|
196 | + * |
|
197 | + * @param mixed $value |
|
198 | + * @return the actual file size set |
|
199 | + */ |
|
200 | + public function setMaxFileSize($value) { |
|
201 | + $maxFileSize = null; |
|
202 | + $numpart = substr($value,0, strlen($value) -2); |
|
203 | + $suffix = strtoupper(substr($value, -2)); |
|
204 | 204 | |
205 | - switch($suffix) { |
|
206 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
207 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
208 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
209 | - default: |
|
210 | - if(is_numeric($value)) { |
|
211 | - $maxFileSize = (int)$value; |
|
212 | - } |
|
213 | - } |
|
205 | + switch($suffix) { |
|
206 | + case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
207 | + case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
208 | + case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
209 | + default: |
|
210 | + if(is_numeric($value)) { |
|
211 | + $maxFileSize = (int)$value; |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | - if($maxFileSize !== null) { |
|
216 | - $this->maxFileSize = abs($maxFileSize); |
|
217 | - } |
|
218 | - return $this->maxFileSize; |
|
219 | - } |
|
215 | + if($maxFileSize !== null) { |
|
216 | + $this->maxFileSize = abs($maxFileSize); |
|
217 | + } |
|
218 | + return $this->maxFileSize; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * @param LoggerLoggingEvent $event |
|
223 | - */ |
|
224 | - public function append(LoggerLoggingEvent $event) { |
|
225 | - parent::append($event); |
|
226 | - if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
227 | - $this->rollOver(); |
|
228 | - } |
|
229 | - } |
|
221 | + /** |
|
222 | + * @param LoggerLoggingEvent $event |
|
223 | + */ |
|
224 | + public function append(LoggerLoggingEvent $event) { |
|
225 | + parent::append($event); |
|
226 | + if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
227 | + $this->rollOver(); |
|
228 | + } |
|
229 | + } |
|
230 | 230 | } |
@@ -225,6 +225,7 @@ |
||
225 | 225 | |
226 | 226 | /** |
227 | 227 | * @param mixed |
228 | + * @param boolean $flag |
|
228 | 229 | */ |
229 | 230 | public function setUseXml($flag) { |
230 | 231 | $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | * Create a socket connection using defined parameters |
103 | 103 | */ |
104 | 104 | public function activateOptions() { |
105 | - if(!$this->dry) { |
|
105 | + if (!$this->dry) { |
|
106 | 106 | $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
107 | 107 | if ($this->sp === false) { |
108 | 108 | throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
109 | 109 | } |
110 | 110 | } |
111 | - if($this->getUseXml()) { |
|
111 | + if ($this->getUseXml()) { |
|
112 | 112 | $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
113 | - if($this->xmlLayout === null) { |
|
113 | + if ($this->xmlLayout === null) { |
|
114 | 114 | $this->setUseXml(false); |
115 | 115 | } else { |
116 | 116 | $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | public function close() { |
125 | - if($this->closed != true) { |
|
126 | - if(!$this->dry and $this->sp !== false) { |
|
125 | + if ($this->closed != true) { |
|
126 | + if (!$this->dry and $this->sp !== false) { |
|
127 | 127 | fclose($this->sp); |
128 | 128 | } |
129 | 129 | $this->closed = true; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function setPort($port) { |
206 | 206 | $port = LoggerOptionConverter::toInt($port, 0); |
207 | - if($port > 0 and $port < 65535) { |
|
207 | + if ($port > 0 and $port < 65535) { |
|
208 | 208 | $this->port = $port; |
209 | 209 | } |
210 | 210 | } |
@@ -231,20 +231,20 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | public function append(LoggerLoggingEvent $event) { |
234 | - if($this->sp || $this->dry) { |
|
235 | - if($this->getLocationInfo()) { |
|
234 | + if ($this->sp || $this->dry) { |
|
235 | + if ($this->getLocationInfo()) { |
|
236 | 236 | $event->getLocationInformation(); |
237 | 237 | } |
238 | 238 | |
239 | - if(!$this->getUseXml()) { |
|
239 | + if (!$this->getUseXml()) { |
|
240 | 240 | $sEvent = serialize($event); |
241 | - if(!$this->dry) { |
|
241 | + if (!$this->dry) { |
|
242 | 242 | fwrite($this->sp, $sEvent, strlen($sEvent)); |
243 | 243 | } else { |
244 | 244 | echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
245 | 245 | } |
246 | 246 | } else { |
247 | - if(!$this->dry) { |
|
247 | + if (!$this->dry) { |
|
248 | 248 | fwrite($this->sp, $this->xmlLayout->format($event)); |
249 | 249 | } else { |
250 | 250 | echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | // not sure about it... |
255 | - if(!$this->dry) { |
|
255 | + if (!$this->dry) { |
|
256 | 256 | fflush($this->sp); |
257 | 257 | } |
258 | 258 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Serialize events and send them to a network socket. |
@@ -46,215 +46,215 @@ discard block |
||
46 | 46 | */ |
47 | 47 | class LoggerAppenderSocket extends LoggerAppender { |
48 | 48 | |
49 | - /** |
|
50 | - * @var mixed socket connection resource |
|
51 | - * @access private |
|
52 | - */ |
|
53 | - private $sp = false; |
|
49 | + /** |
|
50 | + * @var mixed socket connection resource |
|
51 | + * @access private |
|
52 | + */ |
|
53 | + private $sp = false; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Target host. On how to define remote hostaname see |
|
57 | - * {@link PHP_MANUAL#fsockopen} |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - private $remoteHost = ''; |
|
55 | + /** |
|
56 | + * Target host. On how to define remote hostaname see |
|
57 | + * {@link PHP_MANUAL#fsockopen} |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + private $remoteHost = ''; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @var integer the network port. |
|
64 | - */ |
|
65 | - private $port = 4446; |
|
62 | + /** |
|
63 | + * @var integer the network port. |
|
64 | + */ |
|
65 | + private $port = 4446; |
|
66 | 66 | |
67 | - /** |
|
68 | - * @var boolean get event's location info. |
|
69 | - */ |
|
70 | - private $locationInfo = false; |
|
67 | + /** |
|
68 | + * @var boolean get event's location info. |
|
69 | + */ |
|
70 | + private $locationInfo = false; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @var integer connection timeout |
|
74 | - */ |
|
75 | - private $timeout = 30; |
|
72 | + /** |
|
73 | + * @var integer connection timeout |
|
74 | + */ |
|
75 | + private $timeout = 30; |
|
76 | 76 | |
77 | - /** |
|
78 | - * @var boolean output events via {@link LoggerXmlLayout} |
|
79 | - */ |
|
80 | - private $useXml = false; |
|
77 | + /** |
|
78 | + * @var boolean output events via {@link LoggerXmlLayout} |
|
79 | + */ |
|
80 | + private $useXml = false; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
84 | - * Ignored if {@link $useXml} is <i>false</i>. |
|
85 | - */ |
|
86 | - private $log4jNamespace = false; |
|
82 | + /** |
|
83 | + * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
84 | + * Ignored if {@link $useXml} is <i>false</i>. |
|
85 | + */ |
|
86 | + private $log4jNamespace = false; |
|
87 | 87 | |
88 | - /** |
|
89 | - * @var LoggerXmlLayout |
|
90 | - * @access private |
|
91 | - */ |
|
92 | - private $xmlLayout = null; |
|
88 | + /** |
|
89 | + * @var LoggerXmlLayout |
|
90 | + * @access private |
|
91 | + */ |
|
92 | + private $xmlLayout = null; |
|
93 | 93 | |
94 | - /** @var indiciates if this appender should run in dry mode */ |
|
95 | - private $dry = false; |
|
94 | + /** @var indiciates if this appender should run in dry mode */ |
|
95 | + private $dry = false; |
|
96 | 96 | |
97 | - public function __destruct() { |
|
98 | - $this->close(); |
|
99 | - } |
|
97 | + public function __destruct() { |
|
98 | + $this->close(); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Create a socket connection using defined parameters |
|
103 | - */ |
|
104 | - public function activateOptions() { |
|
105 | - if(!$this->dry) { |
|
106 | - $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
107 | - if ($this->sp === false) { |
|
108 | - throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
|
109 | - } |
|
110 | - } |
|
111 | - if($this->getUseXml()) { |
|
112 | - $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
|
113 | - if($this->xmlLayout === null) { |
|
114 | - $this->setUseXml(false); |
|
115 | - } else { |
|
116 | - $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
117 | - $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
118 | - $this->xmlLayout->activateOptions(); |
|
119 | - } |
|
120 | - } |
|
101 | + /** |
|
102 | + * Create a socket connection using defined parameters |
|
103 | + */ |
|
104 | + public function activateOptions() { |
|
105 | + if(!$this->dry) { |
|
106 | + $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
107 | + if ($this->sp === false) { |
|
108 | + throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
|
109 | + } |
|
110 | + } |
|
111 | + if($this->getUseXml()) { |
|
112 | + $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
|
113 | + if($this->xmlLayout === null) { |
|
114 | + $this->setUseXml(false); |
|
115 | + } else { |
|
116 | + $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
117 | + $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
118 | + $this->xmlLayout->activateOptions(); |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $this->closed = false; |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | - public function close() { |
|
125 | - if($this->closed != true) { |
|
126 | - if(!$this->dry and $this->sp !== false) { |
|
127 | - fclose($this->sp); |
|
128 | - } |
|
129 | - $this->closed = true; |
|
130 | - } |
|
131 | - } |
|
124 | + public function close() { |
|
125 | + if($this->closed != true) { |
|
126 | + if(!$this->dry and $this->sp !== false) { |
|
127 | + fclose($this->sp); |
|
128 | + } |
|
129 | + $this->closed = true; |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - public function setDry($dry) { |
|
134 | - $this->dry = $dry; |
|
135 | - } |
|
133 | + public function setDry($dry) { |
|
134 | + $this->dry = $dry; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function getHostname() { |
|
141 | - return $this->getRemoteHost(); |
|
142 | - } |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function getHostname() { |
|
141 | + return $this->getRemoteHost(); |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * @return boolean |
|
146 | - */ |
|
147 | - public function getLocationInfo() { |
|
148 | - return $this->locationInfo; |
|
149 | - } |
|
144 | + /** |
|
145 | + * @return boolean |
|
146 | + */ |
|
147 | + public function getLocationInfo() { |
|
148 | + return $this->locationInfo; |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @return boolean |
|
153 | - */ |
|
154 | - public function getLog4jNamespace() { |
|
155 | - return $this->log4jNamespace; |
|
156 | - } |
|
151 | + /** |
|
152 | + * @return boolean |
|
153 | + */ |
|
154 | + public function getLog4jNamespace() { |
|
155 | + return $this->log4jNamespace; |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @return integer |
|
160 | - */ |
|
161 | - public function getPort() { |
|
162 | - return $this->port; |
|
163 | - } |
|
158 | + /** |
|
159 | + * @return integer |
|
160 | + */ |
|
161 | + public function getPort() { |
|
162 | + return $this->port; |
|
163 | + } |
|
164 | 164 | |
165 | - public function getRemoteHost() { |
|
166 | - return $this->remoteHost; |
|
167 | - } |
|
165 | + public function getRemoteHost() { |
|
166 | + return $this->remoteHost; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * @return integer |
|
171 | - */ |
|
172 | - public function getTimeout() { |
|
173 | - return $this->timeout; |
|
174 | - } |
|
169 | + /** |
|
170 | + * @return integer |
|
171 | + */ |
|
172 | + public function getTimeout() { |
|
173 | + return $this->timeout; |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * @var boolean |
|
178 | - */ |
|
179 | - public function getUseXml() { |
|
180 | - return $this->useXml; |
|
181 | - } |
|
176 | + /** |
|
177 | + * @var boolean |
|
178 | + */ |
|
179 | + public function getUseXml() { |
|
180 | + return $this->useXml; |
|
181 | + } |
|
182 | 182 | |
183 | - public function reset() { |
|
184 | - $this->close(); |
|
185 | - parent::reset(); |
|
186 | - } |
|
183 | + public function reset() { |
|
184 | + $this->close(); |
|
185 | + parent::reset(); |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @param mixed |
|
190 | - */ |
|
191 | - public function setLocationInfo($flag) { |
|
192 | - $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
193 | - } |
|
188 | + /** |
|
189 | + * @param mixed |
|
190 | + */ |
|
191 | + public function setLocationInfo($flag) { |
|
192 | + $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * @param mixed |
|
197 | - */ |
|
198 | - public function setLog4jNamespace($flag) { |
|
199 | - $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
200 | - } |
|
195 | + /** |
|
196 | + * @param mixed |
|
197 | + */ |
|
198 | + public function setLog4jNamespace($flag) { |
|
199 | + $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * @param integer |
|
204 | - */ |
|
205 | - public function setPort($port) { |
|
206 | - $port = LoggerOptionConverter::toInt($port, 0); |
|
207 | - if($port > 0 and $port < 65535) { |
|
208 | - $this->port = $port; |
|
209 | - } |
|
210 | - } |
|
202 | + /** |
|
203 | + * @param integer |
|
204 | + */ |
|
205 | + public function setPort($port) { |
|
206 | + $port = LoggerOptionConverter::toInt($port, 0); |
|
207 | + if($port > 0 and $port < 65535) { |
|
208 | + $this->port = $port; |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @param string |
|
214 | - */ |
|
215 | - public function setRemoteHost($hostname) { |
|
216 | - $this->remoteHost = $hostname; |
|
217 | - } |
|
212 | + /** |
|
213 | + * @param string |
|
214 | + */ |
|
215 | + public function setRemoteHost($hostname) { |
|
216 | + $this->remoteHost = $hostname; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * @param integer |
|
221 | - */ |
|
222 | - public function setTimeout($timeout) { |
|
223 | - $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
224 | - } |
|
219 | + /** |
|
220 | + * @param integer |
|
221 | + */ |
|
222 | + public function setTimeout($timeout) { |
|
223 | + $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
224 | + } |
|
225 | 225 | |
226 | - /** |
|
227 | - * @param mixed |
|
228 | - */ |
|
229 | - public function setUseXml($flag) { |
|
230 | - $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
231 | - } |
|
226 | + /** |
|
227 | + * @param mixed |
|
228 | + */ |
|
229 | + public function setUseXml($flag) { |
|
230 | + $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
231 | + } |
|
232 | 232 | |
233 | - public function append(LoggerLoggingEvent $event) { |
|
234 | - if($this->sp || $this->dry) { |
|
235 | - if($this->getLocationInfo()) { |
|
236 | - $event->getLocationInformation(); |
|
237 | - } |
|
233 | + public function append(LoggerLoggingEvent $event) { |
|
234 | + if($this->sp || $this->dry) { |
|
235 | + if($this->getLocationInfo()) { |
|
236 | + $event->getLocationInformation(); |
|
237 | + } |
|
238 | 238 | |
239 | - if(!$this->getUseXml()) { |
|
240 | - $sEvent = serialize($event); |
|
241 | - if(!$this->dry) { |
|
242 | - fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
243 | - } else { |
|
244 | - echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
|
245 | - } |
|
246 | - } else { |
|
247 | - if(!$this->dry) { |
|
248 | - fwrite($this->sp, $this->xmlLayout->format($event)); |
|
249 | - } else { |
|
250 | - echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
|
251 | - } |
|
252 | - } |
|
239 | + if(!$this->getUseXml()) { |
|
240 | + $sEvent = serialize($event); |
|
241 | + if(!$this->dry) { |
|
242 | + fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
243 | + } else { |
|
244 | + echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
|
245 | + } |
|
246 | + } else { |
|
247 | + if(!$this->dry) { |
|
248 | + fwrite($this->sp, $this->xmlLayout->format($event)); |
|
249 | + } else { |
|
250 | + echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
|
251 | + } |
|
252 | + } |
|
253 | 253 | |
254 | - // not sure about it... |
|
255 | - if(!$this->dry) { |
|
256 | - fflush($this->sp); |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
254 | + // not sure about it... |
|
255 | + if(!$this->dry) { |
|
256 | + fflush($this->sp); |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | 260 | } |