A tumblelog CMS built on AJAX, PHP and MySQL.

gelato.class.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?
  2. /* ===========================
  3. gelato CMS development version
  4. http://www.gelatocms.com/
  5. gelato CMS is a free software licensed under GPL (General public license)
  6. =========================== */
  7. ?>
  8. <?
  9. require_once("configuration.class.php");
  10. require_once("functions.php");
  11. class gelato extends Conexion_Mysql {
  12. var $conf;
  13. function gelato() {
  14. parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
  15. $this->conf = new configuration();
  16. }
  17. function addPost($fieldsArray) {
  18. if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
  19. return true;
  20. } else {
  21. return false;
  22. }
  23. }
  24. function saveMP3($remoteFileName) {
  25. if (getMP3File($remoteFileName)) {
  26. return true;
  27. } else {
  28. return false;
  29. }
  30. }
  31. function savePhoto($remoteFileName) {
  32. if (getPhotoFile($remoteFileName)) {
  33. return true;
  34. } else {
  35. return false;
  36. }
  37. }
  38. function getPosts($limit="10", $from="0") {
  39. $sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
  40. $this->ejecutarConsulta($sqlStr);
  41. return $this->mid_consulta;
  42. }
  43. function getPost($id="") {
  44. $this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
  45. return mysql_fetch_array($this->mid_consulta);
  46. }
  47. function getType($id) {
  48. if ($this->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
  49. if ($this->contarRegistros()>0) {
  50. while($registro = mysql_fetch_array($this->mid_consulta)) {
  51. return $registro[0];
  52. }
  53. }
  54. } else {
  55. return "0";
  56. }
  57. }
  58. function formatConversation($text) {
  59. $formatedText = "";
  60. $odd=true;
  61. $lines = explode("\n", $text);
  62. $formatedText .= "<ul>\n";
  63. foreach ($lines as $line) {
  64. $pos = strpos($line, ":") + 1;
  65. $label = substr($line, 0, $pos);
  66. $desc = substr($line, $pos, strlen($line));
  67. if ($odd) {
  68. $cssClass = "odd";
  69. } else {
  70. $cssClass = "even";
  71. }
  72. $odd=!$odd;
  73. $formatedText .= " <li class=\"".$cssClass."\">\n";
  74. $formatedText .= " <span class=\"label\">".$label."</span>\n";
  75. $formatedText .= " ".$desc."\n";
  76. $formatedText .= " </li>\n";
  77. }
  78. $formatedText .= "</ul>\n";
  79. return $formatedText;
  80. }
  81. function getVideoPlayer($url) {
  82. if (isYoutubeVideo($url)) {
  83. $id_video = getYoutubeVideoUrl($url);
  84. return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object>\n";
  85. } elseif (isVimeoVideo($url)) {
  86. $id_video = getVimeoVideoUrl($url);
  87. return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";
  88. } else {
  89. return "This URL is not a supported video (YouTube or Vimeo)";
  90. }
  91. }
  92. function getMp3Player($url) {
  93. if (isMP3($url)) {
  94. $playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
  95. return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
  96. } else {
  97. return "This URL is not a supported video (YouTube or Vimeo)";
  98. }
  99. }
  100. function getPostsNumber() {
  101. $this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
  102. $row = mysql_fetch_assoc($this->mid_consulta);
  103. return $row['total'];
  104. }
  105. }
  106. ?>