Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 2... Line 2...
2
/**
2
/**
3
 * PEAR_ChannelFile, the channel handling class
3
 * PEAR_ChannelFile, the channel handling class
4
 *
4
 *
5
 * PHP versions 4 and 5
5
 * PHP versions 4 and 5
6
 *
6
 *
7
 * LICENSE: This source file is subject to version 3.0 of the PHP license
-
 
8
 * that is available through the world-wide-web at the following URI:
-
 
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
-
 
10
 * the PHP License and are unable to obtain it through the web, please
-
 
11
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
12
 *
-
 
13
 * @category   pear
7
 * @category   pear
14
 * @package    PEAR
8
 * @package    PEAR
15
 * @author     Greg Beaver <cellog@php.net>
9
 * @author     Greg Beaver <cellog@php.net>
16
 * @copyright  1997-2006 The PHP Group
10
 * @copyright  1997-2009 The Authors
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
11
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
18
 * @version    CVS: $Id: ChannelFile.php,v 1.78 2006/10/31 02:54:40 cellog Exp $
-
 
19
 * @link       http://pear.php.net/package/PEAR
12
 * @link       http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.0a1
13
 * @since      File available since Release 1.4.0a1
21
 */
14
 */
Line 22... Line 15...
22
 
15
 
Line 70... Line 63...
70
/**
63
/**
71
 * Error code when channel summary is multi-line
64
 * Error code when channel summary is multi-line
72
 */
65
 */
73
define('PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY', 9);
66
define('PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY', 9);
74
/**
67
/**
75
 * Error code when channel server is missing for xmlrpc or soap protocol
68
 * Error code when channel server is missing for protocol
76
 */
69
 */
77
define('PEAR_CHANNELFILE_ERROR_NO_HOST', 10);
70
define('PEAR_CHANNELFILE_ERROR_NO_HOST', 10);
78
/**
71
/**
79
 * Error code when channel server is invalid for xmlrpc or soap protocol
72
 * Error code when channel server is invalid for protocol
80
 */
73
 */
81
define('PEAR_CHANNELFILE_ERROR_INVALID_HOST', 11);
74
define('PEAR_CHANNELFILE_ERROR_INVALID_HOST', 11);
82
/**
75
/**
83
 * Error code when a mirror name is invalid
76
 * Error code when a mirror name is invalid
84
 */
77
 */
Line 126... Line 119...
126
define('PEAR_CHANNELFILE_ERROR_NO_STATICVERSION', 34);
119
define('PEAR_CHANNELFILE_ERROR_NO_STATICVERSION', 34);
127
/**
120
/**
128
 * Error code when <baseurl> contains no type attribute in a <rest> protocol definition
121
 * Error code when <baseurl> contains no type attribute in a <rest> protocol definition
129
 */
122
 */
130
define('PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE', 35);
123
define('PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE', 35);
131
/** 
124
/**
132
 * Error code when a mirror is defined and the channel.xml represents the __uri pseudo-channel
125
 * Error code when a mirror is defined and the channel.xml represents the __uri pseudo-channel
133
 */
126
 */
134
define('PEAR_CHANNELFILE_URI_CANT_MIRROR', 36);
127
define('PEAR_CHANNELFILE_URI_CANT_MIRROR', 36);
135
/** 
128
/**
136
 * Error code when ssl attribute is present and is not "yes"
129
 * Error code when ssl attribute is present and is not "yes"
137
 */
130
 */
138
define('PEAR_CHANNELFILE_ERROR_INVALID_SSL', 37);
131
define('PEAR_CHANNELFILE_ERROR_INVALID_SSL', 37);
139
/**#@-*/
132
/**#@-*/
Line 148... Line 141...
148
 * The Channel handling class
141
 * The Channel handling class
149
 *
142
 *
150
 * @category   pear
143
 * @category   pear
151
 * @package    PEAR
144
 * @package    PEAR
152
 * @author     Greg Beaver <cellog@php.net>
145
 * @author     Greg Beaver <cellog@php.net>
153
 * @copyright  1997-2006 The PHP Group
146
 * @copyright  1997-2009 The Authors
154
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
147
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
155
 * @version    Release: 1.5.1
148
 * @version    Release: 1.10.1
156
 * @link       http://pear.php.net/package/PEAR
149
 * @link       http://pear.php.net/package/PEAR
157
 * @since      Class available since Release 1.4.0a1
150
 * @since      Class available since Release 1.4.0a1
158
 */
151
 */
159
class PEAR_ChannelFile {
152
class PEAR_ChannelFile
-
 
153
{
160
    /**
154
    /**
161
     * @access private
155
     * @access private
162
     * @var PEAR_ErrorStack
156
     * @var PEAR_ErrorStack
163
     * @access private
157
     * @access private
164
     */
158
     */
165
    var $_stack;
159
    var $_stack;
166
    
160
 
167
    /**
161
    /**
168
     * Supported channel.xml versions, for parsing
162
     * Supported channel.xml versions, for parsing
169
     * @var array
163
     * @var array
170
     * @access private
164
     * @access private
171
     */
165
     */
Line 189... Line 183...
189
     * index into the mirrors array, used for parsing xml
183
     * index into the mirrors array, used for parsing xml
190
     * @var int
184
     * @var int
191
     * @access private
185
     * @access private
192
     */
186
     */
193
    var $_mirrorIndex;
187
    var $_mirrorIndex;
194
    
188
 
195
    /**
189
    /**
196
     * Flag used to determine the validity of parsed content
190
     * Flag used to determine the validity of parsed content
197
     * @var boolean
191
     * @var boolean
198
     * @access private
192
     * @access private
199
     */
193
     */
200
    var $_isValid = false;
194
    var $_isValid = false;
Line 201... Line 195...
201
 
195
 
202
    function PEAR_ChannelFile()
196
    function __construct()
203
    {
197
    {
204
        $this->_stack = &new PEAR_ErrorStack('PEAR_ChannelFile');
198
        $this->_stack = new PEAR_ErrorStack('PEAR_ChannelFile');
205
        $this->_stack->setErrorMessageTemplate($this->_getErrorMessage());
199
        $this->_stack->setErrorMessageTemplate($this->_getErrorMessage());
206
        $this->_isValid = false;
200
        $this->_isValid = false;
207
    }
201
    }
208
    
202
 
209
    /**
203
    /**
210
     * @return array
204
     * @return array
211
     * @access protected
205
     * @access protected
212
     */
206
     */
Line 282... Line 276...
282
            $parser = new PEAR_XMLParser;
276
            $parser = new PEAR_XMLParser;
283
            $result = $parser->parse($data);
277
            $result = $parser->parse($data);
284
            if ($result !== true) {
278
            if ($result !== true) {
285
                if ($result->getCode() == 1) {
279
                if ($result->getCode() == 1) {
286
                    $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_XML_EXT, 'error',
280
                    $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_XML_EXT, 'error',
287
                        array('error' => $error));
281
                        array('error' => $result->getMessage()));
288
                } else {
282
                } else {
289
                    $this->_stack->push(PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, 'error');
283
                    $this->_stack->push(PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, 'error');
290
                }
284
                }
291
                return false;
285
                return false;
292
            }
286
            }
Line 295... Line 289...
295
        } else {
289
        } else {
296
            $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_VERSION, 'error', array('xml' => $data));
290
            $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_VERSION, 'error', array('xml' => $data));
297
            return false;
291
            return false;
298
        }
292
        }
299
    }
293
    }
300
    
294
 
301
    /**
295
    /**
302
     * @return array
296
     * @return array
303
     */
297
     */
304
    function toArray()
298
    function toArray()
305
    {
299
    {
306
        if (!$this->_isValid && !$this->validate()) {
300
        if (!$this->_isValid && !$this->validate()) {
307
            return false;
301
            return false;
308
        }
302
        }
309
        return $this->_channelInfo;
303
        return $this->_channelInfo;
310
    }
304
    }
311
    
305
 
312
    /**
306
    /**
313
     * @param array
307
     * @param array
314
     * @static
308
     *
315
     * @return PEAR_ChannelFile|false false if invalid
309
     * @return PEAR_ChannelFile|false false if invalid
316
     */
310
     */
-
 
311
    public static function &fromArray(
317
    function &fromArray($data, $compatibility = false, $stackClass = 'PEAR_ErrorStack')
312
        $data, $compatibility = false, $stackClass = 'PEAR_ErrorStack'
318
    {
313
    ) {
319
        $a = new PEAR_ChannelFile($compatibility, $stackClass);
314
        $a = new PEAR_ChannelFile($compatibility, $stackClass);
320
        $a->_fromArray($data);
315
        $a->_fromArray($data);
321
        if (!$a->validate()) {
316
        if (!$a->validate()) {
322
            $a = false;
317
            $a = false;
323
            return $a;
318
            return $a;
Line 325... Line 320...
325
        return $a;
320
        return $a;
326
    }
321
    }
Line 327... Line 322...
327
 
322
 
328
    /**
323
    /**
-
 
324
     * Unlike {@link fromArray()} this does not do any validation
329
     * Unlike {@link fromArray()} this does not do any validation
325
     *
330
     * @param array
326
     * @param array
331
     * @static
327
     *
332
     * @return PEAR_ChannelFile
328
     * @return PEAR_ChannelFile
333
     */
329
     */
334
    function &fromArrayWithErrors($data, $compatibility = false,
330
    public static function &fromArrayWithErrors(
335
                                  $stackClass = 'PEAR_ErrorStack')
331
        $data, $compatibility = false, $stackClass = 'PEAR_ErrorStack'
336
    {
332
    ) {
337
        $a = new PEAR_ChannelFile($compatibility, $stackClass);
333
        $a = new PEAR_ChannelFile($compatibility, $stackClass);
338
        $a->_fromArray($data);
334
        $a->_fromArray($data);
339
        return $a;
335
        return $a;
340
    }
336
    }
341
    
337
 
342
    /**
338
    /**
343
     * @param array
339
     * @param array
344
     * @access private
340
     * @access private
345
     */
341
     */
346
    function _fromArray($data)
342
    function _fromArray($data)
347
    {
343
    {
348
        $this->_channelInfo = $data;
344
        $this->_channelInfo = $data;
349
    }
345
    }
350
    
346
 
351
    /**
347
    /**
352
     * Wrapper to {@link PEAR_ErrorStack::getErrors()}
348
     * Wrapper to {@link PEAR_ErrorStack::getErrors()}
353
     * @param boolean determines whether to purge the error stack after retrieving
349
     * @param boolean determines whether to purge the error stack after retrieving
354
     * @return array
350
     * @return array
Line 482... Line 478...
482
        }
478
        }
483
        if (isset($channelInfo['servers']['primary']['attribs']['port'])) {
479
        if (isset($channelInfo['servers']['primary']['attribs']['port'])) {
484
            $ret .= ' port="' . $channelInfo['servers']['primary']['attribs']['port'] . '"';
480
            $ret .= ' port="' . $channelInfo['servers']['primary']['attribs']['port'] . '"';
485
        }
481
        }
486
        $ret .= ">\n";
482
        $ret .= ">\n";
487
        if (isset($channelInfo['servers']['primary']['xmlrpc'])) {
-
 
488
            $ret .= $this->_makeXmlrpcXml($channelInfo['servers']['primary']['xmlrpc'], '   ');
-
 
489
        }
-
 
490
        if (isset($channelInfo['servers']['primary']['rest'])) {
483
        if (isset($channelInfo['servers']['primary']['rest'])) {
491
            $ret .= $this->_makeRestXml($channelInfo['servers']['primary']['rest'], '   ');
484
            $ret .= $this->_makeRestXml($channelInfo['servers']['primary']['rest'], '   ');
492
        }
485
        }
493
        if (isset($channelInfo['servers']['primary']['soap'])) {
-
 
494
            $ret .= $this->_makeSoapXml($channelInfo['servers']['primary']['soap'], '   ');
-
 
495
        }
-
 
496
        $ret .= "  </primary>\n";
486
        $ret .= "  </primary>\n";
497
        if (isset($channelInfo['servers']['mirror'])) {
487
        if (isset($channelInfo['servers']['mirror'])) {
498
            $ret .= $this->_makeMirrorsXml($channelInfo);
488
            $ret .= $this->_makeMirrorsXml($channelInfo);
499
        }
489
        }
500
        $ret .= " </servers>\n";
490
        $ret .= " </servers>\n";
501
        $ret .= "</channel>";
491
        $ret .= "</channel>";
502
        return str_replace("\r", "\n", str_replace("\r\n", "\n", $ret));
492
        return str_replace("\r", "\n", str_replace("\r\n", "\n", $ret));
503
    }
493
    }
Line 504... Line 494...
504
 
494
 
505
    /**
-
 
506
     * Generate the <xmlrpc> tag
-
 
507
     * @access private
-
 
508
     */
-
 
509
    function _makeXmlrpcXml($info, $indent)
-
 
510
    {
-
 
511
        $ret = $indent . "<xmlrpc";
-
 
512
        if (isset($info['attribs']['path'])) {
-
 
513
            $ret .= ' path="' . htmlspecialchars($info['attribs']['path']) . '"';
-
 
514
        }
-
 
515
        $ret .= ">\n";
-
 
516
        $ret .= $this->_makeFunctionsXml($info['function'], "$indent ");
-
 
517
        $ret .= $indent . "</xmlrpc>\n";
-
 
518
        return $ret;
-
 
519
    }
-
 
520
 
-
 
521
    /**
-
 
522
     * Generate the <soap> tag
-
 
523
     * @access private
-
 
524
     */
-
 
525
    function _makeSoapXml($info, $indent)
-
 
526
    {
-
 
527
        $ret = $indent . "<soap";
-
 
528
        if (isset($info['attribs']['path'])) {
-
 
529
            $ret .= ' path="' . htmlspecialchars($info['attribs']['path']) . '"';
-
 
530
        }
-
 
531
        $ret .= ">\n";
-
 
532
        $ret .= $this->_makeFunctionsXml($info['function'], "$indent ");
-
 
533
        $ret .= $indent . "</soap>\n";
-
 
534
        return $ret;
-
 
535
    }
-
 
536
 
-
 
537
    /**
495
    /**
538
     * Generate the <rest> tag
496
     * Generate the <rest> tag
539
     * @access private
497
     * @access private
540
     */
498
     */
541
    function _makeRestXml($info, $indent)
499
    function _makeRestXml($info, $indent)
542
    {
500
    {
543
        $ret = $indent . "<rest>\n";
501
        $ret = $indent . "<rest>\n";
544
        if (!isset($info['baseurl'][0])) {
502
        if (isset($info['baseurl']) && !isset($info['baseurl'][0])) {
545
            $info['baseurl'] = array($info['baseurl']);
503
            $info['baseurl'] = array($info['baseurl']);
-
 
504
        }
-
 
505
 
546
        }
506
        if (isset($info['baseurl'])) {
547
        foreach ($info['baseurl'] as $url) {
507
            foreach ($info['baseurl'] as $url) {
548
            $ret .= "$indent <baseurl type=\"" . $url['attribs']['type'] . "\"";
508
                $ret .= "$indent <baseurl type=\"" . $url['attribs']['type'] . "\"";
-
 
509
                $ret .= ">" . $url['_content'] . "</baseurl>\n";
549
            $ret .= ">" . $url['_content'] . "</baseurl>\n";
510
            }
550
        }
511
        }
551
        $ret .= $indent . "</rest>\n";
512
        $ret .= $indent . "</rest>\n";
552
        return $ret;
513
        return $ret;
Line 569... Line 530...
569
            }
530
            }
570
            if (isset($mirror['attribs']['ssl'])) {
531
            if (isset($mirror['attribs']['ssl'])) {
571
                $ret .= ' ssl="' . $mirror['attribs']['ssl'] . '"';
532
                $ret .= ' ssl="' . $mirror['attribs']['ssl'] . '"';
572
            }
533
            }
573
            $ret .= ">\n";
534
            $ret .= ">\n";
574
            if (isset($mirror['xmlrpc']) || isset($mirror['soap'])) {
-
 
575
                if (isset($mirror['xmlrpc'])) {
535
            if (isset($mirror['rest'])) {
576
                    $ret .= $this->_makeXmlrpcXml($mirror['xmlrpc'], '   ');
-
 
577
                }
-
 
578
                if (isset($mirror['rest'])) {
536
                if (isset($mirror['rest'])) {
579
                    $ret .= $this->_makeRestXml($mirror['rest'], '   ');
537
                    $ret .= $this->_makeRestXml($mirror['rest'], '   ');
580
                }
538
                }
581
                if (isset($mirror['soap'])) {
-
 
582
                    $ret .= $this->_makeSoapXml($mirror['soap'], '   ');
-
 
583
                }
-
 
584
                $ret .= "  </mirror>\n";
539
                $ret .= "  </mirror>\n";
585
            } else {
540
            } else {
586
                $ret .= "/>\n";
541
                $ret .= "/>\n";
587
            }
542
            }
588
        }
543
        }
Line 678... Line 633...
678
                    null;
633
                    null;
679
                $this->_validateError(PEAR_CHANNELFILE_ERROR_NOVALIDATE_VERSION,
634
                $this->_validateError(PEAR_CHANNELFILE_ERROR_NOVALIDATE_VERSION,
680
                    array('package' => $content));
635
                    array('package' => $content));
681
            }
636
            }
682
        }
637
        }
-
 
638
 
683
        if (isset($info['servers']['primary']['attribs']['port']) &&
639
        if (isset($info['servers']['primary']['attribs'], $info['servers']['primary']['attribs']['port']) &&
684
              !is_numeric($info['servers']['primary']['attribs']['port'])) {
640
              !is_numeric($info['servers']['primary']['attribs']['port'])) {
685
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_PORT,
641
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_PORT,
686
                array('port' => $info['servers']['primary']['attribs']['port']));
642
                array('port' => $info['servers']['primary']['attribs']['port']));
687
        }
643
        }
-
 
644
 
688
        if (isset($info['servers']['primary']['attribs']['ssl']) &&
645
        if (isset($info['servers']['primary']['attribs'], $info['servers']['primary']['attribs']['ssl']) &&
689
              $info['servers']['primary']['attribs']['ssl'] != 'yes') {
646
              $info['servers']['primary']['attribs']['ssl'] != 'yes') {
690
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_SSL,
647
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_SSL,
691
                array('ssl' => $info['servers']['primary']['attribs']['ssl'],
648
                array('ssl' => $info['servers']['primary']['attribs']['ssl'],
692
                    'server' => $info['name']));
649
                    'server' => $info['name']));
693
        }
650
        }
Line 694... Line -...
694
 
-
 
695
        if (isset($info['servers']['primary']['xmlrpc']) &&
-
 
696
              isset($info['servers']['primary']['xmlrpc']['function'])) {
-
 
697
            $this->_validateFunctions('xmlrpc', $info['servers']['primary']['xmlrpc']['function']);
-
 
698
        }
-
 
699
        if (isset($info['servers']['primary']['soap']) &&
-
 
700
              isset($info['servers']['primary']['soap']['function'])) {
-
 
701
            $this->_validateFunctions('soap', $info['servers']['primary']['soap']['function']);
-
 
702
        }
651
 
703
        if (isset($info['servers']['primary']['rest']) &&
652
        if (isset($info['servers']['primary']['rest']) &&
704
              isset($info['servers']['primary']['rest']['baseurl'])) {
653
              isset($info['servers']['primary']['rest']['baseurl'])) {
705
            $this->_validateFunctions('rest', $info['servers']['primary']['rest']['baseurl']);
654
            $this->_validateFunctions('rest', $info['servers']['primary']['rest']['baseurl']);
706
        }
655
        }
Line 709... Line 658...
709
                $this->_validateError(PEAR_CHANNELFILE_URI_CANT_MIRROR);
658
                $this->_validateError(PEAR_CHANNELFILE_URI_CANT_MIRROR);
710
            }
659
            }
711
            if (!isset($info['servers']['mirror'][0])) {
660
            if (!isset($info['servers']['mirror'][0])) {
712
                $info['servers']['mirror'] = array($info['servers']['mirror']);
661
                $info['servers']['mirror'] = array($info['servers']['mirror']);
713
            }
662
            }
714
            $i = 0;
-
 
715
            foreach ($info['servers']['mirror'] as $mirror) {
663
            foreach ($info['servers']['mirror'] as $mirror) {
716
                if (!isset($mirror['attribs']['host'])) {
664
                if (!isset($mirror['attribs']['host'])) {
717
                    $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_HOST,
665
                    $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_HOST,
718
                      array('type' => 'mirror'));
666
                      array('type' => 'mirror'));
719
                } elseif (!$this->validChannelServer($mirror['attribs']['host'])) {
667
                } elseif (!$this->validChannelServer($mirror['attribs']['host'])) {
Line 722... Line 670...
722
                }
670
                }
723
                if (isset($mirror['attribs']['ssl']) && $mirror['attribs']['ssl'] != 'yes') {
671
                if (isset($mirror['attribs']['ssl']) && $mirror['attribs']['ssl'] != 'yes') {
724
                    $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_SSL,
672
                    $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_SSL,
725
                        array('ssl' => $info['ssl'], 'server' => $mirror['attribs']['host']));
673
                        array('ssl' => $info['ssl'], 'server' => $mirror['attribs']['host']));
726
                }
674
                }
727
                if (isset($mirror['xmlrpc'])) {
-
 
728
                    $this->_validateFunctions('xmlrpc',
-
 
729
                        $mirror['xmlrpc']['function'], $mirror['attribs']['host']);
-
 
730
                }
-
 
731
                if (isset($mirror['soap'])) {
-
 
732
                    $this->_validateFunctions('soap', $mirror['soap']['function'],
-
 
733
                        $mirror['attribs']['host']);
-
 
734
                }
-
 
735
                if (isset($mirror['rest'])) {
675
                if (isset($mirror['rest'])) {
736
                    $this->_validateFunctions('rest', $mirror['rest']['baseurl'],
676
                    $this->_validateFunctions('rest', $mirror['rest']['baseurl'],
737
                        $mirror['attribs']['host']);
677
                        $mirror['attribs']['host']);
738
                }
678
                }
739
            }
679
            }
740
        }
680
        }
741
        return $this->_isValid;
681
        return $this->_isValid;
742
    }
682
    }
Line 743... Line 683...
743
 
683
 
744
    /**
684
    /**
745
     * @param string xmlrpc or soap - protocol name this function applies to
685
     * @param string  rest - protocol name this function applies to
746
     * @param array the functions
686
     * @param array the functions
747
     * @param string the name of the parent element (mirror name, for instance)
687
     * @param string the name of the parent element (mirror name, for instance)
748
     */
688
     */
749
    function _validateFunctions($protocol, $functions, $parent = '')
689
    function _validateFunctions($protocol, $functions, $parent = '')
750
    {
690
    {
751
        if (!isset($functions[0])) {
691
        if (!isset($functions[0])) {
752
            $functions = array($functions);
692
            $functions = array($functions);
-
 
693
        }
753
        }
694
 
754
        foreach ($functions as $function) {
695
        foreach ($functions as $function) {
755
            if (!isset($function['_content']) || empty($function['_content'])) {
696
            if (!isset($function['_content']) || empty($function['_content'])) {
756
                $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_FUNCTIONNAME,
697
                $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_FUNCTIONNAME,
757
                    array('parent' => $parent, 'protocol' => $protocol));
698
                    array('parent' => $parent, 'protocol' => $protocol));
-
 
699
            }
758
            }
700
 
759
            if ($protocol == 'rest') {
701
            if ($protocol == 'rest') {
760
                if (!isset($function['attribs']['type']) ||
702
                if (!isset($function['attribs']['type']) ||
761
                      empty($function['attribs']['type'])) {
703
                      empty($function['attribs']['type'])) {
762
                    $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_BASEURLTYPE,
704
                    $this->_validateError(PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE,
763
                        array('parent' => $parent, 'protocol' => $protocol));
705
                        array('parent' => $parent, 'protocol' => $protocol));
764
                }
706
                }
765
            } else {
707
            } else {
766
                if (!isset($function['attribs']['version']) ||
708
                if (!isset($function['attribs']['version']) ||
Line 790... Line 732...
790
     */
732
     */
791
    function getName()
733
    function getName()
792
    {
734
    {
793
        if (isset($this->_channelInfo['name'])) {
735
        if (isset($this->_channelInfo['name'])) {
794
            return $this->_channelInfo['name'];
736
            return $this->_channelInfo['name'];
795
        } else {
-
 
796
            return false;
-
 
797
        }
737
        }
-
 
738
 
-
 
739
        return false;
798
    }
740
    }
Line 799... Line 741...
799
 
741
 
800
    /**
742
    /**
801
     * @return string|false
743
     * @return string|false
802
     */
744
     */
803
    function getServer()
745
    function getServer()
804
    {
746
    {
805
        if (isset($this->_channelInfo['name'])) {
747
        if (isset($this->_channelInfo['name'])) {
806
            return $this->_channelInfo['name'];
-
 
807
        } else {
-
 
808
            return false;
748
            return $this->_channelInfo['name'];
-
 
749
        }
-
 
750
 
809
        }
751
        return false;
Line 810... Line 752...
810
    }
752
    }
811
 
753
 
812
    /**
754
    /**
Line 816... Line 758...
816
    {
758
    {
817
        if ($mirror) {
759
        if ($mirror) {
818
            if ($mir = $this->getMirror($mirror)) {
760
            if ($mir = $this->getMirror($mirror)) {
819
                if (isset($mir['attribs']['port'])) {
761
                if (isset($mir['attribs']['port'])) {
820
                    return $mir['attribs']['port'];
762
                    return $mir['attribs']['port'];
821
                } else {
-
 
822
                    if ($this->getSSL($mirror)) {
-
 
823
                        return 443;
-
 
824
                    }
-
 
825
                    return 80;
-
 
826
                }
763
                }
-
 
764
 
-
 
765
                if ($this->getSSL($mirror)) {
-
 
766
                    return 443;
-
 
767
                }
-
 
768
 
-
 
769
                return 80;
827
            }
770
            }
-
 
771
 
828
            return false;
772
            return false;
829
        }
773
        }
-
 
774
 
830
        if (isset($this->_channelInfo['servers']['primary']['attribs']['port'])) {
775
        if (isset($this->_channelInfo['servers']['primary']['attribs']['port'])) {
831
            return $this->_channelInfo['servers']['primary']['attribs']['port'];
776
            return $this->_channelInfo['servers']['primary']['attribs']['port'];
832
        }
777
        }
-
 
778
 
833
        if ($this->getSSL()) {
779
        if ($this->getSSL()) {
834
            return 443;
780
            return 443;
835
        }
781
        }
-
 
782
 
836
        return 80;
783
        return 80;
837
    }
784
    }
Line 838... Line 785...
838
 
785
 
839
    /**
786
    /**
Line 843... Line 790...
843
    {
790
    {
844
        if ($mirror) {
791
        if ($mirror) {
845
            if ($mir = $this->getMirror($mirror)) {
792
            if ($mir = $this->getMirror($mirror)) {
846
                if (isset($mir['attribs']['ssl'])) {
793
                if (isset($mir['attribs']['ssl'])) {
847
                    return true;
794
                    return true;
848
                } else {
-
 
849
                    return false;
-
 
850
                }
795
                }
-
 
796
 
-
 
797
                return false;
851
            }
798
            }
-
 
799
 
852
            return false;
800
            return false;
853
        }
801
        }
-
 
802
 
854
        if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {
803
        if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {
855
            return true;
804
            return true;
856
        }
805
        }
-
 
806
 
857
        return false;
807
        return false;
858
    }
808
    }
Line 859... Line 809...
859
 
809
 
860
    /**
810
    /**
861
     * @return string|false
811
     * @return string|false
862
     */
812
     */
863
    function getSummary()
813
    function getSummary()
864
    {
814
    {
865
        if (isset($this->_channelInfo['summary'])) {
815
        if (isset($this->_channelInfo['summary'])) {
866
            return $this->_channelInfo['summary'];
-
 
867
        } else {
-
 
868
            return false;
816
            return $this->_channelInfo['summary'];
869
        }
-
 
Line 870... Line -...
870
    }
-
 
871
 
-
 
872
    /**
-
 
873
     * @param string xmlrpc or soap
-
 
874
     * @param string|false mirror name or false for primary server
-
 
875
     */
-
 
876
    function getPath($protocol, $mirror = false)
-
 
877
    {   
817
        }
878
        if (!in_array($protocol, array('xmlrpc', 'soap'))) {
-
 
879
            return false;
-
 
880
        }
-
 
881
        if ($mirror) {
-
 
882
            if (!($mir = $this->getMirror($mirror))) {
-
 
883
                return false;
-
 
884
            }
-
 
885
            if (isset($mir[$protocol]['attribs']['path'])) {
-
 
886
                return $mir[$protocol]['attribs']['path'];
-
 
887
            } else {
-
 
888
                return $protocol . '.php';
-
 
889
            }
-
 
890
        } elseif (isset($this->_channelInfo['servers']['primary'][$protocol]['attribs']['path'])) {
-
 
891
            return $this->_channelInfo['servers']['primary'][$protocol]['attribs']['path'];
-
 
892
        }
818
 
Line 893... Line 819...
893
        return $protocol . '.php';
819
        return false;
894
    }
820
    }
895
 
821
 
896
    /**
822
    /**
897
     * @param string protocol type (xmlrpc, soap)
823
     * @param string protocol type
898
     * @param string Mirror name
824
     * @param string Mirror name
899
     * @return array|false
825
     * @return array|false
900
     */
826
     */
901
    function getFunctions($protocol, $mirror = false)
827
    function getFunctions($protocol, $mirror = false)
902
    {
828
    {
-
 
829
        if ($this->getName() == '__uri') {
903
        if ($this->getName() == '__uri') {
830
            return false;
904
            return false;
-
 
905
        }
-
 
906
        if ($protocol == 'rest') {
-
 
907
            $function = 'baseurl';
-
 
908
        } else {
831
        }
909
            $function = 'function';
832
 
910
        }
833
        $function = $protocol == 'rest' ? 'baseurl' : 'function';
911
        if ($mirror) {
834
        if ($mirror) {
912
            if ($mir = $this->getMirror($mirror)) {
835
            if ($mir = $this->getMirror($mirror)) {
913
                if (isset($mir[$protocol][$function])) {
836
                if (isset($mir[$protocol][$function])) {
-
 
837
                    return $mir[$protocol][$function];
914
                    return $mir[$protocol][$function];
838
                }
915
                }
839
            }
-
 
840
 
916
            }
841
            return false;
917
            return false;
842
        }
918
        }
-
 
919
        if (isset($this->_channelInfo['servers']['primary'][$protocol][$function])) {
-
 
920
            return $this->_channelInfo['servers']['primary'][$protocol][$function];
843
 
-
 
844
        if (isset($this->_channelInfo['servers']['primary'][$protocol][$function])) {
-
 
845
            return $this->_channelInfo['servers']['primary'][$protocol][$function];
921
        } else {
846
        }
Line 922... Line 847...
922
            return false;
847
 
923
        }
848
        return false;
924
    }
849
    }
Line 934... Line 859...
934
     {
859
     {
935
        $protocols = $this->getFunctions($type, $mirror);
860
        $protocols = $this->getFunctions($type, $mirror);
936
        if (!$protocols) {
861
        if (!$protocols) {
937
            return false;
862
            return false;
938
        }
863
        }
-
 
864
 
939
        foreach ($protocols as $protocol) {
865
        foreach ($protocols as $protocol) {
940
            if ($name === null) {
866
            if ($name === null) {
941
                return $protocol;
867
                return $protocol;
942
            }
868
            }
-
 
869
 
943
            if ($protocol['_content'] != $name) {
870
            if ($protocol['_content'] != $name) {
944
                continue;
871
                continue;
945
            }
872
            }
-
 
873
 
946
            return $protocol;
874
            return $protocol;
947
        }
875
        }
-
 
876
 
948
        return false;
877
        return false;
949
     }
878
     }
Line 950... Line 879...
950
 
879
 
951
    /**
880
    /**
Line 959... Line 888...
959
    {
888
    {
960
        $protocols = $this->getFunctions($type, $mirror);
889
        $protocols = $this->getFunctions($type, $mirror);
961
        if (!$protocols) {
890
        if (!$protocols) {
962
            return false;
891
            return false;
963
        }
892
        }
-
 
893
 
964
        foreach ($protocols as $protocol) {
894
        foreach ($protocols as $protocol) {
965
            if ($protocol['attribs']['version'] != $version) {
895
            if ($protocol['attribs']['version'] != $version) {
966
                continue;
896
                continue;
967
            }
897
            }
-
 
898
 
968
            if ($name === null) {
899
            if ($name === null) {
969
                return true;
900
                return true;
970
            }
901
            }
-
 
902
 
971
            if ($protocol['_content'] != $name) {
903
            if ($protocol['_content'] != $name) {
972
                continue;
904
                continue;
973
            }
905
            }
-
 
906
 
974
            return true;
907
            return true;
975
        }
908
        }
-
 
909
 
976
        return false;
910
        return false;
977
    }
911
    }
Line 978... Line 912...
978
 
912
 
979
    /**
913
    /**
Line 985... Line 919...
985
    function supportsREST($mirror = false)
919
    function supportsREST($mirror = false)
986
    {
920
    {
987
        if ($mirror == $this->_channelInfo['name']) {
921
        if ($mirror == $this->_channelInfo['name']) {
988
            $mirror = false;
922
            $mirror = false;
989
        }
923
        }
-
 
924
 
990
        if ($mirror) {
925
        if ($mirror) {
991
            if ($mir = $this->getMirror($mirror)) {
926
            if ($mir = $this->getMirror($mirror)) {
992
                return isset($mir['rest']);
927
                return isset($mir['rest']);
993
            }
928
            }
-
 
929
 
994
            return false;
930
            return false;
995
        }
931
        }
-
 
932
 
996
        return isset($this->_channelInfo['servers']['primary']['rest']);
933
        return isset($this->_channelInfo['servers']['primary']['rest']);
997
    }
934
    }
Line 998... Line 935...
998
 
935
 
999
    /**
936
    /**
Line 1006... Line 943...
1006
    function getBaseURL($resourceType, $mirror = false)
943
    function getBaseURL($resourceType, $mirror = false)
1007
    {
944
    {
1008
        if ($mirror == $this->_channelInfo['name']) {
945
        if ($mirror == $this->_channelInfo['name']) {
1009
            $mirror = false;
946
            $mirror = false;
1010
        }
947
        }
-
 
948
 
1011
        if ($mirror) {
949
        if ($mirror) {
1012
            if ($mir = $this->getMirror($mirror)) {
950
            $mir = $this->getMirror($mirror);
1013
                $rest = $mir['rest'];
-
 
1014
            } else {
951
            if (!$mir) {
1015
                return false;
952
                return false;
1016
            }
953
            }
-
 
954
 
1017
            $server = $mirror;
955
            $rest = $mir['rest'];
1018
        } else {
956
        } else {
1019
            $rest = $this->_channelInfo['servers']['primary']['rest'];
957
            $rest = $this->_channelInfo['servers']['primary']['rest'];
1020
            $server = $this->getServer();
-
 
1021
        }
958
        }
-
 
959
 
1022
        if (!isset($rest['baseurl'][0])) {
960
        if (!isset($rest['baseurl'][0])) {
1023
            $rest['baseurl'] = array($rest['baseurl']);
961
            $rest['baseurl'] = array($rest['baseurl']);
1024
        }
962
        }
-
 
963
 
1025
        foreach ($rest['baseurl'] as $baseurl) {
964
        foreach ($rest['baseurl'] as $baseurl) {
1026
            if (strtolower($baseurl['attribs']['type']) == strtolower($resourceType)) {
965
            if (strtolower($baseurl['attribs']['type']) == strtolower($resourceType)) {
1027
                return $baseurl['_content'];
966
                return $baseurl['_content'];
1028
            }
967
            }
1029
        }
968
        }
-
 
969
 
1030
        return false;
970
        return false;
1031
    }
971
    }
Line 1032... Line 972...
1032
 
972
 
1033
    /**
973
    /**
Line 1040... Line 980...
1040
        return $this->resetFunctions('rest', $mirror);
980
        return $this->resetFunctions('rest', $mirror);
1041
    }
981
    }
Line 1042... Line 982...
1042
 
982
 
1043
    /**
983
    /**
1044
     * Empty all protocol definitions
984
     * Empty all protocol definitions
1045
     * @param string protocol type (xmlrpc, soap)
985
     * @param string protocol type
1046
     * @param string|false mirror name, if any
986
     * @param string|false mirror name, if any
1047
     */
987
     */
1048
    function resetFunctions($type, $mirror = false)
988
    function resetFunctions($type, $mirror = false)
1049
    {
989
    {
1050
        if ($mirror) {
990
        if ($mirror) {
1051
            if (isset($this->_channelInfo['servers']['mirror'])) {
991
            if (isset($this->_channelInfo['servers']['mirror'])) {
1052
                $mirrors = $this->_channelInfo['servers']['mirror'];
992
                $mirrors = $this->_channelInfo['servers']['mirror'];
1053
                if (!isset($mirrors[0])) {
993
                if (!isset($mirrors[0])) {
1054
                    $mirrors = array($mirrors);
994
                    $mirrors = array($mirrors);
-
 
995
                }
1055
                }
996
 
1056
                foreach ($mirrors as $i => $mir) {
997
                foreach ($mirrors as $i => $mir) {
1057
                    if ($mir['attribs']['host'] == $mirror) {
998
                    if ($mir['attribs']['host'] == $mirror) {
1058
                        if (isset($this->_channelInfo['servers']['mirror'][$i][$type])) {
999
                        if (isset($this->_channelInfo['servers']['mirror'][$i][$type])) {
1059
                            unset($this->_channelInfo['servers']['mirror'][$i][$type]);
1000
                            unset($this->_channelInfo['servers']['mirror'][$i][$type]);
-
 
1001
                        }
1060
                        }
1002
 
1061
                        return true;
1003
                        return true;
1062
                    }
1004
                    }
-
 
1005
                }
1063
                }
1006
 
1064
                return false;
-
 
1065
            } else {
-
 
1066
                return false;
-
 
1067
            }
-
 
1068
        } else {
-
 
1069
            if (isset($this->_channelInfo['servers']['primary'][$type])) {
-
 
1070
                unset($this->_channelInfo['servers']['primary'][$type]);
1007
                return false;
-
 
1008
            }
1071
            }
1009
 
1072
            return true;
1010
            return false;
-
 
1011
        }
-
 
1012
 
-
 
1013
        if (isset($this->_channelInfo['servers']['primary'][$type])) {
-
 
1014
            unset($this->_channelInfo['servers']['primary'][$type]);
-
 
1015
        }
-
 
1016
 
1073
        }
1017
        return true;
Line 1074... Line 1018...
1074
    }
1018
    }
1075
 
1019
 
1076
    /**
1020
    /**
1077
     * Set a channel's protocols to the protocols supported by pearweb
1021
     * Set a channel's protocols to the protocols supported by pearweb
1078
     */
1022
     */
1079
    function setDefaultPEARProtocols($version = '1.0', $mirror = false)
1023
    function setDefaultPEARProtocols($version = '1.0', $mirror = false)
1080
    {
1024
    {
1081
        switch ($version) {
-
 
1082
            case '1.0' :
-
 
1083
                $this->resetFunctions('xmlrpc', $mirror);
1025
        switch ($version) {
-
 
1026
            case '1.0' :
1084
                $this->resetFunctions('soap', $mirror);
1027
                $this->resetREST($mirror);
1085
                $this->resetREST($mirror);
-
 
1086
                $this->addFunction('xmlrpc', '1.0', 'logintest', $mirror);
1028
 
1087
                $this->addFunction('xmlrpc', '1.0', 'package.listLatestReleases', $mirror);
1029
                if (!isset($this->_channelInfo['servers'])) {
1088
                $this->addFunction('xmlrpc', '1.0', 'package.listAll', $mirror);
-
 
1089
                $this->addFunction('xmlrpc', '1.0', 'package.info', $mirror);
1030
                    $this->_channelInfo['servers'] = array('primary' =>
1090
                $this->addFunction('xmlrpc', '1.0', 'package.getDownloadURL', $mirror);
-
 
1091
                $this->addFunction('xmlrpc', '1.1', 'package.getDownloadURL', $mirror);
-
 
1092
                $this->addFunction('xmlrpc', '1.0', 'package.getDepDownloadURL', $mirror);
1031
                        array('rest' => array()));
1093
                $this->addFunction('xmlrpc', '1.1', 'package.getDepDownloadURL', $mirror);
1032
                } elseif (!isset($this->_channelInfo['servers']['primary'])) {
-
 
1033
                    $this->_channelInfo['servers']['primary'] = array('rest' => array());
1094
                $this->addFunction('xmlrpc', '1.0', 'package.search', $mirror);
1034
                }
1095
                $this->addFunction('xmlrpc', '1.0', 'channel.listAll', $mirror);
1035
 
1096
                return true;
1036
                return true;
1097
            break;
1037
            break;
1098
            default :
1038
            default :
1099
                return false;
1039
                return false;
1100
            break;
1040
            break;
1101
        }
1041
        }
1102
    }
1042
    }
1103
    
1043
 
1104
    /**
1044
    /**
1105
     * @return array
1045
     * @return array
1106
     */
1046
     */
1107
    function getMirrors()
1047
    function getMirrors()
1108
    {
1048
    {
1109
        if (isset($this->_channelInfo['servers']['mirror'])) {
1049
        if (isset($this->_channelInfo['servers']['mirror'])) {
1110
            $mirrors = $this->_channelInfo['servers']['mirror'];
1050
            $mirrors = $this->_channelInfo['servers']['mirror'];
1111
            if (!isset($mirrors[0])) {
1051
            if (!isset($mirrors[0])) {
-
 
1052
                $mirrors = array($mirrors);
1112
                $mirrors = array($mirrors);
1053
            }
1113
            }
-
 
1114
            return $mirrors;
-
 
1115
        } else {
1054
 
-
 
1055
            return $mirrors;
-
 
1056
        }
1116
            return array();
1057
 
Line 1117... Line 1058...
1117
        }
1058
        return array();
1118
    }
1059
    }
1119
 
1060
 
Line 1126... Line 1067...
1126
        foreach ($this->getMirrors() as $mirror) {
1067
        foreach ($this->getMirrors() as $mirror) {
1127
            if ($mirror['attribs']['host'] == $server) {
1068
            if ($mirror['attribs']['host'] == $server) {
1128
                return $mirror;
1069
                return $mirror;
1129
            }
1070
            }
1130
        }
1071
        }
-
 
1072
 
1131
        return false;
1073
        return false;
1132
    }
1074
    }
Line 1133... Line 1075...
1133
 
1075
 
1134
    /**
1076
    /**
Line 1153... Line 1095...
1153
            if (!isset($this->_channelInfo['servers']['mirror'])) {
1095
            if (!isset($this->_channelInfo['servers']['mirror'])) {
1154
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1096
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1155
                    array('mirror' => $mirror));
1097
                    array('mirror' => $mirror));
1156
                return false;
1098
                return false;
1157
            }
1099
            }
1158
            $setmirror = false;
-
 
-
 
1100
 
1159
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
1101
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
1160
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1102
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1161
                    if ($mirror == $mir['attribs']['host']) {
1103
                    if ($mirror == $mir['attribs']['host']) {
1162
                        $this->_channelInfo['servers']['mirror'][$i]['attribs']['port'] = $port;
1104
                        $this->_channelInfo['servers']['mirror'][$i]['attribs']['port'] = $port;
1163
                        return true;
1105
                        return true;
1164
                    }
1106
                    }
1165
                }
1107
                }
-
 
1108
 
1166
                return false;
1109
                return false;
1167
            } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1110
            } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1168
                $this->_channelInfo['servers']['mirror']['attribs']['port'] = $port;
1111
                $this->_channelInfo['servers']['mirror']['attribs']['port'] = $port;
1169
                $this->_isValid = false;
1112
                $this->_isValid = false;
1170
                return true;
1113
                return true;
1171
            }
1114
            }
1172
        }
1115
        }
-
 
1116
 
1173
        $this->_channelInfo['servers']['primary']['attribs']['port'] = $port;
1117
        $this->_channelInfo['servers']['primary']['attribs']['port'] = $port;
1174
        $this->_isValid = false;
1118
        $this->_isValid = false;
1175
        return true;
1119
        return true;
1176
    }
1120
    }
Line 1186... Line 1130...
1186
            if (!isset($this->_channelInfo['servers']['mirror'])) {
1130
            if (!isset($this->_channelInfo['servers']['mirror'])) {
1187
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1131
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1188
                    array('mirror' => $mirror));
1132
                    array('mirror' => $mirror));
1189
                return false;
1133
                return false;
1190
            }
1134
            }
1191
            $setmirror = false;
-
 
-
 
1135
 
1192
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
1136
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
1193
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1137
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1194
                    if ($mirror == $mir['attribs']['host']) {
1138
                    if ($mirror == $mir['attribs']['host']) {
1195
                        if (!$ssl) {
1139
                        if (!$ssl) {
1196
                            if (isset($this->_channelInfo['servers']['mirror'][$i]
1140
                            if (isset($this->_channelInfo['servers']['mirror'][$i]
Line 1198... Line 1142...
1198
                                unset($this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl']);
1142
                                unset($this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl']);
1199
                            }
1143
                            }
1200
                        } else {
1144
                        } else {
1201
                            $this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl'] = 'yes';
1145
                            $this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl'] = 'yes';
1202
                        }
1146
                        }
-
 
1147
 
1203
                        return true;
1148
                        return true;
1204
                    }
1149
                    }
1205
                }
1150
                }
-
 
1151
 
1206
                return false;
1152
                return false;
1207
            } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1153
            } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1208
                if (!$ssl) {
1154
                if (!$ssl) {
1209
                    if (isset($this->_channelInfo['servers']['mirror']['attribs']['ssl'])) {
1155
                    if (isset($this->_channelInfo['servers']['mirror']['attribs']['ssl'])) {
1210
                        unset($this->_channelInfo['servers']['mirror']['attribs']['ssl']);
1156
                        unset($this->_channelInfo['servers']['mirror']['attribs']['ssl']);
1211
                    }
1157
                    }
1212
                } else {
1158
                } else {
1213
                    $this->_channelInfo['servers']['mirror']['attribs']['ssl'] = 'yes';
1159
                    $this->_channelInfo['servers']['mirror']['attribs']['ssl'] = 'yes';
1214
                }
1160
                }
-
 
1161
 
1215
                $this->_isValid = false;
1162
                $this->_isValid = false;
1216
                return true;
1163
                return true;
1217
            }
1164
            }
1218
        }
1165
        }
-
 
1166
 
1219
        if ($ssl) {
1167
        if ($ssl) {
1220
            $this->_channelInfo['servers']['primary']['attribs']['ssl'] = 'yes';
1168
            $this->_channelInfo['servers']['primary']['attribs']['ssl'] = 'yes';
1221
        } else {
1169
        } else {
1222
            if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {
1170
            if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {
1223
                unset($this->_channelInfo['servers']['primary']['attribs']['ssl']);
1171
                unset($this->_channelInfo['servers']['primary']['attribs']['ssl']);
1224
            }
1172
            }
1225
        }
1173
        }
1226
        $this->_isValid = false;
-
 
1227
        return true;
-
 
1228
    }
-
 
Line 1229... Line -...
1229
 
-
 
1230
    /**
-
 
1231
     * Set the socket number (port) that is used to connect to this channel
-
 
1232
     * @param integer
-
 
1233
     * @param string|false name of the mirror server, or false for the primary
-
 
1234
     */
-
 
1235
    function setPath($protocol, $path, $mirror = false)
-
 
1236
    {
-
 
1237
        if (!in_array($protocol, array('xmlrpc', 'soap'))) {
-
 
1238
            return false;
-
 
1239
        }
-
 
1240
        if ($mirror) {
-
 
1241
            if (!isset($this->_channelInfo['servers']['mirror'])) {
-
 
1242
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
-
 
1243
                    array('mirror' => $mirror));
-
 
1244
                return false;
-
 
1245
            }
-
 
1246
            $setmirror = false;
-
 
1247
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
-
 
1248
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
-
 
1249
                    if ($mirror == $mir['attribs']['host']) {
-
 
1250
                        $this->_channelInfo['servers']['mirror'][$i][$protocol]['attribs']['path'] =
-
 
1251
                            $path;
-
 
1252
                        return true;
-
 
1253
                    }
-
 
1254
                }
-
 
1255
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
-
 
1256
                    array('mirror' => $mirror));
-
 
1257
                return false;
-
 
1258
            } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
-
 
1259
                $this->_channelInfo['servers']['mirror'][$protocol]['attribs']['path'] = $path;
-
 
1260
                $this->_isValid = false;
-
 
1261
                return true;
-
 
1262
            }
-
 
1263
        }
-
 
1264
        $this->_channelInfo['servers']['primary'][$protocol]['attribs']['path'] = $path;
1174
 
1265
        $this->_isValid = false;
1175
        $this->_isValid = false;
1266
        return true;
1176
        return true;
Line 1267... Line 1177...
1267
    }
1177
    }
Line 1280... Line 1190...
1280
        } elseif (!$this->validChannelServer($server)) {
1190
        } elseif (!$this->validChannelServer($server)) {
1281
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME,
1191
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME,
1282
                array('tag' => 'name', 'name' => $server));
1192
                array('tag' => 'name', 'name' => $server));
1283
            return false;
1193
            return false;
1284
        }
1194
        }
-
 
1195
 
1285
        if ($mirror) {
1196
        if ($mirror) {
1286
            $found = false;
1197
            $found = false;
1287
            foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1198
            foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1288
                if ($mirror == $mir['attribs']['host']) {
1199
                if ($mirror == $mir['attribs']['host']) {
1289
                    $found = true;
1200
                    $found = true;
1290
                    break;
1201
                    break;
1291
                }
1202
                }
1292
            }
1203
            }
-
 
1204
 
1293
            if (!$found) {
1205
            if (!$found) {
1294
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1206
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1295
                    array('mirror' => $mirror));
1207
                    array('mirror' => $mirror));
1296
                return false;
1208
                return false;
1297
            }
1209
            }
-
 
1210
 
1298
            $this->_channelInfo['mirror'][$i]['attribs']['host'] = $server;
1211
            $this->_channelInfo['mirror'][$i]['attribs']['host'] = $server;
1299
            return true;
1212
            return true;
1300
        }
1213
        }
-
 
1214
 
1301
        $this->_channelInfo['name'] = $server;
1215
        $this->_channelInfo['name'] = $server;
1302
        return true;
1216
        return true;
1303
    }
1217
    }
Line 1304... Line 1218...
1304
 
1218
 
Line 1315... Line 1229...
1315
            return false;
1229
            return false;
1316
        } elseif (strpos(trim($summary), "\n") !== false) {
1230
        } elseif (strpos(trim($summary), "\n") !== false) {
1317
            $this->_validateWarning(PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY,
1231
            $this->_validateWarning(PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY,
1318
                array('summary' => $summary));
1232
                array('summary' => $summary));
1319
        }
1233
        }
-
 
1234
 
1320
        $this->_channelInfo['summary'] = $summary;
1235
        $this->_channelInfo['summary'] = $summary;
1321
        return true;
1236
        return true;
1322
    }
1237
    }
Line 1323... Line 1238...
1323
 
1238
 
Line 1331... Line 1246...
1331
        if (!$this->validChannelServer($alias)) {
1246
        if (!$this->validChannelServer($alias)) {
1332
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME,
1247
            $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME,
1333
                array('tag' => 'suggestedalias', 'name' => $alias));
1248
                array('tag' => 'suggestedalias', 'name' => $alias));
1334
            return false;
1249
            return false;
1335
        }
1250
        }
-
 
1251
 
1336
        if ($local) {
1252
        if ($local) {
1337
            $this->_channelInfo['localalias'] = $alias;
1253
            $this->_channelInfo['localalias'] = $alias;
1338
        } else {
1254
        } else {
1339
            $this->_channelInfo['suggestedalias'] = $alias;
1255
            $this->_channelInfo['suggestedalias'] = $alias;
1340
        }
1256
        }
-
 
1257
 
1341
        return true;
1258
        return true;
1342
    }
1259
    }
Line 1343... Line 1260...
1343
 
1260
 
1344
    /**
1261
    /**
Line 1353... Line 1270...
1353
            return $this->_channelInfo['suggestedalias'];
1270
            return $this->_channelInfo['suggestedalias'];
1354
        }
1271
        }
1355
        if (isset($this->_channelInfo['name'])) {
1272
        if (isset($this->_channelInfo['name'])) {
1356
            return $this->_channelInfo['name'];
1273
            return $this->_channelInfo['name'];
1357
        }
1274
        }
-
 
1275
        return '';
1358
    }
1276
    }
Line 1359... Line 1277...
1359
 
1277
 
1360
    /**
1278
    /**
1361
     * Set the package validation object if it differs from PEAR's default
1279
     * Set the package validation object if it differs from PEAR's default
Line 1384... Line 1302...
1384
    function addFunction($type, $version, $name = '', $mirror = false)
1302
    function addFunction($type, $version, $name = '', $mirror = false)
1385
    {
1303
    {
1386
        if ($mirror) {
1304
        if ($mirror) {
1387
            return $this->addMirrorFunction($mirror, $type, $version, $name);
1305
            return $this->addMirrorFunction($mirror, $type, $version, $name);
1388
        }
1306
        }
-
 
1307
 
1389
        $set = array('attribs' => array('version' => $version), '_content' => $name);
1308
        $set = array('attribs' => array('version' => $version), '_content' => $name);
1390
        if (!isset($this->_channelInfo['servers']['primary'][$type]['function'])) {
1309
        if (!isset($this->_channelInfo['servers']['primary'][$type]['function'])) {
1391
            if (!isset($this->_channelInfo['servers'])) {
1310
            if (!isset($this->_channelInfo['servers'])) {
1392
                $this->_channelInfo['servers'] = array('primary' =>
1311
                $this->_channelInfo['servers'] = array('primary' =>
1393
                    array($type => array()));
1312
                    array($type => array()));
1394
            } elseif (!isset($this->_channelInfo['servers']['primary'])) {
1313
            } elseif (!isset($this->_channelInfo['servers']['primary'])) {
1395
                $this->_channelInfo['servers']['primary'] = array($type => array());
1314
                $this->_channelInfo['servers']['primary'] = array($type => array());
1396
            }
1315
            }
-
 
1316
 
1397
            $this->_channelInfo['servers']['primary'][$type]['function'] = $set;
1317
            $this->_channelInfo['servers']['primary'][$type]['function'] = $set;
1398
            $this->_isValid = false;
1318
            $this->_isValid = false;
1399
            return true;
1319
            return true;
1400
        } elseif (!isset($this->_channelInfo['servers']['primary'][$type]['function'][0])) {
1320
        } elseif (!isset($this->_channelInfo['servers']['primary'][$type]['function'][0])) {
1401
            $this->_channelInfo['servers']['primary'][$type]['function'] = array(
1321
            $this->_channelInfo['servers']['primary'][$type]['function'] = array(
1402
                $this->_channelInfo['servers']['primary'][$type]['function']);
1322
                $this->_channelInfo['servers']['primary'][$type]['function']);
1403
        }
1323
        }
-
 
1324
 
1404
        $this->_channelInfo['servers']['primary'][$type]['function'][] = $set;
1325
        $this->_channelInfo['servers']['primary'][$type]['function'][] = $set;
1405
        return true;
1326
        return true;
1406
    }
1327
    }
1407
    /**
1328
    /**
1408
     * Add a protocol to a mirror's provides section
1329
     * Add a protocol to a mirror's provides section
Line 1411... Line 1332...
1411
     * @param string protocol version
1332
     * @param string protocol version
1412
     * @param string protocol name, if any
1333
     * @param string protocol name, if any
1413
     */
1334
     */
1414
    function addMirrorFunction($mirror, $type, $version, $name = '')
1335
    function addMirrorFunction($mirror, $type, $version, $name = '')
1415
    {
1336
    {
1416
        $found = false;
-
 
1417
        if (!isset($this->_channelInfo['servers']['mirror'])) {
1337
        if (!isset($this->_channelInfo['servers']['mirror'])) {
1418
            $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1338
            $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1419
                array('mirror' => $mirror));
1339
                array('mirror' => $mirror));
1420
            return false;
1340
            return false;
1421
        }
1341
        }
-
 
1342
 
1422
        $setmirror = false;
1343
        $setmirror = false;
1423
        if (isset($this->_channelInfo['servers']['mirror'][0])) {
1344
        if (isset($this->_channelInfo['servers']['mirror'][0])) {
1424
            foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1345
            foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1425
                if ($mirror == $mir['attribs']['host']) {
1346
                if ($mirror == $mir['attribs']['host']) {
1426
                    $setmirror = &$this->_channelInfo['servers']['mirror'][$i];
1347
                    $setmirror = &$this->_channelInfo['servers']['mirror'][$i];
Line 1430... Line 1351...
1430
        } else {
1351
        } else {
1431
            if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1352
            if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1432
                $setmirror = &$this->_channelInfo['servers']['mirror'];
1353
                $setmirror = &$this->_channelInfo['servers']['mirror'];
1433
            }
1354
            }
1434
        }
1355
        }
-
 
1356
 
1435
        if (!$setmirror) {
1357
        if (!$setmirror) {
1436
            $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1358
            $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1437
                array('mirror' => $mirror));
1359
                array('mirror' => $mirror));
1438
            return false;
1360
            return false;
1439
        }
1361
        }
-
 
1362
 
1440
        $set = array('attribs' => array('version' => $version), '_content' => $name);
1363
        $set = array('attribs' => array('version' => $version), '_content' => $name);
1441
        if (!isset($setmirror[$type]['function'])) {
1364
        if (!isset($setmirror[$type]['function'])) {
1442
            $setmirror[$type]['function'] = $set;
1365
            $setmirror[$type]['function'] = $set;
1443
            $this->_isValid = false;
1366
            $this->_isValid = false;
1444
            return true;
1367
            return true;
1445
        } elseif (!isset($setmirror[$type]['function'][0])) {
1368
        } elseif (!isset($setmirror[$type]['function'][0])) {
1446
            $setmirror[$type]['function'] = array($setmirror[$type]['function']);
1369
            $setmirror[$type]['function'] = array($setmirror[$type]['function']);
1447
        }
1370
        }
-
 
1371
 
1448
        $setmirror[$type]['function'][] = $set;
1372
        $setmirror[$type]['function'][] = $set;
1449
        $this->_isValid = false;
1373
        $this->_isValid = false;
1450
        return true;
1374
        return true;
1451
    }
1375
    }
Line 1456... Line 1380...
1456
     * @param string|false mirror name, if this is not a primary server REST base URL
1380
     * @param string|false mirror name, if this is not a primary server REST base URL
1457
     */
1381
     */
1458
    function setBaseURL($resourceType, $url, $mirror = false)
1382
    function setBaseURL($resourceType, $url, $mirror = false)
1459
    {
1383
    {
1460
        if ($mirror) {
1384
        if ($mirror) {
1461
            $found = false;
-
 
1462
            if (!isset($this->_channelInfo['servers']['mirror'])) {
1385
            if (!isset($this->_channelInfo['servers']['mirror'])) {
1463
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1386
                $this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
1464
                    array('mirror' => $mirror));
1387
                    array('mirror' => $mirror));
1465
                return false;
1388
                return false;
1466
            }
1389
            }
-
 
1390
 
1467
            $setmirror = false;
1391
            $setmirror = false;
1468
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
1392
            if (isset($this->_channelInfo['servers']['mirror'][0])) {
1469
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1393
                foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1470
                    if ($mirror == $mir['attribs']['host']) {
1394
                    if ($mirror == $mir['attribs']['host']) {
1471
                        $setmirror = &$this->_channelInfo['servers']['mirror'][$i];
1395
                        $setmirror = &$this->_channelInfo['servers']['mirror'][$i];
Line 1478... Line 1402...
1478
                }
1402
                }
1479
            }
1403
            }
1480
        } else {
1404
        } else {
1481
            $setmirror = &$this->_channelInfo['servers']['primary'];
1405
            $setmirror = &$this->_channelInfo['servers']['primary'];
1482
        }
1406
        }
-
 
1407
 
1483
        $set = array('attribs' => array('type' => $resourceType), '_content' => $url);
1408
        $set = array('attribs' => array('type' => $resourceType), '_content' => $url);
1484
        if (!isset($setmirror['rest'])) {
1409
        if (!isset($setmirror['rest'])) {
1485
            $setmirror['rest'] = array();
1410
            $setmirror['rest'] = array();
1486
        }
1411
        }
-
 
1412
 
1487
        if (!isset($setmirror['rest']['baseurl'])) {
1413
        if (!isset($setmirror['rest']['baseurl'])) {
1488
            $setmirror['rest']['baseurl'] = $set;
1414
            $setmirror['rest']['baseurl'] = $set;
1489
            $this->_isValid = false;
1415
            $this->_isValid = false;
1490
            return true;
1416
            return true;
1491
        } elseif (!isset($setmirror['rest']['baseurl'][0])) {
1417
        } elseif (!isset($setmirror['rest']['baseurl'][0])) {
1492
            $setmirror['rest']['baseurl'] = array($setmirror['rest']['baseurl']);
1418
            $setmirror['rest']['baseurl'] = array($setmirror['rest']['baseurl']);
1493
        }
1419
        }
-
 
1420
 
1494
        foreach ($setmirror['rest']['baseurl'] as $i => $url) {
1421
        foreach ($setmirror['rest']['baseurl'] as $i => $url) {
1495
            if ($url['attribs']['type'] == $resourceType) {
1422
            if ($url['attribs']['type'] == $resourceType) {
1496
                $this->_isValid = false;
1423
                $this->_isValid = false;
1497
                $setmirror['rest']['baseurl'][$i] = $set;
1424
                $setmirror['rest']['baseurl'][$i] = $set;
1498
                return true;
1425
                return true;
1499
            }
1426
            }
1500
        }
1427
        }
-
 
1428
 
1501
        $setmirror['rest']['baseurl'][] = $set;
1429
        $setmirror['rest']['baseurl'][] = $set;
1502
        $this->_isValid = false;
1430
        $this->_isValid = false;
1503
        return true;
1431
        return true;
1504
    }
1432
    }
Line 1511... Line 1439...
1511
    function addMirror($server, $port = null)
1439
    function addMirror($server, $port = null)
1512
    {
1440
    {
1513
        if ($this->_channelInfo['name'] == '__uri') {
1441
        if ($this->_channelInfo['name'] == '__uri') {
1514
            return false; // the __uri channel cannot have mirrors by definition
1442
            return false; // the __uri channel cannot have mirrors by definition
1515
        }
1443
        }
-
 
1444
 
1516
        $set = array('attribs' => array('host' => $server));
1445
        $set = array('attribs' => array('host' => $server));
1517
        if (is_numeric($port)) {
1446
        if (is_numeric($port)) {
1518
            $set['attribs']['port'] = $port;
1447
            $set['attribs']['port'] = $port;
1519
        }
1448
        }
-
 
1449
 
1520
        if (!isset($this->_channelInfo['servers']['mirror'])) {
1450
        if (!isset($this->_channelInfo['servers']['mirror'])) {
1521
            $this->_channelInfo['servers']['mirror'] = $set;
1451
            $this->_channelInfo['servers']['mirror'] = $set;
1522
            return true;
1452
            return true;
1523
        } else {
-
 
1524
            if (!isset($this->_channelInfo['servers']['mirror'][0])) {
-
 
1525
                $this->_channelInfo['servers']['mirror'] =
-
 
1526
                    array($this->_channelInfo['servers']['mirror']);
-
 
1527
            }
-
 
1528
        }
1453
        }
-
 
1454
 
-
 
1455
        if (!isset($this->_channelInfo['servers']['mirror'][0])) {
-
 
1456
            $this->_channelInfo['servers']['mirror'] =
-
 
1457
                array($this->_channelInfo['servers']['mirror']);
-
 
1458
        }
-
 
1459
 
1529
        $this->_channelInfo['servers']['mirror'][] = $set;
1460
        $this->_channelInfo['servers']['mirror'][] = $set;
1530
        return true;
1461
        return true;
1531
    }
1462
    }
Line 1532... Line 1463...
1532
 
1463
 
Line 1537... Line 1468...
1537
    function getValidationPackage()
1468
    function getValidationPackage()
1538
    {
1469
    {
1539
        if (!$this->_isValid && !$this->validate()) {
1470
        if (!$this->_isValid && !$this->validate()) {
1540
            return false;
1471
            return false;
1541
        }
1472
        }
-
 
1473
 
1542
        if (!isset($this->_channelInfo['validatepackage'])) {
1474
        if (!isset($this->_channelInfo['validatepackage'])) {
1543
            return array('attribs' => array('version' => 'default'),
1475
            return array('attribs' => array('version' => 'default'),
1544
                '_content' => 'PEAR_Validate');
1476
                '_content' => 'PEAR_Validate');
1545
        }
1477
        }
-
 
1478
 
1546
        return $this->_channelInfo['validatepackage'];
1479
        return $this->_channelInfo['validatepackage'];
1547
    }
1480
    }
Line 1548... Line 1481...
1548
 
1481
 
1549
    /**
1482
    /**
Line 1556... Line 1489...
1556
    function &getValidationObject($package = false)
1489
    function &getValidationObject($package = false)
1557
    {
1490
    {
1558
        if (!class_exists('PEAR_Validate')) {
1491
        if (!class_exists('PEAR_Validate')) {
1559
            require_once 'PEAR/Validate.php';
1492
            require_once 'PEAR/Validate.php';
1560
        }
1493
        }
-
 
1494
 
1561
        if (!$this->_isValid) {
1495
        if (!$this->_isValid) {
1562
            if (!$this->validate()) {
1496
            if (!$this->validate()) {
1563
                $a = false;
1497
                $a = false;
1564
                return $a;
1498
                return $a;
1565
            }
1499
            }
1566
        }
1500
        }
-
 
1501
 
1567
        if (isset($this->_channelInfo['validatepackage'])) {
1502
        if (isset($this->_channelInfo['validatepackage'])) {
1568
            if ($package == $this->_channelInfo['validatepackage']) {
1503
            if ($package == $this->_channelInfo['validatepackage']) {
1569
                // channel validation packages are always validated by PEAR_Validate
1504
                // channel validation packages are always validated by PEAR_Validate
1570
                $val = &new PEAR_Validate;
1505
                $val = new PEAR_Validate;
1571
                return $val;
1506
                return $val;
1572
            }
1507
            }
-
 
1508
 
1573
            if (!class_exists(str_replace('.', '_',
1509
            if (!class_exists(str_replace('.', '_',
1574
                  $this->_channelInfo['validatepackage']['_content']))) {
1510
                  $this->_channelInfo['validatepackage']['_content']))) {
1575
                if ($this->isIncludeable(str_replace('_', '/',
1511
                if ($this->isIncludeable(str_replace('_', '/',
1576
                      $this->_channelInfo['validatepackage']['_content']) . '.php')) {
1512
                      $this->_channelInfo['validatepackage']['_content']) . '.php')) {
1577
                    include_once str_replace('_', '/',
1513
                    include_once str_replace('_', '/',
1578
                        $this->_channelInfo['validatepackage']['_content']) . '.php';
1514
                        $this->_channelInfo['validatepackage']['_content']) . '.php';
1579
                    $vclass = str_replace('.', '_',
1515
                    $vclass = str_replace('.', '_',
1580
                        $this->_channelInfo['validatepackage']['_content']);
1516
                        $this->_channelInfo['validatepackage']['_content']);
1581
                    $val = &new $vclass;
1517
                    $val = new $vclass;
1582
                } else {
1518
                } else {
1583
                    $a = false;
1519
                    $a = false;
1584
                    return $a;
1520
                    return $a;
1585
                }
1521
                }
1586
            } else {
1522
            } else {
1587
                $vclass = str_replace('.', '_',
1523
                $vclass = str_replace('.', '_',
1588
                    $this->_channelInfo['validatepackage']['_content']);
1524
                    $this->_channelInfo['validatepackage']['_content']);
1589
                $val = &new $vclass;
1525
                $val = new $vclass;
1590
            }
1526
            }
1591
        } else {
1527
        } else {
1592
            $val = &new PEAR_Validate;
1528
            $val = new PEAR_Validate;
1593
        }
1529
        }
-
 
1530
 
1594
        return $val;
1531
        return $val;
1595
    }
1532
    }
Line 1596... Line 1533...
1596
 
1533
 
1597
    function isIncludeable($path)
1534
    function isIncludeable($path)
Line 1601... Line 1538...
1601
            if (file_exists($dir . DIRECTORY_SEPARATOR . $path)
1538
            if (file_exists($dir . DIRECTORY_SEPARATOR . $path)
1602
                  && is_readable($dir . DIRECTORY_SEPARATOR . $path)) {
1539
                  && is_readable($dir . DIRECTORY_SEPARATOR . $path)) {
1603
                return true;
1540
                return true;
1604
            }
1541
            }
1605
        }
1542
        }
-
 
1543
 
1606
        return false;
1544
        return false;
1607
    }
1545
    }
Line 1608... Line 1546...
1608
 
1546
 
1609
    /**
1547
    /**
Line 1614... Line 1552...
1614
    function lastModified()
1552
    function lastModified()
1615
    {
1553
    {
1616
        if (isset($this->_channelInfo['_lastmodified'])) {
1554
        if (isset($this->_channelInfo['_lastmodified'])) {
1617
            return $this->_channelInfo['_lastmodified'];
1555
            return $this->_channelInfo['_lastmodified'];
1618
        }
1556
        }
-
 
1557
 
1619
        return time();
1558
        return time();
1620
    }
1559
    }
1621
}
1560
}
1622
?>
-