added: some more orphans to polish default locale
added: new options to the config: url_proto: default: http:// url_ssl_proto: default: https:// use_ssl, use_ssl_static, use_ssl_common (whether or not to use SSL protocol) use_ssl_only_for_logged_users now we are able to use SSL encryption (https) together with normal connections removed: config option: base_server git-svn-id: svn://ttmath.org/publicrep/winix/trunk@755 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
12
core/app.cpp
12
core/app.cpp
@@ -175,13 +175,14 @@ void App::Close()
|
||||
|
||||
bool App::BaseUrlRedirect()
|
||||
{
|
||||
if( config.base_url_http_host.empty() )
|
||||
if( config.base_url.empty() )
|
||||
return false;
|
||||
|
||||
if( Equal(config.base_url_http_host.c_str(), cur.request->env_http_host) )
|
||||
if( Equal(config.base_url.c_str(), cur.request->env_http_host) )
|
||||
return false;
|
||||
|
||||
cur.request->redirect_to = config.base_url;
|
||||
system.PutUrlProto(config.use_ssl, cur.request->redirect_to);
|
||||
cur.request->redirect_to += config.base_url;
|
||||
AssignString(cur.request->env_request_uri, cur.request->redirect_to, false);
|
||||
// cur.request->env_request_uri should not be UrlEncoded
|
||||
cur.request->redirect_url_encoded = true;
|
||||
@@ -1164,7 +1165,10 @@ sigset_t set;
|
||||
app->Lock();
|
||||
app->synchro.was_stop_signal = true;
|
||||
FCGX_ShutdownPending();
|
||||
Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit);
|
||||
|
||||
// here we don't have to use SSL version so we always use config.url_proto
|
||||
Ezc::WideToUTF8(app->config.url_proto, app->url_to_fetch_on_exit);
|
||||
Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit, false);
|
||||
app->Unlock();
|
||||
|
||||
// this thread will hang on this method
|
||||
|
@@ -144,12 +144,18 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
db_pass = AText(L"db_pass");
|
||||
item_url_empty = Text(L"item_url_empty");
|
||||
|
||||
base_server = Text(L"base_server");
|
||||
url_proto = Text(L"url_proto", L"http://");
|
||||
url_ssl_proto = Text(L"url_ssl_proto", L"https://");
|
||||
|
||||
use_ssl = Bool(L"use_ssl", false);
|
||||
use_ssl_static = Bool(L"use_ssl_static", false);
|
||||
use_ssl_common = Bool(L"use_ssl_common", false);
|
||||
use_ssl_only_for_logged_users = Bool(L"use_ssl_only_for_logged_users", true);
|
||||
|
||||
base_url = Text(L"base_url");
|
||||
base_url_static = Text(L"base_url_static");
|
||||
base_url_common = Text(L"base_url_common");
|
||||
|
||||
NoLastSlash(base_server);
|
||||
NoLastSlash(base_url);
|
||||
NoLastSlash(base_url_static);
|
||||
NoLastSlash(base_url_common);
|
||||
@@ -218,8 +224,6 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
|
||||
void Config::SetAdditionalVariables()
|
||||
{
|
||||
SetHttpHost(base_url, base_url_http_host);
|
||||
|
||||
if( html_filter_orphans_mode_str == "160" )
|
||||
html_filter_orphans_mode = HTMLFilter::orphan_160space;
|
||||
else
|
||||
@@ -283,21 +287,6 @@ void Config::CheckPasswd()
|
||||
}
|
||||
|
||||
|
||||
void Config::SetHttpHost(const std::wstring & in, std::wstring & out)
|
||||
{
|
||||
const char http[] = "http://";
|
||||
const char https[] = "https://";
|
||||
size_t http_len = sizeof(http) / sizeof(char) - 1;
|
||||
size_t https_len = sizeof(https) / sizeof(char) - 1;
|
||||
|
||||
if( IsSubString(http, in.c_str()) )
|
||||
out = in.substr(http_len);
|
||||
else
|
||||
if( IsSubString(https, in.c_str()) )
|
||||
out = in.substr(https_len);
|
||||
else
|
||||
out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done
|
||||
}
|
||||
|
||||
|
||||
std::wstring Config::Text(const wchar_t * name)
|
||||
|
@@ -119,11 +119,6 @@ public:
|
||||
|
||||
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
|
||||
std::wstring priv_no_user;
|
||||
std::wstring priv_no_group;
|
||||
@@ -286,16 +281,48 @@ public:
|
||||
// not available in config -- set automatically based on locale_default
|
||||
size_t locale_default_index;
|
||||
|
||||
// the main address of the server (e.g. someserver.com) (without the 'www' part etc)
|
||||
std::wstring base_server;
|
||||
|
||||
// the main address of the site (e.g. http://www.someserver.com)
|
||||
// url protocol
|
||||
// default: http://
|
||||
std::wstring url_proto;
|
||||
|
||||
// url protocol when using SSL
|
||||
// default: https://
|
||||
std::wstring url_ssl_proto;
|
||||
|
||||
// enables SSL
|
||||
// this is related to [doc_base_url] ezc function
|
||||
// default: false
|
||||
bool use_ssl;
|
||||
|
||||
// enables SSL with [doc_base_url_static]
|
||||
// default: false
|
||||
bool use_ssl_static;
|
||||
|
||||
// enables SSL with [doc_base_url_common]
|
||||
// default: false
|
||||
bool use_ssl_common;
|
||||
|
||||
// if SSL is enabled then if this is true the SSL will be used
|
||||
// only for logged users
|
||||
// default: true
|
||||
bool use_ssl_only_for_logged_users;
|
||||
|
||||
// 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;
|
||||
|
||||
// the main address of the site (e.g. www.someserver.com)
|
||||
// (without http:// prefix)
|
||||
std::wstring base_url;
|
||||
|
||||
// static content not authorized by winix
|
||||
// (e.g. static.someserver.com)
|
||||
std::wstring base_url_static;
|
||||
|
||||
// additional static server for common content (not authorized)
|
||||
// (e.g. common.someserver.com)
|
||||
std::wstring base_url_common;
|
||||
|
||||
// separator used in <title> html tag
|
||||
@@ -390,13 +417,10 @@ public:
|
||||
size_t pattern_cacher_how_many_delete;
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
// based on base_url
|
||||
// set by SetAdditionalVariables()
|
||||
// without the first part http:// (or https://) or the whole string is empty
|
||||
std::wstring base_url_http_host;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Config();
|
||||
@@ -427,7 +451,6 @@ public:
|
||||
private:
|
||||
void ShowError();
|
||||
void AssignValues(bool stdout_is_closed);
|
||||
void SetHttpHost(const std::wstring & in, std::wstring & out);
|
||||
void SetAdditionalVariables();
|
||||
void CheckLocale();
|
||||
void CheckPasswd();
|
||||
|
@@ -99,7 +99,7 @@ void Request::SetCookie(const char * name, const char * value, tm * expires)
|
||||
if( expires )
|
||||
headers << "; expires=" << DateToStrCookie(expires) << " GMT";
|
||||
|
||||
headers << "; path=/; domain=." << config->base_server << "\r\n";
|
||||
headers << "; path=/; domain=" << config->base_url << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ void Request::SetCookie(const char * name, long value, tm * expires)
|
||||
if( expires )
|
||||
headers << "; expires=" << DateToStrCookie(expires) << " GMT";
|
||||
|
||||
headers << "; path=/; domain=." << config->base_server << "\r\n";
|
||||
headers << "; path=/; domain=" << config->base_url << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
|
@@ -86,11 +86,33 @@ void System::Init()
|
||||
}
|
||||
|
||||
|
||||
void System::PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str)
|
||||
{
|
||||
bool ssl = false;
|
||||
|
||||
if( clear_str )
|
||||
str.clear();
|
||||
|
||||
if( can_use_ssl )
|
||||
{
|
||||
if( !config->use_ssl_only_for_logged_users || cur->session->puser )
|
||||
{
|
||||
str += config->url_ssl_proto;
|
||||
ssl = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( !ssl )
|
||||
str += config->url_proto;
|
||||
}
|
||||
|
||||
|
||||
// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad
|
||||
// !! moze zwracac jakas wartosc?
|
||||
void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
{
|
||||
cur->request->redirect_to = config->base_url;
|
||||
PutUrlProto(config->use_ssl, cur->request->redirect_to);
|
||||
cur->request->redirect_to += config->base_url;
|
||||
|
||||
if( item.type == Item::dir )
|
||||
{
|
||||
@@ -112,7 +134,8 @@ void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
|
||||
void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
{
|
||||
cur->request->redirect_to = config->base_url;
|
||||
PutUrlProto(config->use_ssl, cur->request->redirect_to);
|
||||
cur->request->redirect_to += config->base_url;
|
||||
Item * pdir = dirs.GetDir(item_id);
|
||||
|
||||
if( pdir )
|
||||
@@ -148,7 +171,8 @@ void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
|
||||
void System::RedirectTo(const std::wstring & url)
|
||||
{
|
||||
cur->request->redirect_to = config->base_url;
|
||||
PutUrlProto(config->use_ssl, cur->request->redirect_to);
|
||||
cur->request->redirect_to += config->base_url;
|
||||
|
||||
if( !url.empty() && url[0] == '/' )
|
||||
{
|
||||
|
@@ -75,6 +75,7 @@ public:
|
||||
|
||||
void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true);
|
||||
|
||||
void PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str = true);
|
||||
void RedirectTo(const Item & item, const wchar_t * postfix = 0);
|
||||
void RedirectTo(long item_id, const wchar_t * postfix = 0);
|
||||
void RedirectTo(const std::wstring & url);
|
||||
|
Reference in New Issue
Block a user