A tumblelog CMS built on AJAX, PHP and MySQL.

gelato.class.php 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  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. <?php
  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 saveSettings($fieldsArray) {
  18. if ($this->modificarDeFormulario($this->conf->tablePrefix."config", $fieldsArray)) {
  19. header("Location: ".$this->conf->urlGelato."/admin/settings.php?modified=true");
  20. die();
  21. } else {
  22. header("Location: ".$this->conf->urlGelato."/admin/settings.php?error=1&des=".$this->merror);
  23. die();
  24. }
  25. }
  26. function addPost($fieldsArray) {
  27. if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
  28. return true;
  29. } else {
  30. return false;
  31. }
  32. }
  33. function modifyPost($fieldsArray, $id_post) {
  34. if ($this->modificarDeFormulario($this->conf->tablePrefix."data", $fieldsArray, "id_post=$id_post")) {
  35. header("Location: ".$this->conf->urlGelato."/admin/index.php?modified=true");
  36. die();
  37. } else {
  38. header("Location: ".$this->conf->urlGelato."/admin/index.php?error=2&des=".$this->merror);
  39. die();
  40. }
  41. }
  42. function deletePost($idPost) {
  43. $this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."data WHERE id_post=".$idPost);
  44. }
  45. function getPosts($limit="10", $from="0") {
  46. $sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
  47. $this->ejecutarConsulta($sqlStr);
  48. return $this->mid_consulta;
  49. }
  50. function getPost($id="") {
  51. $this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
  52. return mysql_fetch_array($this->mid_consulta);
  53. }
  54. function getPostsNumber() {
  55. $this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
  56. $row = mysql_fetch_assoc($this->mid_consulta);
  57. return $row['total'];
  58. }
  59. function getType($id) {
  60. if ($this->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
  61. if ($this->contarRegistros()>0) {
  62. while($registro = mysql_fetch_array($this->mid_consulta)) {
  63. return $registro[0];
  64. }
  65. }
  66. } else {
  67. return "0";
  68. }
  69. }
  70. function formatConversation($text) {
  71. $formatedText = "";
  72. $odd=true;
  73. $lines = explode("\n", $text);
  74. $formatedText .= "<ul>\n";
  75. foreach ($lines as $line) {
  76. $pos = strpos($line, ":") + 1;
  77. $label = substr($line, 0, $pos);
  78. $desc = substr($line, $pos, strlen($line));
  79. if ($odd) {
  80. $cssClass = "odd";
  81. } else {
  82. $cssClass = "even";
  83. }
  84. $odd=!$odd;
  85. $formatedText .= " <li class=\"".$cssClass."\">\n";
  86. $formatedText .= " <span class=\"label\">".$label."</span>\n";
  87. $formatedText .= " ".$desc."\n";
  88. $formatedText .= " </li>\n";
  89. }
  90. $formatedText .= "</ul>\n";
  91. return $formatedText;
  92. }
  93. function saveMP3($remoteFileName) {
  94. if (getMP3File($remoteFileName)) {
  95. return true;
  96. } elseif (isGoEar($remoteFileName)) {
  97. return true;
  98. } else {
  99. return false;
  100. }
  101. }
  102. function savePhoto($remoteFileName) {
  103. if (getPhotoFile($remoteFileName)) {
  104. return true;
  105. } else {
  106. return false;
  107. }
  108. }
  109. function getVideoPlayer($url) {
  110. if (isYoutubeVideo($url)) {
  111. $id_video = getYoutubeVideoUrl($url);
  112. 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";
  113. } elseif (isVimeoVideo($url)) {
  114. $id_video = getVimeoVideoUrl($url);
  115. 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";
  116. } else {
  117. return "This URL is not a supported video (YouTube or Vimeo)";
  118. }
  119. }
  120. function getMp3Player($url) {
  121. if (isMP3($url)) {
  122. $playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
  123. 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";
  124. } elseif (isGoEar($url)) {
  125. return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"http://www.goear.com/files/localplayer.swf\" width=\"366\" height=\"75\"><param name=\"movie\" value=\"http://www.goear.com/files/localautoplayer.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"file=c0a2c85\" /></object>\n";
  126. } else {
  127. return "This URL is not an MP3 file.";
  128. }
  129. }
  130. }
  131. ?>