⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rss_parse.inc

📁 下载系统 # 汉化:Fising # 邮箱:fising@163.com # 网址:http://www.fising.cn # 声明:本人水平有限
💻 INC
📖 第 1 页 / 共 2 页
字号:
                $this->append_content("<$el />");            }            array_shift( $this->stack );        }        else {            array_shift( $this->stack );        }                $this->current_namespace = false;    }        function concat (&$str1, $str2="") {        if (!isset($str1) ) {            $str1="";        }        $str1 .= $str2;    }                function append_content($text) {        if ( $this->initem ) {            $this->concat( $this->current_item[ $this->incontent ], $text );        }        elseif ( $this->inchannel ) {            $this->concat( $this->channel[ $this->incontent ], $text );        }    }        // smart append - field and namespace aware    function append($el, $text) {        if (!$el) {            return;        }        if ( $this->current_namespace )         {            if ( $this->initem ) {                $this->concat(                    $this->current_item[ $this->current_namespace ][ $el ], $text);            }            elseif ($this->inchannel) {                $this->concat(                    $this->channel[ $this->current_namespace][ $el ], $text );            }            elseif ($this->intextinput) {                $this->concat(                    $this->textinput[ $this->current_namespace][ $el ], $text );            }            elseif ($this->inimage) {                $this->concat(                    $this->image[ $this->current_namespace ][ $el ], $text );            }        }        else {            if ( $this->initem ) {                $this->concat(                    $this->current_item[ $el ], $text);            }            elseif ($this->intextinput) {                $this->concat(                    $this->textinput[ $el ], $text );            }            elseif ($this->inimage) {                $this->concat(                    $this->image[ $el ], $text );            }            elseif ($this->inchannel) {                $this->concat(                    $this->channel[ $el ], $text );            }                    }    }        function normalize () {        // if atom populate rss fields        if ( $this->is_atom() ) {            $this->channel['description'] = $this->channel['tagline'];            for ( $i = 0; $i < count($this->items); $i++) {                $item = $this->items[$i];                if ( isset($item['summary']) )                    $item['description'] = $item['summary'];                if ( isset($item['atom_content']))                    $item['content']['encoded'] = $item['atom_content'];                                $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];                if ( $atom_date ) {                    $epoch = @parse_w3cdtf($atom_date);                    if ($epoch and $epoch > 0) {                        $item['date_timestamp'] = $epoch;                    }                }                                $this->items[$i] = $item;            }               }        elseif ( $this->is_rss() ) {            $this->channel['tagline'] = $this->channel['description'];            for ( $i = 0; $i < count($this->items); $i++) {                $item = $this->items[$i];                if ( isset($item['description']))                    $item['summary'] = $item['description'];                if ( isset($item['content']['encoded'] ) )                    $item['atom_content'] = $item['content']['encoded'];                                if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {                    $epoch = @parse_w3cdtf($item['dc']['date']);                    if ($epoch and $epoch > 0) {                        $item['date_timestamp'] = $epoch;                    }                }                elseif ( isset($item['pubdate']) ) {                    $epoch = @strtotime($item['pubdate']);                    if ($epoch > 0) {                        $item['date_timestamp'] = $epoch;                    }                }                                $this->items[$i] = $item;            }        }    }            function is_rss () {        if ( $this->feed_type == RSS ) {            return $this->feed_version;         }        else {            return false;        }    }        function is_atom() {        if ( $this->feed_type == ATOM ) {            return $this->feed_version;        }        else {            return false;        }    }    /**    * return XML parser, and possibly re-encoded source    *    */    function create_parser($source, $out_enc, $in_enc, $detect) {        if ( substr(phpversion(),0,1) == 5) {            $parser = $this->php5_create_parser($in_enc, $detect);        }        else {            list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);        }        if ($out_enc) {            $this->encoding = $out_enc;            xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc);        }                return array($parser, $source);    }        /**    * Instantiate an XML parser under PHP5    *    * PHP5 will do a fine job of detecting input encoding    * if passed an empty string as the encoding.     *    * All hail libxml2!    *    */    function php5_create_parser($in_enc, $detect) {        // by default php5 does a fine job of detecting input encodings        if(!$detect && $in_enc) {            return xml_parser_create($in_enc);        }        else {            return xml_parser_create('');        }    }        /**    * Instaniate an XML parser under PHP4    *    * Unfortunately PHP4's support for character encodings    * and especially XML and character encodings sucks.  As    * long as the documents you parse only contain characters    * from the ISO-8859-1 character set (a superset of ASCII,    * and a subset of UTF-8) you're fine.  However once you    * step out of that comfy little world things get mad, bad,    * and dangerous to know.    *    * The following code is based on SJM's work with FoF    * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss    *    */    function php4_create_parser($source, $in_enc, $detect) {        if ( !$detect ) {            return array(xml_parser_create($in_enc), $source);        }                if (!$in_enc) {            if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {                $in_enc = strtoupper($m[1]);                $this->source_encoding = $in_enc;            }            else {                $in_enc = 'UTF-8';            }        }                if ($this->known_encoding($in_enc)) {            return array(xml_parser_create($in_enc), $source);        }                // the dectected encoding is not one of the simple encodings PHP knows                // attempt to use the iconv extension to        // cast the XML to a known encoding        // @see http://php.net/iconv               if (function_exists('iconv'))  {            $encoded_source = iconv($in_enc,'UTF-8', $source);            if ($encoded_source) {                return array(xml_parser_create('UTF-8'), $encoded_source);            }        }                // iconv didn't work, try mb_convert_encoding        // @see http://php.net/mbstring        if(function_exists('mb_convert_encoding')) {            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc );            if ($encoded_source) {                return array(xml_parser_create('UTF-8'), $encoded_source);            }        }                // else         $this->error("Feed is in an unsupported character encoding. ($in_enc) " .                     "You may see strange artifacts, and mangled characters.",                     E_USER_NOTICE);                    return array(xml_parser_create(), $source);    }        function known_encoding($enc) {        $enc = strtoupper($enc);        if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {            return $enc;        }        else {            return false;        }    }    function error ($errormsg, $lvl=E_USER_WARNING) {        // append PHP's error message if track_errors enabled        if ( isset($php_errormsg) ) {             $errormsg .= " ($php_errormsg)";        }        if ( MAGPIE_DEBUG ) {            trigger_error( $errormsg, $lvl);                }        else {            error_log( $errormsg, 0);        }                $notices = E_USER_NOTICE|E_NOTICE;        if ( $lvl&$notices ) {            $this->WARNING = $errormsg;        } else {            $this->ERROR = $errormsg;        }    }        } // end class RSSfunction map_attrs($k, $v) {    return "$k=\"$v\"";}// patch to support medieval versions of PHP4.1.x, // courtesy, Ryan Currie, ryan@digibliss.comif (!function_exists('array_change_key_case')) {	define("CASE_UPPER",1);	define("CASE_LOWER",0);	function array_change_key_case($array,$case=CASE_LOWER) {       if ($case=CASE_LOWER) $cmd=strtolower;       elseif ($case=CASE_UPPER) $cmd=strtoupper;       foreach($array as $key=>$value) {               $output[$cmd($key)]=$value;       }       return $output;	}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -