日期:2013-05-04 浏览次数:20480 次
<?php
/**
* Rss Parse Class ver0.1
*
* @link http://www.ugia.cn/?p=42
* @author: legend (PASiOcn@msn.com)
* @version 0.1
*/
class RssParse {
var $encoding = "utf-8";
var $rssurl = "http://www.ugia.cn/wp-rss2.php";
var $resource = "";
var $tag = "";
var $insidechannel = false;
var $insideitem = false;
var $insideimage = false;
var $item = array();
var $channel = array();
var $image = "";
var $items = array();
var $images = array();
function rssReset()
{
$this->item = array();
$this->channel = array();
$this->images = "";
$this->items = array();
$this->images = array();
}
function getResource()
{
$fp = @fopen($this->rssurl, "rb");
if (is_resource($fp)) {
while($data = fread($fp, 4096)) {
$ipd .= $data;
}
$this->resource = $ipd;
@fclose($fp);
return true;
}
return false;
}
function getEncoding()
{
if (preg_match('| encoding="([^"]*)"|', $this->resource, $result))
{
$this->encoding = strtolower($result[1]);
}
else
{
$this->encoding = "utf-8";
}
}
function parseRss($rssurl = '')
{
if (!empty($rssurl))
{
$this->rssurl = $rssurl;