A tumblelog CMS built on AJAX, PHP and MySQL.

configuration.class.php 3.2KB

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