Example #1
0
 /**
  * read wikidot.ini file
  * set some default values
  * calculate other values 
  */
 public static function init()
 {
     self::$iniConfig = parse_ini_file(WIKIDOT_ROOT . "/conf/wikidot.ini", true);
     // main settings
     self::$WIKI_FARM = self::fromIni("main", "wiki_farm", false);
     self::$HTTP_PORT = self::fromIni("main", "port", 8080);
     if (self::$WIKI_FARM) {
         self::$SERVICE_NAME = self::fromIni("main", "service");
         //no default
         self::$URL_DOMAIN = self::fromIni("main", "domain", "singlewiki.wikidot.dev");
         self::$URL_HOST = self::fromIni("main", "main_wiki", "www." . self::$URL_DOMAIN);
     } else {
         self::$SERVICE_NAME = "";
         self::$URL_DOMAIN = self::fromIni("main", "domain", "singlewiki.wikidot.dev");
         self::$URL_HOST = self::fromIni("main", "main_wiki", "www." . self::$URL_DOMAIN);
     }
     // security settings
     self::$SECRET = self::fromIni("security", "secret", self::fromFile('secret'));
     self::$USE_SSL = self::fromIni("security", "ssl", false);
     self::$SECRET_DOMAIN_LOGIN = self::fromIni("security", "secret_login", self::$SECRET . "_custom_domain_login");
     self::$USE_UPLOAD_DOMAIN = self::fromIni("security", "upload_separate_domain", false);
     self::$URL_UPLOAD_DOMAIN = self::fromIni("security", "upload_domain", "wd.files." . self::$URL_DOMAIN);
     self::$RESTRICT_HTML = self::fromIni("security", "upload_restrict_html", true);
     self::$SECRET_MANAGE_SUPERADMIN = self::fromIni("security", "secret_manage_superadmin", md5(self::$SECRET . '_super_admin'));
     // database settings
     self::$DATABASE_USER = self::fromIni("db", "user");
     // no default!
     self::$DATABASE_PASSWORD = self::fromIni("db", "password");
     // no default!
     self::$DATABASE_NAME = self::fromIni("db", "database");
     // no default!
     self::$DATABASE_SERVER = self::fromIni("db", "host", "127.0.0.1");
     self::$DATABASE_PORT = self::fromIni("db", "port", "5432");
     // search settings
     self::$SEARCH_LUCENE_INDEX = self::fromIni("search", "lucene_index", WIKIDOT_ROOT . "/tmp/lucene_index");
     self::$SEARCH_LUCENE_QUEUE = self::fromIni("search", "lucene_queue", WIKIDOT_ROOT . "/tmp/lucene_queue");
     self::$SEARCH_LUCENE_LOCK = self::fromIni("search", "lucene_lock", WIKIDOT_ROOT . "/tmp/lucene_lock");
     self::$SEARCH_HIGHLIGHT = self::fromIni("search", "highlight", false);
     self::$SEARCH_USE_JAVA = self::fromIni("search", "use_java", false);
     // mail settings
     self::$DEFAULT_SMTP_HOST = self::fromIni("mail", "host", "127.0.0.1");
     self::$DEFAULT_SMTP_SECURE = self::fromIni("mail", "ssl", false) ? "ssl" : "";
     self::$DEFAULT_SMTP_PORT = self::fromIni("mail", "port", self::$DEFAULT_SMTP_SECURE == "ssl" ? 465 : 25);
     self::$DEFAULT_SMTP_USER = self::fromIni("mail", "user", "admin");
     self::$DEFAULT_SMTP_PASSWORD = self::fromIni("mail", "password", "");
     self::$DEFAULT_SMTP_AUTH = self::fromIni("mail", "auth", false);
     self::$DEFAULT_SMTP_HOSTNAME = self::fromIni("mail", "hostname", self::$DEFAULT_SMTP_HOST);
     self::$DEFAULT_SMTP_FROM_EMAIL = self::fromIni("mail", "from_mail", strstr(self::$DEFAULT_SMTP_USER, "@") ? self::$DEFAULT_SMTP_USER : self::$DEFAULT_SMTP_USER . "@" . self::$DEFAULT_SMTP_HOSTNAME);
     self::$DEFAULT_SMTP_FROM_NAME = self::fromIni("mail", "from_name", self::$SERVICE_NAME . " Mailer");
     self::$DEFAULT_SMTP_REPLY_TO = self::fromIni("mail", "reply_to", "no-reply@" . self::$DEFAULT_SMTP_HOSTNAME);
     self::$DEFAULT_SMTP_SENDER = self::fromIni("mail", "sender", self::$DEFAULT_SMTP_FROM_EMAIL);
     self::$SUPPORT_EMAIL = self::fromIni("mail", "support", self::$DEFAULT_SMTP_FROM_EMAIL);
     // memcache settings
     self::$USE_MEMCACHE = self::fromIni("memcached", "enable", false);
     self::$MEMCACHE_HOST = self::fromIni("memcached", "host", "127.0.0.1");
     self::$MEMCACHE_PORT = self::fromIni("memcached", "port", 11211);
     // session settings
     self::$SESSION_TIMEOUT = self::fromIni("session", "timeout", 3600);
     self::$SESSION_COOKIE_NAME = self::fromIni("session", "cookie_name", "WIKIDOT_SESSION_ID");
     self::$SESSION_COOKIE_SECURE = self::fromIni("session", "cookie_ssl", false);
     self::$SESSION_COOKIE_NAME_IE = self::fromIni("session", "ie_cookie_name", self::$SESSION_COOKIE_NAME . "_IE");
     // ui settings
     self::$UI_SLEEP = self::fromIni("ui", "sleep", true);
     self::$DEFAULT_LANGUAGE = self::fromIni("ui", "language", "en");
     // log settings
     self::$LOGGER_LEVEL = self::fromIni("log", "level", "fatal");
     self::$LOGGER_FILE = self::fromIni("log", "file", "wikidot.log");
     // TODO: use this setting
     // other settings
     self::$CACHE_FILES_FOR = self::fromIni("misc", "cache_files_for", 0);
     self::$URL_DOCS = self::fromIni("misc", "doc_url", "http://www.wikidot.org/doc");
     self::$IP_HOST = self::fromIni("misc", "ip", "127.0.0.1");
     self::$USE_CUSTOM_DOMAINS = self::fromIni("misc", "custom_domains", false);
     self::$MODULES_JS_PATH = self::fromIni("misc", "modules_js_path", "web/files--common/modules/js");
     self::$MODULES_JS_URL = self::fromIni("misc", "modules_js_url", "/common--modules/js");
     self::$MODULES_CSS_PATH = self::fromIni("misc", "modules_css_path", "web/files--common/modules/css");
     self::$MODULES_CSS_URL = self::fromIni("misc", "modules_css_url", "/common--modules/css");
     self::$XSENDFILE_USE = self::fromIni("misc", "xsendfile", false);
     self::$XSENDFILE_HEADER = self::fromIni("misc", "xsendfile_header", "X-LIGHTTPD-send-file");
     // non-configurable properties
     self::$DATABASE_TYPE = "pgsql";
     self::$DATABASE_USE_PERSISTENT_CONNECTIONS = false;
     self::$SESSION_COOKIE_DOMAIN = "." . self::$URL_DOMAIN;
     self::$DEFAULT_SKIN = "default";
     self::$URL_HOST_PREG = preg_quote(self::$URL_HOST);
     self::$URL_DOMAIN_PREG = preg_quote(self::$URL_DOMAIN);
     self::$URL_UPLOAD_DOMAIN_PREG = preg_quote(self::$URL_UPLOAD_DOMAIN);
 }