A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. header("Content-type: text/xml; charset=utf-8");
  13. require(dirname(__FILE__)."/config.php");
  14. include("classes/configuration.class.php");
  15. include("classes/gelato.class.php");
  16. include("classes/textile.class.php");
  17. $isFeed = true;
  18. $tumble = new gelato();
  19. $conf = new configuration();
  20. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  21. ?>
  22. <gelato version="1.0">
  23. <?php
  24. if (isset($_GET["action"]) && $_GET["action"] == "read") {
  25. if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
  26. if (isset($_GET["num"])) { $num = $_GET["num"]; } else { $num = 20; }
  27. if (isset($_GET["type"])) { $type = $_GET["type"]; } else { $type = null; }
  28. if ($num > 50) { $num = 50; }
  29. ?>
  30. <tumblelog name="<?php echo $_SESSION["user_login"];?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>"><?php echo $conf->description;?></tumblelog>
  31. <?php
  32. switch ($type) {
  33. case "post":
  34. $_GET["type"] = "1";
  35. break;
  36. case "photo":
  37. $_GET["type"] = "2";
  38. break;
  39. case "quote":
  40. $_GET["type"] = "3";
  41. break;
  42. case "url":
  43. $_GET["type"] = "4";
  44. break;
  45. case "conversation":
  46. $_GET["type"] = "5";
  47. break;
  48. case "video":
  49. $_GET["type"] = "6";
  50. break;
  51. case "mp3":
  52. $_GET["type"] = "7";
  53. break;
  54. }
  55. $rs = $tumble->getPosts($num, $start);
  56. if ($tumble->contarRegistros()>0) {
  57. ?>
  58. <posts start="<?php echo $start; ?>" total="<?php echo $num; ?>">
  59. <?php/*
  60. while($register = mysql_fetch_array($rs)) {
  61. $textile = new Textile();
  62. $register["description"] = $textile->TextileThis($register["description"]);
  63. switch ($register["type"]) {
  64. case "1":
  65. $tit = ($register["title"]=="") ? strip_tags($register["description"]) : $register["title"];
  66. $desc = $register["description"];
  67. break;
  68. case "2":
  69. $tit = ($register["description"]=="") ? "Photo" : strip_tags($register["description"]);
  70. $desc = "<img src=\"".$register["url"]."\"/>";
  71. break;
  72. case "3":
  73. $tit = "\"".strip_tags($register["description"])."\"";
  74. $tmpStr = ($register["title"]!="") ? "<br /><br /> - <em>".$register["title"]."</em>" : "";
  75. $desc = "\"".$register["description"]."\"".$tmpStr;
  76. break;
  77. case "4":
  78. $tit = ($register["title"]=="") ? $register["url"] : $register["title"];
  79. $tmpStr = ($register["description"]!="") ? "<br /><br /> - <em>".$register["description"]."</em>" : "";
  80. $desc = "<a href=\"".$register["url"]."\">".$tit."</a>".$tmpStr;
  81. break;
  82. case "5":
  83. $lines = explode("\n", $register["description"]);
  84. $line = $lines[0];
  85. $tit = ($register["title"]=="") ? $line : $register["title"];
  86. $desc = $tumble->formatConversation($register["description"]);
  87. break;
  88. case "6":
  89. $tit = ($register["description"]=="") ? "Video" : strip_tags($register["description"]);
  90. $desc = $tumble->getVideoPlayer($register["url"]);
  91. break;
  92. case "7":
  93. $tit = ($register["description"]=="") ? "MP3" : strip_tags($register["description"]);
  94. $desc = $tumble->getMp3Player($register["url"]);
  95. break;
  96. }
  97. $url = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
  98. $formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"])+transform_offset($conf->offsetTime));
  99. ?>
  100. <item>
  101. <title><?php echo $tit;?></title>
  102. <description><![CDATA[<?php echo $desc;?>]]></description>
  103. <link><?php echo $url;?></link>
  104. <guid isPermaLink="true"><?php echo $conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>
  105. <pubDate><?php echo $formatedDate;?></pubDate>
  106. </item>
  107. <?php
  108. }
  109. */?>
  110. </posts>
  111. <?php
  112. }
  113. }
  114. ?>
  115. </gelato>