settings.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php namespace HashOver;
  2. // Copyright (C) 2010-2017 Jacob Barkdull
  3. // This file is part of HashOver.
  4. //
  5. // I, Jacob Barkdull, hereby release this work into the public domain.
  6. // This applies worldwide. If this is not legally possible, I grant any
  7. // entity the right to use this work for any purpose, without any
  8. // conditions, unless such conditions are required by law.
  9. //
  10. //--------------------
  11. //
  12. // IMPORTANT NOTICE:
  13. //
  14. // To retain your settings and maintain proper functionality, when
  15. // downloading or otherwise upgrading to a new version of HashOver it
  16. // is important that you preserve this file, unless directed otherwise.
  17. //
  18. // It is also important to choose UNIQUE values for the encryption key,
  19. // admin name, and admin password, as not doing so puts HashOver at
  20. // risk of being hijacked. Allowing someone to delete comments and/or
  21. // edit existing comments to post spam, impersonate you or your
  22. // visitors in order to push some sort of agenda/propaganda, to defame
  23. // you or your visitors, or to imply endorsement of some product(s),
  24. // service(s), and/or political ideology.
  25. class Settings
  26. {
  27. // Required setup
  28. public $notificationEmail = 'comentarios@freakspot.net'; // E-mail for notification of new comments
  29. protected $encryptionKey = 'SECRETO'; // Unique encryption key
  30. protected $adminName = 'SECRETO'; // Login name to gain admin rights (case-sensitive)
  31. protected $adminPassword = 'SECRETO'; // Login password to gain admin rights (case-sensitive)
  32. // Primary settings
  33. public $language = 'es'; // UI language, for example 'en', 'de', etc. 'auto' to use system locale
  34. public $theme = 'default'; // Comment Cascading Style Sheet (CSS)
  35. public $usesModeration = false; // Whether comments must be approved before they appear to other visitors
  36. public $dataFormat = 'json'; // Format comments will be stored in; options: xml, json, sql
  37. public $defaultName = 'Anónimo'; // Default name to use when one isn't given
  38. public $allowsImages = true; // Whether external image URLs wrapped in [img] tags are embedded
  39. public $allowsLogin = true; // Whether users can login and logout (when false form cookies are still set)
  40. public $allowsLikes = true; // Whether a "Like" link is displayed
  41. public $allowsDislikes = true; // Whether a "Dislike" link is displayed; allowing Reddit-style voting
  42. public $usesAJAX = true; // Whether AJAX is used for posting, editing, and loading comments
  43. public $collapsesUI = false; // Whether the comment form, thread, and end links are all initially hidden
  44. public $collapsesComments = true; // Whether to hide comments and display a link to show them
  45. public $collapseLimit = 5; // Number of comments that aren't hidden
  46. public $replyMode = 'thread'; // Whether to display replies as a 'thread' or as a 'stream'
  47. public $streamDepth = 3; // In stream mode, the number of reply indentions to allow before the thread flattens
  48. public $popularityThreshold = 5; // Minimum likes a comment needs to be popular
  49. public $popularityLimit = 2; // Number of comments allowed to become popular
  50. // Date and Time settings
  51. public $serverTimezone = 'Europe/Madrid'; // Server timezone
  52. public $usesUserTimezone = true; // Whether comment dates should use the user's timezone (JavaScript-mode)
  53. public $usesShortDates = true; // Whether comment dates are shortened, for example "X days ago"
  54. public $timeFormat = 'H:i'; // Time format, use 'H:i' for 24-hour format (see: http://php.net/manual/en/function.date.php)
  55. public $dateFormat = 'd/m/Y'; // Date format (see: http://php.net/manual/en/function.date.php)
  56. // Field options, use true/false to enable/disable a field,
  57. // use 'required' to require a field be properly filled
  58. public $fieldOptions = array (
  59. 'name' => true,
  60. 'password' => false,
  61. 'email' => true,
  62. 'website' => true
  63. );
  64. // Behavior settings
  65. public $displaysTitle = false; // Whether page title is shown or not
  66. public $formPosition = 'bottom'; // Position for primary form; options: 'top' or 'bottom'
  67. public $usesAutoLogin = true; // Whether a user's first comment automatically logs them in
  68. public $showsReplyCount = true; // Whether to show reply count separately from total
  69. public $countIncludesDeleted = true; // Whether comment counts should include deleted comments
  70. public $iconMode = 'image'; // How to display avatar icons (either 'image', 'count' or 'none')
  71. public $iconSize = '45'; // Size of Gravatar icons in pixels
  72. public $imageFormat = 'png'; // Format for icons and other images (use 'svg' for HDPI)
  73. public $usesLabels = false; // Whether to display labels above inputs
  74. public $usesCancelButtons = true; // Whether forms have "Cancel" buttons
  75. public $appendsCSS = true; // Whether to automatically add a CSS <link> element to the page <head>
  76. public $displaysRSSLink = false; // Whether a comment RSS feed link is displayed
  77. // Technical settings
  78. public $loginMethod = 'defaultLogin'; // Login method class for handling user login information
  79. public $setsCookies = true; // Whether cookies are enabled
  80. public $secureCookies = false; // Whether cookies set over secure HTTPS will only be transmitted over HTTPS
  81. public $storesIPAddress = false; // Whether to store users' IP addresses
  82. public $allowsUserReplies = false; // Whether given e-mails are sent as reply-to address to users
  83. public $noreplyEmail = 'noreply@example.com'; // E-mail used when no e-mail is given
  84. public $spamDatabase = 'remote'; // Whether to use a remote or local spam database
  85. public $spamCheckModes = 'php'; // Perform IP spam check in 'javascript' or 'php' mode, or 'both'
  86. public $gravatarDefault = 'wavatar'; // Gravatar theme to use ('custom', 'identicon', 'monsterid', 'wavatar', or 'retro')
  87. public $gravatarForce = false; // Whether to force the themed Gravatar images instead of an avatar image
  88. public $minifiesJavaScript = false; // Whether JavaScript output should be minified
  89. public $minifyLevel = 4; // How much to minify JavaScript code, options: 1, 2, 3, 4
  90. public $enablesAPI = true; // API: true = fully-enabled, false = fully disabled, or array of modes
  91. public $latestMax = 10; // Maximum number of comments to save as latest comments
  92. public $latestTrimWidth = 100; // Number of characters to trim latest comments to, 0 for no trim
  93. public $userDeletionsUnlink = false; // Whether user deleted files are actually unlinked from the filesystem
  94. // Types of images allowed to be embedded in comments
  95. public $imageTypes = array (
  96. 'jpeg',
  97. 'jpg',
  98. 'png',
  99. 'gif'
  100. );
  101. // External domains allowed to remotely load HashOver scripts
  102. public $allowedDomains = array (
  103. // '*.example.com',
  104. // '*.example.org',
  105. // '*.example.net'
  106. );
  107. // General database options
  108. public $databaseType = 'sqlite'; // Type of database, sqlite or mysql
  109. public $databaseName = 'hashover-pages'; // Database name
  110. // SQL database options
  111. public $databaseHost = 'localhost'; // Database host name
  112. public $databaseUser = 'root'; // Database login user
  113. public $databasePassword = 'password'; // Database login password
  114. public $databaseCharset = 'utf8'; // Database character set
  115. // Automated settings
  116. public $isMobile = false;
  117. // Technical settings placeholders
  118. public $rootDirectory;
  119. public $httpRoot;
  120. public $httpScripts;
  121. public $httpImages;
  122. public $cookieExpiration;
  123. public $domain;
  124. public function __construct ()
  125. {
  126. // Set server timezone
  127. date_default_timezone_set ($this->serverTimezone);
  128. // Set encoding
  129. mb_internal_encoding ('UTF-8');
  130. // Get parent directory
  131. $root_directory = dirname (__DIR__);
  132. // Get HTTP parent directory
  133. $document_root = realpath ($_SERVER['DOCUMENT_ROOT']);
  134. $http_directory = mb_substr ($root_directory, mb_strlen ($document_root));
  135. // Replace backslashes with forwardslashes on Windows
  136. if (DIRECTORY_SEPARATOR === '\\') {
  137. $http_directory = str_replace ('\\', '/', $http_directory);
  138. }
  139. // Determine HTTP or HTTPS
  140. $protocol = ($this->isHTTPS () ? 'https' : 'http') . '://';
  141. // Technical settings
  142. $this->rootDirectory = $root_directory; // Root directory for script
  143. $this->httpRoot = $http_directory; // Root directory for HTTP
  144. $this->cookieExpiration = time () + 60 * 60 * 24 * 30; // Cookie expiration date
  145. $this->domain = $_SERVER['HTTP_HOST']; // Domain name for refer checking & notifications
  146. $this->absolutePath = $protocol . $this->domain; // Absolute path or remote access
  147. // Synchronize settings
  148. $this->syncSettings ();
  149. }
  150. function isHTTPS ()
  151. {
  152. // The connection is HTTPS if server says so
  153. if (!empty ($_SERVER['HTTPS']) and $_SERVER['HTTPS'] !== 'off') {
  154. return true;
  155. }
  156. // Assume the connection is HTTPS on standard SSL port
  157. if ($_SERVER['SERVER_PORT'] == 443) {
  158. return true;
  159. }
  160. return false;
  161. }
  162. // Synchronizes specific settings after remote changes
  163. public function syncSettings ()
  164. {
  165. // Disable likes and dislikes if cookies are disabled
  166. if ($this->setsCookies === false) {
  167. $this->allowsLikes = false;
  168. $this->allowsDislikes = false;
  169. }
  170. // Setup default field options
  171. foreach (array ('name', 'password', 'email', 'website') as $field) {
  172. if (!isset ($this->fieldOptions[$field])) {
  173. $this->fieldOptions[$field] = true;
  174. }
  175. }
  176. // Disable password if name is disabled
  177. if ($this->fieldOptions['name'] === false) {
  178. $this->fieldOptions['password'] = false;
  179. }
  180. // Disable login if name or password is disabled
  181. if ($this->fieldOptions['name'] === false
  182. or $this->fieldOptions['password'] === false)
  183. {
  184. $this->allowsLogin = false;
  185. }
  186. // Disable autologin if login is disabled
  187. if ($this->allowsLogin === false) {
  188. $this->usesAutoLogin = false;
  189. }
  190. $this->httpScripts = $this->httpRoot . '/scripts'; // Script directory for HTTP
  191. $this->httpImages = $this->httpRoot . '/images'; // Image directory for HTTP
  192. }
  193. }