Completed
Push — master ( 9528ad...369c90 )
by Michael
03:33
created
class/PEAR.php 1 patch
Indentation   +979 added lines, -979 removed lines patch added patch discarded remove patch
@@ -40,25 +40,25 @@  discard block
 block discarded – undo
40 40
 define('references_PEAR_ERROR_EXCEPTION', 32);
41 41
 /**#@-*/
42 42
 define('references_PEAR_ZE2', (function_exists('version_compare') &&
43
-                    version_compare(zend_version(), "2-dev", "ge")));
43
+					version_compare(zend_version(), "2-dev", "ge")));
44 44
 
45 45
 if (substr(PHP_OS, 0, 3) == 'WIN') {
46
-    define('references_OS_WINDOWS', true);
47
-    define('references_OS_UNIX',    false);
48
-    define('references_PEAR_OS',    'Windows');
46
+	define('references_OS_WINDOWS', true);
47
+	define('references_OS_UNIX',    false);
48
+	define('references_PEAR_OS',    'Windows');
49 49
 } else {
50
-    define('references_OS_WINDOWS', false);
51
-    define('references_OS_UNIX',    true);
52
-    define('references_PEAR_OS',    'Unix'); // blatant assumption
50
+	define('references_OS_WINDOWS', false);
51
+	define('references_OS_UNIX',    true);
52
+	define('references_PEAR_OS',    'Unix'); // blatant assumption
53 53
 }
54 54
 
55 55
 // instant backwards compatibility
56 56
 if (!defined('PATH_SEPARATOR')) {
57
-    if (references_OS_WINDOWS) {
58
-        define('PATH_SEPARATOR', ';');
59
-    } else {
60
-        define('PATH_SEPARATOR', ':');
61
-    }
57
+	if (references_OS_WINDOWS) {
58
+		define('PATH_SEPARATOR', ';');
59
+	} else {
60
+		define('PATH_SEPARATOR', ':');
61
+	}
62 62
 }
63 63
 
64 64
 $GLOBALS['_PEAR_default_error_mode']     = references_PEAR_ERROR_RETURN;
@@ -101,704 +101,704 @@  discard block
 block discarded – undo
101 101
  */
102 102
 class references_PEAR
103 103
 {
104
-    // {{{ properties
105
-
106
-    /**
107
-     * Whether to enable internal debug messages.
108
-     *
109
-     * @var     bool
110
-     * @access  private
111
-     */
112
-    public $_debug = false;
113
-
114
-    /**
115
-     * Default error mode for this object.
116
-     *
117
-     * @var     int
118
-     * @access  private
119
-     */
120
-    public $_default_error_mode = null;
121
-
122
-    /**
123
-     * Default error options used for this object when error mode
124
-     * is references_PEAR_ERROR_TRIGGER.
125
-     *
126
-     * @var     int
127
-     * @access  private
128
-     */
129
-    public $_default_error_options = null;
130
-
131
-    /**
132
-     * Default error handler (callback) for this object, if error mode is
133
-     * references_PEAR_ERROR_CALLBACK.
134
-     *
135
-     * @var     string
136
-     * @access  private
137
-     */
138
-    public $_default_error_handler = '';
139
-
140
-    /**
141
-     * Which class to use for error objects.
142
-     *
143
-     * @var     string
144
-     * @access  private
145
-     */
146
-    public $_error_class = 'PEAR_Error';
147
-
148
-    /**
149
-     * An array of expected errors.
150
-     *
151
-     * @var     array
152
-     * @access  private
153
-     */
154
-    public $_expected_errors = array();
155
-
156
-    // }}}
157
-
158
-    // {{{ constructor
159
-
160
-    /**
161
-     * Constructor.  Registers this object in
162
-     * $_PEAR_destructor_object_list for destructor emulation if a
163
-     * destructor object exists.
164
-     *
165
-     * @param string $error_class  (optional) which class to use for
166
-     *        error objects, defaults to PEAR_Error.
167
-     * @access public
168
-     * @return void
169
-     */
170
-    function __construct($error_class = null)
171
-    {
172
-        $classname = strtolower(get_class($this));
173
-        if ($this->_debug) {
174
-            print "PEAR constructor called, class=$classname\n";
175
-        }
176
-        if ($error_class !== null) {
177
-            $this->_error_class = $error_class;
178
-        }
179
-        while ($classname && strcasecmp($classname, "pear")) {
180
-            $destructor = "_$classname";
181
-            if (method_exists($this, $destructor)) {
182
-                global $_PEAR_destructor_object_list;
183
-                $_PEAR_destructor_object_list[] = &$this;
184
-                if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
185
-                    register_shutdown_function("references_PEAR_call_destructors");
186
-                    $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
187
-                }
188
-                break;
189
-            } else {
190
-                $classname = get_parent_class($classname);
191
-            }
192
-        }
193
-    }
194
-
195
-    // }}}
196
-    // {{{ destructor
197
-
198
-    /**
199
-     * Destructor (the emulated type of...).  Does nothing right now,
200
-     * but is included for forward compatibility, so subclass
201
-     * destructors should always call it.
202
-     *
203
-     * See the note in the class desciption about output from
204
-     * destructors.
205
-     *
206
-     * @access public
207
-     * @return void
208
-     */
209
-    function _PEAR() {
210
-        if ($this->_debug) {
211
-            printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
212
-        }
213
-    }
214
-
215
-    // }}}
216
-    // {{{ getStaticProperty()
217
-
218
-    /**
219
-    * If you have a class that's mostly/entirely static, and you need static
220
-    * properties, you can use this method to simulate them. Eg. in your method(s)
221
-    * do this: $myVar = &references_PEAR::getStaticProperty('myclass', 'myVar');
222
-    * You MUST use a reference, or they will not persist!
223
-    *
224
-    * @access public
225
-    * @param  string $class  The calling classname, to prevent clashes
226
-    * @param  string $var    The variable to retrieve.
227
-    * @return mixed   A reference to the variable. If not set it will be
228
-    *                 auto initialised to NULL.
229
-    */
230
-    function &getStaticProperty($class, $var)
231
-    {
232
-        static $properties;
233
-        if (!isset($properties[$class])) {
234
-            $properties[$class] = array();
235
-        }
236
-        if (!array_key_exists($var, $properties[$class])) {
237
-            $properties[$class][$var] = null;
238
-        }
239
-        return $properties[$class][$var];
240
-    }
241
-
242
-    // }}}
243
-    // {{{ registerShutdownFunc()
244
-
245
-    /**
246
-    * Use this function to register a shutdown method for static
247
-    * classes.
248
-    *
249
-    * @access public
250
-    * @param  mixed $func  The function name (or array of class/method) to call
251
-    * @param  mixed $args  The arguments to pass to the function
252
-    * @return void
253
-    */
254
-    function registerShutdownFunc($func, $args = array())
255
-    {
256
-        // if we are called statically, there is a potential
257
-        // that no shutdown func is registered.  Bug #6445
258
-        if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
259
-            register_shutdown_function("references__PEAR_call_destructors");
260
-            $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
261
-        }
262
-        $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
263
-    }
264
-
265
-    // }}}
266
-    // {{{ isError()
267
-
268
-    /**
269
-     * Tell whether a value is a PEAR error.
270
-     *
271
-     * @param   mixed $data   the value to test
272
-     * @param   int   $code   if $data is an error object, return true
273
-     *                        only if $code is a string and
274
-     *                        $obj->getMessage() == $code or
275
-     *                        $code is an integer and $obj->getCode() == $code
276
-     * @access  public
277
-     * @return  bool    true if parameter is an error
278
-     */
279
-    function isError($data, $code = null)
280
-    {
281
-        if (is_a($data, 'PEAR_Error')) {
282
-            if (is_null($code)) {
283
-                return true;
284
-            } elseif (is_string($code)) {
285
-                return $data->getMessage() == $code;
286
-            } else {
287
-                return $data->getCode() == $code;
288
-            }
289
-        }
290
-        return false;
291
-    }
292
-
293
-    // }}}
294
-    // {{{ setErrorHandling()
295
-
296
-    /**
297
-     * Sets how errors generated by this object should be handled.
298
-     * Can be invoked both in objects and statically.  If called
299
-     * statically, setErrorHandling sets the default behaviour for all
300
-     * PEAR objects.  If called in an object, setErrorHandling sets
301
-     * the default behaviour for that object.
302
-     *
303
-     * @param int $mode
304
-     *        One of references_PEAR_ERROR_RETURN, references_PEAR_ERROR_PRINT,
305
-     *        references_PEAR_ERROR_TRIGGER, references_PEAR_ERROR_DIE,
306
-     *        references_PEAR_ERROR_CALLBACK or references_PEAR_ERROR_EXCEPTION.
307
-     *
308
-     * @param mixed $options
309
-     *        When $mode is references_PEAR_ERROR_TRIGGER, this is the error level (one
310
-     *        of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
311
-     *
312
-     *        When $mode is references_PEAR_ERROR_CALLBACK, this parameter is expected
313
-     *        to be the callback function or method.  A callback
314
-     *        function is a string with the name of the function, a
315
-     *        callback method is an array of two elements: the element
316
-     *        at index 0 is the object, and the element at index 1 is
317
-     *        the name of the method to call in the object.
318
-     *
319
-     *        When $mode is references_PEAR_ERROR_PRINT or references_PEAR_ERROR_DIE, this is
320
-     *        a printf format string used when printing the error
321
-     *        message.
322
-     *
323
-     * @access public
324
-     * @return void
325
-     * @see references_PEAR_ERROR_RETURN
326
-     * @see references_PEAR_ERROR_PRINT
327
-     * @see references_PEAR_ERROR_TRIGGER
328
-     * @see references_PEAR_ERROR_DIE
329
-     * @see references_PEAR_ERROR_CALLBACK
330
-     * @see references_PEAR_ERROR_EXCEPTION
331
-     *
332
-     * @since PHP 4.0.5
333
-     */
334
-
335
-    function setErrorHandling($mode = null, $options = null)
336
-    {
337
-        if (isset($this) && is_a($this, 'PEAR')) {
338
-            $setmode     = &$this->_default_error_mode;
339
-            $setoptions  = &$this->_default_error_options;
340
-        } else {
341
-            $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
342
-            $setoptions  = &$GLOBALS['_PEAR_default_error_options'];
343
-        }
344
-
345
-        switch ($mode) {
346
-            case references_PEAR_ERROR_EXCEPTION:
347
-            case references_PEAR_ERROR_RETURN:
348
-            case references_PEAR_ERROR_PRINT:
349
-            case references_PEAR_ERROR_TRIGGER:
350
-            case references_PEAR_ERROR_DIE:
351
-            case null:
352
-                $setmode = $mode;
353
-                $setoptions = $options;
354
-                break;
355
-
356
-            case references_PEAR_ERROR_CALLBACK:
357
-                $setmode = $mode;
358
-                // class/object method callback
359
-                if (is_callable($options)) {
360
-                    $setoptions = $options;
361
-                } else {
362
-                    trigger_error("invalid error callback", E_USER_WARNING);
363
-                }
364
-                break;
365
-
366
-            default:
367
-                trigger_error("invalid error mode", E_USER_WARNING);
368
-                break;
369
-        }
370
-    }
371
-
372
-    // }}}
373
-    // {{{ expectError()
374
-
375
-    /**
376
-     * This method is used to tell which errors you expect to get.
377
-     * Expected errors are always returned with error mode
378
-     * references_PEAR_ERROR_RETURN.  Expected error codes are stored in a stack,
379
-     * and this method pushes a new element onto it.  The list of
380
-     * expected errors are in effect until they are popped off the
381
-     * stack with the popExpect() method.
382
-     *
383
-     * Note that this method can not be called statically
384
-     *
385
-     * @param mixed $code a single error code or an array of error codes to expect
386
-     *
387
-     * @return int     the new depth of the "expected errors" stack
388
-     * @access public
389
-     */
390
-    function expectError($code = '*')
391
-    {
392
-        if (is_array($code)) {
393
-            array_push($this->_expected_errors, $code);
394
-        } else {
395
-            array_push($this->_expected_errors, array($code));
396
-        }
397
-        return sizeof($this->_expected_errors);
398
-    }
399
-
400
-    // }}}
401
-    // {{{ popExpect()
402
-
403
-    /**
404
-     * This method pops one element off the expected error codes
405
-     * stack.
406
-     *
407
-     * @return array   the list of error codes that were popped
408
-     */
409
-    function popExpect()
410
-    {
411
-        return array_pop($this->_expected_errors);
412
-    }
413
-
414
-    // }}}
415
-    // {{{ _checkDelExpect()
416
-
417
-    /**
418
-     * This method checks unsets an error code if available
419
-     *
420
-     * @param mixed error code
421
-     * @return bool true if the error code was unset, false otherwise
422
-     * @access private
423
-     * @since PHP 4.3.0
424
-     */
425
-    function _checkDelExpect($error_code)
426
-    {
427
-        $deleted = false;
428
-
429
-        foreach ($this->_expected_errors AS $key => $error_array) {
430
-            if (in_array($error_code, $error_array)) {
431
-                unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
432
-                $deleted = true;
433
-            }
434
-
435
-            // clean up empty arrays
436
-            if (0 == count($this->_expected_errors[$key])) {
437
-                unset($this->_expected_errors[$key]);
438
-            }
439
-        }
440
-        return $deleted;
441
-    }
442
-
443
-    // }}}
444
-    // {{{ delExpect()
445
-
446
-    /**
447
-     * This method deletes all occurences of the specified element from
448
-     * the expected error codes stack.
449
-     *
450
-     * @param  mixed $error_code error code that should be deleted
451
-     * @return mixed list of error codes that were deleted or error
452
-     * @access public
453
-     * @since PHP 4.3.0
454
-     */
455
-    function delExpect($error_code)
456
-    {
457
-        $deleted = false;
458
-
459
-        if ((is_array($error_code) && (0 != count($error_code)))) {
460
-            // $error_code is a non-empty array here;
461
-            // we walk through it trying to unset all
462
-            // values
463
-            foreach($error_code as $key => $error) {
464
-                if ($this->_checkDelExpect($error)) {
465
-                    $deleted =  true;
466
-                } else {
467
-                    $deleted = false;
468
-                }
469
-            }
470
-            return $deleted ? true : references_PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
471
-        } elseif (!empty($error_code)) {
472
-            // $error_code comes alone, trying to unset it
473
-            if ($this->_checkDelExpect($error_code)) {
474
-                return true;
475
-            } else {
476
-                return references_PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
477
-            }
478
-        } else {
479
-            // $error_code is empty
480
-            return references_PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
481
-        }
482
-    }
483
-
484
-    // }}}
485
-    // {{{ raiseError()
486
-
487
-    /**
488
-     * This method is a wrapper that returns an instance of the
489
-     * configured error class with this object's default error
490
-     * handling applied.  If the $mode and $options parameters are not
491
-     * specified, the object's defaults are used.
492
-     *
493
-     * @param mixed $message a text error message or a PEAR error object
494
-     *
495
-     * @param int $code      a numeric error code (it is up to your class
496
-     *                  to define these if you want to use codes)
497
-     *
498
-     * @param int $mode      One of references_PEAR_ERROR_RETURN, references_PEAR_ERROR_PRINT,
499
-     *                  references_PEAR_ERROR_TRIGGER, references_PEAR_ERROR_DIE,
500
-     *                  references_PEAR_ERROR_CALLBACK, references_PEAR_ERROR_EXCEPTION.
501
-     *
502
-     * @param mixed $options If $mode is references_PEAR_ERROR_TRIGGER, this parameter
503
-     *                  specifies the PHP-internal error level (one of
504
-     *                  E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
505
-     *                  If $mode is references_PEAR_ERROR_CALLBACK, this
506
-     *                  parameter specifies the callback function or
507
-     *                  method.  In other error modes this parameter
508
-     *                  is ignored.
509
-     *
510
-     * @param string $userinfo If you need to pass along for example debug
511
-     *                  information, this parameter is meant for that.
512
-     *
513
-     * @param string $error_class The returned error object will be
514
-     *                  instantiated from this class, if specified.
515
-     *
516
-     * @param bool $skipmsg If true, raiseError will only pass error codes,
517
-     *                  the error message parameter will be dropped.
518
-     *
519
-     * @access public
520
-     * @return object   a PEAR error object
521
-     * @see references_PEAR::setErrorHandling
522
-     * @since PHP 4.0.5
523
-     */
524
-    function &raiseError($message = null,
525
-                         $code = null,
526
-                         $mode = null,
527
-                         $options = null,
528
-                         $userinfo = null,
529
-                         $error_class = null,
530
-                         $skipmsg = false)
531
-    {
532
-        // The error is yet a PEAR error object
533
-        if (is_object($message)) {
534
-            $code        = $message->getCode();
535
-            $userinfo    = $message->getUserInfo();
536
-            $error_class = $message->getType();
537
-            $message->error_message_prefix = '';
538
-            $message     = $message->getMessage();
539
-        }
540
-
541
-        if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
542
-            if ($exp[0] == "*" ||
543
-                (is_int(reset($exp)) && in_array($code, $exp)) ||
544
-                (is_string(reset($exp)) && in_array($message, $exp))) {
545
-                $mode = references_PEAR_ERROR_RETURN;
546
-            }
547
-        }
548
-        // No mode given, try global ones
549
-        if ($mode === null) {
550
-            // Class error handler
551
-            if (isset($this) && isset($this->_default_error_mode)) {
552
-                $mode    = $this->_default_error_mode;
553
-                $options = $this->_default_error_options;
554
-            // Global error handler
555
-            } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
556
-                $mode    = $GLOBALS['_PEAR_default_error_mode'];
557
-                $options = $GLOBALS['_PEAR_default_error_options'];
558
-            }
559
-        }
560
-
561
-        if ($error_class !== null) {
562
-            $ec = $error_class;
563
-        } elseif (isset($this) && isset($this->_error_class)) {
564
-            $ec = $this->_error_class;
565
-        } else {
566
-            $ec = 'references_PEAR_Error';
567
-        }
568
-        if ($skipmsg) {
569
-            $a = new $ec($code, $mode, $options, $userinfo);
570
-            return $a;
571
-        } else {
572
-            $a = new $ec($message, $code, $mode, $options, $userinfo);
573
-            return $a;
574
-        }
575
-    }
576
-
577
-    // }}}
578
-    // {{{ throwError()
579
-
580
-    /**
581
-     * Simpler form of raiseError with fewer options.  In most cases
582
-     * message, code and userinfo are enough.
583
-     *
584
-     * @param string $message
585
-     *
586
-     */
587
-    function &throwError($message = null,
588
-                         $code = null,
589
-                         $userinfo = null)
590
-    {
591
-        if (isset($this) && is_a($this, 'PEAR')) {
592
-            $a = &$this->raiseError($message, $code, null, null, $userinfo);
593
-            return $a;
594
-        } else {
595
-            $a = &references_PEAR::raiseError($message, $code, null, null, $userinfo);
596
-            return $a;
597
-        }
598
-    }
599
-
600
-    // }}}
601
-    function staticPushErrorHandling($mode, $options = null)
602
-    {
603
-        $stack = &$GLOBALS['_PEAR_error_handler_stack'];
604
-        $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
605
-        $def_options = &$GLOBALS['_PEAR_default_error_options'];
606
-        $stack[] = array($def_mode, $def_options);
607
-        switch ($mode) {
608
-            case references_PEAR_ERROR_EXCEPTION:
609
-            case references_PEAR_ERROR_RETURN:
610
-            case references_PEAR_ERROR_PRINT:
611
-            case references_PEAR_ERROR_TRIGGER:
612
-            case references_PEAR_ERROR_DIE:
613
-            case null:
614
-                $def_mode = $mode;
615
-                $def_options = $options;
616
-                break;
617
-
618
-            case references_PEAR_ERROR_CALLBACK:
619
-                $def_mode = $mode;
620
-                // class/object method callback
621
-                if (is_callable($options)) {
622
-                    $def_options = $options;
623
-                } else {
624
-                    trigger_error("invalid error callback", E_USER_WARNING);
625
-                }
626
-                break;
627
-
628
-            default:
629
-                trigger_error("invalid error mode", E_USER_WARNING);
630
-                break;
631
-        }
632
-        $stack[] = array($mode, $options);
633
-        return true;
634
-    }
635
-
636
-    function staticPopErrorHandling()
637
-    {
638
-        $stack = &$GLOBALS['_PEAR_error_handler_stack'];
639
-        $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
640
-        $setoptions  = &$GLOBALS['_PEAR_default_error_options'];
641
-        array_pop($stack);
642
-        list($mode, $options) = $stack[sizeof($stack) - 1];
643
-        array_pop($stack);
644
-        switch ($mode) {
645
-            case references_PEAR_ERROR_EXCEPTION:
646
-            case references_PEAR_ERROR_RETURN:
647
-            case references_PEAR_ERROR_PRINT:
648
-            case references_PEAR_ERROR_TRIGGER:
649
-            case references_PEAR_ERROR_DIE:
650
-            case null:
651
-                $setmode = $mode;
652
-                $setoptions = $options;
653
-                break;
654
-
655
-            case references_PEAR_ERROR_CALLBACK:
656
-                $setmode = $mode;
657
-                // class/object method callback
658
-                if (is_callable($options)) {
659
-                    $setoptions = $options;
660
-                } else {
661
-                    trigger_error("invalid error callback", E_USER_WARNING);
662
-                }
663
-                break;
664
-
665
-            default:
666
-                trigger_error("invalid error mode", E_USER_WARNING);
667
-                break;
668
-        }
669
-        return true;
670
-    }
671
-
672
-    // {{{ pushErrorHandling()
673
-
674
-    /**
675
-     * Push a new error handler on top of the error handler options stack. With this
676
-     * you can easily override the actual error handler for some code and restore
677
-     * it later with popErrorHandling.
678
-     *
679
-     * @param mixed $mode (same as setErrorHandling)
680
-     * @param mixed $options (same as setErrorHandling)
681
-     *
682
-     * @return bool Always true
683
-     *
684
-     * @see references_PEAR::setErrorHandling
685
-     */
686
-    function pushErrorHandling($mode, $options = null)
687
-    {
688
-        $stack = &$GLOBALS['_PEAR_error_handler_stack'];
689
-        if (isset($this) && is_a($this, 'PEAR')) {
690
-            $def_mode    = &$this->_default_error_mode;
691
-            $def_options = &$this->_default_error_options;
692
-        } else {
693
-            $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
694
-            $def_options = &$GLOBALS['_PEAR_default_error_options'];
695
-        }
696
-        $stack[] = array($def_mode, $def_options);
697
-
698
-        if (isset($this) && is_a($this, 'PEAR')) {
699
-            $this->setErrorHandling($mode, $options);
700
-        } else {
701
-            references_PEAR::setErrorHandling($mode, $options);
702
-        }
703
-        $stack[] = array($mode, $options);
704
-        return true;
705
-    }
706
-
707
-    // }}}
708
-    // {{{ popErrorHandling()
709
-
710
-    /**
711
-    * Pop the last error handler used
712
-    *
713
-    * @return bool Always true
714
-    *
715
-    * @see references_PEAR::pushErrorHandling
716
-    */
717
-    function popErrorHandling()
718
-    {
719
-        $stack = &$GLOBALS['_PEAR_error_handler_stack'];
720
-        array_pop($stack);
721
-        list($mode, $options) = $stack[sizeof($stack) - 1];
722
-        array_pop($stack);
723
-        if (isset($this) && is_a($this, 'PEAR')) {
724
-            $this->setErrorHandling($mode, $options);
725
-        } else {
726
-            references_PEAR::setErrorHandling($mode, $options);
727
-        }
728
-        return true;
729
-    }
730
-
731
-    // }}}
732
-    // {{{ loadExtension()
733
-
734
-    /**
735
-    * OS independant PHP extension load. Remember to take care
736
-    * on the correct extension name for case sensitive OSes.
737
-    *
738
-    * @param string $ext The extension name
739
-    * @return bool Success or not on the dl() call
740
-    */
741
-    function loadExtension($ext)
742
-    {
743
-        if (!extension_loaded($ext)) {
744
-            // if either returns true dl() will produce a FATAL error, stop that
745
-            if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
746
-                return false;
747
-            }
748
-            if (references_OS_WINDOWS) {
749
-                $suffix = '.dll';
750
-            } elseif (PHP_OS == 'HP-UX') {
751
-                $suffix = '.sl';
752
-            } elseif (PHP_OS == 'AIX') {
753
-                $suffix = '.a';
754
-            } elseif (PHP_OS == 'OSX') {
755
-                $suffix = '.bundle';
756
-            } else {
757
-                $suffix = '.so';
758
-            }
759
-            return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
760
-        }
761
-        return true;
762
-    }
763
-
764
-    // }}}
104
+	// {{{ properties
105
+
106
+	/**
107
+	 * Whether to enable internal debug messages.
108
+	 *
109
+	 * @var     bool
110
+	 * @access  private
111
+	 */
112
+	public $_debug = false;
113
+
114
+	/**
115
+	 * Default error mode for this object.
116
+	 *
117
+	 * @var     int
118
+	 * @access  private
119
+	 */
120
+	public $_default_error_mode = null;
121
+
122
+	/**
123
+	 * Default error options used for this object when error mode
124
+	 * is references_PEAR_ERROR_TRIGGER.
125
+	 *
126
+	 * @var     int
127
+	 * @access  private
128
+	 */
129
+	public $_default_error_options = null;
130
+
131
+	/**
132
+	 * Default error handler (callback) for this object, if error mode is
133
+	 * references_PEAR_ERROR_CALLBACK.
134
+	 *
135
+	 * @var     string
136
+	 * @access  private
137
+	 */
138
+	public $_default_error_handler = '';
139
+
140
+	/**
141
+	 * Which class to use for error objects.
142
+	 *
143
+	 * @var     string
144
+	 * @access  private
145
+	 */
146
+	public $_error_class = 'PEAR_Error';
147
+
148
+	/**
149
+	 * An array of expected errors.
150
+	 *
151
+	 * @var     array
152
+	 * @access  private
153
+	 */
154
+	public $_expected_errors = array();
155
+
156
+	// }}}
157
+
158
+	// {{{ constructor
159
+
160
+	/**
161
+	 * Constructor.  Registers this object in
162
+	 * $_PEAR_destructor_object_list for destructor emulation if a
163
+	 * destructor object exists.
164
+	 *
165
+	 * @param string $error_class  (optional) which class to use for
166
+	 *        error objects, defaults to PEAR_Error.
167
+	 * @access public
168
+	 * @return void
169
+	 */
170
+	function __construct($error_class = null)
171
+	{
172
+		$classname = strtolower(get_class($this));
173
+		if ($this->_debug) {
174
+			print "PEAR constructor called, class=$classname\n";
175
+		}
176
+		if ($error_class !== null) {
177
+			$this->_error_class = $error_class;
178
+		}
179
+		while ($classname && strcasecmp($classname, "pear")) {
180
+			$destructor = "_$classname";
181
+			if (method_exists($this, $destructor)) {
182
+				global $_PEAR_destructor_object_list;
183
+				$_PEAR_destructor_object_list[] = &$this;
184
+				if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
185
+					register_shutdown_function("references_PEAR_call_destructors");
186
+					$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
187
+				}
188
+				break;
189
+			} else {
190
+				$classname = get_parent_class($classname);
191
+			}
192
+		}
193
+	}
194
+
195
+	// }}}
196
+	// {{{ destructor
197
+
198
+	/**
199
+	 * Destructor (the emulated type of...).  Does nothing right now,
200
+	 * but is included for forward compatibility, so subclass
201
+	 * destructors should always call it.
202
+	 *
203
+	 * See the note in the class desciption about output from
204
+	 * destructors.
205
+	 *
206
+	 * @access public
207
+	 * @return void
208
+	 */
209
+	function _PEAR() {
210
+		if ($this->_debug) {
211
+			printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
212
+		}
213
+	}
214
+
215
+	// }}}
216
+	// {{{ getStaticProperty()
217
+
218
+	/**
219
+	 * If you have a class that's mostly/entirely static, and you need static
220
+	 * properties, you can use this method to simulate them. Eg. in your method(s)
221
+	 * do this: $myVar = &references_PEAR::getStaticProperty('myclass', 'myVar');
222
+	 * You MUST use a reference, or they will not persist!
223
+	 *
224
+	 * @access public
225
+	 * @param  string $class  The calling classname, to prevent clashes
226
+	 * @param  string $var    The variable to retrieve.
227
+	 * @return mixed   A reference to the variable. If not set it will be
228
+	 *                 auto initialised to NULL.
229
+	 */
230
+	function &getStaticProperty($class, $var)
231
+	{
232
+		static $properties;
233
+		if (!isset($properties[$class])) {
234
+			$properties[$class] = array();
235
+		}
236
+		if (!array_key_exists($var, $properties[$class])) {
237
+			$properties[$class][$var] = null;
238
+		}
239
+		return $properties[$class][$var];
240
+	}
241
+
242
+	// }}}
243
+	// {{{ registerShutdownFunc()
244
+
245
+	/**
246
+	 * Use this function to register a shutdown method for static
247
+	 * classes.
248
+	 *
249
+	 * @access public
250
+	 * @param  mixed $func  The function name (or array of class/method) to call
251
+	 * @param  mixed $args  The arguments to pass to the function
252
+	 * @return void
253
+	 */
254
+	function registerShutdownFunc($func, $args = array())
255
+	{
256
+		// if we are called statically, there is a potential
257
+		// that no shutdown func is registered.  Bug #6445
258
+		if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
259
+			register_shutdown_function("references__PEAR_call_destructors");
260
+			$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
261
+		}
262
+		$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
263
+	}
264
+
265
+	// }}}
266
+	// {{{ isError()
267
+
268
+	/**
269
+	 * Tell whether a value is a PEAR error.
270
+	 *
271
+	 * @param   mixed $data   the value to test
272
+	 * @param   int   $code   if $data is an error object, return true
273
+	 *                        only if $code is a string and
274
+	 *                        $obj->getMessage() == $code or
275
+	 *                        $code is an integer and $obj->getCode() == $code
276
+	 * @access  public
277
+	 * @return  bool    true if parameter is an error
278
+	 */
279
+	function isError($data, $code = null)
280
+	{
281
+		if (is_a($data, 'PEAR_Error')) {
282
+			if (is_null($code)) {
283
+				return true;
284
+			} elseif (is_string($code)) {
285
+				return $data->getMessage() == $code;
286
+			} else {
287
+				return $data->getCode() == $code;
288
+			}
289
+		}
290
+		return false;
291
+	}
292
+
293
+	// }}}
294
+	// {{{ setErrorHandling()
295
+
296
+	/**
297
+	 * Sets how errors generated by this object should be handled.
298
+	 * Can be invoked both in objects and statically.  If called
299
+	 * statically, setErrorHandling sets the default behaviour for all
300
+	 * PEAR objects.  If called in an object, setErrorHandling sets
301
+	 * the default behaviour for that object.
302
+	 *
303
+	 * @param int $mode
304
+	 *        One of references_PEAR_ERROR_RETURN, references_PEAR_ERROR_PRINT,
305
+	 *        references_PEAR_ERROR_TRIGGER, references_PEAR_ERROR_DIE,
306
+	 *        references_PEAR_ERROR_CALLBACK or references_PEAR_ERROR_EXCEPTION.
307
+	 *
308
+	 * @param mixed $options
309
+	 *        When $mode is references_PEAR_ERROR_TRIGGER, this is the error level (one
310
+	 *        of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
311
+	 *
312
+	 *        When $mode is references_PEAR_ERROR_CALLBACK, this parameter is expected
313
+	 *        to be the callback function or method.  A callback
314
+	 *        function is a string with the name of the function, a
315
+	 *        callback method is an array of two elements: the element
316
+	 *        at index 0 is the object, and the element at index 1 is
317
+	 *        the name of the method to call in the object.
318
+	 *
319
+	 *        When $mode is references_PEAR_ERROR_PRINT or references_PEAR_ERROR_DIE, this is
320
+	 *        a printf format string used when printing the error
321
+	 *        message.
322
+	 *
323
+	 * @access public
324
+	 * @return void
325
+	 * @see references_PEAR_ERROR_RETURN
326
+	 * @see references_PEAR_ERROR_PRINT
327
+	 * @see references_PEAR_ERROR_TRIGGER
328
+	 * @see references_PEAR_ERROR_DIE
329
+	 * @see references_PEAR_ERROR_CALLBACK
330
+	 * @see references_PEAR_ERROR_EXCEPTION
331
+	 *
332
+	 * @since PHP 4.0.5
333
+	 */
334
+
335
+	function setErrorHandling($mode = null, $options = null)
336
+	{
337
+		if (isset($this) && is_a($this, 'PEAR')) {
338
+			$setmode     = &$this->_default_error_mode;
339
+			$setoptions  = &$this->_default_error_options;
340
+		} else {
341
+			$setmode     = &$GLOBALS['_PEAR_default_error_mode'];
342
+			$setoptions  = &$GLOBALS['_PEAR_default_error_options'];
343
+		}
344
+
345
+		switch ($mode) {
346
+			case references_PEAR_ERROR_EXCEPTION:
347
+			case references_PEAR_ERROR_RETURN:
348
+			case references_PEAR_ERROR_PRINT:
349
+			case references_PEAR_ERROR_TRIGGER:
350
+			case references_PEAR_ERROR_DIE:
351
+			case null:
352
+				$setmode = $mode;
353
+				$setoptions = $options;
354
+				break;
355
+
356
+			case references_PEAR_ERROR_CALLBACK:
357
+				$setmode = $mode;
358
+				// class/object method callback
359
+				if (is_callable($options)) {
360
+					$setoptions = $options;
361
+				} else {
362
+					trigger_error("invalid error callback", E_USER_WARNING);
363
+				}
364
+				break;
365
+
366
+			default:
367
+				trigger_error("invalid error mode", E_USER_WARNING);
368
+				break;
369
+		}
370
+	}
371
+
372
+	// }}}
373
+	// {{{ expectError()
374
+
375
+	/**
376
+	 * This method is used to tell which errors you expect to get.
377
+	 * Expected errors are always returned with error mode
378
+	 * references_PEAR_ERROR_RETURN.  Expected error codes are stored in a stack,
379
+	 * and this method pushes a new element onto it.  The list of
380
+	 * expected errors are in effect until they are popped off the
381
+	 * stack with the popExpect() method.
382
+	 *
383
+	 * Note that this method can not be called statically
384
+	 *
385
+	 * @param mixed $code a single error code or an array of error codes to expect
386
+	 *
387
+	 * @return int     the new depth of the "expected errors" stack
388
+	 * @access public
389
+	 */
390
+	function expectError($code = '*')
391
+	{
392
+		if (is_array($code)) {
393
+			array_push($this->_expected_errors, $code);
394
+		} else {
395
+			array_push($this->_expected_errors, array($code));
396
+		}
397
+		return sizeof($this->_expected_errors);
398
+	}
399
+
400
+	// }}}
401
+	// {{{ popExpect()
402
+
403
+	/**
404
+	 * This method pops one element off the expected error codes
405
+	 * stack.
406
+	 *
407
+	 * @return array   the list of error codes that were popped
408
+	 */
409
+	function popExpect()
410
+	{
411
+		return array_pop($this->_expected_errors);
412
+	}
413
+
414
+	// }}}
415
+	// {{{ _checkDelExpect()
416
+
417
+	/**
418
+	 * This method checks unsets an error code if available
419
+	 *
420
+	 * @param mixed error code
421
+	 * @return bool true if the error code was unset, false otherwise
422
+	 * @access private
423
+	 * @since PHP 4.3.0
424
+	 */
425
+	function _checkDelExpect($error_code)
426
+	{
427
+		$deleted = false;
428
+
429
+		foreach ($this->_expected_errors AS $key => $error_array) {
430
+			if (in_array($error_code, $error_array)) {
431
+				unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
432
+				$deleted = true;
433
+			}
434
+
435
+			// clean up empty arrays
436
+			if (0 == count($this->_expected_errors[$key])) {
437
+				unset($this->_expected_errors[$key]);
438
+			}
439
+		}
440
+		return $deleted;
441
+	}
442
+
443
+	// }}}
444
+	// {{{ delExpect()
445
+
446
+	/**
447
+	 * This method deletes all occurences of the specified element from
448
+	 * the expected error codes stack.
449
+	 *
450
+	 * @param  mixed $error_code error code that should be deleted
451
+	 * @return mixed list of error codes that were deleted or error
452
+	 * @access public
453
+	 * @since PHP 4.3.0
454
+	 */
455
+	function delExpect($error_code)
456
+	{
457
+		$deleted = false;
458
+
459
+		if ((is_array($error_code) && (0 != count($error_code)))) {
460
+			// $error_code is a non-empty array here;
461
+			// we walk through it trying to unset all
462
+			// values
463
+			foreach($error_code as $key => $error) {
464
+				if ($this->_checkDelExpect($error)) {
465
+					$deleted =  true;
466
+				} else {
467
+					$deleted = false;
468
+				}
469
+			}
470
+			return $deleted ? true : references_PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
471
+		} elseif (!empty($error_code)) {
472
+			// $error_code comes alone, trying to unset it
473
+			if ($this->_checkDelExpect($error_code)) {
474
+				return true;
475
+			} else {
476
+				return references_PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
477
+			}
478
+		} else {
479
+			// $error_code is empty
480
+			return references_PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
481
+		}
482
+	}
483
+
484
+	// }}}
485
+	// {{{ raiseError()
486
+
487
+	/**
488
+	 * This method is a wrapper that returns an instance of the
489
+	 * configured error class with this object's default error
490
+	 * handling applied.  If the $mode and $options parameters are not
491
+	 * specified, the object's defaults are used.
492
+	 *
493
+	 * @param mixed $message a text error message or a PEAR error object
494
+	 *
495
+	 * @param int $code      a numeric error code (it is up to your class
496
+	 *                  to define these if you want to use codes)
497
+	 *
498
+	 * @param int $mode      One of references_PEAR_ERROR_RETURN, references_PEAR_ERROR_PRINT,
499
+	 *                  references_PEAR_ERROR_TRIGGER, references_PEAR_ERROR_DIE,
500
+	 *                  references_PEAR_ERROR_CALLBACK, references_PEAR_ERROR_EXCEPTION.
501
+	 *
502
+	 * @param mixed $options If $mode is references_PEAR_ERROR_TRIGGER, this parameter
503
+	 *                  specifies the PHP-internal error level (one of
504
+	 *                  E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
505
+	 *                  If $mode is references_PEAR_ERROR_CALLBACK, this
506
+	 *                  parameter specifies the callback function or
507
+	 *                  method.  In other error modes this parameter
508
+	 *                  is ignored.
509
+	 *
510
+	 * @param string $userinfo If you need to pass along for example debug
511
+	 *                  information, this parameter is meant for that.
512
+	 *
513
+	 * @param string $error_class The returned error object will be
514
+	 *                  instantiated from this class, if specified.
515
+	 *
516
+	 * @param bool $skipmsg If true, raiseError will only pass error codes,
517
+	 *                  the error message parameter will be dropped.
518
+	 *
519
+	 * @access public
520
+	 * @return object   a PEAR error object
521
+	 * @see references_PEAR::setErrorHandling
522
+	 * @since PHP 4.0.5
523
+	 */
524
+	function &raiseError($message = null,
525
+						 $code = null,
526
+						 $mode = null,
527
+						 $options = null,
528
+						 $userinfo = null,
529
+						 $error_class = null,
530
+						 $skipmsg = false)
531
+	{
532
+		// The error is yet a PEAR error object
533
+		if (is_object($message)) {
534
+			$code        = $message->getCode();
535
+			$userinfo    = $message->getUserInfo();
536
+			$error_class = $message->getType();
537
+			$message->error_message_prefix = '';
538
+			$message     = $message->getMessage();
539
+		}
540
+
541
+		if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
542
+			if ($exp[0] == "*" ||
543
+				(is_int(reset($exp)) && in_array($code, $exp)) ||
544
+				(is_string(reset($exp)) && in_array($message, $exp))) {
545
+				$mode = references_PEAR_ERROR_RETURN;
546
+			}
547
+		}
548
+		// No mode given, try global ones
549
+		if ($mode === null) {
550
+			// Class error handler
551
+			if (isset($this) && isset($this->_default_error_mode)) {
552
+				$mode    = $this->_default_error_mode;
553
+				$options = $this->_default_error_options;
554
+			// Global error handler
555
+			} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
556
+				$mode    = $GLOBALS['_PEAR_default_error_mode'];
557
+				$options = $GLOBALS['_PEAR_default_error_options'];
558
+			}
559
+		}
560
+
561
+		if ($error_class !== null) {
562
+			$ec = $error_class;
563
+		} elseif (isset($this) && isset($this->_error_class)) {
564
+			$ec = $this->_error_class;
565
+		} else {
566
+			$ec = 'references_PEAR_Error';
567
+		}
568
+		if ($skipmsg) {
569
+			$a = new $ec($code, $mode, $options, $userinfo);
570
+			return $a;
571
+		} else {
572
+			$a = new $ec($message, $code, $mode, $options, $userinfo);
573
+			return $a;
574
+		}
575
+	}
576
+
577
+	// }}}
578
+	// {{{ throwError()
579
+
580
+	/**
581
+	 * Simpler form of raiseError with fewer options.  In most cases
582
+	 * message, code and userinfo are enough.
583
+	 *
584
+	 * @param string $message
585
+	 *
586
+	 */
587
+	function &throwError($message = null,
588
+						 $code = null,
589
+						 $userinfo = null)
590
+	{
591
+		if (isset($this) && is_a($this, 'PEAR')) {
592
+			$a = &$this->raiseError($message, $code, null, null, $userinfo);
593
+			return $a;
594
+		} else {
595
+			$a = &references_PEAR::raiseError($message, $code, null, null, $userinfo);
596
+			return $a;
597
+		}
598
+	}
599
+
600
+	// }}}
601
+	function staticPushErrorHandling($mode, $options = null)
602
+	{
603
+		$stack = &$GLOBALS['_PEAR_error_handler_stack'];
604
+		$def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
605
+		$def_options = &$GLOBALS['_PEAR_default_error_options'];
606
+		$stack[] = array($def_mode, $def_options);
607
+		switch ($mode) {
608
+			case references_PEAR_ERROR_EXCEPTION:
609
+			case references_PEAR_ERROR_RETURN:
610
+			case references_PEAR_ERROR_PRINT:
611
+			case references_PEAR_ERROR_TRIGGER:
612
+			case references_PEAR_ERROR_DIE:
613
+			case null:
614
+				$def_mode = $mode;
615
+				$def_options = $options;
616
+				break;
617
+
618
+			case references_PEAR_ERROR_CALLBACK:
619
+				$def_mode = $mode;
620
+				// class/object method callback
621
+				if (is_callable($options)) {
622
+					$def_options = $options;
623
+				} else {
624
+					trigger_error("invalid error callback", E_USER_WARNING);
625
+				}
626
+				break;
627
+
628
+			default:
629
+				trigger_error("invalid error mode", E_USER_WARNING);
630
+				break;
631
+		}
632
+		$stack[] = array($mode, $options);
633
+		return true;
634
+	}
635
+
636
+	function staticPopErrorHandling()
637
+	{
638
+		$stack = &$GLOBALS['_PEAR_error_handler_stack'];
639
+		$setmode     = &$GLOBALS['_PEAR_default_error_mode'];
640
+		$setoptions  = &$GLOBALS['_PEAR_default_error_options'];
641
+		array_pop($stack);
642
+		list($mode, $options) = $stack[sizeof($stack) - 1];
643
+		array_pop($stack);
644
+		switch ($mode) {
645
+			case references_PEAR_ERROR_EXCEPTION:
646
+			case references_PEAR_ERROR_RETURN:
647
+			case references_PEAR_ERROR_PRINT:
648
+			case references_PEAR_ERROR_TRIGGER:
649
+			case references_PEAR_ERROR_DIE:
650
+			case null:
651
+				$setmode = $mode;
652
+				$setoptions = $options;
653
+				break;
654
+
655
+			case references_PEAR_ERROR_CALLBACK:
656
+				$setmode = $mode;
657
+				// class/object method callback
658
+				if (is_callable($options)) {
659
+					$setoptions = $options;
660
+				} else {
661
+					trigger_error("invalid error callback", E_USER_WARNING);
662
+				}
663
+				break;
664
+
665
+			default:
666
+				trigger_error("invalid error mode", E_USER_WARNING);
667
+				break;
668
+		}
669
+		return true;
670
+	}
671
+
672
+	// {{{ pushErrorHandling()
673
+
674
+	/**
675
+	 * Push a new error handler on top of the error handler options stack. With this
676
+	 * you can easily override the actual error handler for some code and restore
677
+	 * it later with popErrorHandling.
678
+	 *
679
+	 * @param mixed $mode (same as setErrorHandling)
680
+	 * @param mixed $options (same as setErrorHandling)
681
+	 *
682
+	 * @return bool Always true
683
+	 *
684
+	 * @see references_PEAR::setErrorHandling
685
+	 */
686
+	function pushErrorHandling($mode, $options = null)
687
+	{
688
+		$stack = &$GLOBALS['_PEAR_error_handler_stack'];
689
+		if (isset($this) && is_a($this, 'PEAR')) {
690
+			$def_mode    = &$this->_default_error_mode;
691
+			$def_options = &$this->_default_error_options;
692
+		} else {
693
+			$def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
694
+			$def_options = &$GLOBALS['_PEAR_default_error_options'];
695
+		}
696
+		$stack[] = array($def_mode, $def_options);
697
+
698
+		if (isset($this) && is_a($this, 'PEAR')) {
699
+			$this->setErrorHandling($mode, $options);
700
+		} else {
701
+			references_PEAR::setErrorHandling($mode, $options);
702
+		}
703
+		$stack[] = array($mode, $options);
704
+		return true;
705
+	}
706
+
707
+	// }}}
708
+	// {{{ popErrorHandling()
709
+
710
+	/**
711
+	 * Pop the last error handler used
712
+	 *
713
+	 * @return bool Always true
714
+	 *
715
+	 * @see references_PEAR::pushErrorHandling
716
+	 */
717
+	function popErrorHandling()
718
+	{
719
+		$stack = &$GLOBALS['_PEAR_error_handler_stack'];
720
+		array_pop($stack);
721
+		list($mode, $options) = $stack[sizeof($stack) - 1];
722
+		array_pop($stack);
723
+		if (isset($this) && is_a($this, 'PEAR')) {
724
+			$this->setErrorHandling($mode, $options);
725
+		} else {
726
+			references_PEAR::setErrorHandling($mode, $options);
727
+		}
728
+		return true;
729
+	}
730
+
731
+	// }}}
732
+	// {{{ loadExtension()
733
+
734
+	/**
735
+	 * OS independant PHP extension load. Remember to take care
736
+	 * on the correct extension name for case sensitive OSes.
737
+	 *
738
+	 * @param string $ext The extension name
739
+	 * @return bool Success or not on the dl() call
740
+	 */
741
+	function loadExtension($ext)
742
+	{
743
+		if (!extension_loaded($ext)) {
744
+			// if either returns true dl() will produce a FATAL error, stop that
745
+			if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
746
+				return false;
747
+			}
748
+			if (references_OS_WINDOWS) {
749
+				$suffix = '.dll';
750
+			} elseif (PHP_OS == 'HP-UX') {
751
+				$suffix = '.sl';
752
+			} elseif (PHP_OS == 'AIX') {
753
+				$suffix = '.a';
754
+			} elseif (PHP_OS == 'OSX') {
755
+				$suffix = '.bundle';
756
+			} else {
757
+				$suffix = '.so';
758
+			}
759
+			return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
760
+		}
761
+		return true;
762
+	}
763
+
764
+	// }}}
765 765
 }
766 766
 
767 767
 // {{{ _PEAR_call_destructors()
768 768
 
769 769
 function references_PEAR_call_destructors()
770 770
 {
771
-    global $_PEAR_destructor_object_list;
772
-    if (is_array($_PEAR_destructor_object_list) &&
773
-        sizeof($_PEAR_destructor_object_list))
774
-    {
775
-        reset($_PEAR_destructor_object_list);
776
-        if (references_PEAR::getStaticProperty('PEAR', 'destructlifo')) {
777
-            $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
778
-        }
779
-        while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
780
-            $classname = get_class($objref);
781
-            while ($classname) {
782
-                $destructor = "_$classname";
783
-                if (method_exists($objref, $destructor)) {
784
-                    $objref->$destructor();
785
-                    break;
786
-                } else {
787
-                    $classname = get_parent_class($classname);
788
-                }
789
-            }
790
-        }
791
-        // Empty the object list to ensure that destructors are
792
-        // not called more than once.
793
-        $_PEAR_destructor_object_list = array();
794
-    }
795
-
796
-    // Now call the shutdown functions
797
-    if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
798
-        foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
799
-            call_user_func_array($value[0], $value[1]);
800
-        }
801
-    }
771
+	global $_PEAR_destructor_object_list;
772
+	if (is_array($_PEAR_destructor_object_list) &&
773
+		sizeof($_PEAR_destructor_object_list))
774
+	{
775
+		reset($_PEAR_destructor_object_list);
776
+		if (references_PEAR::getStaticProperty('PEAR', 'destructlifo')) {
777
+			$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
778
+		}
779
+		while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
780
+			$classname = get_class($objref);
781
+			while ($classname) {
782
+				$destructor = "_$classname";
783
+				if (method_exists($objref, $destructor)) {
784
+					$objref->$destructor();
785
+					break;
786
+				} else {
787
+					$classname = get_parent_class($classname);
788
+				}
789
+			}
790
+		}
791
+		// Empty the object list to ensure that destructors are
792
+		// not called more than once.
793
+		$_PEAR_destructor_object_list = array();
794
+	}
795
+
796
+	// Now call the shutdown functions
797
+	if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
798
+		foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
799
+			call_user_func_array($value[0], $value[1]);
800
+		}
801
+	}
802 802
 }
803 803
 
804 804
 // }}}
@@ -821,281 +821,281 @@  discard block
 block discarded – undo
821 821
  */
822 822
 class references_PEAR_Error
823 823
 {
824
-    // {{{ properties
825
-
826
-    public $error_message_prefix = '';
827
-    public $mode                 = references_PEAR_ERROR_RETURN;
828
-    public $level                = E_USER_NOTICE;
829
-    public $code                 = -1;
830
-    public $message              = '';
831
-    public $userinfo             = '';
832
-    public $backtrace            = null;
833
-
834
-    // }}}
835
-    // {{{ constructor
836
-
837
-    /**
838
-     * PEAR_Error constructor
839
-     *
840
-     * @param string $message  message
841
-     *
842
-     * @param int $code     (optional) error code
843
-     *
844
-     * @param int $mode     (optional) error mode, one of: references_PEAR_ERROR_RETURN,
845
-     * references_PEAR_ERROR_PRINT, references_PEAR_ERROR_DIE, references_PEAR_ERROR_TRIGGER,
846
-     * references_PEAR_ERROR_CALLBACK or references_PEAR_ERROR_EXCEPTION
847
-     *
848
-     * @param mixed $options   (optional) error level, _OR_ in the case of
849
-     * references_PEAR_ERROR_CALLBACK, the callback function or object/method
850
-     * tuple.
851
-     *
852
-     * @param string $userinfo (optional) additional user/debug info
853
-     *
854
-     * @access public
855
-     *
856
-     */
857
-    function __construct($message = 'unknown error', $code = null,
858
-                        $mode = null, $options = null, $userinfo = null)
859
-    {
860
-        if ($mode === null) {
861
-            $mode = references_PEAR_ERROR_RETURN;
862
-        }
863
-        $this->message   = $message;
864
-        $this->code      = $code;
865
-        $this->mode      = $mode;
866
-        $this->userinfo  = $userinfo;
867
-        if (!references_PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
868
-            $this->backtrace = debug_backtrace();
869
-            if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
870
-                unset($this->backtrace[0]['object']);
871
-            }
872
-        }
873
-        if ($mode & references_PEAR_ERROR_CALLBACK) {
874
-            $this->level = E_USER_NOTICE;
875
-            $this->callback = $options;
876
-        } else {
877
-            if ($options === null) {
878
-                $options = E_USER_NOTICE;
879
-            }
880
-            $this->level = $options;
881
-            $this->callback = null;
882
-        }
883
-        if ($this->mode & references_PEAR_ERROR_PRINT) {
884
-            if (is_null($options) || is_int($options)) {
885
-                $format = "%s";
886
-            } else {
887
-                $format = $options;
888
-            }
889
-            printf($format, $this->getMessage());
890
-        }
891
-        if ($this->mode & references_PEAR_ERROR_TRIGGER) {
892
-            trigger_error($this->getMessage(), $this->level);
893
-        }
894
-        if ($this->mode & references_PEAR_ERROR_DIE) {
895
-            $msg = $this->getMessage();
896
-            if (is_null($options) || is_int($options)) {
897
-                $format = "%s";
898
-                if (substr($msg, -1) != "\n") {
899
-                    $msg .= "\n";
900
-                }
901
-            } else {
902
-                $format = $options;
903
-            }
904
-            die(sprintf($format, $msg));
905
-        }
906
-        if ($this->mode & references_PEAR_ERROR_CALLBACK) {
907
-            if (is_callable($this->callback)) {
908
-                call_user_func($this->callback, $this);
909
-            }
910
-        }
911
-        if ($this->mode & references_PEAR_ERROR_EXCEPTION) {
912
-            trigger_error("references_PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
913
-            eval('$e = new Exception($this->message, $this->code);throw($e);');
914
-        }
915
-    }
916
-
917
-    // }}}
918
-    // {{{ getMode()
919
-
920
-    /**
921
-     * Get the error mode from an error object.
922
-     *
923
-     * @return int error mode
924
-     * @access public
925
-     */
926
-    function getMode() {
927
-        return $this->mode;
928
-    }
929
-
930
-    // }}}
931
-    // {{{ getCallback()
932
-
933
-    /**
934
-     * Get the callback function/method from an error object.
935
-     *
936
-     * @return mixed callback function or object/method array
937
-     * @access public
938
-     */
939
-    function getCallback() {
940
-        return $this->callback;
941
-    }
942
-
943
-    // }}}
944
-    // {{{ getMessage()
945
-
946
-
947
-    /**
948
-     * Get the error message from an error object.
949
-     *
950
-     * @return  string  full error message
951
-     * @access public
952
-     */
953
-    function getMessage()
954
-    {
955
-        return ($this->error_message_prefix . $this->message);
956
-    }
957
-
958
-
959
-    // }}}
960
-    // {{{ getCode()
961
-
962
-    /**
963
-     * Get error code from an error object
964
-     *
965
-     * @return int error code
966
-     * @access public
967
-     */
968
-     function getCode()
969
-     {
970
-        return $this->code;
971
-     }
972
-
973
-    // }}}
974
-    // {{{ getType()
975
-
976
-    /**
977
-     * Get the name of this error/exception.
978
-     *
979
-     * @return string error/exception name (type)
980
-     * @access public
981
-     */
982
-    function getType()
983
-    {
984
-        return get_class($this);
985
-    }
986
-
987
-    // }}}
988
-    // {{{ getUserInfo()
989
-
990
-    /**
991
-     * Get additional user-supplied information.
992
-     *
993
-     * @return string user-supplied information
994
-     * @access public
995
-     */
996
-    function getUserInfo()
997
-    {
998
-        return $this->userinfo;
999
-    }
1000
-
1001
-    // }}}
1002
-    // {{{ getDebugInfo()
1003
-
1004
-    /**
1005
-     * Get additional debug information supplied by the application.
1006
-     *
1007
-     * @return string debug information
1008
-     * @access public
1009
-     */
1010
-    function getDebugInfo()
1011
-    {
1012
-        return $this->getUserInfo();
1013
-    }
1014
-
1015
-    // }}}
1016
-    // {{{ getBacktrace()
1017
-
1018
-    /**
1019
-     * Get the call backtrace from where the error was generated.
1020
-     * Supported with PHP 4.3.0 or newer.
1021
-     *
1022
-     * @param int $frame (optional) what frame to fetch
1023
-     * @return array Backtrace, or NULL if not available.
1024
-     * @access public
1025
-     */
1026
-    function getBacktrace($frame = null)
1027
-    {
1028
-        if (defined('PEAR_IGNORE_BACKTRACE')) {
1029
-            return null;
1030
-        }
1031
-        if ($frame === null) {
1032
-            return $this->backtrace;
1033
-        }
1034
-        return $this->backtrace[$frame];
1035
-    }
1036
-
1037
-    // }}}
1038
-    // {{{ addUserInfo()
1039
-
1040
-    function addUserInfo($info)
1041
-    {
1042
-        if (empty($this->userinfo)) {
1043
-            $this->userinfo = $info;
1044
-        } else {
1045
-            $this->userinfo .= " ** $info";
1046
-        }
1047
-    }
1048
-
1049
-    // }}}
1050
-    // {{{ toString()
1051
-
1052
-    /**
1053
-     * Make a string representation of this object.
1054
-     *
1055
-     * @return string a string with an object summary
1056
-     * @access public
1057
-     */
1058
-    function toString() {
1059
-        $modes = array();
1060
-        $levels = array(E_USER_NOTICE  => 'notice',
1061
-                        E_USER_WARNING => 'warning',
1062
-                        E_USER_ERROR   => 'error');
1063
-        if ($this->mode & references_PEAR_ERROR_CALLBACK) {
1064
-            if (is_array($this->callback)) {
1065
-                $callback = (is_object($this->callback[0]) ?
1066
-                    strtolower(get_class($this->callback[0])) :
1067
-                    $this->callback[0]) . '::' .
1068
-                    $this->callback[1];
1069
-            } else {
1070
-                $callback = $this->callback;
1071
-            }
1072
-            return sprintf('[%s: message="%s" code=%d mode=callback '.
1073
-                           'callback=%s prefix="%s" info="%s"]',
1074
-                           strtolower(get_class($this)), $this->message, $this->code,
1075
-                           $callback, $this->error_message_prefix,
1076
-                           $this->userinfo);
1077
-        }
1078
-        if ($this->mode & references_PEAR_ERROR_PRINT) {
1079
-            $modes[] = 'print';
1080
-        }
1081
-        if ($this->mode & references_PEAR_ERROR_TRIGGER) {
1082
-            $modes[] = 'trigger';
1083
-        }
1084
-        if ($this->mode & references_PEAR_ERROR_DIE) {
1085
-            $modes[] = 'die';
1086
-        }
1087
-        if ($this->mode & references_PEAR_ERROR_RETURN) {
1088
-            $modes[] = 'return';
1089
-        }
1090
-        return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
1091
-                       'prefix="%s" info="%s"]',
1092
-                       strtolower(get_class($this)), $this->message, $this->code,
1093
-                       implode("|", $modes), $levels[$this->level],
1094
-                       $this->error_message_prefix,
1095
-                       $this->userinfo);
1096
-    }
1097
-
1098
-    // }}}
824
+	// {{{ properties
825
+
826
+	public $error_message_prefix = '';
827
+	public $mode                 = references_PEAR_ERROR_RETURN;
828
+	public $level                = E_USER_NOTICE;
829
+	public $code                 = -1;
830
+	public $message              = '';
831
+	public $userinfo             = '';
832
+	public $backtrace            = null;
833
+
834
+	// }}}
835
+	// {{{ constructor
836
+
837
+	/**
838
+	 * PEAR_Error constructor
839
+	 *
840
+	 * @param string $message  message
841
+	 *
842
+	 * @param int $code     (optional) error code
843
+	 *
844
+	 * @param int $mode     (optional) error mode, one of: references_PEAR_ERROR_RETURN,
845
+	 * references_PEAR_ERROR_PRINT, references_PEAR_ERROR_DIE, references_PEAR_ERROR_TRIGGER,
846
+	 * references_PEAR_ERROR_CALLBACK or references_PEAR_ERROR_EXCEPTION
847
+	 *
848
+	 * @param mixed $options   (optional) error level, _OR_ in the case of
849
+	 * references_PEAR_ERROR_CALLBACK, the callback function or object/method
850
+	 * tuple.
851
+	 *
852
+	 * @param string $userinfo (optional) additional user/debug info
853
+	 *
854
+	 * @access public
855
+	 *
856
+	 */
857
+	function __construct($message = 'unknown error', $code = null,
858
+						$mode = null, $options = null, $userinfo = null)
859
+	{
860
+		if ($mode === null) {
861
+			$mode = references_PEAR_ERROR_RETURN;
862
+		}
863
+		$this->message   = $message;
864
+		$this->code      = $code;
865
+		$this->mode      = $mode;
866
+		$this->userinfo  = $userinfo;
867
+		if (!references_PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
868
+			$this->backtrace = debug_backtrace();
869
+			if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
870
+				unset($this->backtrace[0]['object']);
871
+			}
872
+		}
873
+		if ($mode & references_PEAR_ERROR_CALLBACK) {
874
+			$this->level = E_USER_NOTICE;
875
+			$this->callback = $options;
876
+		} else {
877
+			if ($options === null) {
878
+				$options = E_USER_NOTICE;
879
+			}
880
+			$this->level = $options;
881
+			$this->callback = null;
882
+		}
883
+		if ($this->mode & references_PEAR_ERROR_PRINT) {
884
+			if (is_null($options) || is_int($options)) {
885
+				$format = "%s";
886
+			} else {
887
+				$format = $options;
888
+			}
889
+			printf($format, $this->getMessage());
890
+		}
891
+		if ($this->mode & references_PEAR_ERROR_TRIGGER) {
892
+			trigger_error($this->getMessage(), $this->level);
893
+		}
894
+		if ($this->mode & references_PEAR_ERROR_DIE) {
895
+			$msg = $this->getMessage();
896
+			if (is_null($options) || is_int($options)) {
897
+				$format = "%s";
898
+				if (substr($msg, -1) != "\n") {
899
+					$msg .= "\n";
900
+				}
901
+			} else {
902
+				$format = $options;
903
+			}
904
+			die(sprintf($format, $msg));
905
+		}
906
+		if ($this->mode & references_PEAR_ERROR_CALLBACK) {
907
+			if (is_callable($this->callback)) {
908
+				call_user_func($this->callback, $this);
909
+			}
910
+		}
911
+		if ($this->mode & references_PEAR_ERROR_EXCEPTION) {
912
+			trigger_error("references_PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
913
+			eval('$e = new Exception($this->message, $this->code);throw($e);');
914
+		}
915
+	}
916
+
917
+	// }}}
918
+	// {{{ getMode()
919
+
920
+	/**
921
+	 * Get the error mode from an error object.
922
+	 *
923
+	 * @return int error mode
924
+	 * @access public
925
+	 */
926
+	function getMode() {
927
+		return $this->mode;
928
+	}
929
+
930
+	// }}}
931
+	// {{{ getCallback()
932
+
933
+	/**
934
+	 * Get the callback function/method from an error object.
935
+	 *
936
+	 * @return mixed callback function or object/method array
937
+	 * @access public
938
+	 */
939
+	function getCallback() {
940
+		return $this->callback;
941
+	}
942
+
943
+	// }}}
944
+	// {{{ getMessage()
945
+
946
+
947
+	/**
948
+	 * Get the error message from an error object.
949
+	 *
950
+	 * @return  string  full error message
951
+	 * @access public
952
+	 */
953
+	function getMessage()
954
+	{
955
+		return ($this->error_message_prefix . $this->message);
956
+	}
957
+
958
+
959
+	// }}}
960
+	// {{{ getCode()
961
+
962
+	/**
963
+	 * Get error code from an error object
964
+	 *
965
+	 * @return int error code
966
+	 * @access public
967
+	 */
968
+	 function getCode()
969
+	 {
970
+		return $this->code;
971
+	 }
972
+
973
+	// }}}
974
+	// {{{ getType()
975
+
976
+	/**
977
+	 * Get the name of this error/exception.
978
+	 *
979
+	 * @return string error/exception name (type)
980
+	 * @access public
981
+	 */
982
+	function getType()
983
+	{
984
+		return get_class($this);
985
+	}
986
+
987
+	// }}}
988
+	// {{{ getUserInfo()
989
+
990
+	/**
991
+	 * Get additional user-supplied information.
992
+	 *
993
+	 * @return string user-supplied information
994
+	 * @access public
995
+	 */
996
+	function getUserInfo()
997
+	{
998
+		return $this->userinfo;
999
+	}
1000
+
1001
+	// }}}
1002
+	// {{{ getDebugInfo()
1003
+
1004
+	/**
1005
+	 * Get additional debug information supplied by the application.
1006
+	 *
1007
+	 * @return string debug information
1008
+	 * @access public
1009
+	 */
1010
+	function getDebugInfo()
1011
+	{
1012
+		return $this->getUserInfo();
1013
+	}
1014
+
1015
+	// }}}
1016
+	// {{{ getBacktrace()
1017
+
1018
+	/**
1019
+	 * Get the call backtrace from where the error was generated.
1020
+	 * Supported with PHP 4.3.0 or newer.
1021
+	 *
1022
+	 * @param int $frame (optional) what frame to fetch
1023
+	 * @return array Backtrace, or NULL if not available.
1024
+	 * @access public
1025
+	 */
1026
+	function getBacktrace($frame = null)
1027
+	{
1028
+		if (defined('PEAR_IGNORE_BACKTRACE')) {
1029
+			return null;
1030
+		}
1031
+		if ($frame === null) {
1032
+			return $this->backtrace;
1033
+		}
1034
+		return $this->backtrace[$frame];
1035
+	}
1036
+
1037
+	// }}}
1038
+	// {{{ addUserInfo()
1039
+
1040
+	function addUserInfo($info)
1041
+	{
1042
+		if (empty($this->userinfo)) {
1043
+			$this->userinfo = $info;
1044
+		} else {
1045
+			$this->userinfo .= " ** $info";
1046
+		}
1047
+	}
1048
+
1049
+	// }}}
1050
+	// {{{ toString()
1051
+
1052
+	/**
1053
+	 * Make a string representation of this object.
1054
+	 *
1055
+	 * @return string a string with an object summary
1056
+	 * @access public
1057
+	 */
1058
+	function toString() {
1059
+		$modes = array();
1060
+		$levels = array(E_USER_NOTICE  => 'notice',
1061
+						E_USER_WARNING => 'warning',
1062
+						E_USER_ERROR   => 'error');
1063
+		if ($this->mode & references_PEAR_ERROR_CALLBACK) {
1064
+			if (is_array($this->callback)) {
1065
+				$callback = (is_object($this->callback[0]) ?
1066
+					strtolower(get_class($this->callback[0])) :
1067
+					$this->callback[0]) . '::' .
1068
+					$this->callback[1];
1069
+			} else {
1070
+				$callback = $this->callback;
1071
+			}
1072
+			return sprintf('[%s: message="%s" code=%d mode=callback '.
1073
+						   'callback=%s prefix="%s" info="%s"]',
1074
+						   strtolower(get_class($this)), $this->message, $this->code,
1075
+						   $callback, $this->error_message_prefix,
1076
+						   $this->userinfo);
1077
+		}
1078
+		if ($this->mode & references_PEAR_ERROR_PRINT) {
1079
+			$modes[] = 'print';
1080
+		}
1081
+		if ($this->mode & references_PEAR_ERROR_TRIGGER) {
1082
+			$modes[] = 'trigger';
1083
+		}
1084
+		if ($this->mode & references_PEAR_ERROR_DIE) {
1085
+			$modes[] = 'die';
1086
+		}
1087
+		if ($this->mode & references_PEAR_ERROR_RETURN) {
1088
+			$modes[] = 'return';
1089
+		}
1090
+		return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
1091
+					   'prefix="%s" info="%s"]',
1092
+					   strtolower(get_class($this)), $this->message, $this->code,
1093
+					   implode("|", $modes), $levels[$this->level],
1094
+					   $this->error_message_prefix,
1095
+					   $this->userinfo);
1096
+	}
1097
+
1098
+	// }}}
1099 1099
 }
1100 1100
 
1101 1101
 /*
Please login to merge, or discard this patch.
class/lite.php 1 patch
Indentation   +791 added lines, -791 removed lines patch added patch discarded remove patch
@@ -29,798 +29,798 @@
 block discarded – undo
29 29
 class references_Cache_Lite
30 30
 {
31 31
 
32
-    // --- Private properties ---
33
-
34
-    /**
35
-    * Directory where to put the cache files
36
-    * (make sure to add a trailing slash)
37
-    *
38
-    * @var string $_cacheDir
39
-    */
40
-    public $_cacheDir = '/tmp/';
41
-
42
-    /**
43
-    * Enable / disable caching
44
-    *
45
-    * (can be very usefull for the debug of cached scripts)
46
-    *
47
-    * @var boolean $_caching
48
-    */
49
-    public $_caching = true;
50
-
51
-    /**
52
-    * Cache lifetime (in seconds)
53
-    *
54
-    * If null, the cache is valid forever.
55
-    *
56
-    * @var int $_lifeTime
57
-    */
58
-    public $_lifeTime = 3600;
59
-
60
-    /**
61
-    * Enable / disable fileLocking
62
-    *
63
-    * (can avoid cache corruption under bad circumstances)
64
-    *
65
-    * @var boolean $_fileLocking
66
-    */
67
-    public $_fileLocking = true;
68
-
69
-    /**
70
-    * Timestamp of the last valid cache
71
-    *
72
-    * @var int $_refreshTime
73
-    */
74
-    public $_refreshTime;
75
-
76
-    /**
77
-    * File name (with path)
78
-    *
79
-    * @var string $_file
80
-    */
81
-    public $_file;
82
-
83
-    /**
84
-    * File name (without path)
85
-    *
86
-    * @var string $_fileName
87
-    */
88
-    public $_fileName;
89
-
90
-    /**
91
-    * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
92
-    *
93
-    * Enable write control will lightly slow the cache writing but not the cache reading
94
-    * Write control can detect some corrupt cache files but maybe it's not a perfect control
95
-    *
96
-    * @var boolean $_writeControl
97
-    */
98
-    public $_writeControl = true;
99
-
100
-    /**
101
-    * Enable / disable read control
102
-    *
103
-    * If enabled, a control key is embeded in cache file and this key is compared with the one
104
-    * calculated after the reading.
105
-    *
106
-    * @var boolean $_writeControl
107
-    */
108
-    public $_readControl = true;
109
-
110
-    /**
111
-    * Type of read control (only if read control is enabled)
112
-    *
113
-    * Available values are :
114
-    * 'md5' for a md5 hash control (best but slowest)
115
-    * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
116
-    * 'strlen' for a length only test (fastest)
117
-    *
118
-    * @var boolean $_readControlType
119
-    */
120
-    public $_readControlType = 'crc32';
121
-
122
-    /**
123
-    * Pear error mode (when raiseError is called)
124
-    *
125
-    * (see PEAR doc)
126
-    *
127
-    * @see setToDebug()
128
-    * @var int $_pearErrorMode
129
-    */
130
-    public $_pearErrorMode = REFERENCES_CACHE_LITE_ERROR_RETURN;
131
-
132
-    /**
133
-    * Current cache id
134
-    *
135
-    * @var string $_id
136
-    */
137
-    public $_id;
138
-
139
-    /**
140
-    * Current cache group
141
-    *
142
-    * @var string $_group
143
-    */
144
-    public $_group;
145
-
146
-    /**
147
-    * Enable / Disable "Memory Caching"
148
-    *
149
-    * NB : There is no lifetime for memory caching !
150
-    *
151
-    * @var boolean $_memoryCaching
152
-    */
153
-    public $_memoryCaching = false;
154
-
155
-    /**
156
-    * Enable / Disable "Only Memory Caching"
157
-    * (be carefull, memory caching is "beta quality")
158
-    *
159
-    * @var boolean $_onlyMemoryCaching
160
-    */
161
-    public $_onlyMemoryCaching = false;
162
-
163
-    /**
164
-    * Memory caching array
165
-    *
166
-    * @var array $_memoryCachingArray
167
-    */
168
-    public $_memoryCachingArray = array();
169
-
170
-    /**
171
-    * Memory caching counter
172
-    *
173
-    * @var int $memoryCachingCounter
174
-    */
175
-    public $_memoryCachingCounter = 0;
176
-
177
-    /**
178
-    * Memory caching limit
179
-    *
180
-    * @var int $memoryCachingLimit
181
-    */
182
-    public $_memoryCachingLimit = 1000;
183
-
184
-    /**
185
-    * File Name protection
186
-    *
187
-    * if set to true, you can use any cache id or group name
188
-    * if set to false, it can be faster but cache ids and group names
189
-    * will be used directly in cache file names so be carefull with
190
-    * special characters...
191
-    *
192
-    * @var boolean $fileNameProtection
193
-    */
194
-    public $_fileNameProtection = true;
195
-
196
-    /**
197
-    * Enable / disable automatic serialization
198
-    *
199
-    * it can be used to save directly datas which aren't strings
200
-    * (but it's slower)
201
-    *
202
-    * @var boolean $_serialize
203
-    */
204
-    public $_automaticSerialization = false;
205
-
206
-    /**
207
-    * Disable / Tune the automatic cleaning process
208
-    *
209
-    * The automatic cleaning process destroy too old (for the given life time)
210
-    * cache files when a new cache file is written.
211
-    * 0               => no automatic cache cleaning
212
-    * 1               => systematic cache cleaning
213
-    * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
214
-    *
215
-    * @var int $_automaticCleaning
216
-    */
217
-    public $_automaticCleaningFactor = 0;
218
-
219
-    /**
220
-    * Nested directory level
221
-    *
222
-    * Set the hashed directory structure level. 0 means "no hashed directory
223
-    * structure", 1 means "one level of directory", 2 means "two levels"...
224
-    * This option can speed up Cache_Lite only when you have many thousands of
225
-    * cache file. Only specific benchs can help you to choose the perfect value
226
-    * for you. Maybe, 1 or 2 is a good start.
227
-    *
228
-    * @var int $_hashedDirectoryLevel
229
-    */
230
-    public $_hashedDirectoryLevel = 0;
231
-
232
-    /**
233
-    * Umask for hashed directory structure
234
-    *
235
-    * @var int $_hashedDirectoryUmask
236
-    */
237
-    public $_hashedDirectoryUmask = 0700;
238
-
239
-    /**
240
-     * API break for error handling in REFERENCES_CACHE_LITE_ERROR_RETURN mode
241
-     *
242
-     * In REFERENCES_CACHE_LITE_ERROR_RETURN mode, error handling was not good because
243
-     * for example save() method always returned a boolean (a PEAR_Error object
244
-     * would be better in REFERENCES_CACHE_LITE_ERROR_RETURN mode). To correct this without
245
-     * breaking the API, this option (false by default) can change this handling.
246
-     *
247
-     * @var boolean
248
-     */
249
-    public $_errorHandlingAPIBreak = false;
250
-
251
-    // --- Public methods ---
252
-
253
-    /**
254
-    * Constructor
255
-    *
256
-    * $options is an assoc. Available options are :
257
-    * $options = array(
258
-    *     'cacheDir' => directory where to put the cache files (string),
259
-    *     'caching' => enable / disable caching (boolean),
260
-    *     'lifeTime' => cache lifetime in seconds (int),
261
-    *     'fileLocking' => enable / disable fileLocking (boolean),
262
-    *     'writeControl' => enable / disable write control (boolean),
263
-    *     'readControl' => enable / disable read control (boolean),
264
-    *     'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string),
265
-    *     'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int),
266
-    *     'memoryCaching' => enable / disable memory caching (boolean),
267
-    *     'onlyMemoryCaching' => enable / disable only memory caching (boolean),
268
-    *     'memoryCachingLimit' => max nbr of records to store into memory caching (int),
269
-    *     'fileNameProtection' => enable / disable automatic file name protection (boolean),
270
-    *     'automaticSerialization' => enable / disable automatic serialization (boolean),
271
-    *     'automaticCleaningFactor' => distable / tune automatic cleaning process (int),
272
-    *     'hashedDirectoryLevel' => level of the hashed directory system (int),
273
-    *     'hashedDirectoryUmask' => umask for hashed directory structure (int),
274
-    *     'errorHandlingAPIBreak' => API break for better error handling ? (boolean)
275
-    * );
276
-    *
277
-    * @param array $options options
278
-    * @access public
279
-    */
280
-    function __construct($options = array(NULL))
281
-    {
282
-        foreach($options as $key => $value) {
283
-            $this->setOption($key, $value);
284
-        }
285
-    }
286
-
287
-    /**
288
-    * Generic way to set a Cache_Lite option
289
-    *
290
-    * see Cache_Lite constructor for available options
291
-    *
292
-    * @var string $name name of the option
293
-    * @var mixed $value value of the option
294
-    * @access public
295
-    */
296
-    function setOption($name, $value)
297
-    {
298
-        $availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode');
299
-        if (in_array($name, $availableOptions)) {
300
-            $property = '_'.$name;
301
-            $this->$property = $value;
302
-        }
303
-    }
304
-
305
-    /**
306
-    * Test if a cache is available and (if yes) return it
307
-    *
308
-    * @param string $id cache id
309
-    * @param string $group name of the cache group
310
-    * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
311
-    * @return string data of the cache (else : false)
312
-    * @access public
313
-    */
314
-    function get($id, $group = 'default', $doNotTestCacheValidity = false)
315
-    {
316
-        $this->_id = $id;
317
-        $this->_group = $group;
318
-        $data = false;
319
-        if ($this->_caching) {
320
-            $this->_setRefreshTime();
321
-            $this->_setFileName($id, $group);
322
-            clearstatcache();
323
-            if ($this->_memoryCaching) {
324
-                if (isset($this->_memoryCachingArray[$this->_file])) {
325
-                    if ($this->_automaticSerialization) {
326
-                        return unserialize($this->_memoryCachingArray[$this->_file]);
327
-                    }
328
-                    return $this->_memoryCachingArray[$this->_file];
329
-                }
330
-                if ($this->_onlyMemoryCaching) {
331
-                    return false;
332
-                }
333
-            }
334
-            if (($doNotTestCacheValidity) || (is_null($this->_refreshTime))) {
335
-                if (file_exists($this->_file)) {
336
-                    $data = $this->_read();
337
-                }
338
-            } else {
339
-                if ((file_exists($this->_file)) && (@filemtime($this->_file) > $this->_refreshTime)) {
340
-                    $data = $this->_read();
341
-                }
342
-            }
343
-            if (($data) and ($this->_memoryCaching)) {
344
-                $this->_memoryCacheAdd($data);
345
-            }
346
-            if (($this->_automaticSerialization) and (is_string($data))) {
347
-                $data = unserialize($data);
348
-            }
349
-            return $data;
350
-        }
351
-        return false;
352
-    }
353
-
354
-    /**
355
-    * Save some data in a cache file
356
-    *
357
-    * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
358
-    * @param string $id cache id
359
-    * @param string $group name of the cache group
360
-    * @return boolean true if no problem (else : false or a PEAR_Error object)
361
-    * @access public
362
-    */
363
-    function save($data, $id = NULL, $group = 'default')
364
-    {
365
-        if ($this->_caching) {
366
-            if ($this->_automaticSerialization) {
367
-                $data = serialize($data);
368
-            }
369
-            if (isset($id)) {
370
-                $this->_setFileName($id, $group);
371
-            }
372
-            if ($this->_memoryCaching) {
373
-                $this->_memoryCacheAdd($data);
374
-                if ($this->_onlyMemoryCaching) {
375
-                    return true;
376
-                }
377
-            }
378
-            if ($this->_automaticCleaningFactor>0 && ($this->_automaticCleaningFactor==1 || mt_rand(1, $this->_automaticCleaningFactor)==1)) {
379
-                    $this->clean(false, 'old');
380
-                }
381
-            if ($this->_writeControl) {
382
-                $res = $this->_writeAndControl($data);
383
-                if (is_bool($res)) {
384
-                    if ($res) {
385
-                        return true;
386
-                    }
387
-                    // if $res if false, we need to invalidate the cache
388
-                    @touch($this->_file, time() - 2*abs($this->_lifeTime));
389
-                    return false;
390
-                }
391
-            } else {
392
-                $res = $this->_write($data);
393
-            }
394
-            if (is_object($res)) {
395
-	        	// $res is a PEAR_Error object
396
-                if (!($this->_errorHandlingAPIBreak)) {
397
-	                return false; // we return false (old API)
398
-	            }
399
-	        }
400
-            return $res;
401
-        }
402
-        return false;
403
-    }
404
-
405
-    /**
406
-    * Remove a cache file
407
-    *
408
-    * @param string $id cache id
409
-    * @param string $group name of the cache group
410
-    * @param boolean $checkbeforeunlink check if file exists before removing it
411
-    * @return boolean true if no problem
412
-    * @access public
413
-    */
414
-    function remove($id, $group = 'default', $checkbeforeunlink = false)
415
-    {
416
-        $this->_setFileName($id, $group);
417
-        if ($this->_memoryCaching) {
418
-            if (isset($this->_memoryCachingArray[$this->_file])) {
419
-                unset($this->_memoryCachingArray[$this->_file]);
420
-                $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
421
-            }
422
-            if ($this->_onlyMemoryCaching) {
423
-                return true;
424
-            }
425
-        }
426
-        if ( $checkbeforeunlink ) {
427
-            if (!file_exists($this->_file)) return true;
428
-        }
429
-        return $this->_unlink($this->_file);
430
-    }
431
-
432
-    /**
433
-    * Clean the cache
434
-    *
435
-    * if no group is specified all cache files will be destroyed
436
-    * else only cache files of the specified group will be destroyed
437
-    *
438
-    * @param string $group name of the cache group
439
-    * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
440
-    *                                        'callback_myFunction'
441
-    * @return boolean true if no problem
442
-    * @access public
443
-    */
444
-    function clean($group = false, $mode = 'ingroup')
445
-    {
446
-        return $this->_cleanDir($this->_cacheDir, $group, $mode);
447
-    }
448
-
449
-    /**
450
-    * Set to debug mode
451
-    *
452
-    * When an error is found, the script will stop and the message will be displayed
453
-    * (in debug mode only).
454
-    *
455
-    * @access public
456
-    */
457
-    function setToDebug()
458
-    {
459
-        $this->setOption('pearErrorMode', REFERENCES_CACHE_LITE_ERROR_DIE);
460
-    }
461
-
462
-    /**
463
-    * Set a new life time
464
-    *
465
-    * @param int $newLifeTime new life time (in seconds)
466
-    * @access public
467
-    */
468
-    function setLifeTime($newLifeTime)
469
-    {
470
-        $this->_lifeTime = $newLifeTime;
471
-        $this->_setRefreshTime();
472
-    }
473
-
474
-    /**
475
-    * Save the state of the caching memory array into a cache file cache
476
-    *
477
-    * @param string $id cache id
478
-    * @param string $group name of the cache group
479
-    * @access public
480
-    */
481
-    function saveMemoryCachingState($id, $group = 'default')
482
-    {
483
-        if ($this->_caching) {
484
-            $array = array(
485
-                'counter' => $this->_memoryCachingCounter,
486
-                'array' => $this->_memoryCachingArray
487
-            );
488
-            $data = serialize($array);
489
-            $this->save($data, $id, $group);
490
-        }
491
-    }
492
-
493
-    /**
494
-    * Load the state of the caching memory array from a given cache file cache
495
-    *
496
-    * @param string $id cache id
497
-    * @param string $group name of the cache group
498
-    * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
499
-    * @access public
500
-    */
501
-    function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
502
-    {
503
-        if ($this->_caching) {
504
-            if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
505
-                $array = unserialize($data);
506
-                $this->_memoryCachingCounter = $array['counter'];
507
-                $this->_memoryCachingArray = $array['array'];
508
-            }
509
-        }
510
-    }
511
-
512
-    /**
513
-    * Return the cache last modification time
514
-    *
515
-    * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
516
-    *
517
-    * @return int last modification time
518
-    */
519
-    function lastModified()
520
-    {
521
-        return @filemtime($this->_file);
522
-    }
523
-
524
-    /**
525
-    * Trigger a PEAR error
526
-    *
527
-    * To improve performances, the PEAR.php file is included dynamically.
528
-    * The file is so included only when an error is triggered. So, in most
529
-    * cases, the file isn't included and perfs are much better.
530
-    *
531
-    * @param string $msg error message
532
-    * @param int $code error code
533
-    * @access public
534
-    */
535
-    function raiseError($msg, $code)
536
-    {
537
-        include_once('PEAR.php');
538
-        return references_PEAR::raiseError($msg, $code, $this->_pearErrorMode);
539
-    }
540
-
541
-    /**
542
-     * Extend the life of a valid cache file
543
-     *
544
-     * see http://pear.php.net/bugs/bug.php?id=6681
545
-     *
546
-     * @access public
547
-     */
548
-    function extendLife()
549
-    {
550
-        @touch($this->_file);
551
-    }
552
-
553
-    // --- Private methods ---
554
-
555
-    /**
556
-    * Compute & set the refresh time
557
-    *
558
-    * @access private
559
-    */
560
-    function _setRefreshTime()
561
-    {
562
-        if (is_null($this->_lifeTime)) {
563
-            $this->_refreshTime = null;
564
-        } else {
565
-            $this->_refreshTime = time() - $this->_lifeTime;
566
-        }
567
-    }
568
-
569
-    /**
570
-    * Remove a file
571
-    *
572
-    * @param string $file complete file path and name
573
-    * @return boolean true if no problem
574
-    * @access private
575
-    */
576
-    function _unlink($file)
577
-    {
578
-        if (!@unlink($file)) {
579
-            return $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
580
-        }
581
-        return true;
582
-    }
583
-
584
-    /**
585
-    * Recursive function for cleaning cache file in the given directory
586
-    *
587
-    * @param string $dir directory complete path (with a trailing slash)
588
-    * @param string $group name of the cache group
589
-    * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
32
+	// --- Private properties ---
33
+
34
+	/**
35
+	 * Directory where to put the cache files
36
+	 * (make sure to add a trailing slash)
37
+	 *
38
+	 * @var string $_cacheDir
39
+	 */
40
+	public $_cacheDir = '/tmp/';
41
+
42
+	/**
43
+	 * Enable / disable caching
44
+	 *
45
+	 * (can be very usefull for the debug of cached scripts)
46
+	 *
47
+	 * @var boolean $_caching
48
+	 */
49
+	public $_caching = true;
50
+
51
+	/**
52
+	 * Cache lifetime (in seconds)
53
+	 *
54
+	 * If null, the cache is valid forever.
55
+	 *
56
+	 * @var int $_lifeTime
57
+	 */
58
+	public $_lifeTime = 3600;
59
+
60
+	/**
61
+	 * Enable / disable fileLocking
62
+	 *
63
+	 * (can avoid cache corruption under bad circumstances)
64
+	 *
65
+	 * @var boolean $_fileLocking
66
+	 */
67
+	public $_fileLocking = true;
68
+
69
+	/**
70
+	 * Timestamp of the last valid cache
71
+	 *
72
+	 * @var int $_refreshTime
73
+	 */
74
+	public $_refreshTime;
75
+
76
+	/**
77
+	 * File name (with path)
78
+	 *
79
+	 * @var string $_file
80
+	 */
81
+	public $_file;
82
+
83
+	/**
84
+	 * File name (without path)
85
+	 *
86
+	 * @var string $_fileName
87
+	 */
88
+	public $_fileName;
89
+
90
+	/**
91
+	 * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
92
+	 *
93
+	 * Enable write control will lightly slow the cache writing but not the cache reading
94
+	 * Write control can detect some corrupt cache files but maybe it's not a perfect control
95
+	 *
96
+	 * @var boolean $_writeControl
97
+	 */
98
+	public $_writeControl = true;
99
+
100
+	/**
101
+	 * Enable / disable read control
102
+	 *
103
+	 * If enabled, a control key is embeded in cache file and this key is compared with the one
104
+	 * calculated after the reading.
105
+	 *
106
+	 * @var boolean $_writeControl
107
+	 */
108
+	public $_readControl = true;
109
+
110
+	/**
111
+	 * Type of read control (only if read control is enabled)
112
+	 *
113
+	 * Available values are :
114
+	 * 'md5' for a md5 hash control (best but slowest)
115
+	 * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
116
+	 * 'strlen' for a length only test (fastest)
117
+	 *
118
+	 * @var boolean $_readControlType
119
+	 */
120
+	public $_readControlType = 'crc32';
121
+
122
+	/**
123
+	 * Pear error mode (when raiseError is called)
124
+	 *
125
+	 * (see PEAR doc)
126
+	 *
127
+	 * @see setToDebug()
128
+	 * @var int $_pearErrorMode
129
+	 */
130
+	public $_pearErrorMode = REFERENCES_CACHE_LITE_ERROR_RETURN;
131
+
132
+	/**
133
+	 * Current cache id
134
+	 *
135
+	 * @var string $_id
136
+	 */
137
+	public $_id;
138
+
139
+	/**
140
+	 * Current cache group
141
+	 *
142
+	 * @var string $_group
143
+	 */
144
+	public $_group;
145
+
146
+	/**
147
+	 * Enable / Disable "Memory Caching"
148
+	 *
149
+	 * NB : There is no lifetime for memory caching !
150
+	 *
151
+	 * @var boolean $_memoryCaching
152
+	 */
153
+	public $_memoryCaching = false;
154
+
155
+	/**
156
+	 * Enable / Disable "Only Memory Caching"
157
+	 * (be carefull, memory caching is "beta quality")
158
+	 *
159
+	 * @var boolean $_onlyMemoryCaching
160
+	 */
161
+	public $_onlyMemoryCaching = false;
162
+
163
+	/**
164
+	 * Memory caching array
165
+	 *
166
+	 * @var array $_memoryCachingArray
167
+	 */
168
+	public $_memoryCachingArray = array();
169
+
170
+	/**
171
+	 * Memory caching counter
172
+	 *
173
+	 * @var int $memoryCachingCounter
174
+	 */
175
+	public $_memoryCachingCounter = 0;
176
+
177
+	/**
178
+	 * Memory caching limit
179
+	 *
180
+	 * @var int $memoryCachingLimit
181
+	 */
182
+	public $_memoryCachingLimit = 1000;
183
+
184
+	/**
185
+	 * File Name protection
186
+	 *
187
+	 * if set to true, you can use any cache id or group name
188
+	 * if set to false, it can be faster but cache ids and group names
189
+	 * will be used directly in cache file names so be carefull with
190
+	 * special characters...
191
+	 *
192
+	 * @var boolean $fileNameProtection
193
+	 */
194
+	public $_fileNameProtection = true;
195
+
196
+	/**
197
+	 * Enable / disable automatic serialization
198
+	 *
199
+	 * it can be used to save directly datas which aren't strings
200
+	 * (but it's slower)
201
+	 *
202
+	 * @var boolean $_serialize
203
+	 */
204
+	public $_automaticSerialization = false;
205
+
206
+	/**
207
+	 * Disable / Tune the automatic cleaning process
208
+	 *
209
+	 * The automatic cleaning process destroy too old (for the given life time)
210
+	 * cache files when a new cache file is written.
211
+	 * 0               => no automatic cache cleaning
212
+	 * 1               => systematic cache cleaning
213
+	 * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
214
+	 *
215
+	 * @var int $_automaticCleaning
216
+	 */
217
+	public $_automaticCleaningFactor = 0;
218
+
219
+	/**
220
+	 * Nested directory level
221
+	 *
222
+	 * Set the hashed directory structure level. 0 means "no hashed directory
223
+	 * structure", 1 means "one level of directory", 2 means "two levels"...
224
+	 * This option can speed up Cache_Lite only when you have many thousands of
225
+	 * cache file. Only specific benchs can help you to choose the perfect value
226
+	 * for you. Maybe, 1 or 2 is a good start.
227
+	 *
228
+	 * @var int $_hashedDirectoryLevel
229
+	 */
230
+	public $_hashedDirectoryLevel = 0;
231
+
232
+	/**
233
+	 * Umask for hashed directory structure
234
+	 *
235
+	 * @var int $_hashedDirectoryUmask
236
+	 */
237
+	public $_hashedDirectoryUmask = 0700;
238
+
239
+	/**
240
+	 * API break for error handling in REFERENCES_CACHE_LITE_ERROR_RETURN mode
241
+	 *
242
+	 * In REFERENCES_CACHE_LITE_ERROR_RETURN mode, error handling was not good because
243
+	 * for example save() method always returned a boolean (a PEAR_Error object
244
+	 * would be better in REFERENCES_CACHE_LITE_ERROR_RETURN mode). To correct this without
245
+	 * breaking the API, this option (false by default) can change this handling.
246
+	 *
247
+	 * @var boolean
248
+	 */
249
+	public $_errorHandlingAPIBreak = false;
250
+
251
+	// --- Public methods ---
252
+
253
+	/**
254
+	 * Constructor
255
+	 *
256
+	 * $options is an assoc. Available options are :
257
+	 * $options = array(
258
+	 *     'cacheDir' => directory where to put the cache files (string),
259
+	 *     'caching' => enable / disable caching (boolean),
260
+	 *     'lifeTime' => cache lifetime in seconds (int),
261
+	 *     'fileLocking' => enable / disable fileLocking (boolean),
262
+	 *     'writeControl' => enable / disable write control (boolean),
263
+	 *     'readControl' => enable / disable read control (boolean),
264
+	 *     'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string),
265
+	 *     'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int),
266
+	 *     'memoryCaching' => enable / disable memory caching (boolean),
267
+	 *     'onlyMemoryCaching' => enable / disable only memory caching (boolean),
268
+	 *     'memoryCachingLimit' => max nbr of records to store into memory caching (int),
269
+	 *     'fileNameProtection' => enable / disable automatic file name protection (boolean),
270
+	 *     'automaticSerialization' => enable / disable automatic serialization (boolean),
271
+	 *     'automaticCleaningFactor' => distable / tune automatic cleaning process (int),
272
+	 *     'hashedDirectoryLevel' => level of the hashed directory system (int),
273
+	 *     'hashedDirectoryUmask' => umask for hashed directory structure (int),
274
+	 *     'errorHandlingAPIBreak' => API break for better error handling ? (boolean)
275
+	 * );
276
+	 *
277
+	 * @param array $options options
278
+	 * @access public
279
+	 */
280
+	function __construct($options = array(NULL))
281
+	{
282
+		foreach($options as $key => $value) {
283
+			$this->setOption($key, $value);
284
+		}
285
+	}
286
+
287
+	/**
288
+	 * Generic way to set a Cache_Lite option
289
+	 *
290
+	 * see Cache_Lite constructor for available options
291
+	 *
292
+	 * @var string $name name of the option
293
+	 * @var mixed $value value of the option
294
+	 * @access public
295
+	 */
296
+	function setOption($name, $value)
297
+	{
298
+		$availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode');
299
+		if (in_array($name, $availableOptions)) {
300
+			$property = '_'.$name;
301
+			$this->$property = $value;
302
+		}
303
+	}
304
+
305
+	/**
306
+	 * Test if a cache is available and (if yes) return it
307
+	 *
308
+	 * @param string $id cache id
309
+	 * @param string $group name of the cache group
310
+	 * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
311
+	 * @return string data of the cache (else : false)
312
+	 * @access public
313
+	 */
314
+	function get($id, $group = 'default', $doNotTestCacheValidity = false)
315
+	{
316
+		$this->_id = $id;
317
+		$this->_group = $group;
318
+		$data = false;
319
+		if ($this->_caching) {
320
+			$this->_setRefreshTime();
321
+			$this->_setFileName($id, $group);
322
+			clearstatcache();
323
+			if ($this->_memoryCaching) {
324
+				if (isset($this->_memoryCachingArray[$this->_file])) {
325
+					if ($this->_automaticSerialization) {
326
+						return unserialize($this->_memoryCachingArray[$this->_file]);
327
+					}
328
+					return $this->_memoryCachingArray[$this->_file];
329
+				}
330
+				if ($this->_onlyMemoryCaching) {
331
+					return false;
332
+				}
333
+			}
334
+			if (($doNotTestCacheValidity) || (is_null($this->_refreshTime))) {
335
+				if (file_exists($this->_file)) {
336
+					$data = $this->_read();
337
+				}
338
+			} else {
339
+				if ((file_exists($this->_file)) && (@filemtime($this->_file) > $this->_refreshTime)) {
340
+					$data = $this->_read();
341
+				}
342
+			}
343
+			if (($data) and ($this->_memoryCaching)) {
344
+				$this->_memoryCacheAdd($data);
345
+			}
346
+			if (($this->_automaticSerialization) and (is_string($data))) {
347
+				$data = unserialize($data);
348
+			}
349
+			return $data;
350
+		}
351
+		return false;
352
+	}
353
+
354
+	/**
355
+	 * Save some data in a cache file
356
+	 *
357
+	 * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
358
+	 * @param string $id cache id
359
+	 * @param string $group name of the cache group
360
+	 * @return boolean true if no problem (else : false or a PEAR_Error object)
361
+	 * @access public
362
+	 */
363
+	function save($data, $id = NULL, $group = 'default')
364
+	{
365
+		if ($this->_caching) {
366
+			if ($this->_automaticSerialization) {
367
+				$data = serialize($data);
368
+			}
369
+			if (isset($id)) {
370
+				$this->_setFileName($id, $group);
371
+			}
372
+			if ($this->_memoryCaching) {
373
+				$this->_memoryCacheAdd($data);
374
+				if ($this->_onlyMemoryCaching) {
375
+					return true;
376
+				}
377
+			}
378
+			if ($this->_automaticCleaningFactor>0 && ($this->_automaticCleaningFactor==1 || mt_rand(1, $this->_automaticCleaningFactor)==1)) {
379
+					$this->clean(false, 'old');
380
+				}
381
+			if ($this->_writeControl) {
382
+				$res = $this->_writeAndControl($data);
383
+				if (is_bool($res)) {
384
+					if ($res) {
385
+						return true;
386
+					}
387
+					// if $res if false, we need to invalidate the cache
388
+					@touch($this->_file, time() - 2*abs($this->_lifeTime));
389
+					return false;
390
+				}
391
+			} else {
392
+				$res = $this->_write($data);
393
+			}
394
+			if (is_object($res)) {
395
+				// $res is a PEAR_Error object
396
+				if (!($this->_errorHandlingAPIBreak)) {
397
+					return false; // we return false (old API)
398
+				}
399
+			}
400
+			return $res;
401
+		}
402
+		return false;
403
+	}
404
+
405
+	/**
406
+	 * Remove a cache file
407
+	 *
408
+	 * @param string $id cache id
409
+	 * @param string $group name of the cache group
410
+	 * @param boolean $checkbeforeunlink check if file exists before removing it
411
+	 * @return boolean true if no problem
412
+	 * @access public
413
+	 */
414
+	function remove($id, $group = 'default', $checkbeforeunlink = false)
415
+	{
416
+		$this->_setFileName($id, $group);
417
+		if ($this->_memoryCaching) {
418
+			if (isset($this->_memoryCachingArray[$this->_file])) {
419
+				unset($this->_memoryCachingArray[$this->_file]);
420
+				$this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
421
+			}
422
+			if ($this->_onlyMemoryCaching) {
423
+				return true;
424
+			}
425
+		}
426
+		if ( $checkbeforeunlink ) {
427
+			if (!file_exists($this->_file)) return true;
428
+		}
429
+		return $this->_unlink($this->_file);
430
+	}
431
+
432
+	/**
433
+	 * Clean the cache
434
+	 *
435
+	 * if no group is specified all cache files will be destroyed
436
+	 * else only cache files of the specified group will be destroyed
437
+	 *
438
+	 * @param string $group name of the cache group
439
+	 * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
440
+	 *                                        'callback_myFunction'
441
+	 * @return boolean true if no problem
442
+	 * @access public
443
+	 */
444
+	function clean($group = false, $mode = 'ingroup')
445
+	{
446
+		return $this->_cleanDir($this->_cacheDir, $group, $mode);
447
+	}
448
+
449
+	/**
450
+	 * Set to debug mode
451
+	 *
452
+	 * When an error is found, the script will stop and the message will be displayed
453
+	 * (in debug mode only).
454
+	 *
455
+	 * @access public
456
+	 */
457
+	function setToDebug()
458
+	{
459
+		$this->setOption('pearErrorMode', REFERENCES_CACHE_LITE_ERROR_DIE);
460
+	}
461
+
462
+	/**
463
+	 * Set a new life time
464
+	 *
465
+	 * @param int $newLifeTime new life time (in seconds)
466
+	 * @access public
467
+	 */
468
+	function setLifeTime($newLifeTime)
469
+	{
470
+		$this->_lifeTime = $newLifeTime;
471
+		$this->_setRefreshTime();
472
+	}
473
+
474
+	/**
475
+	 * Save the state of the caching memory array into a cache file cache
476
+	 *
477
+	 * @param string $id cache id
478
+	 * @param string $group name of the cache group
479
+	 * @access public
480
+	 */
481
+	function saveMemoryCachingState($id, $group = 'default')
482
+	{
483
+		if ($this->_caching) {
484
+			$array = array(
485
+				'counter' => $this->_memoryCachingCounter,
486
+				'array' => $this->_memoryCachingArray
487
+			);
488
+			$data = serialize($array);
489
+			$this->save($data, $id, $group);
490
+		}
491
+	}
492
+
493
+	/**
494
+	 * Load the state of the caching memory array from a given cache file cache
495
+	 *
496
+	 * @param string $id cache id
497
+	 * @param string $group name of the cache group
498
+	 * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
499
+	 * @access public
500
+	 */
501
+	function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
502
+	{
503
+		if ($this->_caching) {
504
+			if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
505
+				$array = unserialize($data);
506
+				$this->_memoryCachingCounter = $array['counter'];
507
+				$this->_memoryCachingArray = $array['array'];
508
+			}
509
+		}
510
+	}
511
+
512
+	/**
513
+	 * Return the cache last modification time
514
+	 *
515
+	 * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
516
+	 *
517
+	 * @return int last modification time
518
+	 */
519
+	function lastModified()
520
+	{
521
+		return @filemtime($this->_file);
522
+	}
523
+
524
+	/**
525
+	 * Trigger a PEAR error
526
+	 *
527
+	 * To improve performances, the PEAR.php file is included dynamically.
528
+	 * The file is so included only when an error is triggered. So, in most
529
+	 * cases, the file isn't included and perfs are much better.
530
+	 *
531
+	 * @param string $msg error message
532
+	 * @param int $code error code
533
+	 * @access public
534
+	 */
535
+	function raiseError($msg, $code)
536
+	{
537
+		include_once('PEAR.php');
538
+		return references_PEAR::raiseError($msg, $code, $this->_pearErrorMode);
539
+	}
540
+
541
+	/**
542
+	 * Extend the life of a valid cache file
543
+	 *
544
+	 * see http://pear.php.net/bugs/bug.php?id=6681
545
+	 *
546
+	 * @access public
547
+	 */
548
+	function extendLife()
549
+	{
550
+		@touch($this->_file);
551
+	}
552
+
553
+	// --- Private methods ---
554
+
555
+	/**
556
+	 * Compute & set the refresh time
557
+	 *
558
+	 * @access private
559
+	 */
560
+	function _setRefreshTime()
561
+	{
562
+		if (is_null($this->_lifeTime)) {
563
+			$this->_refreshTime = null;
564
+		} else {
565
+			$this->_refreshTime = time() - $this->_lifeTime;
566
+		}
567
+	}
568
+
569
+	/**
570
+	 * Remove a file
571
+	 *
572
+	 * @param string $file complete file path and name
573
+	 * @return boolean true if no problem
574
+	 * @access private
575
+	 */
576
+	function _unlink($file)
577
+	{
578
+		if (!@unlink($file)) {
579
+			return $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
580
+		}
581
+		return true;
582
+	}
583
+
584
+	/**
585
+	 * Recursive function for cleaning cache file in the given directory
586
+	 *
587
+	 * @param string $dir directory complete path (with a trailing slash)
588
+	 * @param string $group name of the cache group
589
+	 * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
590 590
                                              'callback_myFunction'
591
-    * @return boolean true if no problem
592
-    * @access private
593
-    */
594
-    function _cleanDir($dir, $group = false, $mode = 'ingroup')
595
-    {
596
-        if ($this->_fileNameProtection) {
597
-            $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
598
-        } else {
599
-            $motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
600
-        }
601
-        if ($this->_memoryCaching) {
602
-	    foreach($this->_memoryCachingArray as $key => $v) {
603
-                if (strpos($key, $motif) !== false) {
604
-                    unset($this->_memoryCachingArray[$key]);
605
-                    $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
606
-                }
607
-            }
608
-            if ($this->_onlyMemoryCaching) {
609
-                return true;
610
-            }
611
-        }
612
-        if (!($dh = opendir($dir))) {
613
-            return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
614
-        }
615
-        $result = true;
616
-        while ($file = readdir($dh)) {
617
-            if (($file != '.') && ($file != '..')) {
618
-                if (substr($file, 0, 6)=='cache_') {
619
-                    $file2 = $dir . $file;
620
-                    if (is_file($file2)) {
621
-                        switch (substr($mode, 0, 9)) {
622
-                            case 'old':
623
-                                // files older than lifeTime get deleted from cache
624
-                                if (!is_null($this->_lifeTime)) {
625
-                                    if ((time() - @filemtime($file2)) > $this->_lifeTime) {
626
-                                        $result = ($result and ($this->_unlink($file2)));
627
-                                    }
628
-                                }
629
-                                break;
630
-                            case 'notingrou':
631
-                                if (strpos($file2, $motif) === false) {
632
-                                    $result = ($result and ($this->_unlink($file2)));
633
-                                }
634
-                                break;
635
-                            case 'callback_':
636
-                                $func = substr($mode, 9, strlen($mode) - 9);
637
-                                if ($func($file2, $group)) {
638
-                                    $result = ($result and ($this->_unlink($file2)));
639
-                                }
640
-                                break;
641
-                            case 'ingroup':
642
-                            default:
643
-                                if (strpos($file2, $motif) !== false) {
644
-                                    $result = ($result and ($this->_unlink($file2)));
645
-                                }
646
-                                break;
647
-                        }
648
-                    }
649
-                    if ((is_dir($file2)) and ($this->_hashedDirectoryLevel>0)) {
650
-                        $result = ($result and ($this->_cleanDir($file2 . '/', $group, $mode)));
651
-                    }
652
-                }
653
-            }
654
-        }
655
-        return $result;
656
-    }
657
-
658
-    /**
659
-    * Add some date in the memory caching array
660
-    *
661
-    * @param string $data data to cache
662
-    * @access private
663
-    */
664
-    function _memoryCacheAdd($data)
665
-    {
666
-        $this->_memoryCachingArray[$this->_file] = $data;
667
-        if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
668
-            list($key, ) = each($this->_memoryCachingArray);
669
-            unset($this->_memoryCachingArray[$key]);
670
-        } else {
671
-            $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1;
672
-        }
673
-    }
674
-
675
-    /**
676
-    * Make a file name (with path)
677
-    *
678
-    * @param string $id cache id
679
-    * @param string $group name of the group
680
-    * @access private
681
-    */
682
-    function _setFileName($id, $group)
683
-    {
684
-
685
-        if ($this->_fileNameProtection) {
686
-            $suffix = 'cache_'.md5($group).'_'.md5($id);
687
-        } else {
688
-            $suffix = 'cache_'.$group.'_'.$id;
689
-        }
690
-        $root = $this->_cacheDir;
691
-        if ($this->_hashedDirectoryLevel>0) {
692
-            $hash = md5($suffix);
693
-            for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
694
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
695
-            }
696
-        }
697
-        $this->_fileName = $suffix;
698
-        $this->_file = $root.$suffix;
699
-    }
700
-
701
-    /**
702
-    * Read the cache file and return the content
703
-    *
704
-    * @return string content of the cache file (else : false or a PEAR_Error object)
705
-    * @access private
706
-    */
707
-    function _read()
708
-    {
709
-        $fp = @fopen($this->_file, "rb");
710
-        if ($this->_fileLocking) @flock($fp, LOCK_SH);
711
-        if ($fp) {
712
-            clearstatcache();
713
-            $length = @filesize($this->_file);
714
-            $mqr = get_magic_quotes_runtime();
715
-            @set_magic_quotes_runtime(0);
716
-            if ($this->_readControl) {
717
-                $hashControl = @fread($fp, 32);
718
-                $length = $length - 32;
719
-            }
720
-            if ($length) {
721
-                $data = @fread($fp, $length);
722
-            } else {
723
-                $data = '';
724
-            }
725
-            @set_magic_quotes_runtime($mqr);
726
-            if ($this->_fileLocking) @flock($fp, LOCK_UN);
727
-            @fclose($fp);
728
-            if ($this->_readControl) {
729
-                $hashData = $this->_hash($data, $this->_readControlType);
730
-                if ($hashData != $hashControl) {
731
-                    if (!(is_null($this->_lifeTime))) {
732
-                        @touch($this->_file, time() - 2*abs($this->_lifeTime));
733
-                    } else {
734
-                        @unlink($this->_file);
735
-                    }
736
-                    return false;
737
-                }
738
-            }
739
-            return $data;
740
-        }
741
-        return $this->raiseError('Cache_Lite : Unable to read cache !', -2);
742
-    }
743
-
744
-    /**
745
-    * Write the given data in the cache file
746
-    *
747
-    * @param string $data data to put in cache
748
-    * @return boolean true if ok (a PEAR_Error object else)
749
-    * @access private
750
-    */
751
-    function _write($data)
752
-    {
753
-        if ($this->_hashedDirectoryLevel > 0) {
754
-            $hash = md5($this->_fileName);
755
-            $root = $this->_cacheDir;
756
-            for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
757
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
758
-                if (!(@is_dir($root))) {
759
-                    @mkdir($root, $this->_hashedDirectoryUmask);
760
-                }
761
-            }
762
-        }
763
-        $fp = @fopen($this->_file, "wb");
764
-        if ($fp) {
765
-            if ($this->_fileLocking) @flock($fp, LOCK_EX);
766
-            if ($this->_readControl) {
767
-                @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
768
-            }
769
-            $mqr = get_magic_quotes_runtime();
770
-            @set_magic_quotes_runtime(0);
771
-            @fwrite($fp, $data);
772
-            @set_magic_quotes_runtime($mqr);
773
-            if ($this->_fileLocking) @flock($fp, LOCK_UN);
774
-            @fclose($fp);
775
-            return true;
776
-        }
777
-        return $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1);
778
-    }
779
-
780
-    /**
781
-    * Write the given data in the cache file and control it just after to avoir corrupted cache entries
782
-    *
783
-    * @param string $data data to put in cache
784
-    * @return boolean true if the test is ok (else : false or a PEAR_Error object)
785
-    * @access private
786
-    */
787
-    function _writeAndControl($data)
788
-    {
789
-        $result = $this->_write($data);
790
-        if (is_object($result)) {
791
-            return $result; # We return the PEAR_Error object
792
-        }
793
-        $dataRead = $this->_read();
794
-        if (is_object($dataRead)) {
795
-            return $dataRead; # We return the PEAR_Error object
796
-        }
797
-        if ((is_bool($dataRead)) && (!$dataRead)) {
798
-            return false;
799
-        }
800
-        return ($dataRead==$data);
801
-    }
802
-
803
-    /**
804
-    * Make a control key with the string containing datas
805
-    *
806
-    * @param string $data data
807
-    * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
808
-    * @return string control key
809
-    * @access private
810
-    */
811
-    function _hash($data, $controlType)
812
-    {
813
-        switch ($controlType) {
814
-        case 'md5':
815
-            return md5($data);
816
-        case 'crc32':
817
-            return sprintf('% 32d', crc32($data));
818
-        case 'strlen':
819
-            return sprintf('% 32d', strlen($data));
820
-        default:
821
-            return $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
822
-        }
823
-    }
591
+	 * @return boolean true if no problem
592
+	 * @access private
593
+	 */
594
+	function _cleanDir($dir, $group = false, $mode = 'ingroup')
595
+	{
596
+		if ($this->_fileNameProtection) {
597
+			$motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
598
+		} else {
599
+			$motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
600
+		}
601
+		if ($this->_memoryCaching) {
602
+		foreach($this->_memoryCachingArray as $key => $v) {
603
+				if (strpos($key, $motif) !== false) {
604
+					unset($this->_memoryCachingArray[$key]);
605
+					$this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
606
+				}
607
+			}
608
+			if ($this->_onlyMemoryCaching) {
609
+				return true;
610
+			}
611
+		}
612
+		if (!($dh = opendir($dir))) {
613
+			return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
614
+		}
615
+		$result = true;
616
+		while ($file = readdir($dh)) {
617
+			if (($file != '.') && ($file != '..')) {
618
+				if (substr($file, 0, 6)=='cache_') {
619
+					$file2 = $dir . $file;
620
+					if (is_file($file2)) {
621
+						switch (substr($mode, 0, 9)) {
622
+							case 'old':
623
+								// files older than lifeTime get deleted from cache
624
+								if (!is_null($this->_lifeTime)) {
625
+									if ((time() - @filemtime($file2)) > $this->_lifeTime) {
626
+										$result = ($result and ($this->_unlink($file2)));
627
+									}
628
+								}
629
+								break;
630
+							case 'notingrou':
631
+								if (strpos($file2, $motif) === false) {
632
+									$result = ($result and ($this->_unlink($file2)));
633
+								}
634
+								break;
635
+							case 'callback_':
636
+								$func = substr($mode, 9, strlen($mode) - 9);
637
+								if ($func($file2, $group)) {
638
+									$result = ($result and ($this->_unlink($file2)));
639
+								}
640
+								break;
641
+							case 'ingroup':
642
+							default:
643
+								if (strpos($file2, $motif) !== false) {
644
+									$result = ($result and ($this->_unlink($file2)));
645
+								}
646
+								break;
647
+						}
648
+					}
649
+					if ((is_dir($file2)) and ($this->_hashedDirectoryLevel>0)) {
650
+						$result = ($result and ($this->_cleanDir($file2 . '/', $group, $mode)));
651
+					}
652
+				}
653
+			}
654
+		}
655
+		return $result;
656
+	}
657
+
658
+	/**
659
+	 * Add some date in the memory caching array
660
+	 *
661
+	 * @param string $data data to cache
662
+	 * @access private
663
+	 */
664
+	function _memoryCacheAdd($data)
665
+	{
666
+		$this->_memoryCachingArray[$this->_file] = $data;
667
+		if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
668
+			list($key, ) = each($this->_memoryCachingArray);
669
+			unset($this->_memoryCachingArray[$key]);
670
+		} else {
671
+			$this->_memoryCachingCounter = $this->_memoryCachingCounter + 1;
672
+		}
673
+	}
674
+
675
+	/**
676
+	 * Make a file name (with path)
677
+	 *
678
+	 * @param string $id cache id
679
+	 * @param string $group name of the group
680
+	 * @access private
681
+	 */
682
+	function _setFileName($id, $group)
683
+	{
684
+
685
+		if ($this->_fileNameProtection) {
686
+			$suffix = 'cache_'.md5($group).'_'.md5($id);
687
+		} else {
688
+			$suffix = 'cache_'.$group.'_'.$id;
689
+		}
690
+		$root = $this->_cacheDir;
691
+		if ($this->_hashedDirectoryLevel>0) {
692
+			$hash = md5($suffix);
693
+			for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
694
+				$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
695
+			}
696
+		}
697
+		$this->_fileName = $suffix;
698
+		$this->_file = $root.$suffix;
699
+	}
700
+
701
+	/**
702
+	 * Read the cache file and return the content
703
+	 *
704
+	 * @return string content of the cache file (else : false or a PEAR_Error object)
705
+	 * @access private
706
+	 */
707
+	function _read()
708
+	{
709
+		$fp = @fopen($this->_file, "rb");
710
+		if ($this->_fileLocking) @flock($fp, LOCK_SH);
711
+		if ($fp) {
712
+			clearstatcache();
713
+			$length = @filesize($this->_file);
714
+			$mqr = get_magic_quotes_runtime();
715
+			@set_magic_quotes_runtime(0);
716
+			if ($this->_readControl) {
717
+				$hashControl = @fread($fp, 32);
718
+				$length = $length - 32;
719
+			}
720
+			if ($length) {
721
+				$data = @fread($fp, $length);
722
+			} else {
723
+				$data = '';
724
+			}
725
+			@set_magic_quotes_runtime($mqr);
726
+			if ($this->_fileLocking) @flock($fp, LOCK_UN);
727
+			@fclose($fp);
728
+			if ($this->_readControl) {
729
+				$hashData = $this->_hash($data, $this->_readControlType);
730
+				if ($hashData != $hashControl) {
731
+					if (!(is_null($this->_lifeTime))) {
732
+						@touch($this->_file, time() - 2*abs($this->_lifeTime));
733
+					} else {
734
+						@unlink($this->_file);
735
+					}
736
+					return false;
737
+				}
738
+			}
739
+			return $data;
740
+		}
741
+		return $this->raiseError('Cache_Lite : Unable to read cache !', -2);
742
+	}
743
+
744
+	/**
745
+	 * Write the given data in the cache file
746
+	 *
747
+	 * @param string $data data to put in cache
748
+	 * @return boolean true if ok (a PEAR_Error object else)
749
+	 * @access private
750
+	 */
751
+	function _write($data)
752
+	{
753
+		if ($this->_hashedDirectoryLevel > 0) {
754
+			$hash = md5($this->_fileName);
755
+			$root = $this->_cacheDir;
756
+			for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
757
+				$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
758
+				if (!(@is_dir($root))) {
759
+					@mkdir($root, $this->_hashedDirectoryUmask);
760
+				}
761
+			}
762
+		}
763
+		$fp = @fopen($this->_file, "wb");
764
+		if ($fp) {
765
+			if ($this->_fileLocking) @flock($fp, LOCK_EX);
766
+			if ($this->_readControl) {
767
+				@fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
768
+			}
769
+			$mqr = get_magic_quotes_runtime();
770
+			@set_magic_quotes_runtime(0);
771
+			@fwrite($fp, $data);
772
+			@set_magic_quotes_runtime($mqr);
773
+			if ($this->_fileLocking) @flock($fp, LOCK_UN);
774
+			@fclose($fp);
775
+			return true;
776
+		}
777
+		return $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1);
778
+	}
779
+
780
+	/**
781
+	 * Write the given data in the cache file and control it just after to avoir corrupted cache entries
782
+	 *
783
+	 * @param string $data data to put in cache
784
+	 * @return boolean true if the test is ok (else : false or a PEAR_Error object)
785
+	 * @access private
786
+	 */
787
+	function _writeAndControl($data)
788
+	{
789
+		$result = $this->_write($data);
790
+		if (is_object($result)) {
791
+			return $result; # We return the PEAR_Error object
792
+		}
793
+		$dataRead = $this->_read();
794
+		if (is_object($dataRead)) {
795
+			return $dataRead; # We return the PEAR_Error object
796
+		}
797
+		if ((is_bool($dataRead)) && (!$dataRead)) {
798
+			return false;
799
+		}
800
+		return ($dataRead==$data);
801
+	}
802
+
803
+	/**
804
+	 * Make a control key with the string containing datas
805
+	 *
806
+	 * @param string $data data
807
+	 * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
808
+	 * @return string control key
809
+	 * @access private
810
+	 */
811
+	function _hash($data, $controlType)
812
+	{
813
+		switch ($controlType) {
814
+		case 'md5':
815
+			return md5($data);
816
+		case 'crc32':
817
+			return sprintf('% 32d', crc32($data));
818
+		case 'strlen':
819
+			return sprintf('% 32d', strlen($data));
820
+		default:
821
+			return $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
822
+		}
823
+	}
824 824
 
825 825
 }
826 826
 
Please login to merge, or discard this patch.
extra/clone.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 // work around for PHP < 5.0.x
30 30
 if(!function_exists('file_put_contents')) {
31 31
   function file_put_contents($filename, $data, $file_append = false) {
32
-    $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
33
-    if(!$fp) {
34
-      trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
35
-      return;
36
-    }
37
-    fputs($fp, $data);
38
-    fclose($fp);
32
+	$fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
33
+	if(!$fp) {
34
+	  trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
35
+	  return;
36
+	}
37
+	fputs($fp, $data);
38
+	fclose($fp);
39 39
   }
40 40
 }
41 41
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 		// check all files in dir, and process it
57 57
 		if ($handle = opendir($path)) {
58
-      		while ($file = readdir($handle)) {
58
+	  		while ($file = readdir($handle)) {
59 59
 				if ($file != '.' && $file != '..') {
60 60
 					cloneFileFolder("$path/$file");
61 61
 				}
Please login to merge, or discard this patch.
plugins/actions/twitter/bitly.class.php 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -18,211 +18,211 @@
 block discarded – undo
18 18
 
19 19
 class Bitly {
20 20
 
21
-    protected $api = 'http://api.bit.ly/';
22
-    private $format = 'json';
23
-    private $version = '2.0.1';
24
-    private $validActions = array(
25
-        'shorten',
26
-        'stats',
27
-        'info',
28
-        'expand'
29
-        );
30
-
31
-    public function Bitly($login, $apiKey)
32
-    {
33
-        $this->login = $login;
34
-        $this->apiKey = $apiKey;
35
-        $this->statusCode = 'OK';
36
-        $this->errorMessage = '';
37
-        $this->errorCode = '';
38
-    	return true;
39
-    }
40
-
41
-    private function setError($message, $code = 101)
42
-    {
43
-    	$this->errorCode = $code;
44
-        $this->errorMessage = $message;
45
-        $this->statusCode = 'ERROR';
46
-    }
47
-
48
-    public function validAction($action)
49
-    {
50
-        if( in_array($action, $this->validActions)) {
51
-            return true;
52
-        }
53
-        $this->setError("Undefined method $action", 202);
54
-    	return false;
55
-    }
56
-
57
-    public function error()
58
-    {
59
-        $ret = array(
60
-            "errorCode" => $this->errorCode,
61
-            "errorMessage" => $this->errorMessage,
62
-            "statusCode" => $this->statusCode
63
-            );
64
-
65
-        // Function used for passing empty result sometimes.
66
-        if( $this->statusCode == 'OK') {
67
-            $ret['results'] = array();
68
-        }
69
-        if( $this->format == 'json') {
70
-            return json_encode($ret);
71
-        } else {
72
-            throw new Exception('Unsupported format');
73
-        }
74
-    }
75
-
76
-    public function shorten($message)
77
-    {
78
-
79
-        $postFields = '';
80
-        preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
81
-
82
-        for($i=0;$i<sizeof( $matches[0]);$i++) {
83
-            $curr = $matches[0][$i];
84
-            // ignore bitly urls
85
-            if( !strstr($curr, 'http://bit.ly')) {
86
-                $postFields .= '&longUrl=' . urlencode( $curr);
87
-            }
88
-        }
89
-
90
-        // nothing to shorten, return empty result
91
-        if( !strlen($postFields)) {
92
-            return $this->error();
93
-        }
94
-        return $this->process('shorten', $postFields);
95
-    }
96
-
97
-    public function expand($message)
98
-    {
99
-        $postFields = '&hash=' . $this->getHash($message);
100
-    	return $this->process('expand', $postFields);
101
-    }
102
-
103
-    public function info($bitlyUrl)
104
-    {
105
-        $hash = $this->getHash($bitlyUrl);
106
-        $postFields = '&hash=' . $hash;
107
-        return $this->process('info', $postFields);
108
-    }
109
-
110
-    public function stats($bitlyUrl)
111
-    {
112
-        // Take only first hash or url. Ignore others.
113
-        $a = split(',', $bitlyUrl);
114
-        $postFields = '&hash=' . $this->getHash($a[0]);
115
-        return $this->process('stats', $postFields);
116
-    }
117
-
118
-    protected function process($action, $postFields) {
119
-        $ch = curl_init( $this->api . $action);
120
-
121
-        $postFields = 'version=' . $this->version . $postFields;
122
-        $postFields .= '&format=' . $this->format;
123
-        $postFields .= '&history=1';
124
-
125
-        curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
126
-        curl_setopt($ch, CURLOPT_POST, 1);
127
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
128
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
129
-
130
-        $response = curl_exec($ch);
131
-
132
-        curl_close($ch);
133
-
134
-        return $response;
135
-    }
136
-
137
-    public function setReturnFormat($format)
138
-    {
139
-        // needed for restoration
140
-        $this->oldFormat = $this->format;
141
-    	$this->format = $format;
142
-        return $this->format;
143
-    }
144
-
145
-    private function restoreFormat()
146
-    {
147
-        if( !empty( $this->oldFormat)) {
148
-            $this->format = $this->oldFormat;
149
-        }
150
-        return $this->format;
151
-    }
152
-
153
-    // expect url, shortened url or hash
154
-    public function getHash($message)
155
-    {
156
-        // if url and not bit.ly get shortened first
157
-        if( strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
158
-            $message = $this->shortenSingle($message);
159
-        }
160
-        $hash = str_replace('http://bit.ly/', '', $message);
161
-        return $hash;
162
-    }
163
-
164
-    public function shortenSingle($message)
165
-    {
166
-        $this->setReturnFormat('json');
167
-    	$data = json_decode( $this->shorten($message), true);
168
-        // return to previous state.
169
-        $this->restoreFormat();
170
-
171
-        // replace every long url with short one
172
-        foreach($data['results'] as $url => $d) {
173
-            $message = str_replace($url, $d['shortUrl'], $message);
174
-        }
175
-        return $message;
176
-    }
177
-
178
-    public function expandSingle($shortUrl)
179
-    {
180
-        $this->setReturnFormat('json');
181
-    	$data = json_decode( $this->expand($shortUrl), true);
182
-        $this->restoreFormat();
183
-        return $data['results'][ $this->getHash($shortUrl)]['longUrl'];
184
-    }
185
-
186
-    public function getInfoArray($url)
187
-    {
188
-        $this->setReturnFormat('json');
189
-    	$json = $this->info($url);
190
-        $this->restoreFormat();
191
-        $data = json_decode($json, true);
192
-
193
-        $this->infoArray = array_pop( $data['results']);
194
-        return $this->infoArray;
195
-    }
196
-
197
-    public function getStatsArray($url)
198
-    {
199
-        $this->setReturnFormat('json');
200
-    	$json = $this->stats($url);
201
-        $this->restoreFormat();
202
-        $data = json_decode($json, true);
203
-        $this->statsArray = $data['results'];
204
-        return $this->statsArray;
205
-    }
206
-
207
-    public function getClicks()
208
-    {
209
-    	return $this->statsArray['clicks'];
210
-    }
211
-    // get thumbnail (small, middle, large)
212
-    public function getThumbnail($size = 'small')
213
-    {
214
-        if( !in_array($size, array('small', 'medium', 'large'))) {
215
-            throw new Exception('Invalid size value');
216
-        }
217
-        if( empty( $this->infoArray)) {
218
-            throw new Exception('Info not loaded');
219
-        }
220
-    	return $this->infoArray['thumbnail'][$size];
221
-    }
222
-
223
-    public function getTitle()
224
-    {
225
-    	return $this->infoArray['htmlTitle'];
226
-    }
21
+	protected $api = 'http://api.bit.ly/';
22
+	private $format = 'json';
23
+	private $version = '2.0.1';
24
+	private $validActions = array(
25
+		'shorten',
26
+		'stats',
27
+		'info',
28
+		'expand'
29
+		);
30
+
31
+	public function Bitly($login, $apiKey)
32
+	{
33
+		$this->login = $login;
34
+		$this->apiKey = $apiKey;
35
+		$this->statusCode = 'OK';
36
+		$this->errorMessage = '';
37
+		$this->errorCode = '';
38
+		return true;
39
+	}
40
+
41
+	private function setError($message, $code = 101)
42
+	{
43
+		$this->errorCode = $code;
44
+		$this->errorMessage = $message;
45
+		$this->statusCode = 'ERROR';
46
+	}
47
+
48
+	public function validAction($action)
49
+	{
50
+		if( in_array($action, $this->validActions)) {
51
+			return true;
52
+		}
53
+		$this->setError("Undefined method $action", 202);
54
+		return false;
55
+	}
56
+
57
+	public function error()
58
+	{
59
+		$ret = array(
60
+			"errorCode" => $this->errorCode,
61
+			"errorMessage" => $this->errorMessage,
62
+			"statusCode" => $this->statusCode
63
+			);
64
+
65
+		// Function used for passing empty result sometimes.
66
+		if( $this->statusCode == 'OK') {
67
+			$ret['results'] = array();
68
+		}
69
+		if( $this->format == 'json') {
70
+			return json_encode($ret);
71
+		} else {
72
+			throw new Exception('Unsupported format');
73
+		}
74
+	}
75
+
76
+	public function shorten($message)
77
+	{
78
+
79
+		$postFields = '';
80
+		preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
81
+
82
+		for($i=0;$i<sizeof( $matches[0]);$i++) {
83
+			$curr = $matches[0][$i];
84
+			// ignore bitly urls
85
+			if( !strstr($curr, 'http://bit.ly')) {
86
+				$postFields .= '&longUrl=' . urlencode( $curr);
87
+			}
88
+		}
89
+
90
+		// nothing to shorten, return empty result
91
+		if( !strlen($postFields)) {
92
+			return $this->error();
93
+		}
94
+		return $this->process('shorten', $postFields);
95
+	}
96
+
97
+	public function expand($message)
98
+	{
99
+		$postFields = '&hash=' . $this->getHash($message);
100
+		return $this->process('expand', $postFields);
101
+	}
102
+
103
+	public function info($bitlyUrl)
104
+	{
105
+		$hash = $this->getHash($bitlyUrl);
106
+		$postFields = '&hash=' . $hash;
107
+		return $this->process('info', $postFields);
108
+	}
109
+
110
+	public function stats($bitlyUrl)
111
+	{
112
+		// Take only first hash or url. Ignore others.
113
+		$a = split(',', $bitlyUrl);
114
+		$postFields = '&hash=' . $this->getHash($a[0]);
115
+		return $this->process('stats', $postFields);
116
+	}
117
+
118
+	protected function process($action, $postFields) {
119
+		$ch = curl_init( $this->api . $action);
120
+
121
+		$postFields = 'version=' . $this->version . $postFields;
122
+		$postFields .= '&format=' . $this->format;
123
+		$postFields .= '&history=1';
124
+
125
+		curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
126
+		curl_setopt($ch, CURLOPT_POST, 1);
127
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
128
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
129
+
130
+		$response = curl_exec($ch);
131
+
132
+		curl_close($ch);
133
+
134
+		return $response;
135
+	}
136
+
137
+	public function setReturnFormat($format)
138
+	{
139
+		// needed for restoration
140
+		$this->oldFormat = $this->format;
141
+		$this->format = $format;
142
+		return $this->format;
143
+	}
144
+
145
+	private function restoreFormat()
146
+	{
147
+		if( !empty( $this->oldFormat)) {
148
+			$this->format = $this->oldFormat;
149
+		}
150
+		return $this->format;
151
+	}
152
+
153
+	// expect url, shortened url or hash
154
+	public function getHash($message)
155
+	{
156
+		// if url and not bit.ly get shortened first
157
+		if( strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
158
+			$message = $this->shortenSingle($message);
159
+		}
160
+		$hash = str_replace('http://bit.ly/', '', $message);
161
+		return $hash;
162
+	}
163
+
164
+	public function shortenSingle($message)
165
+	{
166
+		$this->setReturnFormat('json');
167
+		$data = json_decode( $this->shorten($message), true);
168
+		// return to previous state.
169
+		$this->restoreFormat();
170
+
171
+		// replace every long url with short one
172
+		foreach($data['results'] as $url => $d) {
173
+			$message = str_replace($url, $d['shortUrl'], $message);
174
+		}
175
+		return $message;
176
+	}
177
+
178
+	public function expandSingle($shortUrl)
179
+	{
180
+		$this->setReturnFormat('json');
181
+		$data = json_decode( $this->expand($shortUrl), true);
182
+		$this->restoreFormat();
183
+		return $data['results'][ $this->getHash($shortUrl)]['longUrl'];
184
+	}
185
+
186
+	public function getInfoArray($url)
187
+	{
188
+		$this->setReturnFormat('json');
189
+		$json = $this->info($url);
190
+		$this->restoreFormat();
191
+		$data = json_decode($json, true);
192
+
193
+		$this->infoArray = array_pop( $data['results']);
194
+		return $this->infoArray;
195
+	}
196
+
197
+	public function getStatsArray($url)
198
+	{
199
+		$this->setReturnFormat('json');
200
+		$json = $this->stats($url);
201
+		$this->restoreFormat();
202
+		$data = json_decode($json, true);
203
+		$this->statsArray = $data['results'];
204
+		return $this->statsArray;
205
+	}
206
+
207
+	public function getClicks()
208
+	{
209
+		return $this->statsArray['clicks'];
210
+	}
211
+	// get thumbnail (small, middle, large)
212
+	public function getThumbnail($size = 'small')
213
+	{
214
+		if( !in_array($size, array('small', 'medium', 'large'))) {
215
+			throw new Exception('Invalid size value');
216
+		}
217
+		if( empty( $this->infoArray)) {
218
+			throw new Exception('Info not loaded');
219
+		}
220
+		return $this->infoArray['thumbnail'][$size];
221
+	}
222
+
223
+	public function getTitle()
224
+	{
225
+		return $this->infoArray['htmlTitle'];
226
+	}
227 227
 }
228 228
 ?>
Please login to merge, or discard this patch.
class/wideimage/Operation/ApplyMask.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Operations
23
-  **/
21
+	 * @package Internal/Operations
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * An Exception for when an invalid fit method is passed
Please login to merge, or discard this patch.
class/wideimage/Operation/CopyChannelsTrueColor.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Operations
23
-  **/
21
+	 * @package Internal/Operations
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * An Exception for when an invalid fit method is passed
Please login to merge, or discard this patch.
class/wideimage/Operation/Flip.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Operations
23
-  **/
21
+	 * @package Internal/Operations
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * An Exception for when an invalid fit method is passed
Please login to merge, or discard this patch.
class/wideimage/Operation/ApplyFilter.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Operations
23
-  **/
21
+	 * @package Internal/Operations
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * An Exception for when an invalid fit method is passed
Please login to merge, or discard this patch.
class/wideimage/Operation/CorrectGamma.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Operations
23
-  **/
21
+	 * @package Internal/Operations
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * An Exception for when an invalid fit method is passed
Please login to merge, or discard this patch.