A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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(); $actual_feeds = $f->getFeedList();
  32. foreach($actual_feeds as $feed){
  33. $error_text = ($feed["error"]>0) ? "false" : "true";
  34. $feed['url'] = htmlspecialchars($feed['url']);
  35. $feed['type'] = util::type2Text($feed['type']);
  36. $feed['getNextUpdate'] = $f->getNextUpdate($feed['id_feed']);
  37. $feed['title'] = htmlspecialchars($feed['title']);
  38. $feed['error_text'] = $error_text;
  39. $feeds[] = $feed;
  40. }
  41. $theme->set("feeds",$feeds);
  42. if ($hasType) {
  43. $postType = type2Number($_GET["type"]);
  44. }
  45. $rs = $tumble->getPosts($total, $start);
  46. $totalRegistros = $db->contarRegistros();
  47. $theme->set("totalRegistros",$totalRegistros);
  48. if ($db->contarRegistros()>0) {
  49. $theme->set("start",$start);
  50. $theme->set("total",$total);
  51. while($post = mysql_fetch_assoc($rs)){
  52. $post['desc'] = util::trimString($post["description"]);
  53. $strEnd = ($conf->urlFriendly) ? "/" : "";
  54. $post['url'] = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$post["id_post"].$strEnd;
  55. $post['formatedDate'] = gmdate("D, d M Y H:i:s", strtotime($post["date"]) + util::transform_offset($conf->offsetTime));
  56. $post['type'] = util::type2Text($post["type"]);
  57. switch ($post["type"]) {
  58. case "post":
  59. $post['tit'] = (empty($post["title"])) ? $desc : strip_tags($post["title"]);
  60. break;
  61. case "photo":
  62. $post['photoPath'] = str_replace("../", $conf->urlGelato."/", $post["url"]);
  63. $post['tit'] = stripslashes(((empty($post["description"])) ? "Photo" : $post['desc']));
  64. break;
  65. case "quote":
  66. $post['title'] = strip_tags($post["title"]);
  67. break;
  68. case "url":
  69. $post['tit'] = (empty($post["title"])) ? $post["url"] : strip_tags($post["title"]);
  70. break;
  71. case "conversation":
  72. $lines = explode("\n", $desc);
  73. $line = $lines[0];
  74. $post['tit'] = (empty($post["title"])) ? trimString($line) : $post["title"];
  75. $post['desc'] = $tumble->formatConversation($desc);
  76. $post['descAPIFormat'] = $tumble->formatConversation($desc);
  77. break;
  78. case "video":
  79. $post['tit'] = (empty($post["description"])) ? "Video" : $desc;
  80. $post['desc'] = htmlspecialchars($tumble->getVideoPlayer($post["url"]));
  81. break;
  82. case "mp3":
  83. $post['tit'] = (empty($post["description"])) ? "Audio" : $desc;
  84. $desc = htmlspecialchars($tumble->getMp3Player($post["url"]));
  85. break;
  86. }
  87. $posts[] = $post;
  88. }
  89. $theme->set("posts",$posts);
  90. }
  91. $theme->display(Absolute_Path.'admin/themes/admin/api.xml');
  92. }
  93. ?>