A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 4.0KB

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