RSS2 generation class

xiaoxiao2021-03-06  14

* @version beta-2, 2005-03-11 * @since exblog-1.3.0 * * /

Class Rss2Gen {var $ rss_header; // rss document header, store a root element and its version attribute. Var $ item; // var $ items; var $ channel_header; // Channel head information, storage channel name, URL, description, language, copyright, etc. // --------------- The following elements are optional channel child elements -------------- // var $ channel_language; // channel use Language species, such as EN-US, EN-CN, etc. VAR $ CHANNEL_COPYRIGHT; // Copyright statement of the channel content. VAR $ channel_managingEditor; // The personal email address VAR $ CHANNEL_WEBMASTER is responsible for the content of the channel; / / The personal email address VAR $ CHANNEL_PUBDATE (/ /) content for the technical support of the channel; // Time VAR $ CHANNEL_CATEGORY; / / Description Channel belongs to which one or more classification var $ channel_generator = " EXBLOG RSS2 Builder "; // Used to generate the channel VAR $ channel_docs; // rss file User's URL VAR $ CHANNEL_CLOUD; // Allows the process to register as "Cloud", the channel update notifies it VAR $ channel_ttl; // TTL represents the survival time, the survival time is A number, indicating that the number of minutes VAR $ channel_image before refresh; // specifies a GIF, JPEG or PNG image that can be displayed in the channel // var $ channel_Rating; / / About this channel PICS Rating // Var $ CHANNEL_TEXTINPUT; // Defines the input box // var $ channel_skiphours; // tells the aggregator Which hours of updates can ignore // var $ channel_skipdays; // Tell the aggregator The day update can ignore Var $ CHANNEL ; // The entire RSS2 document information is used to generate the entire page. VAR $ HALT_ON_ERROR = true; / ** * Constructor, its parameters are the channel child elements that must be RSS2, if not filling, the default content. * * @Param String $ TITLE Channel name, channel Title should be consistent with the TITLE of the Web site. * @Param String $ LINK The URL of the Web site associated with the channel. * @Param String $ Description For a brief description of the channel, if the introduction channel is doing. * @access public * / function} {$ this-> FillHeader ();} / ** * Generate an RSS document header, must be used as a root element with a element, there is a mandatory version of Version, specifying the current document Comply with RSS version.

* @access private * / function fillheader () {$ this-> rss_header = " / r / n"; $ this-> rss_header. = " / r / n";} / ** * Set the channel head, three of which are required. * @Param String $ TITLE Channel, the channel's title should be as consistent with the TITLE of the Web site. * @Param String $ LINK The URL of the Web site or site area associated with the channel. * @Param String $ Description For a simple description of the channel, what is the brief introduction to what the channel is doing. * / Function setChannel ($ title = "exblog", $ link = "http://www.exblog.org", $ description = "exblog") {$ this-> channel_Header = " <! [Cdata [ "$ TITLE."]]> </ title> / n "; $ this-> channel_header. =" <link> ". $ link." </ link> / r / n "; $ this-> Channel_Header. = "<Description> <! $ Description."]> </ Description> / r / n ";} Function Halt ($ msg) {= {$ this-> Halt_on_error) {$ this-> Haltmsg ($ msg);} Die ("EXBLOG RSS2 EXIT");} Function Haltmsg ($ msg) {sprintf ("<b> EXBLOG RSS2 Builder Error:% S <B> <BR> / R / N", $ msg);} / ** * Set the language of the RSS document, default is Simplified Chinese.</p> <p>* @access public * / function setLanguage ($ tHIS-> CHANNEL_LANGUAGE = "<language>". $ lang. "</ language> / r / n";} / ** * channel content Copyright * @access public * / function setcopyright ($ copyright = "exblog") {$ this-> channel_copyright = "<copyright>". $ Copyright. "</ Copyright> / r / n";} / ** * Personal email address for the content of the channel * @access public * / function setmanagingEditor ($ email = null) {if (Empty ($ email) {$ this-> halt ("If you set the channel content The personal email address, please fill in her. ");} $ This-> Channel_managingEditor =" <managingEditor> ". $ Email." </ ManagingEditor> / r / n ";} / ** * Support for personal email addresses * @access public * / function setWebmaster ($ email = null) {if ($ this-> halt ("If you set the technical support of the channel Email address, please fill in her. :) ");} $ this-> channel_webmaster =" <webmaster> ". $ Email." </ Webmaster> / r / n ";}</p> <p>/ ** * The announcement date of the channel content. * @access public * / function setpubdate ($ DATE = NULL) {IF (Empty ($ DATE) {$ DATE = DATE ("Y / m / D"); $ this-> channel_pubdate = "<pubdate>". $ DATE. "</ pubdate> / r / n";} $ this-> channel_pubdate = "<pubdate>". $ DATE. "</ pubdate> / r / n";} / ** * Last Channel content Change time * @access public * / function setlastbuilddate ($ DATE = null) {if ($ DATE) {$ DATE = Date ("Y / m / D"); $ this-> channel_lastbuilddate = "<LastBuilddate > "$ DATE." </ lastbuilddate> / r / n ";} $ this-> Channel_LastBuilddate =" <lastbuilddate> ". $ date." </ lastbuilddate> / r / n ";} / ** * Which or more categories belong to the channel * @access public * / function setcategory ($ category) {$ this-> Channel_category = "<category>". $ Category. "</ Category> / r / n";</p> <p>/ ** * RSS file The format of the format of the document is located in the URL * @access public * / function setDocs ($ URL) {$ this-> channel_docs = "<docs>". $ URL. "</ Docs> / r / N ";</p> <p>/ ** * TTL represents the survival time, the survival time is a number, indicating that the number of minutes before refreshing * @access public * / function settl ($ minute) {$ this-> channel_ttl = "<ttl>". "</ ttl> / r / n";}</p> <p>/ ** * Specifies a GIF, JPEG or PNG image * @Param string $ URL that can be displayed in the channel, is the URL * @Param string $ TIL * @Param string $ TIL * @Param string $ TIL * @Param string $ TIL * @Param String $ TIL Description of icons. When the channel is presented in HTML, it is used as an Alt property of the HTML <image> tag. * @Param string $ link must be the URL of the site. If the channel is presented in HTML, the image is used as a link to this site. * @Param Integer $ width indicates the pixel wide image, must be set with $ HEIGHT, otherwise this property will not be displayed. * @Param Integer $ HEIGHT indicates that the image is high, must be set with $ WIDTH, otherwise this property will not be displayed. * @Param String $ Description The title attribute of the link element formed by the image. * * @Access public * / Function SetChannelImage ($ URL, $ TITLE, $ LINK, $ Width = NULL, $ TISRIGHT = NULL, $ Description = NULL) {if (! Isset ($ URL)) $ this-> Halt "If you want to set pictures, the image address attribute must be filled in."); If (! Isset ($ TITLE)) $ this-> halt ("If you want to set pictures, the image description property must be filled."); If (! isset) $ this-> halt ("If you want to set a picture, the image link attribute must be filled in. This URL is generally the same as the image address property"); $ this-> channel_image = "<image> / R / N "; $ this-> channel_image. =" <url> ". $ URL." </ url> / r / n "; $ this-> channel_image. =" <title> <! [cdata [". $ TITLE. "]]> </ title> / r / n"; $ this-> channel_image. = "<link>". $ link. "</ link> / r / n"; // If the image is set Wide, high to add this property.</p> <p>IF (! EMPTY ($ held)) {$ this-> channel_image. = "<width>". $ width. "</ width> / r / n"; $ this-> channel_image. = "<HEIGHT>". $ Height. "</ Height> / r / n";} IF (! EMPTY ($ description)) $ this-> channel_image. = "<Description> <! [Cdata [". Description. "]> </ description> / r / n"; $ this-> channel_image. = "</ image> / r / n";} / ** * Add a item to Channel, although Item Elements are optional, but at least there is at least a title or description * * @Param String $ Title item (Item) title * @Param String $ Description (Item) Outline * @Param String $ LINK Item (Item) URL * @Param String $ Author Item (Item) Author's email address * @Param string $ Category includes one or more categories of item (Item) * @Param String $ Comments About UNO (Item) Note Page URL * @Param String $ Enclosure Support and This (Item) related media object * @Param string $ GUID Unique permanent link to this (item) Contact * @Param string $ pubdate This (item) is when Published * @Param String $ source This (item) comes from which RSS channel, very useful when the item (item) is aggregated together * * @access public * / function additem ($ title = null, $ description = null, $ link = null, $ author = null, $ category = null, $ comments = n ULL, $ Enclosure = NULL, $ Guid = NULL, $ Pubdate = NULL, $ SOURCE = NULL) {// Judgment does at least add Title or Description if ($ TITLE) && Empty ($ description)) {$ THIS -> Halt ("Item: Please set at least the Title or Description property.</p> <p>");} Else {$ this-> item =" <item> / r / n "; if (! EMPTY ($ TITLE)) $ this-> item. =" <Title> <! [Cdata [". Title. "]]> </ title> / r / n"; if (! EMPTY ($ LINK)) $ this-> item. = "<link>". $ link. "</ link> / r / n "; If (! EMPTY ($ description)) $ this-> item. =" <Design> <! [Cdata [". $ Description."]]> </ Description> / r / n "; if (! EMPTY) ($ author)) $ this-> item. = "<author> <! [cdata [". $ author. "]]> </ author> / r / n"; if (! Empty ($ category)) $ This-> item. = "<category> <! [cdata [". $ category. "]]> </ category> / r / n"; if (! Empty ($ comments)) $ this-> item. = "<Comments> <! [Cdata [". $ Comments. "]]> </ Comments> / r / n"; if (! EMPTY ($ enclosure)) $ this-> item. = "<Enclosure> <! [Cdata ["$ enclosure."]> </ Enclosure> / r / n "; if (! EMPTY ($ GUID)) $ this-> item. =" <Guid> ". $ Guid." </ Guid> / r / n "; if (! EMPTY ($ Pubdate)) $ this-> item. =" <pubdate> ". $ Pubdate." </ pubdate> / r / n "; if (! EMPTY ($ Source)) $ this-> item. = "<source> <! [cdata [". $ source. "]]> </ source> / r / n"; $ this-> item. = "</ item> / r / n";} $ this-> items. = $ this-> item;} / ** * Output RSS2 Document * / Function Builder () {$ this-> stuff (); Header ("Content-Type: Application / XML"); Print $ this-> channel;} / ** * Compatible with the old version RSS generation method, remove the write file function.</p> <p>* * / Function buildrssfeed ($ param = null) {$ this-> builder ();</p> <p>/ ** * Synthetic Over RSS2 Document * * / Function Stuff () {$ this-> Channel = $ THIS-> RSS_HEADER; $ this-> Channel. = $ This-> channel_header; if (isset ($ this-> channel_language $ This-> channel. = $ This-> channel_language; if ($ this-> channel_copyright) $ this-> channel. = $ This-> channel_copyright; if ($ this-> channel_manageditor)) $ this-> Channel. = $ this-> Channel_managingEditor; if ($ this-> channel_webmaster) $ this-> channel_webmaster; if (isset ($ this-> channel_pubdate)) $ THIS -> Channel. = $ this-> channel_pubdate; if ($ 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 ($ this-> channel_ttl) $ this-> channel. = $ this-> channel_ttl; if (isset ($ this-> channel_image)) $ this-> channel. = $ TH IS-> Channel_Image; $ this-> channel_generator; $ this-> channel. = $ this-> items; $ this-> channel. = "</ rS> / r / n";} } / ***************************** RSS2GEN class usage comment ************ ****** / / * $ rss2gen = new rss2gen (); $ rS2gen-> setChannel ("EXBLOG222RSS", "http://elliott.fengling.net", "Elliott RSS2GEN"); // The following section is Additional information // $ rss2gen-> setLanguage ("en-cn"); // $ rss2gen-> setcopyright ("exblog @"); //$ r $ @> sTManagingEditor ("elliott_hee@163.com "); / / $ rS2gen-></p> <p>SetWebmaster ("Elliott@yeah.net"); // $ rss2gen-> setpubdate (); // $ rss2gen-> setlastbuilddate (); // $ rss2gen-> setcategory ("none"); // $ r s2gen-> SetDOCS ("http://www.exblog.org/rss_docs.html"); // $ r $ r 2 en-> setttl (600); //$Rss2GEN->SetChannelImage ("http://www.exblog.org/demo .gif "," demo ~~ :) "," http://www.exblog.org "); // ----------------------- - // - Add a record to the RSS document, at least one parameter, Title or Description $ RSS2GEN-> AddItem ("ITEM1", "Item1's Description", "http://www.exblog.org/?play = 1 "," Elliott "," Default Category "," Description. "," Support and Media Objects related to this (Item) "," Unique Permanent Link " "2005-03-12", "This (item) comes from which RSS channel is very useful when the item (ITEM) is aggregated"); $ RSS2GEN-> AddItem ("Item2", "Item2's Description") ; $ Rss2gen-> additem ("item3");</p> <p>$ RSS2GEN-> Builder (); // Compatible with the old version Method // $ rss2gen-> buildrsSfeed (); * /?></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-48024.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="48024" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.047</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Ac_2BSTYdxu5eBe0mGWnk_2BFVCnNnMlrow2EJ12det57im6GNw1T0685eLsMV8ydLylsF8JJFcXDOhoq2Q4PtS81A_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>