changed: now we are parsing directories and functions before checking a session

added:   need_session to FunctionBase (true if the functions requires a session)
         default: true
         



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1114 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2018-06-19 13:52:08 +00:00
parent 436a198c36
commit 35b93b1655
4 changed files with 49 additions and 20 deletions

View File

@ -402,6 +402,14 @@ void App::ProcessRequestThrow()
// and then BaseUrlRedirect() will be called (for performance)
if( !BaseUrlRedirect() )
{
if( cur.request->env_request_uri.size() <= WINIX_URL_MAX_SIZE )
{
functions.Parse(); // parsing directories, files, functions and parameters
if( !cur.request->dir_tab.empty() )
{
functions.CheckFunctionAndSymlink(); // CHECK ME it is correct now?
session_manager.SetSession();
cur.session = session_manager.GetCurSession();
SetLocale();
@ -413,10 +421,7 @@ void App::ProcessRequestThrow()
}
plugin.Call(WINIX_SESSION_CHANGED);
if( cur.request->env_request_uri.size() <= WINIX_URL_MAX_SIZE )
{
functions.Parse(); // parsing directories, files, functions and parameters
}
}
else
{
@ -436,6 +441,18 @@ void App::ProcessRequestThrow()
log << log1 << "App: the URL is too long: " << cur.request->env_request_uri.size() << logend;
}
if( cur.request->dir_tab.empty() )
{
log << log1 << "App: there is no a root dir (dir_tab is empty), adding a root dir" << logend;
Item * root_dir = system.dirs.GetRootDir();
if( root_dir )
{
cur.request->dir_tab.push_back(root_dir);
cur.request->last_item = cur.request->dir_tab.back();
}
}
cur.mount = system.mounts.CalcCurMount();
if( cur.mount->type != system.mounts.MountTypeStatic() )
@ -659,8 +676,8 @@ void App::Make()
if( cur.request->status == WINIX_ERR_OK )
plugin.Call(WINIX_PREPARE_REQUEST);
if( cur.request->status == WINIX_ERR_OK )
functions.CheckFunctionAndSymlink();
// if( cur.request->status == WINIX_ERR_OK )
// functions.CheckFunctionAndSymlink();
CheckAccessFromPlugins();

View File

@ -459,6 +459,8 @@ void SessionManager::SetSession()
is_session_set = false;
if( !IsIPBanned() )
{
if( cur->request->function && cur->request->function->need_session )
{
CookieTab::iterator i = cur->request->cookie_tab.find(config->http_session_id_name);
@ -472,6 +474,11 @@ void SessionManager::SetSession()
NoSessionCookieCheckBan();
}
}
else
{
SetTemporarySession();
}
}
if( !is_session_set )
CreateSession();

View File

@ -45,6 +45,7 @@ FunctionBase::FunctionBase()
follow_symlinks = true;
template_index = size_t(-1);
need_ssl = false;
need_session = true;
fun.user_id = -1;
fun.group_id = -1;

View File

@ -80,6 +80,10 @@ public:
// (this option is ignored if 'use_ssl' in the config is false)
bool need_ssl;
// true if the function need a session object
// if false then a temporary session is used
bool need_session;
virtual void Init();
virtual bool HasAccess();
virtual void MakePost();