Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
Línea 2... Línea -...
2
 
-
 
3
declare(strict_types=1);
2
 
4
/**
3
/**
5
 * SimplePie
4
 * SimplePie
6
 *
5
 *
7
 * A PHP-Based RSS and Atom Feed Framework.
6
 * A PHP-Based RSS and Atom Feed Framework.
Línea 69... Línea 68...
69
    public const NAME = 'SimplePie';
68
    public const NAME = 'SimplePie';
Línea 70... Línea 69...
70
 
69
 
71
    /**
70
    /**
72
     * SimplePie Version
71
     * SimplePie Version
73
     */
72
     */
Línea 74... Línea 73...
74
    public const VERSION = '1.8.0';
73
    public const VERSION = '1.8.1';
75
 
74
 
76
    /**
75
    /**
77
     * SimplePie Website URL
76
     * SimplePie Website URL
Línea 689... Línea 688...
689
     * @since 1.0 Preview Release
688
     * @since 1.0 Preview Release
690
     */
689
     */
691
    public function __construct()
690
    public function __construct()
692
    {
691
    {
693
        if (version_compare(PHP_VERSION, '7.2', '<')) {
692
        if (version_compare(PHP_VERSION, '7.2', '<')) {
694
            trigger_error('Please upgrade to PHP 7.2 or newer.');
693
            exit('Please upgrade to PHP 7.2 or newer.');
695
            die();
-
 
696
        }
694
        }
Línea 697... Línea 695...
697
 
695
 
Línea 698... Línea 696...
698
        $this->set_useragent();
696
        $this->set_useragent();
Línea 801... Línea 799...
801
    public function set_file(&$file)
799
    public function set_file(&$file)
802
    {
800
    {
803
        if ($file instanceof \SimplePie\File) {
801
        if ($file instanceof \SimplePie\File) {
804
            $this->feed_url = $file->url;
802
            $this->feed_url = $file->url;
805
            $this->permanent_url = $this->feed_url;
803
            $this->permanent_url = $this->feed_url;
806
            $this->file =& $file;
804
            $this->file = &$file;
807
            return true;
805
            return true;
808
        }
806
        }
809
        return false;
807
        return false;
810
    }
808
    }
Línea 1373... Línea 1371...
1373
        if ($tags === '') {
1371
        if ($tags === '') {
1374
            $tags = $this->strip_htmltags;
1372
            $tags = $this->strip_htmltags;
1375
        }
1373
        }
1376
        $this->sanitize->strip_htmltags($tags);
1374
        $this->sanitize->strip_htmltags($tags);
1377
        if ($encode !== null) {
1375
        if ($encode !== null) {
1378
            $this->sanitize->encode_instead_of_strip($tags);
1376
            $this->sanitize->encode_instead_of_strip($encode);
1379
        }
1377
        }
1380
    }
1378
    }
Línea 1381... Línea 1379...
1381
 
1379
 
1382
    public function encode_instead_of_strip($enable = true)
1380
    public function encode_instead_of_strip($enable = true)
Línea 1664... Línea 1662...
1664
                    }
1662
                    }
1665
                    $this->data['build'] = \SimplePie\Misc::get_build();
1663
                    $this->data['build'] = \SimplePie\Misc::get_build();
Línea 1666... Línea 1664...
1666
 
1664
 
1667
                    // Cache the file if caching is enabled
1665
                    // Cache the file if caching is enabled
1668
                    $this->data['cache_expiration_time'] = $this->cache_duration + time();
1666
                    $this->data['cache_expiration_time'] = $this->cache_duration + time();
1669
                    if ($cache && ! $cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) {
1667
                    if ($cache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) {
1670
                        trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
1668
                        trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
1671
                    }
1669
                    }
1672
                    return true;
1670
                    return true;
1673
                }
1671
                }
Línea 1714... Línea 1712...
1714
        if (is_object($cache) && $cache instanceof Base) {
1712
        if (is_object($cache) && $cache instanceof Base) {
1715
            // @trigger_error(sprintf('Providing $cache as "\SimplePie\Cache\Base" in %s() is deprecated since SimplePie 1.8.0, please provide "\SimplePie\Cache\DataCache" implementation instead.', __METHOD__), \E_USER_DEPRECATED);
1713
            // @trigger_error(sprintf('Providing $cache as "\SimplePie\Cache\Base" in %s() is deprecated since SimplePie 1.8.0, please provide "\SimplePie\Cache\DataCache" implementation instead.', __METHOD__), \E_USER_DEPRECATED);
1716
            $cache = new BaseDataCache($cache);
1714
            $cache = new BaseDataCache($cache);
1717
        }
1715
        }
Línea 1718... Línea 1716...
1718
 
1716
 
1719
        if ($cache !== false && ! $cache instanceof DataCache) {
1717
        if ($cache !== false && !$cache instanceof DataCache) {
1720
            throw new InvalidArgumentException(sprintf(
1718
            throw new InvalidArgumentException(sprintf(
1721
                '%s(): Argument #1 ($cache) must be of type %s|false',
1719
                '%s(): Argument #1 ($cache) must be of type %s|false',
1722
                __METHOD__,
1720
                __METHOD__,
1723
                DataCache::class
1721
                DataCache::class
Línea 1772... Línea 1770...
1772
                        }
1770
                        }
1773
                        if (isset($this->data['headers']['etag'])) {
1771
                        if (isset($this->data['headers']['etag'])) {
1774
                            $headers['if-none-match'] = $this->data['headers']['etag'];
1772
                            $headers['if-none-match'] = $this->data['headers']['etag'];
1775
                        }
1773
                        }
Línea 1776... Línea 1774...
1776
 
1774
 
1777
                        $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
1775
                        $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
Línea 1778... Línea 1776...
1778
                        $this->status_code = $file->status_code;
1776
                        $this->status_code = $file->status_code;
1779
 
1777
 
1780
                        if ($file->success) {
1778
                        if ($file->success) {
Línea 1809... Línea 1807...
1809
        }
1807
        }
Línea 1810... Línea 1808...
1810
 
1808
 
1811
        // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
1809
        // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
1812
        if (!isset($file)) {
1810
        if (!isset($file)) {
1813
            if ($this->file instanceof \SimplePie\File && $this->file->url === $this->feed_url) {
1811
            if ($this->file instanceof \SimplePie\File && $this->file->url === $this->feed_url) {
1814
                $file =& $this->file;
1812
                $file = &$this->file;
1815
            } else {
1813
            } else {
1816
                $headers = [
1814
                $headers = [
1817
                    'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
1815
                    'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
1818
                ];
1816
                ];
Línea 1831... Línea 1829...
1831
            // Check if the supplied URL is a feed, if it isn't, look for it.
1829
            // Check if the supplied URL is a feed, if it isn't, look for it.
1832
            $locate = $this->registry->create(Locator::class, [&$file, $this->timeout, $this->useragent, $this->max_checked_feeds, $this->force_fsockopen, $this->curl_options]);
1830
            $locate = $this->registry->create(Locator::class, [&$file, $this->timeout, $this->useragent, $this->max_checked_feeds, $this->force_fsockopen, $this->curl_options]);
Línea 1833... Línea 1831...
1833
 
1831
 
1834
            if (!$locate->is_feed($file)) {
1832
            if (!$locate->is_feed($file)) {
1835
                $copyStatusCode = $file->status_code;
1833
                $copyStatusCode = $file->status_code;
1836
                $copyContentType = $file->headers['content-type'];
1834
                $copyContentType = $file->headers['content-type'] ?? '';
1837
                try {
1835
                try {
1838
                    $microformats = false;
1836
                    $microformats = false;
1839
                    if (class_exists('DOMXpath') && function_exists('Mf2\parse')) {
1837
                    if (class_exists('DOMXpath') && function_exists('Mf2\parse')) {
1840
                        $doc = new \DOMDocument();
1838
                        $doc = new \DOMDocument();
Línea 2639... Línea 2637...
2639
            $keys = array_keys($this->data['links']);
2637
            $keys = array_keys($this->data['links']);
2640
            foreach ($keys as $key) {
2638
            foreach ($keys as $key) {
2641
                if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
2639
                if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
2642
                    if (isset($this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key])) {
2640
                    if (isset($this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key])) {
2643
                        $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]);
2641
                        $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]);
2644
                        $this->data['links'][$key] =& $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key];
2642
                        $this->data['links'][$key] = &$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key];
2645
                    } else {
2643
                    } else {
2646
                        $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2644
                        $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
2647
                    }
2645
                    }
2648
                } elseif (substr($key, 0, 41) === self::IANA_LINK_RELATIONS_REGISTRY) {
2646
                } elseif (substr($key, 0, 41) === self::IANA_LINK_RELATIONS_REGISTRY) {
2649
                    $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2647
                    $this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
2650
                }
2648
                }
2651
                $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2649
                $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2652
            }
2650
            }
2653
        }
2651
        }
Línea 3101... Línea 3099...
3101
 
3099
 
3102
        $class = get_class($this);
3100
        $class = get_class($this);
3103
        $trace = debug_backtrace();
3101
        $trace = debug_backtrace();
3104
        $file = $trace[0]['file'];
3102
        $file = $trace[0]['file'];
3105
        $line = $trace[0]['line'];
3103
        $line = $trace[0]['line'];
3106
        trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR);
3104
        throw new SimplePieException("Call to undefined method $class::$method() in $file on line $line");
Línea 3107... Línea 3105...
3107
    }
3105
    }
3108
 
3106
 
3109
    /**
3107
    /**