A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 3.7KB

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