Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. require_once('../includes/config.php');
  3. include '../includes/Parsedown.php';
  4. $rss_id = 0;
  5. $rss_author = "";
  6. if ($_GET['content'])
  7. {
  8. $rss_content = safe($_GET['content']);
  9. switch ($rss_content)
  10. {
  11. case "blog":
  12. $rss_title = $CONF['blog_title'];
  13. $rss_desc = $CONF['blog_desc'];
  14. if ($_GET['author'])
  15. {
  16. if ($userTools->checkUsernameExists($_GET['author']))
  17. {
  18. $rss_user = $userTools->getUser($_GET['author']);
  19. $rss_id = $rss_user->id;
  20. $rss_author = $rss_user->username;
  21. $rss_title = rawurldecode($rss_user->blog_title);
  22. $rss_desc = rawurldecode($rss_user->blog_desc);
  23. }
  24. }
  25. break;
  26. case "podcast":
  27. $rss_title = $CONF['podcast_title'];
  28. $rss_desc = $CONF['podcast_desc'];
  29. break;
  30. default:
  31. break;
  32. }
  33. header("Content-Type: application/xml; charset=UTF-8");
  34. $rssfeed = '<?xml version="1.0" encoding="UTF-8"?>';
  35. $rssfeed .= '<rss version="2.0">';
  36. $rssfeed .= '<channel>';
  37. $rssfeed .= '<title><![CDATA['.$rss_title.']]></title>';
  38. $rssfeed .= '<link>'.get_page_url($rss_content, $CONF).'/'.$rss_author.'</link>';
  39. $rssfeed .= '<description><![CDATA['.$rss_desc.']]></description>';
  40. $rssfeed .= '<language>en-us</language>';
  41. $rssfeed .= '<copyright>Copyright (C) 2013-'.date('Y', time()).' Teknik.io';
  42. if (!empty($rss_author))
  43. {
  44. $rssfeed .= 'and '.$rss_author;
  45. }
  46. $rssfeed .= '</copyright>';
  47. switch ($rss_content)
  48. {
  49. case "blog":
  50. // Grab blog posts //
  51. $blog_posts = $db->select('blog', "user_id=? ORDER BY date_posted DESC", array($rss_id));
  52. $posts = array();
  53. foreach ($blog_posts as $post)
  54. {
  55. if (!is_array($post))
  56. {
  57. $posts = array($blog_posts);
  58. break;
  59. }
  60. array_push($posts, $post);
  61. }
  62. if ($posts)
  63. {
  64. foreach ($posts as $post)
  65. {
  66. $post_id = $post['id'];
  67. $author_id = $post['author_id'];
  68. $author = $userTools->get($author_id);
  69. $date = $post['date_posted'];
  70. $title = rawurldecode($post['title']);
  71. $tags = $post['tags'];
  72. $Parsedown = new Parsedown();
  73. $post = $Parsedown->text($post['post']);
  74. $rssfeed .= '<item>';
  75. $rssfeed .= '<title><![CDATA[' . $title . ']]></title>';
  76. $rssfeed .= '<description><![CDATA[' . $post . ']]></description>';
  77. $rssfeed .= '<link>' . get_page_url("blog", $CONF) .'/'. $author->username .'/'. $post_id . '</link>';
  78. $rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O",strtotime($date)) . '</pubDate>';
  79. $rssfeed .= '</item>';
  80. }
  81. }
  82. break;
  83. case "podcast":
  84. // Grab podcasts //
  85. $podcasts = $db->select('podcast', "1=? ORDER BY date_posted DESC", array(1));
  86. $pods = array();
  87. foreach ($podcasts as $pod)
  88. {
  89. if (!is_array($pod))
  90. {
  91. $pods = array($podcasts);
  92. break;
  93. }
  94. array_push($pods, $pod);
  95. }
  96. if ($pods)
  97. {
  98. foreach ($pods as $pod)
  99. {
  100. $post_id = $pod['id'];
  101. $user_id = $pod['user_id'];
  102. $date = $pod['date_posted'];
  103. $title = rawurldecode($pod['title']);
  104. $tags = $pod['tags'];
  105. $file = $pod['file_name'];
  106. $files = explode(',', $file);
  107. $Parsedown = new Parsedown();
  108. $post = $Parsedown->text($pod['description']);
  109. $rssfeed .= '<item>';
  110. $rssfeed .= '<title><![CDATA[' . $title . ']]></title>';
  111. $rssfeed .= '<description><![CDATA[' . $post . ']]></description>';
  112. foreach ($files as $filename)
  113. {
  114. $file_path = get_page_url("podcast", $CONF).'/Podcasts/'.$title.'/'.$filename;
  115. $direct_path = $CONF['podcast_dir'].$title.'/'.$filename;
  116. $file_type = mime_content_type($direct_path);
  117. $file_length = filesize($direct_path);
  118. $rssfeed .= '<enclosure url="'.$file_path.'" length="'.$file_length.'" type="'.$file_type.'" />';
  119. }
  120. $rssfeed .= '<link>' . get_page_url("podcast", $CONF) .'/' . $post_id . '</link>';
  121. $rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O",strtotime($date)) . '</pubDate>';
  122. $rssfeed .= '</item>';
  123. }
  124. }
  125. break;
  126. default:
  127. break;
  128. }
  129. $rssfeed .= '</channel>';
  130. $rssfeed .= '</rss>';
  131. echo $rssfeed;
  132. }
  133. ?>