A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. if (!defined('entry')) {
  3. define('entry', true);
  4. }
  5. /* ===========================
  6. Sorbet CMS - A PHP based tumblelog CMS forked from Gelato CMS
  7. Sorbet CMS is a free software licensed under the GPL 3.0
  8. =========================== */
  9. ?>
  10. <?php
  11. $isFeed = true;
  12. require('entry.php');
  13. global $user, $conf, $tumble;
  14. $f = new feeds();
  15. $theme = new themes;
  16. if (isset($_GET["action"]) && $_GET["action"] == "read") {
  17. if (isset($_GET["start"])) {
  18. $start = $_GET["start"];
  19. } else {
  20. $start = 0;
  21. }
  22. if (isset($_GET["total"])) {
  23. $total = $_GET["total"];
  24. } else {
  25. $total = 20;
  26. }
  27. if (isset($_GET["type"])) {
  28. $hasType = true;
  29. } else {
  30. $hasType = false;
  31. }
  32. if ($total > 50) {
  33. $total = 50;
  34. }
  35. $user = new user();
  36. $userData = $user->getUserByID(1);
  37. $username = ($userData["name"] == "") ? "sorbet" : $userData["name"];
  38. $theme->set("username", $username);
  39. $theme->set("conf", array(
  40. "offsetCity"=>$conf->offsetCity,
  41. "title"=>$conf->title,
  42. "description"=>$conf->description
  43. ));
  44. $feeds = array();
  45. $actual_feeds = $f->getFeedList();
  46. foreach ($actual_feeds as $feed) {
  47. $error_text = ($feed["error"]>0) ? "false" : "true";
  48. $feed['url'] = htmlspecialchars($feed['url']);
  49. $feed['type'] = util::type2Text($feed['type']);
  50. $feed['getNextUpdate'] = $f->getNextUpdate($feed['id_feed']);
  51. $feed['title'] = htmlspecialchars($feed['title']);
  52. $feed['error_text'] = $error_text;
  53. $feeds[] = $feed;
  54. }
  55. $theme->set("feeds", $feeds);
  56. if ($hasType) {
  57. $postType = type2Number($_GET["type"]);
  58. }
  59. $rs = $tumble->getPosts($total, $start);
  60. $totalRegistros = $db->contarRegistros();
  61. $theme->set("totalRegistros", $totalRegistros);
  62. if ($totalRegistros>0) {
  63. $theme->set("start", $start);
  64. $theme->set("total", $total);
  65. while ($post = $rs->fetch()) {
  66. $post['desc'] = util::trimString($post["description"]);
  67. $strEnd = ($conf->urlFriendly) ? "/" : "";
  68. $post['url'] = $conf->urlSorbet.($conf->urlFriendly ? "/post/" : "/index.php?post=").$post["id_post"].$strEnd;
  69. $post['formatedDate'] = gmdate("D, d M Y H:i:s", strtotime($post["date"]) + util::transform_offset($conf->offsetTime));
  70. $post["type"] = util::type2Text($post["type"]);
  71. switch ($post["type"]) {
  72. case "post":
  73. $post['tit'] = (empty($post["title"])) ? $post['desc'] : strip_tags($post["title"]);
  74. break;
  75. case "photo":
  76. $post['photoPath'] = str_replace("../", $conf->urlSorbet."/", $post["url"]);
  77. $post['tit'] = stripslashes(((empty($post["description"])) ? "Photo" : $post['desc']));
  78. break;
  79. case "quote":
  80. $post['title'] = strip_tags($post["title"]);
  81. break;
  82. case "url":
  83. $post['tit'] = (empty($post["title"])) ? $post["url"] : strip_tags($post["title"]);
  84. break;
  85. case "conversation":
  86. $lines = explode("\n", $post['desc']);
  87. $line = $lines[0];
  88. $post['tit'] = (empty($post["title"])) ? util::trimString($line) : $post["title"];
  89. $post['desc'] = $tumble->formatConversation($post['desc']);
  90. $post['descAPIFormat'] = $tumble->formatConversation($post['desc']);
  91. break;
  92. case "video":
  93. $post['tit'] = (empty($post["description"])) ? "Video" : $post['desc'];
  94. $post['desc'] = htmlspecialchars($tumble->getVideoPlayer($post["url"]));
  95. break;
  96. case "mp3":
  97. $post['tit'] = (empty($post["description"])) ? "Audio" : $post['desc'];
  98. $post['desc'] = htmlspecialchars($tumble->getMp3Player($post["url"]));
  99. break;
  100. }
  101. $posts[] = $post;
  102. }
  103. $theme->set("posts", $posts);
  104. }
  105. $theme->display(Absolute_Path.'admin/themes/admin/api.xml');
  106. }
  107. ?>