rss
/**
* 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;
}
if (!$this->getResource())
{
return false;
}
$this->getEncoding();
if ($this->encoding != "utf-8")
{
$this->resource = iconv($this->encoding, "UTF-8", $this->resource);
}
$xml_parser = xml_parser_create("utf-8");
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
xml_set_object($xml_parser, $this);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
xml_parse($xml_parser, $this->resource, true);
xml_parser_free($xml_parser);
if ( count($this->channel) > 1)
{
$this->channel['pubdate'] = $this->mystrtotime($this->channel['pubdate']);
if ($this->channel['pubdate'] {
$this->channel['pubdate'] = $this->items[0]['pubdate'];
}
}
return true;
}
function getAll()
{
return array(
'channel' => $this->channel,
'items' => $this->items,
'images' => $this->images
);
}
function getChannel()
{
return $this->channel;
}
function getItems()
{
return $this->items;
}
function getImages()
{
return $this->images;
}
function startElement($parser, $name, $attrs)
{
if ($this->insideitem || $this->insideimage || $this->insidechannel)
{
$this->tag = strtolower($name);
}
switch ($name)
{
case "channel" : $this->insidechannel = true; break;
case "item" : $this->insideitem = true; break;
case "image" : $this->insideimage = true; break;
}
}
function endElement($parser, $name)
{
if ($name == "channel")
{
$this->insidechannel = false;
}
else if ($name == "url")
{
$this->images[] = trim($this->image);
$this->insideimage = false;
$this->image = "";
}
else if ($name == "item")
{
$this->item['pubdate'] = $this->mystrtotime($this->item['pubdate']);
$this->item['description'] = trim(strip_tags($this->item['description']));
$this->item['description'] = str_replace(" ", "", $this->item['description']);
/**
if (strlen($this->item['description']) > 700)
{
$this->item['description'] = substr($this->item['description'], 0, 697) . "…";
}
*/
$this->items[] = $this->item;
$this->item = array();
$this->insideitem = false;
}
}
function characterData($parser, $data)
{
if ($this->insideitem)
{
switch ($this->tag)
{
case "title": $this->item['title'] .= $data; break;
case "description": $this->item['description'] .= $data; break;
case "link": $this->item['link'] .= $data; break;
case "dc:date": $this->item['pubdate'] .= $data; break;
case "pubdate": $this->item['pubdate'] .= $data; break;
case "modified": $this->item['pubdate'] .= $data; break;
}
}
elseif ($this->insideimage && $this->tag == "url")
{
$this->image .= $data;
}
elseif ($this->insidechannel)
{
switch ($this->tag)
{
case "title": $this->channel['title'] .= $data; break;
case "description": $this->channel['description'] .= $data; break;
case "link": $this->channel['link'] .= $data; break;
case "dc:date": $this->channel['pubdate'] .= $data; break;
case "pubdate": $this->channel['pubdate'] .= $data; break;
case "lastbuilddate": $this->channel['pubdate'] .= $data; break;
case "modified": $this->channel['pubdate'] .= $data; break;
}
}
}
/**
* 日期格式太多,除了php中的strtotime()函数能够转化的,我另外加了一个格式的识别,其他的未写。
*/
function mystrtotime($time)
{
$curtime = strtotime($time);
if ($curtme {
if (preg_match("|\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}|", $time, $result))
{
$time = str_replace(array("T", "+"), array(" ", " +"), $time);
$time[23] = "";
}
// if (………
$curtime = strtotime($time);
}
return $curtime;
}
function getError($msg)
{
die($msg);
}
}
?>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版
中文版,非常好用

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)