php教程 php手册 rss2生成类

rss2生成类

Jun 21, 2016 am 09:05 AM
channel gt lt this

rss

  • php/**//* * @(#)Rss2Gen.inc.php (beta) 2005/2/19 *  * exblog RSS2 生成类,实现了RSS2规范中的大部分内容。 *  * 使用方法请见本类底部(Rss2Gen类使用注释)信息。 * * 本程序为免费程序,源代码使用者可任意更改(请勿用于商业用途),但请保留本版权信息! *  * @author  HexUzHoNG <hexuzhong> * @version beta-2, 2005-03-11 * @since   exBlog-1.3.0 * */ class Rss2Gen {    var $rss_header;  //RSS文档头,存放一个<rss>根元素及其version属性。  var $item;    //  var $items; var $channel_header; //频道的头部信息,存放频道名称、URL、描述、语言、版权等等。 //--------------- 以下元素是可选的频道子元素 --------------// var $channel_language; //频道使用的语言种类,例如en-us、zh-cn等,放便聚集器组织中一语言的站点。 var $channel_copyright; //频道内容的版权声明。 var $channel_managingEditor; //对该频道内容负责的个人的Email地址 var $channel_webMaster;   //对该频道的技术支持负责的个人的Email地址 var $channel_pubDate;   //该频道内容的公布日期 var $channel_lastBuildDate;  //上次频道内容更改的时间 var $channel_category;   //说明频道属于哪一个或多个分类 var $channel_generator = "<generator>exblog RSS2 builder</generator>"; //用于生成该频道的程序 var $channel_docs;   //RSS文件所使用格式的说明文档所在的URL var $channel_cloud;   //允许进程注册为“cloud”,频道更新时通知它 var $channel_ttl;   //ttl 代表存活时间,存活时间是一个数字,表示提要在刷新之前缓冲的分钟数 var $channel_image;   //指定一个能在频道中显示的GIF、JPEG 或PNG 图像 //var $channel_rating;  //关于该频道的 PICS 评价 //var $channel_textInput;  //定义可与频道一起显示的输入框 //var $channel_skipHours;  //告诉聚集器哪些小时的更新可以忽略 //var $channel_skipDays;  //告诉聚集器那一天的更新可以忽略  var $channel;   //整个rss2文档信息,用与生成整个页面。  var $halt_on_error = true;   /**//**    * 构造函数,其参数皆为rss2必须的频道子元素,如果不填,则为默认内容。   *    * @param String $title 频道的名称,频道的title应该和web站点的title尽量一致。   * @param String $link 与该频道关联的web站点的URL。   * @param String $description 对频道的一段简单描述,如介绍频道是做什么的。   * @access public   */  function Rss2Gen() {  $this->fillHeader();  }    /**//**   * 生成RSS文档头,必须以一个<rss>元素作为根元素,其有一个强制属性version,指定当前文档遵守的RSS版本。   * @access private   */  function fillHeader() {   $this->rss_header = "</rss></rss></hexuzhong>
    로그인 후 복사
    <font face="新宋体"><span style="BORDER-BOTTOM: #ffffff 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000bb"></span><span style="COLOR: #0000bb">xml</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #0000bb">version</span><span style="COLOR: #007700">=</span><span style="COLOR: #007700">"</span><span style="COLOR: #0000bb">1</span><span style="COLOR: #0000bb">.</span><span style="COLOR: #0000bb">0</span><span style="COLOR: #0000bb">"</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #0000bb">encoding</span><span style="COLOR: #0000bb">=</span><span style="COLOR: #0000bb">"</span><span style="COLOR: #0000bb">gb2312</span><span style="COLOR: #0000bb">"</span><span style="COLOR: #0000bb">?></span></span><br></font>
    rn";   $this->rss_header .= " <rss version="2.0">rn";  }  /**//**  * 设置频道头,其中三个元素为必须的。  * @param String $title 频道的名称,频道的title应该和Web站点的title尽量一致。  * @param String $link 与该频道关联的Web站点或者站点区域的URL。  * @param String $description 对频道的一段简单描述,简要介绍频道是做什么的。  */ function setChannel($title = "exblog", $link = "http://www.exblog.org", $description = "exblog") {  $this->channel_header = "  <title></title>n";   $this->channel_header .= "  <link>".$link."rn";   $this->channel_header .= "  <description></description>rn"; }  function halt($msg) {  if ($this->halt_on_error) {   $this->haltmsg($msg);  }  die("exblog RSS2 exit"); }  function haltmsg($msg) {  sprintf("<b>exblog RSS2 builder ERROR: %s</b><br>rn", $msg); }  /**//**  * 设置该RSS文档的语言,默认为简体中文。  * @access public  */  function setLanguage($lang = "zh_cn") {   $this->channel_language = "  <language>".$lang."</language>rn";   }   /**//**  * 频道内容的版权声明  * @access public  */  function setCopyright($copyright = "exblog") {   $this->channel_copyright = "  <copyright>".$copyright."</copyright>rn";  }   /**//**  * 对该频道内容负责的个人的Email地址  * @access public  */  function setManagingEditor($email = NULL) {   if (empty($email)) {    $this->halt("如果你设置了该频道内容负责的个人的Email地址,请填写她。");   }   $this->channel_managingEditor = "  <managingeditor>".$email."</managingeditor>rn";  }   /**//**  * 对该频道的技术支持负责的个人的Email地址  * @access public  */  function setWebMaster($email = NULL) {   if (empty($email)) {    $this->halt("如果你设置了该频道的技术支持负责的个人的Email地址,请填写她。 :)");   }   $this->channel_webMaster = "  <webmaster>".$email."</webmaster>rn";  }  /**//**  * 该频道内容的公布日期。  * @access public  */  function setPubDate($date = NULL) {   if (empty($date)) {   $date = date("Y/m/d");    $this->channel_pubDate = "  <pubdate>".$date."</pubdate>rn";   }   $this->channel_pubDate = "  <pubdate>".$date."</pubdate>rn";  }   /**//**  * 上次频道内容更改的时间  * @access public  */  function setLastBuildDate($date = NULL) {  if (empty($date)) {   $date = date("Y/m/d");     $this->channel_lastBuildDate = "  <lastbuilddate>".$date."</lastbuilddate>rn";   }   $this->channel_lastBuildDate = "  <lastbuilddate>".$date."</lastbuilddate>rn";  } /**//**  * 说明频道属于哪一个或多个分类  * @access public  */  function setCategory($category) {   $this->channel_category = "  <category>".$category."</category>rn";  }  /**//**  * RSS文件所使用格式的说明文档所在的URL  * @access public  */  function setDocs($url) {   $this->channel_docs = "  <docs>".$url."</docs>rn";  }  /**//**  * ttl 代表存活时间,存活时间是一个数字,表示提要在刷新之前缓冲的分钟数  * @access public  */  function setTtl($minute) {   $this->channel_ttl = "  <ttl>".$minute."</ttl>rn";  }  /**//**  * 指定一个能在频道中显示的GIF、JPEG 或PNG 图像  *  * @param String $url 必需,是表示该频道的 GIF、JPEG 或 PNG 图像的URL  * @param String $title 必需,是图象的描述。当频道以 HTML 呈现时,用作 HTML <image> 标签的 ALT 属性。  * @param String $link 必需,是站点的 URL。如果频道以 HTML 呈现,该图像作为到这个站点的链接。  * @param Integer $width 表示图象的像素宽,必须和 $height 一同设置,否则不会显示此属性。  * @param Integer $height 表示图象的像素高,必须和 $width 一同设置,否则不会显示此属性。  * @param String $description 围绕着该图像形成的链接元素的 title 属性。  *  * @access public  */  function setChannelImage($url, $title, $link, $width = NULL, $height = NULL, $description = NULL) {   if (!isset($url))    $this->halt("如果你要设置图片,该图像地址属性必须填写。");   if (!isset($title))    $this->halt("如果你要设置图片,该图像描述属性必须填写。");   if (!isset($link))    $this->halt("如果你要设置图片,该图像链接属性必须填写。这个URL一般和图像地址属性相同");   $this->channel_image = "  <image>rn";   $this->channel_image .= "   <url>".$url."</url>rn";   $this->channel_image .= "   <title></title>rn";   $this->channel_image .= "   <link>".$link."rn";   //如果设置了图像宽、高则添加此属性。   if (!empty($width) && !empty($height)) {    $this->channel_image .= "   <width>".$width."</width>rn";    $this->channel_image .= "   <height>".$height."</height>rn";   }   if (!empty($description))    $this->channel_image .= "   <description></description>rn";   $this->channel_image .= "</image>rn";  }    /**//**   * 添加一条item到channel中,虽然item的子元素都是可选的,但至少要存在一个title或description  *  * @param String $title 项(item)的标题  * @param String $description 项(item)的大纲  * @param String $link 项(item)的URL  * @param String $author 项(item)作者的Email 地址  * @param String $category 包括项(item)的一个或多个分类  * @param String $comments 关于项(item)的注释页的URL  * @param String $enclosure 支持和该项(item)有关的媒体对象  * @param String $guid 唯一与该项(item)联系在一起的永久性链接  * @param String $pubDate 该项(item)是什么时候发布的  * @param String $Source 该项(item)来自哪个RSS 频道,当把项(item)聚合在一起时非常有用  *  * @access public   */  function addItem($title = NULL, $description = NULL, $link = NULL, $author = NULL, $category = NULL, $comments = NULL, $enclosure = NULL, $guid = NULL, $pubDate = NULL, $source = NULL) {   //判断是否至少添加了title或description   if (empty($title) && empty($description)) {   $this->halt("item:请至少设置title或description属性。");  }  else {    $this->item = "  <item>rn";    if (!empty($title))     $this->item .= "   <title></title>rn";    if (!empty($link))     $this->item .= "   <link>".$link."rn";    if (!empty($description))     $this->item .= "   <description></description>rn";    if (!empty($author))     $this->item .= "   <author></author>rn";    if (!empty($category))     $this->item .= "  <category></category>rn";    if (!empty($comments))     $this->item .= "   <comments></comments>rn";    if (!empty($enclosure))     $this->item .= "   <enclosure></enclosure>rn";     if (!empty($guid))     $this->item .= "   <guid>".$guid."</guid>rn";    if (!empty($pubDate))     $this->item .= "   <pubdate>".$pubDate."</pubdate>rn";    if (!empty($source))     $this->item .= "   <source></source>rn";    $this->item .= "</item>rn";   }   $this->items .= $this->item;  }   /**//**  * 输出 rss2 文档  */  function builder() {  $this->stuff();  header("Content-type:application/xml");  print $this->channel;  }  /**//**  * 兼容老版本rss生成方法,去掉了写文件功能。  *  */ function buildRssFeed($param = NULL) {  $this->builder(); } /**//**  * 合成整个RSS2文档  *  */ function stuff() {  $this->channel = $this->rss_header;  $this->channel .= $this->channel_header;  if (isset($this->channel_language))   $this->channel .= $this->channel_language;  if (isset($this->channel_copyright))   $this->channel .= $this->channel_copyright;  if (isset($this->channel_managingEditor))   $this->channel .= $this->channel_managingEditor;  if (isset($this->channel_webMaster))   $this->channel .= $this->channel_webMaster;  if (isset($this->channel_pubDate))   $this->channel .= $this->channel_pubDate;  if (isset($this->channel_lastBuildDate))   $this->channel .= $this->channel_lastBuildDate;  if (isset($this->channel_category))   $this->channel .= $this->channel_category;  if (isset($this->channel_docs))   $this->channel .= $this->channel_docs;  if (isset($this->channel_cloud))   $this->channel .= $this->channel_cloud;  if (isset($this->channel_ttl))   $this->channel .= $this->channel_ttl;  if (isset($this->channel_image))   $this->channel .= $this->channel_image;  $this->channel .= $this->channel_generator;  $this->channel .= $this->items;  $this->channel .= "</image></rss>rn"; } } /**//******************************* Rss2Gen 类使用注释 *******************/ /**//* $rss2gen = new Rss2Gen(); $rss2gen->setChannel("exblog222rss", "http://elliott.fengling.net", "elliott rss2gen"); //以下部分为可添加信息 //$rss2gen->setLanguage("zh-cn"); //$rss2gen->setCopyright("exblog @"); //$rss2gen->setManagingEditor("elliott_hee@163.com"); //$rss2gen->setWebMaster("elliott@yeah.net"); //$rss2gen->setPubDate(); //$rss2gen->setLastBuildDate(); //$rss2gen->setCategory("none"); //$rss2gen->setDocs("http://www.exblog.org/rss_docs.html"); //$rss2gen->setTtl(600); //$rss2gen->setChannelImage("/XrssFile/2006-9/24/200692413947513.gif", "demo~~ :)", "http://www.exblog.org"); //------------------------ //---添加一条记录到rss文档中,至少需要一个参数,title或description $rss2gen->addItem("item1", "item1's description", "http://www.exblog.org/?play=1",        "elliott", "默认分类", "描述呀描述。", "支持和该项(item)有关的媒体对象",       "唯一与该项(item)联系在一起的永久性链接", "2005-03-12",       "该项(item)来自哪个RSS 频道,当把项(item)聚合在一起时非常有用"); $rss2gen->addItem("item2", "item2's description"); $rss2gen->addItem("item3"); $rss2gen->builder(); //兼容老版本中方法 //$rss2gen->buildRssFeed(); */
    로그인 후 복사


  • 본 웹사이트의 성명
    본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

    핫 AI 도구

    Undresser.AI Undress

    Undresser.AI Undress

    사실적인 누드 사진을 만들기 위한 AI 기반 앱

    AI Clothes Remover

    AI Clothes Remover

    사진에서 옷을 제거하는 온라인 AI 도구입니다.

    Undress AI Tool

    Undress AI Tool

    무료로 이미지를 벗다

    Clothoff.io

    Clothoff.io

    AI 옷 제거제

    AI Hentai Generator

    AI Hentai Generator

    AI Hentai를 무료로 생성하십시오.

    인기 기사

    R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
    4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. 최고의 그래픽 설정
    4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
    4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
    1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌

    뜨거운 도구

    메모장++7.3.1

    메모장++7.3.1

    사용하기 쉬운 무료 코드 편집기

    SublimeText3 중국어 버전

    SublimeText3 중국어 버전

    중국어 버전, 사용하기 매우 쉽습니다.

    스튜디오 13.0.1 보내기

    스튜디오 13.0.1 보내기

    강력한 PHP 통합 개발 환경

    드림위버 CS6

    드림위버 CS6

    시각적 웹 개발 도구

    SublimeText3 Mac 버전

    SublimeText3 Mac 버전

    신 수준의 코드 편집 소프트웨어(SublimeText3)

    화웨이 GT3 Pro와 GT4의 차이점은 무엇입니까? 화웨이 GT3 Pro와 GT4의 차이점은 무엇입니까? Dec 29, 2023 pm 02:27 PM

    많은 사용자들이 스마트 시계를 선택할 때 Huawei 브랜드를 선택하게 됩니다. 그 중 Huawei GT3pro와 GT4가 가장 인기 있는 선택입니다. 두 제품의 차이점을 궁금해하는 사용자가 많습니다. Huawei GT3pro와 GT4의 차이점은 무엇입니까? 1. 외관 GT4: 46mm와 41mm, 재질은 유리 거울 + 스테인레스 스틸 본체 + 고해상도 섬유 후면 쉘입니다. GT3pro: 46.6mm 및 42.9mm, 재질은 사파이어 유리 + 티타늄 본체/세라믹 본체 + 세라믹 백 쉘입니다. 2. 건강한 GT4: 최신 Huawei Truseen5.5+ 알고리즘을 사용하면 결과가 더 정확해집니다. GT3pro: ECG 심전도, 혈관 및 안전성 추가

    수정: Windows 11에서 캡처 도구가 작동하지 않음 수정: Windows 11에서 캡처 도구가 작동하지 않음 Aug 24, 2023 am 09:48 AM

    Windows 11에서 캡처 도구가 작동하지 않는 이유 문제의 근본 원인을 이해하면 올바른 솔루션을 찾는 데 도움이 될 수 있습니다. 캡처 도구가 제대로 작동하지 않는 주요 이유는 다음과 같습니다. 초점 도우미가 켜져 있습니다. 이렇게 하면 캡처 도구가 열리지 않습니다. 손상된 응용 프로그램: 캡처 도구가 실행 시 충돌하는 경우 응용 프로그램이 손상되었을 수 있습니다. 오래된 그래픽 드라이버: 호환되지 않는 드라이버가 캡처 도구를 방해할 수 있습니다. 다른 응용 프로그램의 간섭: 실행 중인 다른 응용 프로그램이 캡처 도구와 충돌할 수 있습니다. 인증서가 만료되었습니다. 업그레이드 프로세스 중 오류로 인해 이 문제가 발생할 수 있습니다. 이 문제는 대부분의 사용자에게 적합하며 특별한 기술 지식이 필요하지 않습니다. 1. Windows 및 Microsoft Store 앱 업데이트

    iPhone에서 App Store 오류에 연결할 수 없는 문제를 해결하는 방법 iPhone에서 App Store 오류에 연결할 수 없는 문제를 해결하는 방법 Jul 29, 2023 am 08:22 AM

    1부: 초기 문제 해결 단계 Apple 시스템 상태 확인: 복잡한 솔루션을 살펴보기 전에 기본 사항부터 시작해 보겠습니다. 문제는 귀하의 기기에 있는 것이 아닐 수도 있습니다. Apple 서버가 다운되었을 수도 있습니다. Apple의 시스템 상태 페이지를 방문하여 AppStore가 제대로 작동하는지 확인하세요. 문제가 있는 경우 Apple이 문제를 해결하기를 기다리는 것뿐입니다. 인터넷 연결 확인: "AppStore에 연결할 수 없음" 문제는 때때로 연결 불량으로 인해 발생할 수 있으므로 인터넷 연결이 안정적인지 확인하십시오. Wi-Fi와 모바일 데이터 간을 전환하거나 네트워크 설정을 재설정해 보세요(일반 > 재설정 > 네트워크 설정 재설정 > 설정). iOS 버전을 업데이트하세요.

    php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

    php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

    Go 언어에서 채널은 무엇을 의미하나요? Go 언어에서 채널은 무엇을 의미하나요? Dec 14, 2023 pm 02:21 PM

    Go 언어의 채널은 코루틴 간의 통신 및 데이터 동기화를 위한 메커니즘입니다. 서로 다른 코루틴 간에 데이터를 전송하는 데 사용되는 큐 또는 파이프와 유사한 특수 데이터 유형으로 생각할 수 있습니다. 채널은 보내기와 받기라는 두 가지 주요 작업을 제공합니다. 채널의 전송 및 수신 작업이 모두 차단됩니다. 즉, 전송자나 수신자가 준비되지 않은 경우 코루틴이 해당 작업을 수행할 준비가 될 때까지 작업이 차단됩니다.

    이 점을 이해하고 프론트엔드 70%를 따라잡는 글 이 점을 이해하고 프론트엔드 70%를 따라잡는 글 Sep 06, 2022 pm 05:03 PM

    Vue2의 이 포인팅 문제로 인해 동료가 버그로 인해 화살표 기능이 사용되어 해당 소품을 얻을 수 없게 되었습니다. 제가 그에게 소개했을 때 그는 그것을 몰랐고, 그래서 저는 일부러 프론트엔드 커뮤니케이션 그룹을 살펴보았습니다. 지금까지 적어도 70%의 프론트엔드 프로그래머들은 오늘 그것을 이해하지 못하고 있습니다. 모든 것이 불분명하다면 이 링크를 아직 배우지 않았다면 큰 소리로 말해주세요.

    Vue2가 이를 통해 다양한 옵션의 속성에 접근할 수 있는 이유에 대해 이야기해보겠습니다. Vue2가 이를 통해 다양한 옵션의 속성에 접근할 수 있는 이유에 대해 이야기해보겠습니다. Dec 08, 2022 pm 08:22 PM

    이 글은 Vue 소스 코드를 해석하는 데 도움이 될 것이며 이를 사용하여 Vue2의 다양한 옵션에서 속성에 액세스할 수 있는 이유를 소개하는 것이 모든 사람에게 도움이 되기를 바랍니다!

    watch4pro가 더 나은가요, 아니면 gt인가요? watch4pro가 더 나은가요, 아니면 gt인가요? Sep 26, 2023 pm 02:45 PM

    Watch4pro와 gt는 각각 서로 다른 기능과 적용 가능한 시나리오를 가지고 있습니다. 포괄적인 기능, 고성능, 세련된 외관에 중점을 두고 더 높은 가격을 감수할 의향이 있다면 Watch 4 Pro가 더 적합할 수 있습니다. 높은 기능 요구 사항이 없고 배터리 수명과 합리적인 가격에 더 많은 관심을 기울이는 경우 GT 시리즈가 더 적합할 수 있습니다. 최종 선택은 개인의 필요와 예산, 선호도에 따라 결정되어야 합니다. 자신의 필요를 잘 고려한 후 구매하고, 다양한 제품에 대한 리뷰와 비교를 참고하여 보다 현명한 선택을 하는 것이 좋습니다.

    See all articles