Advertisement
Guest User

Untitled

a guest
Jul 5th, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------------------
  2. PHP file to host anywhere
  3. -------------------------
  4. <?php
  5. //Set your time zone
  6. date_default_timezone_set('Europe/Madrid');
  7.  
  8. //File where items will be stored
  9. $archivo ='https://dl.dropboxusercontent.com/..../RSS/feed.txt';
  10.  
  11.  
  12. $str1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
  13. <rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">
  14. <channel>
  15. <title>Your feed</title>
  16. <link>http://..../feed.xml</link>
  17. <description>Shared RSS</description>
  18. <language>es-es</language>
  19. \r\n<atom:link href=\"http://..../feed.xml\" rel=\"self\" type=\"application/rss+xml\" />";
  20. $str11 = "\r\n<lastBuildDate>".date('D, d M Y H:i:s O')."</lastBuildDate>\r\n";
  21. $str2 = file_get_contents("$archivo");
  22. $str3 = "\r\n</channel></rss>";
  23.  
  24. $result = $str1 . $str11 . $str2 . $str3;
  25. $xml1 = preg_replace('#&(?=[a-z_0-9]+=)#', '&amp;', $result);
  26. $xml = new SimpleXMLElement($xml1);
  27.  
  28. foreach ($xml->channel->item as $item) {
  29.  $pubdate = $item->pubDate;
  30.  
  31.  if (($timestamp = strtotime(str_replace(" at "," ",$pubdate))) === false) {
  32.     $conv = date(DATE_RSS);
  33. } else {
  34.     $conv = date(DATE_RSS, strtotime(str_replace(" at "," ",$pubdate)));
  35. }
  36.  
  37. $item->pubDate = $conv;
  38. }
  39.  
  40. // Stores resultant XML file
  41. $xml->asXML ( '/home/..../public_html/feed.xml' );
  42.  
  43. //Shows XML on screen
  44. echo $xml->asXML();
  45.  
  46. ?>
  47.  
  48.  
  49. ------------------------------
  50. TEXT for the recipe content
  51. ------------------------------
  52. &#60;item&#62;<br/>
  53. &#60;title&#62;{{ArticleTitle}}&#60;/title&#62;<br/>
  54. &#60;link&#62;{{ArticleURL}}&#60;/link&#62;<br/>
  55. &#60;description&#62;
  56. &#60;![CDATA[
  57. {{ArticleContent}}
  58. ]]&#62;
  59. &#60;/description&#62;<br/>
  60. &#60;source url="{{SourceURL}}"&#62; {{SourceTitle}}&#60;/source&#62;<br/>
  61. &#60;pubDate&#62;{{ArticlePublishedAt}}&#60;/pubDate&#62;<br/>
  62. &#60;/item&#62;<br/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement