A tumblelog CMS built on AJAX, PHP and MySQL.

api.php 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. $isFeed = true;
  14. require('entry.php');
  15. global $user, $conf, $tumble;
  16. $f = new feeds();
  17. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  18. ?>
  19. <gelato version="1.0">
  20. <?php
  21. if (isset($_GET["action"]) && $_GET["action"] == "read") {
  22. if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
  23. if (isset($_GET["total"])) { $total = $_GET["total"]; } else { $total = 20; }
  24. if (isset($_GET["type"])) { $hasType = true; } else { $hasType = false; }
  25. if ($total > 50) { $total = 50; }
  26. ?>
  27. <tumblelog name="<?php echo $_SESSION["user_login"];?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>"><?php
  28. echo "\n\t".$conf->description."\n";
  29. ?>
  30. <feeds>
  31. <?php
  32. $actual_feeds = $f->getFeedList();
  33. foreach($actual_feeds as $feed){
  34. $error_text = ($feed["error"]>0) ? "false" : "true";
  35. ?>
  36. <feed id="<?php echo $feed["id_feed"];?>" url="<?php echo htmlspecialchars($feed["url"]);?>" import-type="<?php echo type2Text($feed["type"]);?>" next-update-in-seconds="<? echo $f->getNextUpdate($feed["id_feed"]);?>" title="<?php echo htmlspecialchars($feed["title"]);?>" error-text="<? echo $error_text;?>"/>
  37. <?php
  38. }
  39. ?>
  40. </feeds>
  41. </tumblelog>
  42. <?php
  43. if ($hasType) {
  44. $postType = type2Number($_GET["type"]);
  45. }
  46. $rs = $tumble->getPosts($total, $start);
  47. if ($tumble->contarRegistros()>0) {
  48. ?>
  49. <posts start="<?php echo $start; ?>" total="<?php echo $total; ?>">
  50. <?php
  51. while($register = mysql_fetch_array($rs)) {
  52. $desc = htmlspecialchars($register["description"]);
  53. $url = $conf->urlGelato."/index.php?post=".$register["id_post"];
  54. $formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"])+transform_offset($conf->offsetTime));
  55. switch ($register["type"]) {
  56. case "1":
  57. $tit = ($register["title"]=="") ? $desc : $register["title"];
  58. ?>
  59. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="regular" date="<?php echo $formatedDate;?>">
  60. <regular-title><?php echo $tit;?></regular-title>
  61. <regular-body><?php echo $desc;?></regular-body>
  62. </post>
  63. <?php
  64. break;
  65. case "2":
  66. $tit = ($register["description"]=="") ? "Photo" : $desc;
  67. ?>
  68. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="photo" date="<?php echo $formatedDate;?>">
  69. <?php
  70. $photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
  71. ?>
  72. <photo-caption><?php echo $tit;?></photo-caption>
  73. <photo-url><?php echo $photoPath;?></photo-url>
  74. </post>
  75. <?php
  76. break;
  77. case "3":
  78. ?>
  79. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="quote" date="<?php echo $formatedDate;?>">
  80. <quote-text><?php echo $desc; ?></quote-text>
  81. <quote-source><?php echo $register["title"]; ?></quote-source>
  82. </post>
  83. <?php
  84. break;
  85. case "4":
  86. $tit = ($register["title"]=="") ? $register["url"] : $register["title"];
  87. ?>
  88. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="link" date="<?php echo $formatedDate;?>">
  89. <link-text><?php echo $tit; ?></link-text>
  90. <link-url><?php echo $register["url"]; ?></link-url>
  91. </post>
  92. <?php
  93. break;
  94. case "5":
  95. $lines = explode("\n", $desc);
  96. $line = $lines[0];
  97. $tit = ($register["title"]=="") ? $line : $register["title"];
  98. $desc = $tumble->formatConversation($desc);
  99. ?>
  100. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="conversation" date="<?php echo $formatedDate;?>">
  101. <conversation-title><?php echo $tit; ?></conversation-title>
  102. <conversation-text><?php echo $desc; ?></conversation-text>
  103. <?php echo $tumble->formatApiConversation($desc); ?>
  104. </post>
  105. <?php
  106. break;
  107. case "6":
  108. $tit = ($register["description"]=="") ? "Video" : $desc;
  109. $desc = $tumble->getVideoPlayer($register["url"]);
  110. ?>
  111. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="video" date="<?php echo $formatedDate;?>">
  112. <video-caption><?php echo $tit; ?></video-caption>
  113. <video-source><?php echo $register["url"]; ?></video-source>
  114. <video-player><?php echo htmlspecialchars($desc); ?></video-player>
  115. </post>
  116. <?php
  117. break;
  118. case "7":
  119. $tit = ($register["description"]=="") ? "Audio" : $desc;
  120. $desc = $tumble->getMp3Player($register["url"]);
  121. ?>
  122. <post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="audio" date="<?php echo $formatedDate;?>">
  123. <audio-caption><?php echo $tit; ?></audio-caption>
  124. <audio-player><?php echo htmlspecialchars($desc); ?></audio-player>
  125. </post>
  126. <?php
  127. break;
  128. }
  129. $url = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
  130. $formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"])+transform_offset($conf->offsetTime));
  131. }
  132. ?>
  133. </posts>
  134. <?php
  135. }
  136. }
  137. ?>
  138. </gelato>