A tumblelog CMS built on AJAX, PHP and MySQL.

configuration.class.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. if (!defined('entry') || !entry) {
  3. die('Not a valid page');
  4. }
  5. /* ===========================
  6. gelato CMS - A PHP based tumblelog CMS
  7. development version
  8. http://www.gelatocms.com/
  9. gelato CMS is a free software licensed under the GPL 2.0
  10. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
  11. =========================== */
  12. ?>
  13. <?php
  14. class configuration
  15. {
  16. public $urlGelato;
  17. public $tablePrefix;
  18. public $idUser;
  19. public $postLimit;
  20. public $title;
  21. public $description;
  22. public $lang;
  23. public $template;
  24. public $urlFriendly;
  25. public $richText;
  26. public $offset_city;
  27. public $offset_time;
  28. public $shorten_links;
  29. public $rssImportFrec;
  30. public $check_version;
  31. public $plugins = array();
  32. public function __construct()
  33. {
  34. global $isFeed;
  35. global $db;
  36. if ($db->ejecutarConsulta("SELECT * FROM ".Table_prefix."config")) {
  37. $row=$db->obtenerRegistro();
  38. $this->tablePrefix = Table_prefix;
  39. $this->urlGelato = $row['url_installation'];
  40. $this->postLimit = $row['posts_limit'];
  41. $this->title = $row['title'];
  42. $this->description = $row['description'];
  43. $this->lang = $row['lang'];
  44. $this->template = $row['template'];
  45. initLang($this->lang);
  46. $this->urlFriendly = $this->get_option("url_friendly");
  47. $this->richText = $this->get_option("rich_text");
  48. $this->offsetCity = $this->get_option("offset_city");
  49. $this->offsetTime = $this->get_option("offset_time");
  50. $this->allowComments = $this->get_option("allow_comments");
  51. $this->shorten_links = $this->get_option("shorten_links");
  52. $this->rssImportFrec = $this->get_option("rss_import_frec");
  53. $this->check_version = $this->get_option("check_version");
  54. $this->active_plugins = $this->get_option("active_plugins");
  55. //TODO: Soporte de los plugins desde BD activar/desactivar
  56. //FIXME cambiar esto por el soporte por carpetas, mas organizado.
  57. // asi se pueden estandarizar documentacion y thumbnails,
  58. /*if ($handle = opendir(Absolute_Path."plugins")) {
  59. while (false !== ($file = readdir($handle))) {
  60. if (substr($file, strlen($file)-4, 4) == ".php") {
  61. require_once(Absolute_Path."plugins/{$file}");
  62. $this->plugins[] = substr($file, 0, strlen($file)-4);
  63. }
  64. }
  65. closedir($handle);
  66. }*/
  67. } else {
  68. if ($isFeed) {
  69. header("HTTP/1.0 503 Service Unavailable");
  70. header("Retry-After: 60");
  71. exit();
  72. } else {
  73. $message = "
  74. <h3 class=\"important\">Error establishing a database connection</h3>
  75. <p>The configuration info is not available.</p>";
  76. die($message);
  77. }
  78. }
  79. }
  80. public function get_option($name)
  81. {
  82. global $db;
  83. $sql = "SELECT * FROM ".Table_prefix."options WHERE name='".$name."' LIMIT 1";
  84. $db->ejecutarConsulta($sql);
  85. if ($db->contarRegistros()>0) {
  86. $row=$db->obtenerRegistro();
  87. return $row['val'];
  88. } else {
  89. return "0";
  90. }
  91. }
  92. }
  93. ?>