WIP: remove the old database abstraction layer
remove such classes: - DbBase - DbConn - DbTextStream - Db while here: - remove: TextStream, SLog, TexTextStream
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
#include "account.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +52,7 @@ Account::Account()
|
||||
|
||||
|
||||
|
||||
bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||
bool Account::ActivateAccount(User * puser, long code)
|
||||
{
|
||||
pt::Space * user_code_space = puser->admin_env.get_space(L"activation_code");
|
||||
|
||||
@@ -68,8 +67,8 @@ bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "Account: account: " << puser->login << " activated" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_activated") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << loginfo << T(L"account_activated") << logend;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -85,23 +84,23 @@ bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||
|
||||
log << log2 << "Account: incorrect activation code" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"incorrect_activation_code") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T(L"incorrect_activation_code") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Account: there is no activation_code value in an admin environment" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_cannot_be_activated") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << loginfo << T(L"account_cannot_be_activated") << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Account::ActivateAccount(const std::wstring & login, long code, bool use_ses_log)
|
||||
bool Account::ActivateAccount(const std::wstring & login, long code)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = system->users.GetUser(login);
|
||||
@@ -110,14 +109,14 @@ bool Account::ActivateAccount(const std::wstring & login, long code, bool use_se
|
||||
{
|
||||
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
||||
{
|
||||
result = ActivateAccount(puser, code, use_ses_log);
|
||||
result = ActivateAccount(puser, code);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Account: this account is already activated" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_already_activated") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << loginfo << T(L"account_already_activated") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -137,7 +136,7 @@ void Account::ActivateAccount()
|
||||
|
||||
if( !login.empty() )
|
||||
{
|
||||
ActivateAccount(login, code, true);
|
||||
ActivateAccount(login, code);
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ public:
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
bool ActivateAccount(const std::wstring & login, long code, bool use_ses_log = false);
|
||||
bool ActivateAccount(const std::wstring & login, long code);
|
||||
|
||||
private:
|
||||
|
||||
bool ActivateAccount(User * puser, long code, bool use_ses_log);
|
||||
bool ActivateAccount(User * puser, long code);
|
||||
void ActivateAccount();
|
||||
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -69,14 +69,14 @@ return true;
|
||||
|
||||
|
||||
|
||||
bool AddUser::IsLoginCorrect(const std::wstring & login, bool use_ses_log)
|
||||
bool AddUser::IsLoginCorrect(const std::wstring & login)
|
||||
{
|
||||
if( login.empty() )
|
||||
{
|
||||
log << log2 << "AddUser: login can't be empty" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_login_empty") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_login_empty") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -85,9 +85,9 @@ bool AddUser::IsLoginCorrect(const std::wstring & login, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "AddUser: login can't be longer than: " << WINIX_ACCOUNT_MAX_LOGIN_SIZE << " characters" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_login_too_big") << " " << WINIX_ACCOUNT_MAX_LOGIN_SIZE
|
||||
<< " " << T("adduser_err_login_too_big2") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_login_too_big") << " " << WINIX_ACCOUNT_MAX_LOGIN_SIZE
|
||||
// << " " << T("adduser_err_login_too_big2") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -96,8 +96,8 @@ bool AddUser::IsLoginCorrect(const std::wstring & login, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "AddUser: incorrect login characters" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_login_incorrect_chars") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_login_incorrect_chars") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -106,8 +106,8 @@ bool AddUser::IsLoginCorrect(const std::wstring & login, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "AddUser: such user already exists" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_user_exists") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_user_exists") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -117,15 +117,15 @@ return true;
|
||||
|
||||
|
||||
|
||||
bool AddUser::IsEmailCorrect(const std::wstring & email, bool use_ses_log)
|
||||
bool AddUser::IsEmailCorrect(const std::wstring & email)
|
||||
{
|
||||
if( email.size() > WINIX_ACCOUNT_MAX_EMAIL_SIZE )
|
||||
{
|
||||
log << log2 << "AddUser: email can't be longer than: " << WINIX_ACCOUNT_MAX_EMAIL_SIZE << " characters" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_email_too_big") << " " << WINIX_ACCOUNT_MAX_EMAIL_SIZE
|
||||
<< " " << T("adduser_err_email_too_big2") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_email_too_big") << " " << WINIX_ACCOUNT_MAX_EMAIL_SIZE
|
||||
// << " " << T("adduser_err_email_too_big2") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -134,8 +134,8 @@ bool AddUser::IsEmailCorrect(const std::wstring & email, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "AddUser: email: " << email << " does not seem to be correct" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"adduser_err_email_incorrect") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T(L"adduser_err_email_incorrect") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -210,8 +210,7 @@ bool AddUser::AddNewUser(const std::wstring & login,
|
||||
const std::wstring & pass,
|
||||
const std::wstring & email,
|
||||
bool autoactivate,
|
||||
bool try_login,
|
||||
bool use_ses_log)
|
||||
bool try_login)
|
||||
{
|
||||
user.set_connector(model_connector);
|
||||
user.clear();
|
||||
@@ -248,8 +247,8 @@ bool AddUser::AddNewUser(const std::wstring & login,
|
||||
{
|
||||
system->notify.ActivateAccount(user.login, user.email, code);
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_email_sent") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << loginfo << T(L"account_email_sent") << logend;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -272,9 +271,9 @@ void AddUser::MakePost()
|
||||
// or some other place
|
||||
functions->fun_passwd.set_dependency(this);
|
||||
|
||||
if( !IsLoginCorrect(login, true) ||
|
||||
!IsEmailCorrect(email, true) ||
|
||||
!functions->fun_passwd.IsPasswordCorrect(pass, conf_pass, true) )
|
||||
if( !IsLoginCorrect(login) ||
|
||||
!IsEmailCorrect(email) ||
|
||||
!functions->fun_passwd.IsPasswordCorrect(pass, conf_pass) )
|
||||
return;
|
||||
|
||||
if( cur->session->puser && cur->session->puser->is_super_user )
|
||||
@@ -285,7 +284,7 @@ void AddUser::MakePost()
|
||||
log << log2 << "AddUser: account activated by an admin" << logend;
|
||||
}
|
||||
|
||||
if( AddNewUser(login, pass, email, autoactivate, true, true) )
|
||||
if( AddNewUser(login, pass, email, autoactivate, true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
|
||||
bool IsLoginCorrect(const std::wstring & login, bool use_ses_log = false);
|
||||
bool IsEmailCorrect(const std::wstring & email, bool use_ses_log = false);
|
||||
bool IsLoginCorrect(const std::wstring & login);
|
||||
bool IsEmailCorrect(const std::wstring & email);
|
||||
|
||||
bool HasLoginCorrectChars(const std::wstring & login);
|
||||
bool AddNewUser(User & user, const std::wstring & pass);
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
const std::wstring & pass,
|
||||
const std::wstring & email,
|
||||
bool autoactivate,
|
||||
bool try_login,
|
||||
bool use_ses_log = false);
|
||||
bool try_login);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -60,7 +60,6 @@ void Chmod::MakePost()
|
||||
{
|
||||
priv_changer.SetCur(cur);
|
||||
priv_changer.SetSystem(system);
|
||||
priv_changer.SetDb(db);
|
||||
|
||||
priv_changer.Change(false, true);
|
||||
}
|
||||
@@ -70,7 +69,6 @@ void Chmod::MakeGet()
|
||||
{
|
||||
priv_changer.SetCur(cur);
|
||||
priv_changer.SetSystem(system);
|
||||
priv_changer.SetDb(db);
|
||||
|
||||
priv_changer.CheckAccess();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -61,7 +61,6 @@ void Chown::MakePost()
|
||||
{
|
||||
priv_changer.SetCur(cur);
|
||||
priv_changer.SetSystem(system);
|
||||
priv_changer.SetDb(db);
|
||||
|
||||
priv_changer.Change(true, false);
|
||||
}
|
||||
@@ -71,7 +70,6 @@ void Chown::MakeGet()
|
||||
{
|
||||
priv_changer.SetCur(cur);
|
||||
priv_changer.SetSystem(system);
|
||||
priv_changer.SetDb(db);
|
||||
|
||||
priv_changer.CheckAccess();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "default.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "download.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2021, Tomasz Sowa
|
||||
* Copyright (c) 2012-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "env.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -73,7 +74,7 @@ bool Env::Parse(const std::wstring & env_str)
|
||||
}
|
||||
|
||||
|
||||
bool Env::EditAdminEnv(const std::wstring & env_str, bool use_ses_log)
|
||||
bool Env::EditAdminEnv(const std::wstring & env_str)
|
||||
{
|
||||
if( Parse(env_str) )
|
||||
{
|
||||
@@ -93,15 +94,15 @@ bool Env::EditAdminEnv(const std::wstring & env_str, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "Env: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Env::EditEnv(const std::wstring & env_str, bool use_ses_log)
|
||||
bool Env::EditEnv(const std::wstring & env_str)
|
||||
{
|
||||
if( Parse(env_str) )
|
||||
{
|
||||
@@ -121,8 +122,8 @@ bool Env::EditEnv(const std::wstring & env_str, bool use_ses_log)
|
||||
{
|
||||
log << log2 << "Env: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -139,21 +140,21 @@ void Env::SaveEnv()
|
||||
{
|
||||
if( cur->session->puser->is_super_user )
|
||||
{
|
||||
status = EditAdminEnv(env_str, true);
|
||||
status = EditAdminEnv(env_str);
|
||||
|
||||
if( status )
|
||||
{
|
||||
slog << loginfo << T(L"env_admin_changed_successfully") << logend;
|
||||
//slog << loginfo << T(L"env_admin_changed_successfully") << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = EditEnv(env_str, true);
|
||||
status = EditEnv(env_str);
|
||||
|
||||
if( status )
|
||||
{
|
||||
slog << loginfo << T(L"env_changed_successfully") << logend;
|
||||
//slog << loginfo << T(L"env_changed_successfully") << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2021, Tomasz Sowa
|
||||
* Copyright (c) 2012-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -66,8 +66,8 @@ private:
|
||||
pt::Space space;
|
||||
UserWrapper user_wrapper;
|
||||
|
||||
bool EditAdminEnv(const std::wstring & env_str, bool use_ses_log = false);
|
||||
bool EditEnv(const std::wstring & env_str, bool use_ses_log = false);
|
||||
bool EditAdminEnv(const std::wstring & env_str);
|
||||
bool EditEnv(const std::wstring & env_str);
|
||||
|
||||
bool Parse(const std::wstring & env_str);
|
||||
void SaveEnv();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2023, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "functionbase.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
@@ -60,7 +61,6 @@ FunctionBase::FunctionBase()
|
||||
fun.id = -1;
|
||||
fun.type = Item::file;
|
||||
|
||||
db = nullptr;
|
||||
functions = nullptr;
|
||||
templates = nullptr;
|
||||
}
|
||||
@@ -85,12 +85,6 @@ FunctionBase::~FunctionBase()
|
||||
|
||||
|
||||
|
||||
void FunctionBase::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
//void FunctionBase::SetSystem(System * psystem)
|
||||
//{
|
||||
// system = psystem;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2023, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "db/db.h"
|
||||
#include "core/request.h"
|
||||
#include "core/config.h"
|
||||
#include "core/synchro.h"
|
||||
@@ -160,7 +159,6 @@ public:
|
||||
|
||||
//void SetConfig(Config * pconfig);
|
||||
//void SetCur(Cur * pcur);
|
||||
void SetDb(Db * pdb);
|
||||
//void SetSystem(System * psystem);
|
||||
void SetFunctions(Functions * pfunctions);
|
||||
void SetTemplates(Templates * ptemplates);
|
||||
@@ -172,7 +170,6 @@ public:
|
||||
protected:
|
||||
|
||||
//Config * config;
|
||||
Db * db; // depracated
|
||||
//System * system;
|
||||
Functions * functions;
|
||||
Templates * templates;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "functionparser.h"
|
||||
#include "core/log.h"
|
||||
#include "core/winix_const.h"
|
||||
#include "functions.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "models/item.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "core/winixmodeldeprecated.h"
|
||||
#include "db/db.h"
|
||||
#include "core/cur.h"
|
||||
#include "core/dirs.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2022, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,13 +55,6 @@ void Functions::SetCur(Cur * pcur)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
@@ -190,7 +183,6 @@ void Functions::SetObjects(FunctionBase * fun)
|
||||
|
||||
//fun->SetConfig(config);
|
||||
//fun->SetCur(cur);
|
||||
fun->SetDb(db);
|
||||
//fun->SetSystem(system);
|
||||
fun->SetFunctions(this);
|
||||
fun->SetTemplates(templates);
|
||||
@@ -661,17 +653,17 @@ bool Functions::CheckAntispamCounter()
|
||||
|
||||
// !!uwaga zwracana wartosc zmieniona (true/false)
|
||||
// !! IMPROVE ME in emacs.cpp there is a similar function
|
||||
bool Functions::CheckAbuse(SLog * slog)
|
||||
bool Functions::CheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
|
||||
if( slog )
|
||||
{
|
||||
// put to locale
|
||||
(*slog) << logerror << T(L"rebus_need_to_solve") << logend;
|
||||
}
|
||||
// if( slog )
|
||||
// {
|
||||
// // put to locale
|
||||
// (*slog) << logerror << T(L"rebus_need_to_solve") << logend;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2022, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -169,7 +169,6 @@ public:
|
||||
|
||||
//void SetConfig(Config * pconfig);
|
||||
void SetCur(Cur * pcur);
|
||||
void SetDb(Db * pdb);
|
||||
void SetSystem(System * psystem);
|
||||
void SetTemplates(Templates * ptemplates);
|
||||
//void SetSynchro(Synchro * psynchro);
|
||||
@@ -184,7 +183,7 @@ public:
|
||||
|
||||
void CheckGetPostTimes(time_t difference = 10);
|
||||
|
||||
bool CheckAbuse(SLog * slog = nullptr);
|
||||
bool CheckAbuse();
|
||||
|
||||
// !! dac lepsze nazwy
|
||||
void ReadItemFilterHtml(const std::wstring & html, std::wstring & html_filtered);
|
||||
@@ -206,7 +205,6 @@ private:
|
||||
|
||||
//Config * config;
|
||||
Cur * cur;
|
||||
Db * db;
|
||||
System * system;
|
||||
//Synchro * synchro;
|
||||
Templates * templates;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2022, Tomasz Sowa
|
||||
* Copyright (c) 2013-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "imgcrop.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2021, Tomasz Sowa
|
||||
* Copyright (c) 2012-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -89,7 +89,7 @@ size_t tmp_ip_len = sizeof(tmp_ip_str) / sizeof(char);
|
||||
if( cur->session->ip_ban )
|
||||
cur_ip = cur->session->ip_ban->ip;
|
||||
|
||||
if( wide_to_utf8(cur->request->ParamValue(L"removeip"), tmp_ip_str, tmp_ip_len) )
|
||||
if( pt::wide_to_utf8(cur->request->ParamValue(L"removeip"), tmp_ip_str, tmp_ip_len) )
|
||||
{
|
||||
int ip = (int)inet_addr(tmp_ip_str);
|
||||
session_manager->RemoveIPBan(ip);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2021, Tomasz Sowa
|
||||
* Copyright (c) 2012-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "locale.h"
|
||||
#include "core/misc.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -270,8 +270,7 @@ return true;
|
||||
|
||||
// if you are logging not from a webbrowser but from an application
|
||||
// then probably you need check_abuse to be false
|
||||
bool Login::LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me,
|
||||
bool use_ses_log, bool check_abuse)
|
||||
bool Login::LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me, bool check_abuse)
|
||||
{
|
||||
long user_id;
|
||||
|
||||
@@ -305,7 +304,7 @@ long user_id;
|
||||
|
||||
if( CheckUserPass(login, password, user_id) )
|
||||
{
|
||||
if( system->users.LoginUser(user_id, remember_me, use_ses_log) )
|
||||
if( system->users.LoginUser(user_id, remember_me) )
|
||||
{
|
||||
if( cur->session->ip_ban )
|
||||
cur->session->ip_ban->incorrect_login_events = 0;
|
||||
@@ -328,7 +327,7 @@ void Login::MakePost()
|
||||
const std::wstring & pass = cur->request->PostVar(L"password");
|
||||
const std::wstring & remem = cur->request->PostVar(L"rememberme");
|
||||
|
||||
if( LoginUser(login, pass, !remem.empty(), true, true) )
|
||||
if( LoginUser(login, pass, !remem.empty(), true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -69,8 +69,7 @@ public:
|
||||
bool CannotLoginFrom(const IPBan & ipban);
|
||||
|
||||
bool CheckUserPass(const std::wstring & login, const std::wstring & password, long & user_id);
|
||||
bool LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me,
|
||||
bool use_ses_log = false, bool check_abuse = false);
|
||||
bool LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me, bool check_abuse = false);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2021, Tomasz Sowa
|
||||
* Copyright (c) 2011-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -68,7 +68,7 @@ bool Meta::Parse(const std::wstring & meta_str)
|
||||
|
||||
|
||||
|
||||
bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_ses_log)
|
||||
bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str)
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
@@ -90,8 +90,8 @@ bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_se
|
||||
{
|
||||
log << log2 << "Meta: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -99,7 +99,7 @@ return false;
|
||||
|
||||
|
||||
|
||||
bool Meta::EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log)
|
||||
bool Meta::EditMeta(Item & item, const std::wstring & meta_str)
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
@@ -121,8 +121,8 @@ bool Meta::EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log
|
||||
{
|
||||
log << log2 << "Meta: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -138,7 +138,7 @@ void Meta::ChangeAdminMeta()
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( EditAdminMeta(*cur->request->last_item, meta_str, true) )
|
||||
if( EditAdminMeta(*cur->request->last_item, meta_str) )
|
||||
{
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
@@ -152,7 +152,7 @@ void Meta::ChangeMeta()
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( EditMeta(*cur->request->last_item, meta_str, true) )
|
||||
if( EditMeta(*cur->request->last_item, meta_str) )
|
||||
{
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2021, Tomasz Sowa
|
||||
* Copyright (c) 2011-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
|
||||
bool EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_ses_log = false);
|
||||
bool EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log = false);
|
||||
bool EditAdminMeta(Item & item, const std::wstring & meta_str);
|
||||
bool EditMeta(Item & item, const std::wstring & meta_str);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include "mv.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
@@ -155,7 +156,7 @@ bool Mv::ParseDirCheckLastName()
|
||||
if( out_has_file )
|
||||
{
|
||||
log << log1 << "Mv: incorrent path" << logend;
|
||||
slog << logerror << T("mv_incorrect_path") << logend;
|
||||
//slog << logerror << T("mv_incorrect_path") << logend;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -212,7 +213,7 @@ bool Mv::ParseDir(const std::wstring & dst_path, bool check_access)
|
||||
|
||||
if( res != 0 && res != 1 )
|
||||
{
|
||||
slog << logerror << T("mv_incorrect_dst_path") << logend;
|
||||
//slog << logerror << T("mv_incorrect_dst_path") << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -232,7 +233,7 @@ bool Mv::CanRemoveRenameChild(const Item & child)
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, child.item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Mv: permission denied to: " << child.url << logend;
|
||||
slog << logerror << T("mv_permission_denied_to") << ": " << child.url << logend;
|
||||
//slog << logerror << T("mv_permission_denied_to") << ": " << child.url << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -256,7 +257,7 @@ bool Mv::MoveStaticFile(const std::wstring & from, const std::wstring & to)
|
||||
else
|
||||
{
|
||||
log << log1 << "Mv: cannot move a static file from: " << from << ", to: " << to << logend;
|
||||
slog << logerror << T("internal_error") << logend;
|
||||
//slog << logerror << T("internal_error") << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +278,7 @@ bool ok = true;
|
||||
if( !ok )
|
||||
{
|
||||
log << log1 << "Mv: cannot create a static path" << logend;
|
||||
slog << logerror << T("internal_error") << logend;
|
||||
//slog << logerror << T("internal_error") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -289,7 +290,7 @@ bool ok = true;
|
||||
if( !item.item_content.update() )
|
||||
{
|
||||
log << log1 << "Mv: cannot move static file (database problem)" << logend;
|
||||
slog << logerror << T("internal_error") << logend;
|
||||
//slog << logerror << T("internal_error") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -384,7 +385,7 @@ bool Mv::MoveDir(Item & src_dir, std::vector<Item*> & dst_dir_tab, const std::ws
|
||||
if( dst_dir_id == src_dir.id || system->dirs.HasParent(dst_dir_id, src_dir.id) )
|
||||
{
|
||||
log << log1 << "Mv: cannot move directory to inside it" << logend;
|
||||
slog << logerror << T("mv_cannot_move_to_inside");
|
||||
//slog << logerror << T("mv_cannot_move_to_inside");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -439,7 +440,7 @@ bool Mv::MoveDir2(Item & src_dir, long dst_dir_id, const std::wstring & new_url,
|
||||
if( src_dir.parent_id == -1 )
|
||||
{
|
||||
log << log1 << "Mv: the root directory cannot be moved anywhere" << logend;
|
||||
slog << logerror << T("mv_cant_move_root_dir") << logend;
|
||||
//slog << logerror << T("mv_cant_move_root_dir") << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -455,7 +456,7 @@ bool Mv::MoveDir2(Item & src_dir, long dst_dir_id, const std::wstring & new_url,
|
||||
if( !system->dirs.CreateDirTab(dst_dir_id, out_dir_tab) )
|
||||
{
|
||||
log << log1 << "Mv: incorrect directory" << logend;
|
||||
slog << logerror << T("mv_incorrect_dir") << logend;
|
||||
//slog << logerror << T("mv_incorrect_dir") << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -486,7 +487,7 @@ bool Mv::MoveDir2(Item & src_dir, const std::wstring & dst_path, bool check_acce
|
||||
if( src_dir.parent_id == -1 )
|
||||
{
|
||||
log << log1 << "Mv: the root directory cannot be moved anywhere" << logend;
|
||||
slog << logerror << T("mv_cant_move_root_dir") << logend;
|
||||
//slog << logerror << T("mv_cant_move_root_dir") << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -499,7 +500,7 @@ bool Mv::MoveDir2(Item & src_dir, const std::wstring & dst_path, bool check_acce
|
||||
if( out_has_file )
|
||||
{
|
||||
log << log1 << "Mv: directory can be moved only to a directory" << logend;
|
||||
slog << logerror << T("mv_dir_can_be_moved_to_dir") << logend;
|
||||
//slog << logerror << T("mv_dir_can_be_moved_to_dir") << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -623,7 +624,7 @@ bool Mv::MoveFileOrSymlink2(Item & src_file, const std::wstring & dst_path, bool
|
||||
if( out_has_file )
|
||||
{
|
||||
log << log3 << "Mv: such file already exists (skipping)" << logend;
|
||||
slog << logerror << T("mv_file_exists") << logend;
|
||||
//slog << logerror << T("mv_file_exists") << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -653,7 +654,7 @@ void Mv::MoveAllFilesFromDir(Item & src_dir, std::vector<Item*> & dst_dir_tab, b
|
||||
if( check_access && !system->CanRemoveRenameChild(src_dir, item_tab[i].item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Mv: permission denied to: " << src_dir.url << logend;
|
||||
slog << logerror << T("mv_permission_denied_to") << ": " << src_dir.url << logend;
|
||||
//slog << logerror << T("mv_permission_denied_to") << ": " << src_dir.url << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -688,14 +689,14 @@ void Mv::MoveDirContent2(Item & src_dir, long dst_dir_id, bool check_access)
|
||||
if( src_dir.parent_id == -1 )
|
||||
{
|
||||
log << log1 << "Mv: the root directory cannot be moved anywhere" << logend;
|
||||
slog << logerror << T("mv_cant_move_root_dir") << logend;
|
||||
//slog << logerror << T("mv_cant_move_root_dir") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !system->dirs.CreateDirTab(dst_dir_id, out_dir_tab) )
|
||||
{
|
||||
log << log1 << "Mv: incorrect directory" << logend;
|
||||
slog << logerror << T("mv_incorrect_dir") << logend;
|
||||
//slog << logerror << T("mv_incorrect_dir") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -721,7 +722,7 @@ void Mv::MoveDirContent2(Item & src_dir, const std::wstring & dst_dir, bool chec
|
||||
if( out_has_file || !out_filename.empty() )
|
||||
{
|
||||
log << log1 << "Mv: directory content can be moved only to a directory" << logend;
|
||||
slog << logerror << T("mv_dir_content_can_be_moved_to_dir") << logend;
|
||||
//slog << logerror << T("mv_dir_content_can_be_moved_to_dir") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "node.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2021, Tomasz Sowa
|
||||
* Copyright (c) 2011-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "passwd.h"
|
||||
#include "core/slog.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
@@ -62,14 +62,14 @@ bool Passwd::HasAccess()
|
||||
|
||||
|
||||
|
||||
bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass, bool use_ses_log)
|
||||
bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass)
|
||||
{
|
||||
if( pass != conf_pass )
|
||||
{
|
||||
log << log2 << "Passwd: passwords are different" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_passwords_different") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_passwords_different") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -78,9 +78,9 @@ bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & c
|
||||
{
|
||||
log << log2 << "Passwd: password is too small" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_password_too_small") << " "
|
||||
<< config->pass_min_size << " " << T("adduser_err_password_too_small2") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_password_too_small") << " "
|
||||
// << config->pass_min_size << " " << T("adduser_err_password_too_small2") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -89,9 +89,9 @@ bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & c
|
||||
{
|
||||
log << log2 << "Passwd: password can't be longer than: " << WINIX_ACCOUNT_MAX_PASSWORD_SIZE << " characters" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("adduser_err_password_too_big") << " " << WINIX_ACCOUNT_MAX_PASSWORD_SIZE
|
||||
<< " " << T("adduser_err_password_too_big2") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("adduser_err_password_too_big") << " " << WINIX_ACCOUNT_MAX_PASSWORD_SIZE
|
||||
// << " " << T("adduser_err_password_too_big2") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -143,16 +143,16 @@ long user_id;
|
||||
if( !cur->session->puser->is_super_user && !functions->fun_login.CheckUserPass(puser->login, pass_cur, user_id) )
|
||||
{
|
||||
log << log3 << "Passwd: incorrect current password" << logend;
|
||||
slog << logerror << T("passwd_err_bad_current_password") << logend;
|
||||
//slog << logerror << T("passwd_err_bad_current_password") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !IsPasswordCorrect(pass_new, pass_conf, true) )
|
||||
if( !IsPasswordCorrect(pass_new, pass_conf) )
|
||||
return;
|
||||
|
||||
if( ChangePassword(puser->id, pass_new) )
|
||||
{
|
||||
slog << loginfo << T("passwd_password_changed") << logend;
|
||||
//slog << loginfo << T("passwd_password_changed") << logend;
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
@@ -160,26 +160,26 @@ long user_id;
|
||||
|
||||
|
||||
|
||||
bool Passwd::SetNewPassword(User * puser, bool use_ses_log)
|
||||
bool Passwd::SetNewPassword(User * puser)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
const std::wstring & pass = cur->request->PostVar(L"passwordnew");
|
||||
const std::wstring & pass_conf = cur->request->PostVar(L"passwordconfirm");
|
||||
|
||||
if( IsPasswordCorrect(pass, pass_conf, use_ses_log) )
|
||||
if( IsPasswordCorrect(pass, pass_conf) )
|
||||
{
|
||||
if( ChangePassword(puser->id, pass) )
|
||||
{
|
||||
result = true;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T("pw_password_changed") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << loginfo << T("pw_password_changed") << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("service_unavailable") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T("service_unavailable") << logend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ return result;
|
||||
|
||||
|
||||
|
||||
bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
|
||||
bool Passwd::ResetPassword(User * puser, long code, bool only_check_access)
|
||||
{
|
||||
std::wstring * user_code_str = puser->admin_env.get_wstr(L"password_change_code");
|
||||
|
||||
@@ -199,29 +199,29 @@ bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_
|
||||
if( only_check_access )
|
||||
return true;
|
||||
else
|
||||
return SetNewPassword(puser, use_ses_log);
|
||||
return SetNewPassword(puser);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Passwd: incorrect change password code" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"incorrect_change_password_code") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T(L"incorrect_change_password_code") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Passwd: there is no change password code in admin environment" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"password_cannot_be_changed") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << loginfo << T(L"password_cannot_be_changed") << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_log, bool only_check_access)
|
||||
bool Passwd::ResetPassword(const std::wstring & login, long code, bool only_check_access)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = system->users.GetUser(login);
|
||||
@@ -232,14 +232,14 @@ bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_l
|
||||
|
||||
if( puser->admin_env.to_long(L"password_change_time") + config->reset_password_code_expiration_time > t )
|
||||
{
|
||||
result = ResetPassword(puser, code, use_ses_log, only_check_access);
|
||||
result = ResetPassword(puser, code, only_check_access);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Passwd: the code has expired" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"code_expired") << logend;
|
||||
// if( use_ses_log )
|
||||
// slog << logerror << T(L"code_expired") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -256,7 +256,7 @@ void Passwd::ResetPassword()
|
||||
const std::wstring & login = cur->request->PostVar(L"login");
|
||||
long code = Tol(cur->request->PostVar(L"code"));
|
||||
|
||||
if( ResetPassword(login, code, true, false) )
|
||||
if( ResetPassword(login, code, false) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ void Passwd::ShowResetPasswordForm()
|
||||
|
||||
if( !login.empty() )
|
||||
{
|
||||
if( !ResetPassword(login, code, true, true) )
|
||||
if( !ResetPassword(login, code, true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -55,17 +55,17 @@ public:
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
bool IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass, bool use_ses_log = false);
|
||||
bool IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass);
|
||||
bool ChangePassword(long user_id, const std::wstring & new_password);
|
||||
bool ResetPassword(const std::wstring & login, long code, bool use_ses_log = false, bool only_check_access = false);
|
||||
bool ResetPassword(const std::wstring & login, long code, bool only_check_access = false);
|
||||
|
||||
private:
|
||||
|
||||
void ChangePassword(User * puser);
|
||||
|
||||
bool ResetPassword(User * puser, long code, bool use_ses_log);
|
||||
bool SetNewPassword(User * puser, bool use_ses_log);
|
||||
bool ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access);
|
||||
bool ResetPassword(User * puser, long code);
|
||||
bool SetNewPassword(User * puser);
|
||||
bool ResetPassword(User * puser, long code, bool only_check_access);
|
||||
void ResetPassword();
|
||||
void ShowResetPasswordForm();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -62,7 +62,6 @@ void Priv::MakePost()
|
||||
{
|
||||
priv_changer.SetCur(cur);
|
||||
priv_changer.SetSystem(system);
|
||||
priv_changer.SetDb(db);
|
||||
|
||||
priv_changer.Change(true, true);
|
||||
}
|
||||
@@ -72,7 +71,6 @@ void Priv::MakeGet()
|
||||
{
|
||||
priv_changer.SetCur(cur);
|
||||
priv_changer.SetSystem(system);
|
||||
priv_changer.SetDb(db);
|
||||
|
||||
priv_changer.CheckAccess();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -52,11 +52,6 @@ void PrivChanger::SetSystem(System * psystem)
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
void PrivChanger::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
bool PrivChanger::CheckAccess()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* Copyright (c) 2010-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,9 +36,7 @@
|
||||
#define headerfile_winix_functions_privchanger
|
||||
|
||||
#include "core/winixmodeldeprecated.h"
|
||||
#include "core/request.h"
|
||||
#include "core/system.h"
|
||||
#include "db/db.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -54,13 +52,11 @@ public:
|
||||
|
||||
void SetCur(Cur * pcur);
|
||||
void SetSystem(System * psystem);
|
||||
void SetDb(Db * pdb);
|
||||
|
||||
private:
|
||||
|
||||
Cur * cur;
|
||||
System * system;
|
||||
Db * db;
|
||||
|
||||
long user_id_file, group_id_file, user_id_dir, group_id_dir;
|
||||
int priv_file, priv_dir;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -116,7 +116,7 @@ bool res = false;
|
||||
else
|
||||
{
|
||||
log << log3 << "Rm: directories can be removed only with 'r' parameter" << logend;
|
||||
slog << logerror << T("rm_use_r_option") << logend;
|
||||
//slog << logerror << T("rm_use_r_option") << logend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void Rm::RemoveStaticFile(const std::wstring & path)
|
||||
else
|
||||
{
|
||||
log << log1 << "Rm: I can't remove a static file: " << path << logend;
|
||||
slog << logerror << T("rm_cannot_remove_static_file") << ": " << path << logend;
|
||||
//slog << logerror << T("rm_cannot_remove_static_file") << ": " << path << logend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ void Rm::RemoveStaticFile(const Item & item)
|
||||
log << log1 << "Rm: I cannot create a path to a static file, url: "
|
||||
<< item.url << ", id: " << item.id << logend;
|
||||
|
||||
slog << logerror << T("rm_cannot_create_static_path") << ": " << item.url << logend;
|
||||
//slog << logerror << T("rm_cannot_create_static_path") << ": " << item.url << logend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ bool Rm::RemoveFileOrSymlink(Item & item, bool check_access)
|
||||
if( !system->CanRemoveRenameChild(*dir, item.item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to remove: " << item.url << ", id: " << item.id << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << item.url << logend;
|
||||
//slog << logerror << T("rm_permission_denied_to") << ": " << item.url << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, current_dir->item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to directory: " << current_dir->url << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << current_dir->url << logend;
|
||||
//slog << logerror << T("rm_permission_denied_to") << ": " << current_dir->url << logend;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,7 @@ void Rm::RemoveDirTree(Item * parent_dir, Item * current_dir, bool remove_this_d
|
||||
if( check_access && !system->HasReadExecAccess(*current_dir) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to directory: " << current_dir->url << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << current_dir->url << logend;
|
||||
//slog << logerror << T("rm_permission_denied_to") << ": " << current_dir->url << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ void Rm::RemoveDirTree(Item * parent_dir, Item * current_dir, bool remove_this_d
|
||||
else
|
||||
{
|
||||
log << log1 << "Rm: " << current_dir->url << " directory not empty" << logend;
|
||||
slog << logerror << current_dir->url << T("rm_directory_not_empty") << logend;
|
||||
//slog << logerror << current_dir->url << T("rm_directory_not_empty") << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ void Rm::RemoveDirContent()
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
log << log3 << "Rm: directory content can be removed only with 'r' parameter" << logend;
|
||||
slog << logerror << T("rm_content_use_r_option") << logend;
|
||||
//slog << logerror << T("rm_content_use_r_option") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ void Rm::RemoveDir()
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
log << log3 << "Rm: a directory can be removed only with 'r' parameter" << logend;
|
||||
slog << logerror << T("rm_use_r_option") << logend;
|
||||
//slog << logerror << T("rm_use_r_option") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ void Rm::RemoveDir()
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
log << log1 << "Rm: the root directory cannot be removed" << logend;
|
||||
slog << logerror << T("rm_cannot_remove_root_dir") << logend;
|
||||
//slog << logerror << T("rm_cannot_remove_root_dir") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2022, Tomasz Sowa
|
||||
* Copyright (c) 2011-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include "sort.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/plugin.h"
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2021, Tomasz Sowa
|
||||
* Copyright (c) 2012-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "timezone.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
||||
Reference in New Issue
Block a user