merge from branch 0.7.x:

- initial support for morm
- added: WinixBase, WinixModel, WinixSystem, WinixRequest
- logger moved to pikotools




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1171 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2019-03-06 11:53:28 +00:00
commit def0f8d144
172 changed files with 12095 additions and 8109 deletions

View File

@ -5,7 +5,7 @@ include Makefile.dep
# https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors
GLOBAL_WORKING_DIR := $(shell pwd)/../..
EZC_ADDITIONAL_INCLUDE := -I$(shell pwd) -I$(GLOBAL_WORKING_DIR)/ezc/src
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
@ -27,21 +27,19 @@ endif
# CXX = g++-4.8
ifndef CXXFLAGS
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++17 -I/usr/local/include -I/usr/include/postgresql -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++17 -I/usr/local/include -I/usr/include/postgresql -DEZC_HAS_SPECIAL_STREAM
endif
ifndef AR
AR = ar
endif
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/pikotools
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
ifndef LDFLAGS
LDFLAGS = -L/usr/local/lib
endif
# this macro is used in ezc's Makefile
EZC_USE_WINIX_LOGGER = yes
# for make install
@ -51,8 +49,6 @@ winix_install_dir = /usr/local/winix
export CXX
export CXXFLAGS
export LDFLAGS
export EZC_USE_WINIX_LOGGER
export EZC_ADDITIONAL_INCLUDE
export GLOBAL_WORKING_DIR
@ -73,7 +69,7 @@ winix.so: $(winix.src.files)
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o functions/*.o templates/*.o notify/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/convert/convert.a $(GLOBAL_WORKING_DIR)/pikotools/utf8/utf8.a $(GLOBAL_WORKING_DIR)/pikotools/space/space.a $(GLOBAL_WORKING_DIR)/pikotools/mainparser/mainparser.a $(GLOBAL_WORKING_DIR)/pikotools/date/date.a $(GLOBAL_WORKING_DIR)/pikotools/logger/logger.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -Wl,-no-whole-archive
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o functions/*.o templates/*.o notify/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/convert/convert.a $(GLOBAL_WORKING_DIR)/pikotools/utf8/utf8.a $(GLOBAL_WORKING_DIR)/pikotools/space/space.a $(GLOBAL_WORKING_DIR)/pikotools/mainparser/mainparser.a $(GLOBAL_WORKING_DIR)/pikotools/date/date.a $(GLOBAL_WORKING_DIR)/pikotools/log/log.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -Wl,-no-whole-archive
winix: winix.so $(winix.src.files)

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@ include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/pikotools
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
all: $(o)

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o winixbase.o winixmodel.o winixrequest.o winixsystem.o

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#define headerfile_winix_core_acceptbaseparser
#include <string>
#include "winixbase.h"
namespace Winix
@ -46,7 +47,7 @@ namespace Winix
// sample (you must create your own class derived from this one):
// object.Parse(L" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
class AcceptBaseParser
class AcceptBaseParser : public WinixBase
{
public:

View File

@ -52,6 +52,7 @@
#include "convert/convert.h"
namespace Winix
{
@ -64,39 +65,83 @@ App::App()
last_sessions_save = std::time(0);
fcgi_socket = -1;
file_log.set_synchro(&synchro);
file_log.set_time_zones(&system.time_zones);
log.SetLogBuffer(&log_buffer);
log.SetFileLog(&file_log);
// objects dependency for main thread
winix_base.set_config(&config);
winix_base.set_log_buffer(&log_buffer);
winix_base.set_file_log(&file_log);
winix_base.set_synchro(&synchro);
winix_model.set_dependency(&winix_base);
winix_model.set_plugin(&plugin);
winix_model.set_model_connector(&model_connector);
winix_system.set_dependency(&winix_model);
winix_system.set_system(&system);
winix_request.set_dependency(&winix_system);
winix_request.set_cur(&cur);
winix_request.set_session_manager(&session_manager);
winix_request.set_locale(&TemplatesFunctions::locale);
// //////////////////////////////////
config.SetFileLog(&file_log);
config.SetLogBuffer(&log_buffer);
// temporary there is only one request
cur.request = &req;
cur.session = session_manager.GetTmpSession();
cur.mount = system.mounts.GetEmptyMount();
db_conn.set_dependency(&winix_base);
db.set_dependency(&winix_base);
db.SetConn(db_conn);
plugin.set_dependency(&winix_base);
plugin.SetDb(&db);
plugin.SetConfig(&config);
//plugin.SetConfig(&config);
plugin.SetCur(&cur);
plugin.SetSystem(&system);
plugin.SetFunctions(&functions);
plugin.SetTemplates(&templates);
plugin.SetSynchro(&synchro);
//plugin.SetSynchro(&synchro);
plugin.SetSessionManager(&session_manager);
plugin.SetWinixRequest(&winix_request);
req.SetConfig(&config);
functions.SetConfig(&config);
functions.set_dependency(&winix_request);
// functions.set_config(&config);
// functions.set_file_log(&file_log);
// functions.set_model_connector(&model_connector);
// functions.set_synchro(&synchro);
//functions.SetConfig(&config);
functions.SetCur(&cur);
functions.SetDb(&db);
functions.SetSystem(&system);
functions.SetTemplates(&templates);
functions.SetSynchro(&synchro);
//functions.SetSynchro(&synchro);
functions.SetSessionManager(&session_manager);
system.SetConfig(&config);
system.set_dependency(&winix_model);
//system.SetConfig(&config);
system.SetCur(&cur);
system.SetDb(&db);
system.SetSynchro(&synchro);
//system.SetSynchro(&synchro);
system.SetFunctions(&functions);
system.SetSessionManager(&session_manager);
templates.set_dependency(&winix_request);
templates.SetConfig(&config);
templates.SetCur(&cur);
templates.SetDb(&db);
@ -104,20 +149,39 @@ App::App()
templates.SetFunctions(&functions);
templates.SetSessionManager(&session_manager);
session_manager.set_dependency(&winix_model); // zobaczyc czy wskoczy do przeciazonej metody w session manager
session_manager.SetLastContainer(&system.users.last);
session_manager.SetConfig(&config);
session_manager.SetCur(&cur);
session_manager.SetSystem(&system);
session_manager.SetSynchro(&synchro);
post_multi_parser.set_dependency(&winix_base);
post_multi_parser.SetConfig(&config);
slog.SetCur(&cur);
slog.SetLocale(&TemplatesFunctions::locale);
}
void App::InitLoggers()
{
file_log.init(config.log_file, config.log_stdout, config.log_level, config.log_save_each_line, config.log_time_zone_id);
log.SetMaxRequests(config.log_request);
}
Log & App::GetMainLog()
{
return log;
}
void App::InitPlugins()
{
plugin.LoadPlugins(config.plugins_dir, config.plugin_file);
}
bool App::InitFCGI(char * sock, char * sock_user, char * sock_group)
{
if( !WideToUTF8(config.fcgi_socket, sock, WINIX_OS_PATH_SIZE) )
@ -213,14 +277,25 @@ return true;
bool App::Init()
{
postgresql_connector.set_conn_param(config.db_database, config.db_user, config.db_pass);
postgresql_connector.set_logger(log);
postgresql_connector.set_log_queries(config.log_db_query);
postgresql_connector.wait_for_connection();
model_connector.set_flat_connector(json_connector);
model_connector.set_db_connector(postgresql_connector);
//model_connector.set_doc_connector(doc_html_connector);
db_conn.SetConnParam(config.db_database, config.db_user, config.db_pass);
db_conn.WaitForConnection();
db.PostgreSQLsmallerThan10(config.db_postgresql_smaller_than_10);
db.LogQueries(config.log_db_query);
cur.request->Clear();
compress.set_dependency(&winix_base);
compress.Init();
system.Init();
functions.Init();
templates.Init(); // init templates after functions are created
@ -234,9 +309,14 @@ bool App::Init()
CreateStaticTree();
post_parser.set_dependency(&winix_model);
post_parser.LogValueSize(config.log_post_value_size);
// post_multi_parser has a pointer to the config
cookie_parser.set_dependency(&winix_model);
accept_encoding_parser.set_dependency(&winix_base);
plugin.Call((Session*)0, WINIX_PLUGIN_INIT);
return true;
@ -246,10 +326,21 @@ return true;
void App::Close()
{
session_manager.SaveSessions();
session_manager.DeleteSessions();
cur.request->Clear();
session_manager.UninitTmpSession();
{
Winix::Lock lock(synchro);
plugin.Call((Winix::Session*)0, WINIX_CLOSE);
session_manager.SaveSessions();
session_manager.DeleteSessions();
cur.request->Clear();
session_manager.UninitTmpSession();
// now all sessions are cleared
}
WaitForThreads();
// now all others threads are terminated
}
@ -673,7 +764,9 @@ void App::Make()
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
{
PT::Date date(cur.session->ip_ban->expires);
slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
// IMPROVE ME there is no slog now
//slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
}
@ -717,12 +810,6 @@ void App::Make()
return;
}
if( !cur.request->info_serializer )
{
json_generic_serializer.Clear(); // !! IMPROVE ME add to the end of a request
cur.request->info_serializer = &json_generic_serializer;
}
plugin.Call(WINIX_CONTENT_MAKE);
MakePage();
}
@ -972,7 +1059,7 @@ void App::SetSubdomain()
void App::LogAccess()
{
log << log1;
log.PrintDate(cur.request->start_date, config.log_time_zone_id);
log.PrintDate(cur.request->start_date);
log << ' '
<< cur.request->ip_str << ' '
@ -1393,7 +1480,7 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
if( cur.request->send_as_attachment )
AddHeader(L"Content-Disposition", L"attachment");
if( !cur.request->redirect_to.empty() )
if( !cur.request->redirect_to.empty() && !cur.request->return_json )
{
PrepareHeadersRedirect();
}
@ -1417,6 +1504,23 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
}
void App::PrepareStandardJSONFields()
{
PT::Space & info = cur.request->info;
if( !info.GetFirstValue(L"status") )
{
info.Add(L"status", cur.request->status);
}
if( !cur.request->redirect_to.empty() && !info.GetFirstValue(L"redirect_to") )
{
info.Add(L"redirect_to", cur.request->redirect_to);
}
}
void App::FilterContent()
{
@ -1525,9 +1629,23 @@ void App::SelectCompression(size_t source_len, bool & compression_allowed, int &
bool App::CanSendContent()
{
if( !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
// if there is a redirect or a file to send then we do not send a content
if( !cur.request->x_sendfile.empty() )
{
// if there is a file to send then we do not send a content
return false;
}
if( cur.request->return_json )
{
// if there is a redirect flag then it will be put to info struct
return true;
}
if( !cur.request->redirect_to.empty() )
{
// if there is a redirect and no json is requred then we do not send the content
return false;
}
/*
we don't have to check the HEAD method
@ -1692,6 +1810,15 @@ int compress_encoding;
void App::SendAnswer()
{
if( !cur.request->info_serializer )
{
json_generic_serializer.Clear(); // !! IMPROVE ME add to the end of a request
cur.request->info_serializer = &json_generic_serializer;
}
if( cur.request->return_json )
PrepareStandardJSONFields();
if( cur.request->send_bin_stream )
SendBinaryAnswer();
else
@ -1816,6 +1943,8 @@ void App::LogUserGroups()
{
LogUsers();
LogGroups();
log << log3 << "base_url: " << config.base_url << logend;
}

View File

@ -45,11 +45,6 @@
#include <errno.h>
#include <fcgiapp.h>
#include "config.h"
#include "system.h"
#include "mounts.h"
#include "request.h"
#include "synchro.h"
#include "sessionmanager.h"
#include "db/db.h"
#include "functions/functions.h"
@ -61,6 +56,10 @@
#include "acceptencodingparser.h"
#include "space/jsontospaceparser.h"
#include "winixrequest.h"
#include "log/log.h"
#include "filelog.h"
namespace Winix
{
@ -76,6 +75,9 @@ public:
bool InitFCGI();
bool DropPrivileges();
void InitLoggers();
Log & GetMainLog();
void InitPlugins();
bool Init();
void Start();
void Close();
@ -101,7 +103,7 @@ public:
// users sessions
SessionManager session_manager;
// database
// database (DEPRACATED)
Db db;
DbConn db_conn;
@ -129,6 +131,8 @@ public:
Templates templates;
private:
enum Header
@ -162,6 +166,29 @@ private:
std::wstring http_header;
std::string http_header_8bit;
morm::ModelConnector model_connector; // main thread model connector, each thread has its own connector
morm::JSONConnector json_connector;
morm::PostgreSQLConnector postgresql_connector;
// objects for main thread
WinixBase winix_base;
WinixModel winix_model;
WinixSystem winix_system;
WinixRequest winix_request;
// ///////////////////////
Plugin plugin;
//////////////////////////
// log_buffer for the main thread
PT::WTextStream log_buffer;
// logger only for App object
Log log;
// file logger, one object for every Log objects
FileLog file_log;
bool InitFCGI(char * sock, char * sock_user, char * sock_group);
bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group);
@ -223,6 +250,7 @@ private:
void PrepareHeadersCompression(int compress_encoding);
void PrepareHeadersNormal(Header header, size_t output_size);
void PrepareHeaders(bool compressing, int compress_encoding, Header header, size_t output_size);
void PrepareStandardJSONFields();
int SelectDeflateVersion();
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding);
bool CanSendContent();

View File

@ -37,6 +37,8 @@
#include <pthread.h>
#include "synchro.h"
#include "winixmodel.h"
namespace Winix
@ -45,7 +47,7 @@ namespace Winix
class BaseThread
class BaseThread : public WinixModel
{
public:

View File

@ -38,6 +38,7 @@
#include <cstring>
#include <zlib.h>
#include "requesttypes.h"
#include "winixbase.h"
namespace Winix
@ -45,7 +46,7 @@ namespace Winix
class Compress
class Compress : public WinixBase
{
public:

View File

@ -34,7 +34,6 @@
#include "config.h"
#include "log.h"
#include "plugin.h"
#include "misc.h"
#include "crypt.h"
@ -50,9 +49,16 @@ Config::Config()
}
void Config::SetFileLog(FileLog * file_log)
{
log.SetFileLog(file_log);
}
//!! czy tu w ogole mozemy uzywac log << ?
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny
void Config::SetLogBuffer(PT::WTextStream * log_buffer)
{
log.SetLogBuffer(log_buffer);
}
void Config::ShowError()
@ -130,7 +136,6 @@ void Config::AssignValues(bool stdout_is_closed)
additional_groups = Bool(L"additional_groups", true);
log_file = Text(L"log_file");
log_notify_file = Text(L"log_notify_file");
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
fcgi_socket = Text(L"fcgi_socket");
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
@ -322,11 +327,6 @@ void Config::AssignValues(bool stdout_is_closed)
void Config::SetAdditionalVariables()
{
if( html_filter_orphans_mode_str == L"160" )
html_filter_orphans_mode = HTMLFilter::orphan_160space;
else
html_filter_orphans_mode = HTMLFilter::orphan_nbsp;
for(size_t i=0 ; i<static_dirs.size() ; ++i)
NoLastSlash(static_dirs[i]);

View File

@ -37,7 +37,9 @@
#include <string>
#include "space/spaceparser.h"
#include "htmlfilter.h"
#include "log.h"
#include "filelog.h"
namespace Winix
@ -80,8 +82,8 @@ public:
// default: true
bool additional_groups;
// log file name, log file name for notifications (sending emails, etc)
std::wstring log_file, log_notify_file;
// log file name
std::wstring log_file;
// the log level (how much info should be inserted to logs)
// 1 - minimum
@ -328,7 +330,6 @@ public:
// either: "nbsp" or "160"
// default: "nbsp"
std::wstring html_filter_orphans_mode_str;
HTMLFilter::OrphanMode html_filter_orphans_mode;
// the html nofilter tag
// content betweeng these tags (opening and closing) will not be filtered
@ -819,10 +820,15 @@ public:
PT::Space space;
void SetFileLog(FileLog * file_log);
void SetLogBuffer(PT::WTextStream * log_buffer);
private:
PT::SpaceParser parser;
bool errors_to_stdout;
Log log;
void ShowError();
void AssignValues(bool stdout_is_closed);

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2014, Tomasz Sowa
* Copyright (c) 2011-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#include "crypt.h"
#include "utf8/utf8.h"
#include "log.h"
#include "misc.h"
@ -44,12 +45,18 @@ namespace Winix
void Crypt::SetConfig(Config * pconfig)
{
config = pconfig;
}
//void Crypt::SetConfig(Config * pconfig)
//{
// config = pconfig;
//}
void Crypt::set_dependency(WinixBase * winix_base)
{
WinixBase::set_dependency(winix_base);
run.set_dependency(winix_base);
}
char Crypt::ConvertToHexForm(int val)
{
@ -70,6 +77,7 @@ bool Crypt::HashBin(int hash, const char * in, size_t inlen, std::string & out)
return false;
run.Clear();
run.set_dependency(this);
PT::WideToUTF8(config->opensll_path, command);
run.Cmd(command);
run.Par("dgst");

View File

@ -39,6 +39,8 @@
#include "run.h"
#include "config.h"
#include "user.h"
#include "winixbase.h"
namespace Winix
@ -63,12 +65,15 @@ namespace Winix
/*
calculating hashes, encrypting and decrypting with RSA
*/
class Crypt
class Crypt : public WinixBase
{
public:
void SetConfig(Config * pconfig);
void set_dependency(WinixBase * winix_base);
//void SetConfig(Config * pconfig);
/*
@ -240,7 +245,7 @@ public:
private:
Config * config;
//Config * config;
Run run;
std::string command, bufina, keypatha;
//std::wstring pass_salted;//, pass_hashed;

View File

@ -38,6 +38,7 @@
#include <list>
#include <map>
#include "item.h"
#include "winixbase.h"
namespace Winix
@ -45,7 +46,7 @@ namespace Winix
class DirContainer
class DirContainer : public WinixBase
{
public:

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
#include "dirs.h"
#include "error.h"
#include "log.h"
#include "notify/notify.h"
namespace Winix
@ -60,6 +60,13 @@ void Dirs::SetNotify(Notify * pnotify)
}
void Dirs::set_dependency(WinixModel * winix_model)
{
WinixModel::set_dependency(winix_model);
dir_tab.set_dependency(winix_model);
}
void Dirs::Clear()
{
dir_tab.Clear();

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -44,19 +44,21 @@
#include "dircontainer.h"
#include "db/db.h"
#include "request.h"
#include "notify/notify.h"
#include "winixmodel.h"
namespace Winix
{
class Notify;
// !! IMPROVE ME
// we do not support '..' in a path (for simplicity and security reasons)
// (we will support '..' in the future)
class Dirs
class Dirs : public WinixModel
{
public:
@ -67,6 +69,8 @@ public:
void SetDb(Db * pdb);
void SetNotify(Notify * pnotify);
void set_dependency(WinixModel * winix_model);
// these methods return false if there is no such a dir
bool IsDir(long dir_id);
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_tab); // !! zamienic na GetChilds()

134
winixd/core/filelog.cpp Normal file
View File

@ -0,0 +1,134 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "filelog.h"
#include <ctime>
#include <string.h>
#include "utf8/utf8.h"
#include "timezones.h"
namespace Winix
{
FileLog::FileLog()
{
time_zones = nullptr;
synchro = nullptr;
log_time_zone_id = 0;
}
FileLog::~FileLog()
{
}
void FileLog::set_synchro(Synchro * synchro)
{
this->synchro = synchro;
}
void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id)
{
PT::FileLog::init(log_file, log_stdout, log_level, save_each_line);
this->log_time_zone_id = log_time_zone_id;
}
void FileLog::set_time_zones(TimeZones * time_zones)
{
this->time_zones = time_zones;
}
int FileLog::get_log_level()
{
return log_level;
}
bool FileLog::should_save_each_line()
{
return save_each_line;
}
PT::Date FileLog::get_local_date(const PT::Date & date)
{
if( time_zones )
{
TimeZone * tz = time_zones->GetZone(log_time_zone_id);
if( tz )
{
PT::Date local_date = tz->ToLocal(date);
return local_date;
}
else
{
return date;
}
}
else
{
return date;
}
}
bool FileLog::synchro_lock()
{
return synchro->Lock();
}
void FileLog::synchro_unlock()
{
synchro->Unlock();
}
} // namespace Winix

92
winixd/core/filelog.h Normal file
View File

@ -0,0 +1,92 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_core_filelog
#define headerfile_winix_core_filelog
#include <sstream>
#include <fstream>
#include <iostream>
#include <string>
#include "core/synchro.h"
#include "log/log.h"
namespace Winix
{
class TimeZones;
class FileLog : public PT::FileLog
{
public:
FileLog();
virtual ~FileLog();
void set_synchro(Synchro * synchro);
void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id);
void set_time_zones(TimeZones * time_zones);
PT::Date get_local_date(const PT::Date & date);
int get_log_level();
bool should_save_each_line();
protected:
size_t log_time_zone_id;
TimeZones * time_zones;
Synchro * synchro;
virtual bool synchro_lock();
virtual void synchro_unlock();
};
} // namespace Winix
#endif

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -46,6 +46,13 @@ Groups::Groups()
}
void Groups::set_dependency(WinixModel * winix_model)
{
WinixModel::set_dependency(winix_model);
table.set_dependency(winix_model);
}
void Groups::Clear()
{
table.Clear();

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,6 +40,8 @@
#include "group.h"
#include "ugcontainer.h"
#include "db/db.h"
#include "winixmodel.h"
namespace Winix
@ -47,7 +49,7 @@ namespace Winix
class Groups
class Groups : public WinixModel
{
typedef UGContainer<Group> Table;
@ -55,6 +57,8 @@ Table table;
public:
void set_dependency(WinixModel * winix_model);
typedef Table::Iterator Iterator;
typedef Table::SizeType SizeType;

View File

@ -234,9 +234,12 @@ void HTMLFilter::ClearOrphans()
void HTMLFilter::OrphansMode(HTMLFilter::OrphanMode mode)
void HTMLFilter::OrphansMode(const std::wstring & orphan_mode_str)
{
orphan_mode = mode;
if( orphan_mode_str == L"160" )
orphan_mode = orphan_160space;
else
orphan_mode = orphan_nbsp;
}

View File

@ -39,6 +39,7 @@
#include <map>
#include <vector>
#include <algorithm>
#include "core/winixbase.h"
namespace Winix
@ -86,7 +87,7 @@ namespace Winix
the filter recognizes xml simple tags (with / at the end) such as: <br />
*/
class HTMLFilter
class HTMLFilter : public WinixBase
{
public:
@ -146,7 +147,7 @@ public:
// check 'orphans' for the specicic language
// if an orphan is detected then the non-break space ("&nbsp;" or ascii 160 code) will be put
// default disable (lang_none)
void OrphansMode(OrphanMode mode = orphan_nbsp);
void OrphansMode(const std::wstring & orphan_mode);
// skipping some unsafe tags
// (script, iframe, frame, frameset, applet, head, meta, html, link, body, ...)

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,6 +36,7 @@
#define headerfile_winix_core_httpsimpleparser
#include <string>
#include "winixmodel.h"
namespace Winix
@ -43,7 +44,7 @@ namespace Winix
class HttpSimpleParser
class HttpSimpleParser : public WinixModel
{
protected:

View File

@ -35,9 +35,7 @@
#include <ctime>
#include "image.h"
#include "utf8/utf8.h"
#include "log.h"
#include "system.h"
#include "plugin.h"
#include "lock.h"
@ -492,34 +490,34 @@ void Image::ImageSavedCorrectly()
}
log << log3 << "Image: generated a thumbnail: " << dst_path << logend;
plugin.Call((Session*)0, WINIX_CREATED_THUMB, &file_work);
plugin->Call((Session*)0, WINIX_CREATED_THUMB, &file_work);
}
else
if( item_work.type == WINIX_IMAGE_TYPE_RESIZE )
{
log << log3 << "Image: image resized: " << dst_path << logend;
plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
}
else
if( item_work.type == WINIX_IMAGE_TYPE_CROP )
{
log << log3 << "Image: image cropped: " << dst_path << logend;
// !! IMPROVE ME add a correct message
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
//plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
}
else
if( item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB )
{
log << log3 << "Image: image thumbnail cropped: " << dst_path << logend;
// !! IMPROVE ME add a correct message
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
//plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
}
else
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB )
{
log << log3 << "Image: a new thumbnail from an original image was cropped: " << dst_path << logend;
// !! IMPROVE ME add a correct message
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
//plugin->Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
}
}

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2012-2014, Tomasz Sowa
* Copyright (c) 2012-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,6 +37,8 @@
#include <vector>
#include "ipban.h"
#include "winixmodel.h"
namespace Winix
@ -44,7 +46,7 @@ namespace Winix
class IPBanContainer
class IPBanContainer : public WinixModel
{
public:

View File

@ -169,7 +169,7 @@ void Job::DoJob(PT::Space & job)
{
try
{
PluginRes res = plugin.Call((Session*)0, WINIX_JOB, &job);
PluginRes res = plugin->Call((Session*)0, WINIX_JOB, &job);
if( res.res_true == 0 )
DoWinixJob(job);