A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 4.7KB

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