2008-12-11 03:48:25 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-11 03:48:25 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-11 03:48:25 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
#ifndef headerfilecmslucoreconfig
|
|
|
|
#define headerfilecmslucoreconfig
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
#include <string>
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "confparser.h"
|
2010-08-12 21:10:12 +02:00
|
|
|
#include "htmlfilter.h"
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2010-07-27 22:41:56 +02:00
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
class Config
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2010-10-24 21:26:54 +02:00
|
|
|
// name of the config file
|
|
|
|
// this is the parameter passed to winix programm
|
2010-08-10 18:12:50 +02:00
|
|
|
std::string config_file;
|
|
|
|
|
2010-10-24 21:26:54 +02:00
|
|
|
// start as a demon (in the background)
|
|
|
|
// default: true
|
|
|
|
bool demonize;
|
|
|
|
|
2010-10-24 19:49:38 +02:00
|
|
|
// system user name (to which drop privileges)
|
|
|
|
// used only if winix is started as the root
|
|
|
|
std::string user;
|
|
|
|
|
|
|
|
// system group name (to which drop privileges)
|
|
|
|
// used only if winix is started as the root
|
|
|
|
std::string group;
|
|
|
|
|
|
|
|
// setting additional effective groups from /etc/group
|
|
|
|
// by using initgroups()
|
|
|
|
// used only if winix is started as the root
|
|
|
|
// default: true
|
|
|
|
bool additional_groups;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
// log file name, log file name for notifications (sending emails, etc)
|
|
|
|
std::string log_file, log_notify_file;
|
|
|
|
|
|
|
|
// 1 - minimum
|
|
|
|
// 2 - (default)
|
|
|
|
// 3 - maximum - all logs
|
|
|
|
int log_level;
|
|
|
|
|
|
|
|
// logging to stdout too
|
2010-10-24 21:26:54 +02:00
|
|
|
// only if demonize is 'false'
|
|
|
|
// default: false
|
2010-08-10 18:12:50 +02:00
|
|
|
bool log_stdout;
|
|
|
|
|
|
|
|
// how many requests should be logged in the same time
|
|
|
|
// default: 1
|
|
|
|
int log_request;
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
// logging db queries
|
|
|
|
// default: false
|
|
|
|
bool log_db_query;
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
// request delimiter in the log file, default "---------"
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring log_delimiter;
|
2010-08-12 21:10:12 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
// fast cgi: socket (unix domain)
|
|
|
|
std::string fcgi_socket;
|
|
|
|
|
|
|
|
// fast cgi: socket permissions
|
|
|
|
int fcgi_socket_chmod;
|
|
|
|
|
|
|
|
// fast cgi: owner of the socket
|
|
|
|
std::string fcgi_socket_user;
|
|
|
|
|
|
|
|
// fast cgi: group of the socket
|
|
|
|
std::string fcgi_socket_group;
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring templates_dir;
|
|
|
|
std::wstring templates_dir_default; // templates from winix
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
// prefix and postfix for functions templates
|
|
|
|
// default:
|
|
|
|
// prefix: "fun_"
|
|
|
|
// postfix: ".html"
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring templates_fun_prefix;
|
|
|
|
std::wstring templates_fun_postfix;
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
// main html template
|
|
|
|
// default: index.html
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring templates_index;
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
// if true then only root can use 'template' function
|
|
|
|
// default: false
|
|
|
|
bool template_only_root_use_template_fun;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
std::string db_database;
|
|
|
|
std::string db_user;
|
|
|
|
std::string db_pass;
|
|
|
|
|
|
|
|
std::string http_session_id_name;
|
|
|
|
|
|
|
|
// when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed)
|
|
|
|
// the server will redirect into 'base_url' + 'REQUEST_URI'
|
|
|
|
// it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc.
|
|
|
|
bool base_url_redirect;
|
|
|
|
|
|
|
|
// string used in a place where is a user (or group) selected
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring priv_no_user;
|
|
|
|
std::wstring priv_no_group;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// time in seconds when the user will be automatically logged out (iddle time)
|
|
|
|
int session_max_idle;
|
|
|
|
|
|
|
|
// time in seconds when the user will be automatically logged out (when he selected 'remember me' option)
|
|
|
|
// this time is usually greater than session_max_idle
|
|
|
|
int session_remember_max_idle;
|
|
|
|
|
|
|
|
// this file is used when the program is starting and ending
|
|
|
|
std::string session_file;
|
|
|
|
|
|
|
|
// allow the html ouput to be compressed
|
|
|
|
bool compression;
|
2010-08-12 21:10:12 +02:00
|
|
|
|
|
|
|
// if the output is shorter than this value then it will not be compressed
|
|
|
|
int compression_page_min_size;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-08-18 00:32:47 +02:00
|
|
|
// plugins directory
|
|
|
|
// default: /usr/local/winix/plugins
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring plugins_dir;
|
2010-08-18 00:32:47 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
// plugins
|
2010-08-18 00:32:47 +02:00
|
|
|
// you can provide either a relative path (plugins_dir will be used)
|
|
|
|
// or a full path to a plugin
|
2010-11-21 01:19:17 +01:00
|
|
|
std::vector<std::wstring> plugin_file;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
// should the html code be cleaned by the html filter
|
2010-08-10 18:12:50 +02:00
|
|
|
bool html_filter;
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
// should white characters be trimmed
|
|
|
|
bool html_filter_trim_white;
|
|
|
|
|
|
|
|
// when long lines (lines without a white character) should be break (inserted a space)
|
|
|
|
// default: after 60 non white characters will be put a space
|
|
|
|
// set zero to turn off
|
|
|
|
int html_filter_break_lines;
|
|
|
|
|
|
|
|
// how many spaces will be put at one tree level
|
|
|
|
// default: 2
|
|
|
|
size_t html_filter_tabs;
|
|
|
|
|
|
|
|
// use checking for 'orphans' for a specicic language
|
|
|
|
// default: false
|
|
|
|
bool html_filter_orphans;
|
|
|
|
|
|
|
|
// language for html orphans
|
|
|
|
// default: pl
|
|
|
|
// can be either: "pl" or "cz" or "sk"
|
|
|
|
std::string html_filter_orphans_lang_str;
|
|
|
|
HTMLFilter::Lang html_filter_orphans_lang;
|
|
|
|
|
|
|
|
// orphans mode
|
|
|
|
// either: "nbsp" or "160"
|
|
|
|
// default: "nbsp"
|
|
|
|
std::string html_filter_orphans_mode_str;
|
|
|
|
HTMLFilter::OrphanMode html_filter_orphans_mode;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
// the url of a new empty item (if there is not the subject too)
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring item_url_empty;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// maximum length of a file send by post multipart form
|
|
|
|
// 0 - not used
|
2010-11-21 01:19:17 +01:00
|
|
|
size_t post_file_max;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// directories for static files
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring auth_simplefs_dir;
|
|
|
|
std::wstring auth_hashfs_dir;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// temporary directory for static content used by the upload function
|
|
|
|
// should be on the same partition as auth_simplefs_dir and auth_hashfs_dir
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring auth_tmp_dir;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
// locale: en, pl
|
|
|
|
// default: en
|
|
|
|
std::wstring locale_str;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// directory with locale files
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring locale_dir;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// directory with default locale files (those from winix)
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring locale_dir_default;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// the main address of the server (e.g. someserver.com) (without the 'www' part etc)
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring base_server;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// the main address of the site (e.g. http://www.someserver.com)
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring base_url;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// static content authorized by winix
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring base_url_auth;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// static content not authorized by winix
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring base_url_static;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// additional static server for common content (not authorized)
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring base_url_common;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// separator used in <title> html tag
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring title_separator;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
// http header recognized by www server as a file to send back
|
|
|
|
// default: X-LIGHTTPD-send-file
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring http_header_send_file;
|
2010-08-12 21:10:12 +02:00
|
|
|
|
|
|
|
// the minimum size of a password for new users (function: adduser)
|
|
|
|
// default: 5
|
|
|
|
size_t password_min_size;
|
|
|
|
|
|
|
|
// prints additional information (in the end of the html page as a commentary)
|
|
|
|
bool debug_info;
|
|
|
|
|
2010-08-14 19:56:07 +02:00
|
|
|
// in editors (emacs, ckeditor,...) the html will be filtered and unsafe tags
|
|
|
|
// will be dropped (script, frame, etc.)
|
|
|
|
// default: true;
|
|
|
|
bool editors_html_safe_mode;
|
|
|
|
|
|
|
|
// don't filter the html code for root
|
|
|
|
// default: true
|
|
|
|
// (if true the html code for root is not filtered)
|
|
|
|
bool editors_html_safe_mode_skip_root;
|
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
// temporarily we do not support time zones per user
|
|
|
|
// there is one offset for all users
|
|
|
|
// default: 0
|
|
|
|
int time_zone_offset;
|
|
|
|
|
|
|
|
// time zone offset for guests (not logged users)
|
|
|
|
// default: 0
|
|
|
|
int time_zone_offset_guest;
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
// charset used in templates, locales, logs etc.
|
|
|
|
// default: true (UTF-8)
|
|
|
|
// if false it means 8-bit ASCII
|
|
|
|
bool utf8;
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// based on base_url
|
|
|
|
// set by SetAdditionalVariables()
|
|
|
|
// without the first part http:// (or https://) or the whole string is empty
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring base_url_http_host;
|
|
|
|
std::wstring base_url_auth_http_host;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
Config();
|
|
|
|
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring Text(const wchar_t * name);
|
|
|
|
std::wstring Text(const wchar_t * name, const wchar_t * def);
|
|
|
|
std::wstring Text(const std::wstring & name, const std::wstring & def);
|
|
|
|
std::string AText(const wchar_t * name);
|
|
|
|
std::string AText(const wchar_t * name, const wchar_t * def);
|
|
|
|
std::string AText(const std::wstring & name, const std::wstring & def);
|
|
|
|
|
|
|
|
int Int(const wchar_t *);
|
|
|
|
int Int(const wchar_t * name, int def);
|
|
|
|
int Int(const std::wstring & name, int def);
|
|
|
|
size_t Size(const wchar_t *);
|
|
|
|
size_t Size(const wchar_t * name, size_t def);
|
|
|
|
size_t Size(const std::wstring & name, size_t def);
|
|
|
|
bool Bool(const wchar_t *);
|
|
|
|
bool Bool(const wchar_t * name, bool def);
|
|
|
|
bool Bool(const std::wstring & name, bool def);
|
|
|
|
void ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
|
|
|
void ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
|
|
|
|
|
|
|
// for debug
|
|
|
|
void Print(std::ostream & out);
|
2010-07-27 22:41:56 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void ShowError();
|
2010-08-10 18:12:50 +02:00
|
|
|
void AssignValues(bool stdout_is_closed);
|
2010-11-21 01:19:17 +01:00
|
|
|
void SetHttpHost(const std::wstring & in, std::wstring & out);
|
2010-08-10 18:12:50 +02:00
|
|
|
void SetAdditionalVariables();
|
|
|
|
|
|
|
|
ConfParser parser;
|
2010-07-27 22:41:56 +02:00
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
std::string default_str;
|
2010-01-07 15:45:00 +01:00
|
|
|
int default_int;
|
2008-12-11 03:48:25 +01:00
|
|
|
bool default_bool;
|
|
|
|
|
|
|
|
bool errors_to_stdout;
|
2009-12-30 21:46:12 +01:00
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-07-27 22:41:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
#endif
|