config.EXAMPLE.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. /**
  3. * Copyright 2009 - 2019 SuperTuxKart-Team
  4. *
  5. * This file is part of stk-addons.
  6. *
  7. * stk-addons is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * stk-addons is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with stk-addons. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. declare(strict_types=1);
  21. // useful for phpunit testing
  22. if (!defined('TEST_MODE')) define('TEST_MODE', false);
  23. // useful for cron jobs
  24. if (!defined('CRON_MODE')) define('CRON_MODE', false);
  25. // useful for the API
  26. if (!defined('API_MODE')) define('API_MODE', false);
  27. // useful for to know if downloading file
  28. if (!defined('DOWNLOAD_MODE')) define('DOWNLOAD_MODE', false);
  29. // Check if we are in CLI mode
  30. define('CLI_MODE', php_sapi_name() == "cli");
  31. // WARNING!!!! turn OFF in the production server.
  32. // Enable this when you want detailed debugging output.
  33. // WARNING!!!! turn OFF in the production server.
  34. define('DEBUG_MODE', false);
  35. // Enable the debug toolbar, will only work when in DEBUG_MODE.
  36. // WARNING!!! Never enable in the production server
  37. define('DEBUG_TOOLBAR', false);
  38. // Enable maintenance mode, will disable all requests and redirect to an HTML page
  39. define('MAINTENANCE_MODE', false);
  40. // Indicate if the certificate is signed by an authority
  41. const IS_SSL_CERTIFICATE_VALID = false;
  42. // Do you prefer https?
  43. const PREFER_SSL = true;
  44. // Redirect access from web browser to secure server
  45. // NOTE: Do not redirect API requests or download requests as Old STK versions can't handle proper certificates
  46. const REDIRECT_TO_HTTPS_SERVER_NAME = false;
  47. const STK_HTTPS_SERVER_NAME = "https://online.supertuxkart.net";
  48. if (!API_MODE && !DOWNLOAD_MODE && REDIRECT_TO_HTTPS_SERVER_NAME)
  49. {
  50. header("Location: " . STK_HTTPS_SERVER_NAME . $_SERVER['REQUEST_URI'], true, 307);
  51. exit;
  52. }
  53. // set default values
  54. ini_set('html_errors', 'On');
  55. if (DEBUG_MODE)
  56. {
  57. // This does not show parse errors, to show those edit the php.ini file and edit the display_errors value
  58. error_reporting(E_ALL);
  59. ini_set('display_errors', "true");
  60. }
  61. else
  62. {
  63. error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
  64. ini_set('display_errors', "false");
  65. }
  66. if (empty($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_PORT']))
  67. {
  68. // NOTE: We can't access the server name variable in cron mode
  69. // Make sure that this does not end with a trailing slash, and does not have a prefix in front
  70. $DOMAIN_NAME = 'stk-addons.localhost';
  71. }
  72. else
  73. {
  74. $DOMAIN_NAME = $_SERVER['SERVER_NAME'] . (!in_array($_SERVER['SERVER_PORT'], ['80', '443'], true) ? ':' . $_SERVER['SERVER_PORT'] : '');
  75. }
  76. //
  77. // Cron constants
  78. //
  79. // After how many days should we delete the verification emails
  80. const CRON_DAILY_VERIFICATION_DAYS = 1;
  81. //
  82. // Paths on the local filesystem
  83. //
  84. const DS = DIRECTORY_SEPARATOR;
  85. const ROOT_PATH = __DIR__ . DS;
  86. const INCLUDE_PATH = ROOT_PATH . 'include' . DS;
  87. const TPL_PATH = ROOT_PATH . 'tpl' . DS . 'default' . DS; // Template properties
  88. define('TMP_PATH', sys_get_temp_dir() . DS); // define temporary directory path
  89. const UPLOAD_PATH = ROOT_PATH . 'dl' . DS;
  90. const UP_PATH = UPLOAD_PATH;
  91. const BUGS_PATH = ROOT_PATH . 'bugs' . DS;
  92. const STATS_PATH = ROOT_PATH . 'stats' . DS;
  93. const ASSETS_PATH = ROOT_PATH . 'assets' . DS;
  94. const CACHE_PATH = ASSETS_PATH . 'cache' . DS; // cache for images/html/template
  95. const FONTS_PATH = ASSETS_PATH . 'fonts' . DS;
  96. // For old server, http only
  97. const OLD_NEWS_XML_PATH = UP_PATH . 'xml' . DS . 'news.xml';
  98. const OLD_ASSETS_XML_PATH = UP_PATH . 'xml' . DS . 'assets.xml';
  99. // For new online server, https only
  100. const NEWS_XML_PATH = UP_PATH . 'xml' . DS . 'online_news.xml';
  101. const ASSETS_XML_PATH = UP_PATH . 'xml' . DS . 'online_assets.xml';
  102. //
  103. // Location urls
  104. //
  105. define('ROOT_LOCATION_UNSECURE', 'http://' . $DOMAIN_NAME . '/');
  106. if ((PREFER_SSL && IS_SSL_CERTIFICATE_VALID) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'))
  107. {
  108. define('ROOT_LOCATION', 'https://' . $DOMAIN_NAME . '/');
  109. }
  110. else
  111. {
  112. define('ROOT_LOCATION', ROOT_LOCATION_UNSECURE);
  113. }
  114. // Change this if you want downloads to be from another server
  115. const OLD_DOWNLOAD_LOCATION_ROOT_SERVER = "http://addons.supertuxkart.net/";
  116. const DOWNLOAD_LOCATION_ROOT_SERVER = ROOT_LOCATION;
  117. // Old version, http only
  118. const OLD_DOWNLOAD_LOCATION = OLD_DOWNLOAD_LOCATION_ROOT_SERVER . 'dl/';
  119. const OLD_DOWNLOAD_XML_LOCATION = OLD_DOWNLOAD_LOCATION . 'xml/';
  120. const OLD_ASSETS_XML_LOCATION = OLD_DOWNLOAD_XML_LOCATION . 'assets.xml';
  121. const OLD_NEWS_XML_LOCATION = OLD_DOWNLOAD_XML_LOCATION . 'news.xml';
  122. // New version, https only
  123. const DOWNLOAD_LOCATION = DOWNLOAD_LOCATION_ROOT_SERVER . 'dl/';
  124. const DOWNLOAD_XML_LOCATION = DOWNLOAD_LOCATION . 'xml/';
  125. const ASSETS_XML_LOCATION = DOWNLOAD_XML_LOCATION . 'online_assets.xml';
  126. const NEWS_XML_LOCATION = DOWNLOAD_XML_LOCATION . 'online_news.xml';
  127. const BUGS_LOCATION = ROOT_LOCATION . 'bugs/';
  128. const STATS_LOCATION = ROOT_LOCATION . 'stats/';
  129. const ASSETS_LOCATION = ROOT_LOCATION . 'assets/';
  130. const CACHE_LOCATION = ASSETS_LOCATION . 'cache/';
  131. const LIBS_LOCATION = ASSETS_LOCATION . 'libs/@bower_components/';
  132. const IMG_LOCATION = ASSETS_LOCATION . 'img/';
  133. const JS_LOCATION = ASSETS_LOCATION . 'js/';
  134. const CSS_LOCATION = ASSETS_LOCATION . 'css/';
  135. // CAPTCHA properties, Register API keys at https://www.google.com/recaptcha/admin
  136. const CAPTCHA_SITE_KEY = null;
  137. const CAPTCHA_SECRET = null;
  138. // Database properties
  139. const DB_USER = 'stk_addons';
  140. const DB_PASSWORD = 'your super secret password';
  141. const DB_NAME = 'stk_addons';
  142. const DB_HOST = 'localhost';
  143. // should not be modified
  144. const DB_VERSION = 'v3';
  145. // Mail properties
  146. const IS_SMTP = false; // true for 'smtp' and false for 'sendmail'
  147. const SENDMAIL_PATH = null; // Path to sendmail if your sendmail path is not standard
  148. const SMTP_HOST = null; // SMTP server host
  149. const SMTP_PORT = null; // SMTP server port (usually 25)
  150. const SMTP_PREFIX = 'ssl'; // usually ssl or tls
  151. const SMTP_AUTH = null; // Whether or not to use SMTP authentication, true/false
  152. const SMTP_USER = null; // SMTP username
  153. const SMTP_PASS = null; // SMTP password
  154. // Add-On Flags
  155. //
  156. // Do not change existing flags! Doing so will cause errors with existing add-ons, and possible game incompatibility.
  157. // To add new flags, create a new constant, and set it to the next power of 2. The current database schema allows 24 flags.
  158. const F_APPROVED = 1;
  159. const F_ALPHA = 2;
  160. const F_BETA = 4;
  161. const F_RC = 8;
  162. const F_INVISIBLE = 16;
  163. const F_RESERVED2 = 32; // Reserved for future use
  164. const F_DFSG = 64;
  165. const F_FEATURED = 128;
  166. const F_LATEST = 256;
  167. const F_TEX_NOT_POWER_OF_2 = 512;
  168. // API
  169. // this should be changed depending where you have the api, for api.supertuxkart.net is should be empty string
  170. // for online.supertuxkart.net/api, this is the default location
  171. const API_LOCATION = '/api';
  172. const API_VERSION = 'v2';
  173. // auto load stuff, when testing we do this manually
  174. if (!TEST_MODE)
  175. {
  176. // set string encoding
  177. if (mb_internal_encoding('UTF-8') !== true) user_error('mb_internal_encoding failed');
  178. if (mb_regex_encoding('UTF-8') !== true) user_error('mb_regex_encoding failed');
  179. if (mb_language('uni') !== true) user_error('mb_language failed');
  180. // disable external entity loading
  181. libxml_disable_entity_loader(true);
  182. // Maintenance mode
  183. if (MAINTENANCE_MODE)
  184. {
  185. if (API_MODE) // handle API
  186. {
  187. require(INCLUDE_PATH . 'XMLOutput.class.php');
  188. XMLOutput::exitXML('Server is down for maintenance. More details at ' . ROOT_LOCATION);
  189. }
  190. else
  191. {
  192. require(TPL_PATH . 'maintenance.html');
  193. exit;
  194. }
  195. }
  196. else // normal mode
  197. {
  198. // add composer autoload
  199. require_once(ROOT_PATH . 'vendor' . DS . 'autoload.php');
  200. // add nice error handling https://filp.github.io/whoops/
  201. if (DEBUG_MODE && !CLI_MODE)
  202. {
  203. $whoops = new \Whoops\Run;
  204. $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  205. $whoops->register();
  206. }
  207. }
  208. }