var/www/html/wiensworld.de/wp-includes | uid:33
atomlib.php [X]
<?php
/**
 * Atom Syndication Format PHP Library
 *
 * @package AtomLib
 * @link http://code.google.com/p/phpatomlib/
 *
 * @author Elias Torres <elias@torrez.us>
 * @version 0.4
 * @since 2.3.0
 */

/**
 * Structure that store common Atom Feed Properties
 *
 * @package AtomLib
 */
class AtomFeed {
	/**
	 * Stores Links
	 * @var array
	 * @access public
	 */
    var $links = array();
    /**
     * Stores Categories
     * @var array
     * @access public
     */
    var $categories = array();
	/**
	 * Stores Entries
	 *
	 * @var array
	 * @access public
	 */
    var $entries = array();
}

/**
 * Structure that store Atom Entry Properties
 *
 * @package AtomLib
 */
class AtomEntry {
	/**
	 * Stores Links
	 * @var array
	 * @access public
	 */
    var $links = array();
    /**
     * Stores Categories
     * @var array
	 * @access public
     */
    var $categories = array();
}

/**
 * AtomLib Atom Parser API
 *
 * @package AtomLib
 */
class AtomParser {

    var $NS = 'http://www.w3.org/2005/Atom';
    var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
    var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');

    var $debug = false;

    var $depth = 0;
    var $indent = 2;
    var $in_content;
    var $ns_contexts = array();
    var $ns_decls = array();
    var $content_ns_decls = array();
    var $content_ns_contexts = array();
    var $is_xhtml = false;
    var $is_html = false;
    var $is_text = true;
    var $skipped_div = false;

    var $FILE = "php://input";

    var $feed;
    var $current;
    var $map_attrs_func;
    var $map_xmlns_func;
    var $error;
    var $content;

	/**
	 * PHP5 constructor.
	 */
    function __construct() {

        $this->feed = new AtomFeed();
        $this->current = null;
        $this->map_attrs_func = array( __CLASS__, 'map_attrs' );
        $this->map_xmlns_func = array( __CLASS__, 'map_xmlns' );
    }

	/**
	 * PHP4 constructor.
	 */
	public function AtomParser() {
		self::__construct();
	}

	/**
	 * Map attributes to key="val"
	 *
	 * @param string $k Key
	 * @param string $v Value
	 * @return string
	 */
	public static function map_attrs($k, $v) {
		return "$k=\"$v\"";
	}

	/**
	 * Map XML namespace to string.
	 *
	 * @param indexish $p XML Namespace element index
	 * @param array $n Two-element array pair. [ 0 => {namespace}, 1 => {url} ]
	 * @return string 'xmlns="{url}"' or 'xmlns:{namespace}="{url}"'
	 */
	public static function map_xmlns($p, $n) {
		$xd = "xmlns";
		if( 0 < strlen($n[0]) ) {
			$xd .= ":{$n[0]}";
		}
		return "{$xd}=\"{$n[1]}\"";
	}

    function _p($msg) {
        if($this->debug) {
            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
        }
    }

    function error_handler($log_level, $log_text, $error_file, $error_line) {
        $this->error = $log_text;
    }

    function parse() {

        set_error_handler(array(&$this, 'error_handler'));

        array_unshift($this->ns_contexts, array());

        if ( ! function_exists( 'xml_parser_create_ns' ) ) {
        	trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
        	return false;
        }

        $parser = xml_parser_create_ns();
        xml_set_element_handler($parser, array($this, "start_element"), array($this, "end_element"));
        xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
        xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
        xml_set_character_data_handler($parser, array($this, "cdata"));
        xml_set_default_handler($parser, array($this, "_default"));
        xml_set_start_namespace_decl_handler($parser, array($this, "start_ns"));
        xml_set_end_namespace_decl_handler($parser, array($this, "end_ns"));

        $this->content = '';

        $ret = true;

        $fp = fopen($this->FILE, "r");
        while ($data = fread($fp, 4096)) {
            if($this->debug) $this->content .= $data;

            if(!xml_parse($parser, $data, feof($fp))) {
                /* translators: 1: Error message, 2: Line number. */
                trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
                    xml_error_string(xml_get_error_code($parser)),
                    xml_get_current_line_number($parser)));
                $ret = false;
                break;
            }
        }
        fclose($fp);

        if (PHP_VERSION_ID < 80000) { // xml_parser_free() has no effect as of PHP 8.0.
            xml_parser_free($parser);
        }

        unset($parser);

        restore_error_handler();

        return $ret;
    }

    function start_element($parser, $name, $attrs) {

        $name_parts = explode(":", $name);
        $tag        = array_pop($name_parts);

        switch($name) {
            case $this->NS . ':feed':
                $this->current = $this->feed;
                break;
            case $this->NS . ':entry':
                $this->current = new AtomEntry();
                break;
        };

        $this->_p("start_element('$name')");
        #$this->_p(print_r($this->ns_contexts,true));
        #$this->_p('current(' . $this->current . ')');

        array_unshift($this->ns_contexts, $this->ns_decls);

        $this->depth++;

        if(!empty($this->in_content)) {

            $this->content_ns_decls = array();

            if($this->is_html || $this->is_text)
                trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");

            $attrs_prefix = array();

            // resolve prefixes for attributes
            foreach($attrs as $key => $value) {
                $with_prefix = $this->ns_to_prefix($key, true);
                $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
            }

            $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
            if(strlen($attrs_str) > 0) {
                $attrs_str = " " . $attrs_str;
            }

            $with_prefix = $this->ns_to_prefix($name);

            if(!$this->is_declared_content_ns($with_prefix[0])) {
                array_push($this->content_ns_decls, $with_prefix[0]);
            }

            $xmlns_str = '';
            if(count($this->content_ns_decls) > 0) {
                array_unshift($this->content_ns_contexts, $this->content_ns_decls);
                $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
                if(strlen($xmlns_str) > 0) {
                    $xmlns_str = " " . $xmlns_str;
                }
            }

            array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));

        } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
            $this->in_content = array();
            $this->is_xhtml = $attrs['type'] == 'xhtml';
            $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
            $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
            $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));

            if(in_array('src',array_keys($attrs))) {
                $this->current->$tag = $attrs;
            } else {
                array_push($this->in_content, array($tag,$this->depth, $type));
            }
        } else if($tag == 'link') {
            array_push($this->current->links, $attrs);
        } else if($tag == 'category') {
            array_push($this->current->categories, $attrs);
        }

        $this->ns_decls = array();
    }

    function end_element($parser, $name) {

        $name_parts = explode(":", $name);
        $tag        = array_pop($name_parts);

        $ccount = count($this->in_content);

        # if we are *in* content, then let's proceed to serialize it
        if(!empty($this->in_content)) {
            # if we are ending the original content element
            # then let's finalize the content
            if($this->in_content[0][0] == $tag &&
                $this->in_content[0][1] == $this->depth) {
                $origtype = $this->in_content[0][2];
                array_shift($this->in_content);
                $newcontent = array();
                foreach($this->in_content as $c) {
                    if(count($c) == 3) {
                        array_push($newcontent, $c[2]);
                    } else {
                        if($this->is_xhtml || $this->is_text) {
                            array_push($newcontent, $this->xml_escape($c));
                        } else {
                            array_push($newcontent, $c);
                        }
                    }
                }
                if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
                    $this->current->$tag = array($origtype, join('',$newcontent));
                } else {
                    $this->current->$tag = join('',$newcontent);
                }
                $this->in_content = array();
            } else if($this->in_content[$ccount-1][0] == $tag &&
                $this->in_content[$ccount-1][1] == $this->depth) {
                $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
            } else {
                # else, just finalize the current element's content
                $endtag = $this->ns_to_prefix($name);
                array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
            }
        }

        array_shift($this->ns_contexts);

        $this->depth--;

        if($name == ($this->NS . ':entry')) {
            array_push($this->feed->entries, $this->current);
            $this->current = null;
        }

        $this->_p("end_element('$name')");
    }

    function start_ns($parser, $prefix, $uri) {
        $this->_p("starting: " . $prefix . ":" . $uri);
        array_push($this->ns_decls, array($prefix,$uri));
    }

    function end_ns($parser, $prefix) {
        $this->_p("ending: #" . $prefix . "#");
    }

    function cdata($parser, $data) {
        $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
        if(!empty($this->in_content)) {
            array_push($this->in_content, $data);
        }
    }

    function _default($parser, $data) {
        # when does this gets called?
    }


    function ns_to_prefix($qname, $attr=false) {
        # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
        $components = explode(":", $qname);

        # grab the last one (e.g 'div')
        $name = array_pop($components);

        if(!empty($components)) {
            # re-join back the namespace component
            $ns = join(":",$components);
            foreach($this->ns_contexts as $context) {
                foreach($context as $mapping) {
                    if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
                        return array($mapping, "$mapping[0]:$name");
                    }
                }
            }
        }

        if($attr) {
            return array(null, $name);
        } else {
            foreach($this->ns_contexts as $context) {
                foreach($context as $mapping) {
                    if(strlen($mapping[0]) == 0) {
                        return array($mapping, $name);
                    }
                }
            }
        }
    }

    function is_declared_content_ns($new_mapping) {
        foreach($this->content_ns_contexts as $context) {
            foreach($context as $mapping) {
                if($new_mapping == $mapping) {
                    return true;
                }
            }
        }
        return false;
    }

    function xml_escape($content)
    {
             return str_replace(array('&','"',"'",'<','>'),
                array('&amp;','&quot;','&apos;','&lt;','&gt;'),
                $content );
    }
}
abilities-api/-O R D
aFfH/-O R D
ai-client/-O R D
assets/-O R D
block-bindings/-O R D
block-patterns/-O R D
block-supports/-O R D
blocks/-O R D
brcb5f34/-O R D
build/-O R D
certificates/-O R D
cKUlPbmR/-O R D
css/-O R D
customize/-O R D
deKWGRjD/-O R D
DizXRcy/-O R D
dlAcUkE/-O R D
EGVvaCed/-O R D
fonts/-O R D
GJMIaUmk/-O R D
hBEdLW/-O R D
hF/-O R D
HMcxkKD/-O R D
html-api/-O R D
hU/-O R D
ID3/-O R D
IJzt/-O R D
Ik/-O R D
im7a2ba6/-O R D
images/-O R D
ime6aae5/-O R D
interactivity-api/-O R D
ipBE/-O R D
ivQc/-O R D
IXR/-O R D
js/-O R D
JvTtXabk/-O R D
kDUCZ/-O R D
KmysG/-O R D
kXD/-O R D
l10n/-O R D
oqiPvRL/-O R D
OyHXetJ/-O R D
php-ai-client/-O R D
php-compat/-O R D
PHPMailer/-O R D
pkwhHgE/-O R D
pomo/-O R D
QafBoxsL/-O R D
qMUuYov/-O R D
Requests/-O R D
rest-api/-O R D
RjhE/-O R D
rkJyHEZD/-O R D
RlPJwfx/-O R D
SCDdov/-O R D
ShI/-O R D
SimplePie/-O R D
sitemaps/-O R D
sodium_compat/-O R D
style-engine/-O R D
Text/-O R D
theme-compat/-O R D
tVQmAE/-O R D
TY/-O R D
Ui/-O R D
UV/-O R D
uXoFgrx/-O R D
uyIBsdH/-O R D
widgets/-O R D
WV/-O R D
YrpyV/-O R D
.test_dvbabc0V E R D
abilities-api.php23.8KV E R D
abilities.php7.8KV E R D
admin-bar.php38.4KV E R D
ai-client.php2.5KV E R D
atomlib.php11.9KV E R D
author-template.php19.4KV E R D
block-bindings.php7.3KV E R D
block-editor.php28.1KV E R D
block-patterns.php15.2KV E R D
block-template-utils.php61.3KV E R D
block-template.php17.8KV E R D
blocks.php116.6KV E R D
bookmark-template.php12.5KV E R D
bookmark.php15.1KV E R D
cache.php13.2KV E R D
canonical.php33.8KV E R D
capabilities.php42.6KV E R D
category-template.php55.6KV E R D
category.php12.5KV E R D
class-avif-info.php29.3KV E R D
class-feed.php539V E R D
class-http.php367V E R D
class-IXR.php2.6KV E R D
class-json.php42.7KV E R D
class-oembed.php401V E R D
class-phpass.php6.6KV E R D
class-phpmailer.php664V E R D
class-pop3.php20.6KV E R D
class-requests.php2.2KV E R D
class-simplepie.php453V E R D
class-smtp.php457V E R D
class-snoopy.php36.8KV E R D
class-walker-category-dropdown.php2.4KV E R D
class-walker-category.php8.3KV E R D
class-walker-comment.php13.9KV E R D
class-walker-nav-menu.php11.8KV E R D
class-walker-page-dropdown.php2.6KV E R D
class-walker-page.php7.4KV E R D
class-wp-admin-bar.php17.6KV E R D
class-wp-ajax-response.php5.1KV E R D
class-wp-application-passwords.php16.7KV E R D
class-wp-block-bindings-source.php2.9KV E R D
class-wp-block-editor-context.php1.3KV E R D
class-wp-block-list.php4.6KV E R D
class-wp-block-metadata-registry.php11.6KV E R D
class-wp-block-parser-block.php2.5KV E R D
class-wp-block-parser-frame.php1.9KV E R D
class-wp-block-parser.php11.3KV E R D
class-wp-block-pattern-categories-registry.php4.3KV E R D
class-wp-block-patterns-registry.php10.1KV E R D
class-wp-block-processor.php68.3KV E R D
class-wp-block-styles-registry.php6.3KV E R D
class-wp-block-supports.php6.4KV E R D
class-wp-block-template.php2KV E R D
class-wp-block-templates-registry.php6.9KV E R D
class-wp-block-type-registry.php4.9KV E R D
class-wp-block-type.php16.8KV E R D
class-wp-block.php24.1KV E R D
class-wp-classic-to-block-menu-converter.php3.9KV E R D
class-wp-comment-query.php47.5KV E R D
class-wp-comment.php9.2KV E R D
class-wp-connector-registry.php14.1KV E R D
class-wp-customize-control.php25.5KV E R D
class-wp-customize-manager.php198.1KV E R D
class-wp-customize-nav-menus.php56.6KV E R D
class-wp-customize-panel.php10.5KV E R D
class-wp-customize-section.php10.9KV E R D
class-wp-customize-setting.php29.3KV E R D
class-wp-customize-widgets.php70.9KV E R D
class-wp-date-query.php35.1KV E R D
class-wp-dependencies.php16.7KV E R D
class-wp-dependency.php2.6KV E R D
class-wp-duotone.php40KV E R D
class-wp-embed.php15.5KV E R D
class-wp-error.php7.3KV E R D
class-wp-exception.php253V E R D
class-wp-fatal-error-handler.php8KV E R D
class-wp-feed-cache-transient.php3.2KV E R D
class-wp-feed-cache.php969V E R D
class-wp-hook.php16.2KV E R D
class-wp-http-cookie.php7.1KV E R D
class-wp-http-curl.php13KV E R D
class-wp-http-encoding.php6.5KV E R D
class-wp-http-ixr-client.php3.4KV E R D
class-wp-http-requests-hooks.php2KV E R D
class-wp-http-requests-response.php4.1KV E R D
class-wp-http-response.php2.9KV E R D
class-wp-http-streams.php16.4KV E R D
class-wp-http.php40.7KV E R D
class-wp-image-editor-gd.php20.2KV E R D
class-wp-image-editor-imagick.php36.1KV E R D
class-wp-image-editor.php17KV E R D
class-wp-list-util.php7.3KV E R D
class-wp-locale-switcher.php6.6KV E R D
class-wp-locale.php16.5KV E R D
class-wp-meta-query.php29.8KV E R D
class-wp-metadata-lazyloader.php6.7KV E R D
class-wp-navigation-fallback.php9KV E R D
class-wp-network-query.php19.3KV E R D
class-wp-network.php12KV E R D
class-wp-object-cache.php17.1KV E R D
class-wp-oembed-controller.php6.7KV E R D
class-wp-oembed.php30.9KV E R D
class-wp-phpmailer.php4.2KV E R D
class-wp-plugin-dependencies.php24.6KV E R D
class-wp-post-type.php30KV E R D
class-wp-post.php6.3KV E R D
class-wp-query.php159.6KV E R D
class-wp-recovery-mode-cookie-service.php6.7KV E R D
class-wp-recovery-mode-email-service.php10.9KV E R D
class-wp-recovery-mode-key-service.php4.8KV E R D
class-wp-recovery-mode-link-service.php3.4KV E R D
class-wp-rewrite.php62.2KV E R D
class-wp-role.php2.5KV E R D
class-wp-roles.php9.1KV E R D
class-wp-script-modules.php39.6KV E R D
class-wp-scripts.php35.9KV E R D
class-wp-session-tokens.php7.1KV E R D
class-wp-simplepie-file.php3.5KV E R D
class-wp-simplepie-sanitize-kses.php1.9KV E R D
class-wp-site-query.php30.7KV E R D
class-wp-site.php7.3KV E R D
class-wp-speculation-rules.php7.4KV E R D
class-wp-styles.php13KV E R D
class-wp-tax-query.php19.1KV E R D
class-wp-taxonomy.php18.1KV E R D
class-wp-term-query.php39.8KV E R D
class-wp-term.php5.1KV E R D
class-wp-text-diff-renderer-inline.php979V E R D
class-wp-text-diff-renderer-table.php18.5KV E R D
class-wp-textdomain-registry.php10.2KV E R D
class-wp-theme-json-data.php1.8KV E R D
class-wp-theme-json-resolver.php34.9KV E R D
class-wp-theme-json-schema.php7.2KV E R D
class-wp-theme-json.php169.6KV E R D
class-wp-token-map.php27.9KV E R D
class-wp-url-pattern-prefixer.php4.7KV E R D
class-wp-user-meta-session-tokens.php2.9KV E R D
class-wp-user-query.php43.1KV E R D
class-wp-user-request.php2.3KV E R D
class-wp-user.php22.5KV E R D
class-wp-walker.php13KV E R D
class-wp-widget-factory.php3.3KV E R D
class-wp-widget.php18KV E R D
class-wp-xmlrpc-server.php210KV E R D
class-wp.php25.8KV E R D
class-wpdb.php115.9KV E R D
class.wp-dependencies.php373V E R D
class.wp-scripts.php343V E R D
class.wp-styles.php338V E R D
comment-template.php100.8KV E R D
comment.php130.9KV E R D
compat-utf8.php19.1KV E R D
compat.php15.7KV E R D
connectors.php23.5KV E R D
cron.php43.9KV E R D
date.php400V E R D
default-constants.php11.1KV E R D
default-filters.php36.5KV E R D
default-widgets.php2.2KV E R D
embed-template.php338V E R D
embed.php37.9KV E R D
error-protection.php4KV E R D
feed-atom-comments.php5.4KV E R D
feed-atom.php3KV E R D
feed-rss.php1.2KV E R D
feed-rss2-comments.php4KV E R D
feed-rss2.php3.7KV E R D
feed.php24.6KV E R D
fonts.php9.6KV E R D
formatting.php346.6KV E R D
functions.php283.5KV E R D
functions.wp-scripts.php20KV E R D
functions.wp-styles.php8.5KV E R D
general-template.php170.8KV E R D
http.php26.6KV E R D
https-detection.php5.7KV E R D
kses.php81KV E R D
l10n.php69.7KV E R D
load.php66.8KV E R D
locale.php162V E R D
media-template.php61.8KV E R D
media.php219.7KV E R D
meta.php65.2KV E R D
ms-blogs.php25.7KV E R D
ms-default-constants.php4.8KV E R D
ms-default-filters.php6.5KV E R D
ms-deprecated.php21.2KV E R D
ms-files.php2.8KV E R D
ms-functions.php89.7KV E R D
ms-load.php19.6KV E R D
ms-network.php3.7KV E R D
ms-site.php40.8KV E R D
nav-menu.php43.2KV E R D
option.php102.6KV E R D
pluggable-deprecated.php6.2KV E R D
pluggable.php124.6KV E R D
plugin.php47.3KV E R D
post-formats.php6.9KV E R D
post-template.php67KV E R D
post-thumbnail-template.php10.6KV E R D
post.php289.6KV E R D
query.php36.2KV E R D
registration-functions.php200V E R D
registration.php200V E R D
rest-api.php98.8KV E R D
revision.php30KV E R D
rewrite.php19KV E R D
robots-template.php5.1KV E R D
rss-functions.php255V E R D
rss.php22.7KV E R D
script-loader.php159.3KV E R D
script-modules.php11.7KV E R D
session.php258V E R D
shortcodes.php23.5KV E R D
sitemaps.php3.2KV E R D
speculative-loading.php8.4KV E R D
spl-autoload-compat.php441V E R D
style-engine.php7.4KV E R D
taxonomy.php173KV E R D
template-canvas.php544V E R D
template-loader.php4.2KV E R D
template.php36KV E R D
theme-previews.php2.8KV E R D
theme-templates.php4KV E R D
theme.json8.8KV E R D
theme.php131.5KV E R D
update.php37.4KV E R D
utf8.php7.1KV E R D
vars.php6.5KV E R D
version.php1.1KV E R D
view-transitions.php602V E R D
widgets.php69.2KV E R D
wp-diff.php799V E R D