added: std::wstring * Request::ParamValuep(const wchar_t * param_name)

for taking a pointer (can be null) to a parameter value
added: bool System::IsSSLRequired(bool try_to_use_ssl)
       returns true if we should use ssl
       try_to_use_ssl is to be meant: config->use_ssl, config->use_ssl_static, config->use_ssl_common
       



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1094 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2018-04-22 21:26:56 +00:00
parent a5dfc9974f
commit 55992b5066
20 changed files with 860 additions and 852 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2016, Tomasz Sowa
* Copyright (c) 2010-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -152,33 +152,84 @@ void System::Init()
}
void System::PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str)
/*
* try_to_use_ssl is to be meant: config->use_ssl, config->use_ssl_static, config->use_ssl_common
*/
bool System::IsSSLRequired(bool try_to_use_ssl)
{
bool ssl = false;
bool ssl = false;
if( clear_str )
str.clear();
if( can_use_ssl )
if( try_to_use_ssl )
{
if( !config->use_ssl_only_for_logged_users ||
cur->session->puser ||
(cur->request->function && cur->request->function->need_ssl) )
{
str += config->url_ssl_proto;
ssl = true;
}
}
if( !ssl )
return ssl;
}
bool System::IsSSLRequired()
{
return IsSSLRequired(config->use_ssl);
}
/*
* try_to_use_ssl is to be meant: config->use_ssl, config->use_ssl_static, config->use_ssl_common
*/
void System::PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str)
{
if( clear_str )
str.clear();
if( IsSSLRequired() )
str += config->url_ssl_proto;
else
str += config->url_proto;
}
/*
* try_to_use_ssl is to be meant: config->use_ssl, config->use_ssl_static, config->use_ssl_common
*/
void System::PutUrlProto(bool can_use_ssl, PT::TextStream & str, bool clear_stream)
{
if( clear_stream )
str.clear();
if( IsSSLRequired(can_use_ssl) )
{
str << config->url_ssl_proto;
}
else
{
str << config->url_proto;
}
}
void System::PutUrlProto(std::wstring & str, bool clear_str)
{
return PutUrlProto(config->use_ssl, str, clear_str);
}
void System::PutUrlProto(PT::TextStream & str, bool clear_stream)
{
return PutUrlProto(config->use_ssl, str, clear_stream);
}
void System::CreateItemLink(long parent_id, const std::wstring & url, const std::wstring & subdomain,
std::wstring & link, bool clear_str)
{
PutUrlProto(config->use_ssl, link, clear_str);
PutUrlProto(link, clear_str);
if( !subdomain.empty() )
{
@@ -207,7 +258,7 @@ void System::CreateItemLink(const Item & item, std::wstring & link, bool clear_s
*/
void System::RedirectTo(const Item & item, const wchar_t * postfix, bool use_reqtype)
{
PutUrlProto(config->use_ssl, cur->request->redirect_to);
PutUrlProto(cur->request->redirect_to);
if( !cur->request->subdomain.empty() )
{
@@ -246,7 +297,7 @@ void System::RedirectTo(const Item & item, const wchar_t * postfix, bool use_req
*/
void System::RedirectTo(long item_id, const wchar_t * postfix, bool use_reqtype)
{
PutUrlProto(config->use_ssl, cur->request->redirect_to);
PutUrlProto(cur->request->redirect_to);
if( !cur->request->subdomain.empty() )
{
@@ -300,7 +351,7 @@ void System::RedirectTo(long item_id, const wchar_t * postfix, bool use_reqtype)
*/
void System::RedirectTo(const wchar_t * url, bool use_reqtype)
{
PutUrlProto(config->use_ssl, cur->request->redirect_to);
PutUrlProto(cur->request->redirect_to);
if( !cur->request->subdomain.empty() )
{