Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7468e7a36c | |||
| 145445c713 | |||
| 7fa9314c6b | |||
| 5d37b6c6ae | |||
| fe1f84e29d | |||
| 83e27a6653 | |||
| ee9c68b04e | |||
| c04874397b | |||
| 375604edd6 | |||
| 3e32f3784f | |||
| 5c4a54d998 |
6
Makefile
6
Makefile
@@ -9,7 +9,7 @@ CXX = clang++
|
||||
#endif
|
||||
|
||||
ifndef CXXFLAGS
|
||||
CXXFLAGS = -Wall -O2 -fPIC -pthread -std=c++11 -I/usr/local/include -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
|
||||
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++11 -I/usr/local/include -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
|
||||
endif
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ winix.so: $(winix.src.files)
|
||||
@cd ../ezc/src ; $(MAKE) -e
|
||||
@cd ../tito/src ; $(MAKE) -e
|
||||
@cd ../pikotools ; $(MAKE) -e
|
||||
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a ../tito/src/tito.a ../pikotools/utf8/utf8.a ../pikotools/space/space.a ../pikotools/mainparser/mainparser.a ../pikotools/date/date.a $(LDFLAGS) -lfcgi -lpq -lz -lfetch -lpthread -Wl,-no-whole-archive
|
||||
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a ../tito/src/tito.a ../pikotools/utf8/utf8.a ../pikotools/space/space.a ../pikotools/mainparser/mainparser.a ../pikotools/date/date.a $(LDFLAGS) -lfcgi -lpq -lz -lfetch -lpthread -lcurl -Wl,-no-whole-archive
|
||||
|
||||
|
||||
winix: winix.so $(winix.src.files)
|
||||
@cd main ; $(MAKE) -e
|
||||
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so
|
||||
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so -lfcgi
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,11 @@
|
||||
#include "acceptbaseparser.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
bool AcceptBaseParser::IsWhite(int c)
|
||||
{
|
||||
@@ -112,3 +117,7 @@ void AcceptBaseParser::Parse(const char * str)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,11 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// sample (you must create your own class derived from this one):
|
||||
// object.Parse(" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
|
||||
@@ -43,5 +48,8 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,11 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class AcceptEncodingParser : public AcceptBaseParser
|
||||
{
|
||||
public:
|
||||
@@ -82,4 +87,7 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
565
core/app.cpp
565
core/app.cpp
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,13 +11,11 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
#include <cstdio>
|
||||
#include <fetch.h>
|
||||
#include <signal.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <utility>
|
||||
#include <curl/curl.h>
|
||||
#include "app.h"
|
||||
#include "plugin.h"
|
||||
#include "misc.h"
|
||||
@@ -25,6 +23,10 @@
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
App::App()
|
||||
@@ -162,6 +164,8 @@ bool App::Init()
|
||||
post_parser.LogValueSize(config.log_post_value_size);
|
||||
// post_multi_parser has a pointer to the config
|
||||
|
||||
cookie_parser.UTF8(config.utf8);
|
||||
|
||||
plugin.Call((Session*)0, WINIX_PLUGIN_INIT);
|
||||
|
||||
return true;
|
||||
@@ -337,7 +341,7 @@ void App::ProcessRequest()
|
||||
log << log2 << config.log_delimiter << logend;
|
||||
|
||||
ProcessRequestThrow();
|
||||
SaveSessionsIfNeeded(); // !! przerzucic to na watek sesji
|
||||
SaveSessionsIfNeeded(); // !! IMPROVE ME move to the session's thread
|
||||
|
||||
system.load_avg.StopRequest();
|
||||
}
|
||||
@@ -354,33 +358,63 @@ void App::ProcessRequest()
|
||||
log << log1 << "App: there was an unknown exception" << logend;
|
||||
}
|
||||
|
||||
ClearAfterRequest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::ClearAfterRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.Call(WINIX_END_REQUEST);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log << log1 << "App: an exception when clearing after a request (exception from a plugin)" << logend;
|
||||
log << log1 << "App: an exception from a plugin when clearing after a request" << logend;
|
||||
}
|
||||
|
||||
// simple operations which should not throw an exception
|
||||
templates.RequestEnd();
|
||||
cur.request->Clear();
|
||||
cur.session->ClearOnEndRequest();
|
||||
cur.session = session_manager.GetTmpSession();
|
||||
log << logendrequest;
|
||||
|
||||
try
|
||||
{
|
||||
// simple operations which should not throw an exception
|
||||
json_out_stream.Clear();
|
||||
templates.ClearAfterRequest();
|
||||
cur.request->Clear();
|
||||
cur.session->ClearAfterRequest();
|
||||
cur.session = session_manager.GetTmpSession();
|
||||
output_8bit.clear();
|
||||
compressed_output.clear();
|
||||
html_filtered.clear();
|
||||
aheader_name.clear();
|
||||
aheader_value.clear();
|
||||
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
||||
|
||||
log << logendrequest;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log << log1 << "App: an exception when clearing after a request" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void App::Start()
|
||||
{
|
||||
while( !synchro.was_stop_signal && FCGX_Accept_r(&fcgi_request) == 0 )
|
||||
{
|
||||
Lock();
|
||||
|
||||
if( !synchro.was_stop_signal )
|
||||
if( synchro.was_stop_signal )
|
||||
{
|
||||
FCGX_Finish_r(&fcgi_request);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessRequest();
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
@@ -473,12 +507,6 @@ bool sent = false;
|
||||
{
|
||||
templates.Generate();
|
||||
}
|
||||
|
||||
|
||||
if( cur.request->return_json )
|
||||
{
|
||||
CreateJSONAnswer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -572,26 +600,13 @@ void App::Make()
|
||||
|
||||
plugin.Call(WINIX_CONTENT_MAKE);
|
||||
MakePage();
|
||||
|
||||
if( config.debug_info )
|
||||
{
|
||||
// !! dodac inne informacje (get, post, itp)
|
||||
// jesli jest debug_info wlaczone to nie robic przekierowan
|
||||
PrintEnv();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void App::PrintEnv()
|
||||
void App::LogEnvironmentVariables()
|
||||
{
|
||||
char ** e;
|
||||
|
||||
cur.request->debug << "environment variables:\n";
|
||||
|
||||
for( e = fcgi_request.envp ; *e ; ++e )
|
||||
cur.request->debug << ' ' << *e << "\n";
|
||||
|
||||
cur.request->debug << '\n';
|
||||
for(char ** e = fcgi_request.envp ; *e ; ++e )
|
||||
log << log1 << "Env: " << *e << logend;
|
||||
}
|
||||
|
||||
|
||||
@@ -601,7 +616,6 @@ void App::ReadRequest()
|
||||
{
|
||||
ReadEnvVariables();
|
||||
CheckRequestMethod();
|
||||
CheckFCGIRole();
|
||||
CheckSSL();
|
||||
SetSubdomain();
|
||||
|
||||
@@ -611,14 +625,14 @@ void App::ReadRequest()
|
||||
cookie_parser.Parse(cur.request->env_http_cookie, cur.request->cookie_tab);
|
||||
accept_encoding_parser.ParseAndLog(cur.request->env_http_accept_encoding);
|
||||
|
||||
if( config.log_env_variables )
|
||||
LogEnvironmentVariables();
|
||||
|
||||
CheckIE();
|
||||
CheckKonqueror();
|
||||
|
||||
if( cur.request->using_ssl )
|
||||
log << log3 << "App: connection secure through SSL" << logend;
|
||||
|
||||
if( cur.request->role == Request::authorizer )
|
||||
log << log3 << "App: fast cgi role: authorizer" << logend;
|
||||
}
|
||||
|
||||
|
||||
@@ -658,7 +672,7 @@ void App::ReadEnvVariables()
|
||||
|
||||
void App::CheckRequestMethod()
|
||||
{
|
||||
cur.request->method = Request::none;
|
||||
cur.request->method = Request::unknown_method;
|
||||
|
||||
if( ToSmall(cur.request->env_request_method[0]) == 'g' )
|
||||
cur.request->method = Request::get;
|
||||
@@ -671,15 +685,6 @@ void App::CheckRequestMethod()
|
||||
}
|
||||
|
||||
|
||||
void App::CheckFCGIRole()
|
||||
{
|
||||
// default we assume 'responder'
|
||||
cur.request->role = Request::responder;
|
||||
|
||||
if( ToSmall(cur.request->env_fcgi_role[0]) == 'a' )
|
||||
cur.request->role = Request::authorizer;
|
||||
}
|
||||
|
||||
|
||||
void App::CheckSSL()
|
||||
{
|
||||
@@ -774,22 +779,68 @@ void App::PrepareSessionCookie()
|
||||
|
||||
if( !cur.session->puser || !cur.session->remember_me )
|
||||
{
|
||||
cur.request->SetCookie(config.http_session_id_name.c_str(), cur.session->id);
|
||||
cur.request->AddCookie(config.http_session_id_name, cur.session->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
PT::Date expires = cur.request->start_time + config.session_remember_max_idle;
|
||||
cur.request->SetCookie(config.http_session_id_name.c_str(), cur.session->id, &expires);
|
||||
cur.request->AddCookie(config.http_session_id_name, cur.session->id, expires);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool App::AddHeader(const wchar_t * name, const wchar_t * value)
|
||||
{
|
||||
if( !cur.request->out_headers.GetValue(name) )
|
||||
{
|
||||
cur.request->out_headers.Add(name, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool App::SendHeadersStaticCreateResource()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool App::AddHeader(const std::wstring & name, const std::wstring & value)
|
||||
{
|
||||
if( !cur.request->out_headers.GetValue(name) )
|
||||
{
|
||||
cur.request->out_headers.Add(name, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool App::AddHeader(const wchar_t * name, const PT::WTextStream & value)
|
||||
{
|
||||
if( !cur.request->out_headers.GetValue(name) )
|
||||
{
|
||||
cur.request->out_headers.Add(name, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool App::AddHeader(const std::wstring & name, const PT::WTextStream & value)
|
||||
{
|
||||
if( !cur.request->out_headers.GetValue(name) )
|
||||
{
|
||||
cur.request->out_headers.Add(name, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool App::PrepareHeadersStaticCreateResource(PT::WTextStream & out_path)
|
||||
{
|
||||
size_t i = 0;
|
||||
Item * dir = system.dirs.GetDir(system.mounts.pmount->dir_id);
|
||||
sendh_t3.clear();
|
||||
|
||||
if( !dir )
|
||||
{
|
||||
@@ -808,18 +859,18 @@ bool App::SendHeadersStaticCreateResource()
|
||||
++i;
|
||||
|
||||
if( i > 0 )
|
||||
sendh_t3.assign(path, i);
|
||||
out_path.write(path, i);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void App::SendHeadersStatic()
|
||||
void App::PrepareHeadersStatic()
|
||||
{
|
||||
if( PathHasUpDir(cur.request->env_request_uri) )
|
||||
{
|
||||
log << log1 << "App: incorrect path for a static file" << logend;
|
||||
SendHeadersForbidden();
|
||||
PrepareHeadersForbidden();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -829,211 +880,263 @@ void App::SendHeadersStatic()
|
||||
if( index >= config.static_dirs.size() )
|
||||
{
|
||||
log << log1 << "App: static dir with index " << index << " is not defined in the config" << logend;
|
||||
SendHeadersForbidden();
|
||||
PrepareHeadersForbidden();
|
||||
return;
|
||||
}
|
||||
|
||||
PT::WideToUTF8(config.http_header_send_file, sendh_t);
|
||||
PT::WideToUTF8(config.static_dirs[index], sendh_t2);
|
||||
PT::WTextStream path;
|
||||
path << config.static_dirs[index] << L"/";
|
||||
|
||||
if( !SendHeadersStaticCreateResource() )
|
||||
if( !PrepareHeadersStaticCreateResource(path) )
|
||||
{
|
||||
SendHeadersForbidden();
|
||||
PrepareHeadersForbidden();
|
||||
return;
|
||||
}
|
||||
|
||||
FCGX_FPrintF(fcgi_request.out, "%s: %s/%s\r\n", sendh_t.c_str(), sendh_t2.c_str(), sendh_t3.c_str());
|
||||
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
|
||||
log << log2 << "App: sending a file from a static mountpoint: " << sendh_t2 << "/" << sendh_t3 << logend;
|
||||
AddHeader(L"Status", L"200 OK");
|
||||
|
||||
if( AddHeader(config.http_header_send_file, path) )
|
||||
log << log2 << "App: sending a file from a static mountpoint: " << path << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SendHeaderContentType()
|
||||
void App::PrepareHeaderContentType()
|
||||
{
|
||||
if( cur.request->return_json )
|
||||
std::wstring * value = 0;
|
||||
|
||||
if( !cur.request->out_headers.GetValue(L"Content-Type") )
|
||||
{
|
||||
FCGX_PutS("Content-Type: application/json", fcgi_request.out);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( config.content_type_header )
|
||||
if( cur.request->return_json )
|
||||
{
|
||||
case 1:
|
||||
FCGX_PutS("Content-Type: application/xhtml+xml", fcgi_request.out);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
FCGX_PutS("Content-Type: application/xml", fcgi_request.out);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
FCGX_PutS("Content-Type: text/html", fcgi_request.out);
|
||||
value = &cur.request->out_headers.Add(L"Content-Type", L"application/json");
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( config.content_type_header )
|
||||
{
|
||||
case 1:
|
||||
value = &cur.request->out_headers.Add(L"Content-Type", L"application/xhtml+xml");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
value = &cur.request->out_headers.Add(L"Content-Type", L"application/xml");
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
value = &cur.request->out_headers.Add(L"Content-Type", L"text/html");
|
||||
}
|
||||
}
|
||||
|
||||
if( value && config.utf8 )
|
||||
*value += L"; charset=UTF-8";
|
||||
}
|
||||
|
||||
if( config.utf8 )
|
||||
FCGX_PutS("; charset=UTF-8", fcgi_request.out);
|
||||
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SendHeadersForbidden()
|
||||
void App::PrepareHeadersForbidden()
|
||||
{
|
||||
FCGX_PutS("Status: 403 Forbidden\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
AddHeader(L"Status", L"403 Forbidden");
|
||||
PrepareHeaderContentType();
|
||||
}
|
||||
|
||||
|
||||
void App::SendHeadersRedirect()
|
||||
void App::PrepareHeadersRedirect()
|
||||
{
|
||||
switch(cur.request->redirect_type)
|
||||
{
|
||||
case 300:
|
||||
FCGX_PutS("Status: 300 Multiple Choices\r\n", fcgi_request.out);
|
||||
AddHeader(L"Status", L"300 Multiple Choices");
|
||||
break;
|
||||
|
||||
case 301:
|
||||
FCGX_PutS("Status: 301 Moved Permanently\r\n", fcgi_request.out);
|
||||
AddHeader(L"Status", L"301 Moved Permanently");
|
||||
break;
|
||||
|
||||
case 302:
|
||||
FCGX_PutS("Status: 302 Found\r\n", fcgi_request.out);
|
||||
AddHeader(L"Status", L"302 Found");
|
||||
break;
|
||||
|
||||
case 307:
|
||||
FCGX_PutS("Status: 307 Temporary Redirect\r\n", fcgi_request.out);
|
||||
AddHeader(L"Status", L"307 Temporary Redirect");
|
||||
break;
|
||||
|
||||
case 303:
|
||||
default:
|
||||
FCGX_PutS("Status: 303 See Other\r\n", fcgi_request.out);
|
||||
AddHeader(L"Status", L"303 See Other");
|
||||
break;
|
||||
}
|
||||
|
||||
PT::WideToUTF8(cur.request->redirect_to, cur.request->aredirect_to);
|
||||
FCGX_FPrintF(fcgi_request.out, "Location: %s\r\n", cur.request->aredirect_to.c_str());
|
||||
log << log2 << "App: redirect to: " << cur.request->aredirect_to << logend;
|
||||
AddHeader(L"Location", cur.request->redirect_to);
|
||||
log << log2 << "App: redirect to: " << cur.request->redirect_to << logend;
|
||||
}
|
||||
|
||||
|
||||
void App::SendHeadersSendFile()
|
||||
void App::PrepareHeadersSendFile()
|
||||
{
|
||||
PT::WideToUTF8(config.http_header_send_file, sendfilea);
|
||||
PT::WideToUTF8(cur.request->x_sendfile, sendfile2a);
|
||||
FCGX_FPrintF(fcgi_request.out, "%s: %s\r\n", sendfilea.c_str(), sendfile2a.c_str());
|
||||
AddHeader(L"Status", L"200 OK");
|
||||
|
||||
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
|
||||
log << log2 << "App: sending file: " << cur.request->x_sendfile << logend;
|
||||
if( AddHeader(config.http_header_send_file, cur.request->x_sendfile) )
|
||||
log << log2 << "App: sending file: " << cur.request->x_sendfile << logend;
|
||||
}
|
||||
|
||||
|
||||
void App::SendHeadersCompression(int compress_encoding)
|
||||
void App::PrepareHeadersCompression(int compress_encoding)
|
||||
{
|
||||
if( compress_encoding == 0 || compress_encoding == 1 )
|
||||
FCGX_PutS("Content-Encoding: deflate\r\n", fcgi_request.out);
|
||||
AddHeader(L"Content-Encoding", L"deflate");
|
||||
else
|
||||
FCGX_PutS("Content-Encoding: gzip\r\n", fcgi_request.out);
|
||||
AddHeader(L"Content-Encoding", L"gzip");
|
||||
}
|
||||
|
||||
|
||||
void App::SendHeadersNormal(Header header)
|
||||
void App::PrepareHeadersNormal(Header header, size_t output_size)
|
||||
{
|
||||
switch( header )
|
||||
{
|
||||
case h_404:
|
||||
FCGX_PutS("Status: 404 Not Found\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
AddHeader(L"Status", L"404 Not Found");
|
||||
PrepareHeaderContentType();
|
||||
break;
|
||||
|
||||
case h_403:
|
||||
SendHeadersForbidden();
|
||||
PrepareHeadersForbidden();
|
||||
break;
|
||||
|
||||
default:
|
||||
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
|
||||
AddHeader(L"Status", L"200 OK");
|
||||
PrepareHeaderContentType();
|
||||
}
|
||||
|
||||
if( cur.request->role != Request::authorizer )
|
||||
SendHeaderContentType();
|
||||
if( output_size != static_cast<size_t>(-1) )
|
||||
{
|
||||
PT::WTextStream buf;
|
||||
buf << output_size;
|
||||
AddHeader(L"Content-Length", buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// we can improve SendHeaders and SendCookies methods by checking
|
||||
// whether there is a new line character in either a name or a value
|
||||
// and if such character exists and is being sent to the client it breaks the http headers and content
|
||||
// and if compression is enabled the client's browser will not be able to decompress the stream
|
||||
void App::SendHeaders()
|
||||
{
|
||||
PT::Space::TableSingle::iterator i;
|
||||
PT::Space & headers = cur.request->out_headers;
|
||||
|
||||
void App::SendHeaders(bool compressing, int compress_encoding, Header header)
|
||||
plugin.Call(WINIX_PREPARE_TO_SEND_HTTP_HEADERS, &headers);
|
||||
|
||||
for(i=headers.table_single.begin() ; i != headers.table_single.end() ; ++i)
|
||||
{
|
||||
PT::WideToUTF8(i->first, aheader_name);
|
||||
PT::WideToUTF8(i->second, aheader_value);
|
||||
|
||||
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
|
||||
FCGX_PutS(": ", fcgi_request.out);
|
||||
FCGX_PutS(aheader_value.c_str(), fcgi_request.out);
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
|
||||
if( config.log_http_answer_headers )
|
||||
log << "HTTP Header: " << aheader_name << ": " << aheader_value << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void App::SendCookies()
|
||||
{
|
||||
PT::Space::TableSingle::iterator i;
|
||||
PT::Space & cookies = cur.request->out_cookies;
|
||||
|
||||
plugin.Call(WINIX_PREPARE_TO_SEND_HTTP_COOKIES, &cookies);
|
||||
|
||||
for(i=cookies.table_single.begin() ; i != cookies.table_single.end() ; ++i)
|
||||
{
|
||||
PT::WideToUTF8(i->first, aheader_name);
|
||||
PT::WideToUTF8(i->second, aheader_value);
|
||||
|
||||
FCGX_PutS("Set-Cookie: ", fcgi_request.out);
|
||||
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
|
||||
FCGX_PutS("=", fcgi_request.out);
|
||||
FCGX_PutS(aheader_value.c_str(), fcgi_request.out);
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
|
||||
if( config.log_http_answer_headers )
|
||||
log << "HTTP Header: " << "Set-Cookie: " << aheader_name << "=" << aheader_value << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void App::PrepareHeaders(bool compressing, int compress_encoding, Header header, size_t output_size)
|
||||
{
|
||||
PrepareSessionCookie();
|
||||
|
||||
if( cur.request->send_as_attachment )
|
||||
FCGX_PutS("Content-Disposition: attachment\r\n", fcgi_request.out);
|
||||
AddHeader(L"Content-Disposition", L"attachment");
|
||||
|
||||
if( !cur.request->redirect_to.empty() )
|
||||
{
|
||||
SendHeadersRedirect();
|
||||
PrepareHeadersRedirect();
|
||||
}
|
||||
else
|
||||
if( system.mounts.pmount->type == system.mounts.MountTypeStatic() )
|
||||
{
|
||||
SendHeadersStatic();
|
||||
PrepareHeadersStatic();
|
||||
}
|
||||
else
|
||||
if( !cur.request->x_sendfile.empty() )
|
||||
{
|
||||
SendHeadersSendFile();
|
||||
PrepareHeadersSendFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
SendHeadersNormal(header);
|
||||
PrepareHeadersNormal(header, output_size);
|
||||
}
|
||||
|
||||
if( compressing )
|
||||
SendHeadersCompression(compress_encoding);
|
||||
|
||||
FCGX_PutS(cur.request->headers.CStr(), fcgi_request.out);
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
PrepareHeadersCompression(compress_encoding);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void App::FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref)
|
||||
void App::FilterContent()
|
||||
{
|
||||
const std::wstring * source = &source_ref;
|
||||
Request & req = *cur.request;
|
||||
bool raw = req.is_item && req.item.content_type == Item::ct_raw &&
|
||||
req.status == WINIX_ERR_OK && req.function &&
|
||||
(req.function == &functions.fun_cat || req.function == &functions.fun_run);
|
||||
|
||||
bool raw = cur.request->is_item && cur.request->item.content_type == Item::ct_raw && cur.request->status == WINIX_ERR_OK &&
|
||||
cur.request->function && (cur.request->function == &functions.fun_cat || cur.request->function == &functions.fun_run);
|
||||
size_t start = req.out_streams.size(); // default nothing should be filtered
|
||||
size_t end = req.out_streams.size();
|
||||
|
||||
if( config.html_filter && cur.request->use_html_filter && !raw && !cur.request->return_json )
|
||||
if( config.html_filter && !req.send_bin_stream && !raw )
|
||||
{
|
||||
TemplatesFunctions::html_filter.Filter(*source, clean_html);
|
||||
AddDebugInfo(clean_html);
|
||||
source = &clean_html;
|
||||
}
|
||||
else
|
||||
{
|
||||
html_with_debug = *source;
|
||||
AddDebugInfo(html_with_debug);
|
||||
source = &html_with_debug;
|
||||
if( req.return_json )
|
||||
{
|
||||
if( !req.return_info_only )
|
||||
{
|
||||
start = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
start = 0;
|
||||
end = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( config.utf8 )
|
||||
PT::WideToUTF8(*source, source_a);
|
||||
else
|
||||
AssignString(*source, source_a);
|
||||
|
||||
if( config.log_server_answer )
|
||||
log << log1 << "App: the server's answer is:\n" << source_a << "\nApp: end of the server's answer" << logend;
|
||||
|
||||
if( compressing )
|
||||
compress.CompressAndPut(source_a.c_str(), source_a.length(), fcgi_request.out, compress_encoding);
|
||||
else
|
||||
FCGX_PutS(source_a.c_str(), fcgi_request.out);
|
||||
|
||||
if( cur.request->return_json )
|
||||
json_out_stream.Clear();
|
||||
for(size_t i=start ; i<end ; ++i)
|
||||
{
|
||||
if( req.use_html_filter[i] )
|
||||
{
|
||||
// !! IMPROVE ME may some kind of html_filtered.reserve() here? (optimization)
|
||||
TemplatesFunctions::html_filter.Filter(req.out_streams[i].Str(), html_filtered);
|
||||
req.out_streams[i].Str(std::move(html_filtered));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1048,13 +1151,13 @@ int App::SelectDeflateVersion()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding)
|
||||
{
|
||||
compression_allowed = false;
|
||||
compression_encoding = 0;
|
||||
|
||||
if( config.compression &&
|
||||
cur.request->role == Request::responder &&
|
||||
cur.request->redirect_to.empty() &&
|
||||
cur.request->x_sendfile.empty() &&
|
||||
!cur.request->browser_konqueror && /* !! sprawdzic czy Konqueror bedzie obslugiwal raw deflate */
|
||||
@@ -1096,16 +1199,12 @@ void App::SelectCompression(size_t source_len, bool & compression_allowed, int &
|
||||
|
||||
|
||||
|
||||
bool App::CanSendContent(Header header)
|
||||
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
|
||||
return false;
|
||||
|
||||
if( header == h_200 && cur.request->role == Request::authorizer && cur.request->is_item && cur.request->item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
// if there is an item and the item has 'file' storage we do not send a content
|
||||
return false;
|
||||
|
||||
/*
|
||||
we don't have to check the HEAD method
|
||||
the server (lighttpd) doesn't send the body of its own
|
||||
@@ -1117,35 +1216,11 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
void App::AddDebugInfo(std::wstring & out)
|
||||
|
||||
App::Header App::GetHTTPStatusCode()
|
||||
{
|
||||
if( config.debug_info )
|
||||
{
|
||||
if( !cur.request->debug.Empty() )
|
||||
{
|
||||
out += L"\n<!--\n";
|
||||
out += cur.request->debug.Str();
|
||||
out += L"\n-->\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SendTextAnswer()
|
||||
{
|
||||
const std::wstring * source;
|
||||
Header header = h_200;
|
||||
Error status = cur.request->status;
|
||||
bool compressing;
|
||||
int compress_encoding;
|
||||
|
||||
if( cur.request->return_json )
|
||||
source = &json_out_stream.Str();
|
||||
else
|
||||
source = &cur.request->out_streams[0].Str();
|
||||
|
||||
SelectCompression(source->length(), compressing, compress_encoding);
|
||||
Error status = cur.request->status;
|
||||
Header header = h_200;
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
|
||||
{
|
||||
@@ -1165,12 +1240,67 @@ int compress_encoding;
|
||||
header = h_200;
|
||||
}
|
||||
|
||||
SendHeaders(compressing, compress_encoding, header);
|
||||
return header;
|
||||
}
|
||||
|
||||
if( CanSendContent(header) )
|
||||
|
||||
|
||||
void App::SendTextAnswer()
|
||||
{
|
||||
const std::wstring * source;
|
||||
bool compressing = false;
|
||||
int compress_encoding = 0;
|
||||
size_t output_size = 0;
|
||||
|
||||
Header header = GetHTTPStatusCode();
|
||||
|
||||
if( CanSendContent() )
|
||||
{
|
||||
// filtering (html), compressing and sending back to the web browser
|
||||
FilterCompressSend(compressing, compress_encoding, *source);
|
||||
FilterContent();
|
||||
|
||||
if( cur.request->return_json )
|
||||
{
|
||||
CreateJSONAnswer();
|
||||
source = &json_out_stream.Str(); // json_out_stream was prepared by CreateJSONAnswer()
|
||||
}
|
||||
else
|
||||
{
|
||||
source = &cur.request->out_streams[0].Str();
|
||||
}
|
||||
|
||||
SelectCompression(source->length(), compressing, compress_encoding);
|
||||
|
||||
if( config.utf8 )
|
||||
PT::WideToUTF8(*source, output_8bit);
|
||||
else
|
||||
AssignString(*source, output_8bit);
|
||||
|
||||
// !! IMPROVE ME add to log the binary stream as well
|
||||
if( config.log_server_answer )
|
||||
log << log1 << "App: the server's answer is:\n" << output_8bit << "\nApp: end of the server's answer" << logend;
|
||||
|
||||
if( compressing )
|
||||
{
|
||||
compress.Compressing(output_8bit.c_str(), output_8bit.length(), compressed_output, compress_encoding);
|
||||
output_size = compressed_output.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
output_size = output_8bit.size();
|
||||
}
|
||||
}
|
||||
|
||||
PrepareHeaders(compressing, compress_encoding, header, output_size);
|
||||
SendHeaders();
|
||||
SendCookies();
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
|
||||
if( CanSendContent() )
|
||||
{
|
||||
if( compressing )
|
||||
SendData(compressed_output, fcgi_request.out);
|
||||
else
|
||||
FCGX_PutStr(output_8bit.c_str(), output_8bit.size(), fcgi_request.out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1182,7 +1312,7 @@ void App::SendData(const BinaryPage & page, FCGX_Stream * out)
|
||||
if( send_data_buf.size() != buf_size )
|
||||
send_data_buf.resize(buf_size);
|
||||
|
||||
BinaryPage::const_iterator i = page.begin();
|
||||
BinaryPage::const_iterator i = page.begin();
|
||||
BinaryPage::const_iterator end = page.end();
|
||||
|
||||
while( i != end )
|
||||
@@ -1193,7 +1323,7 @@ void App::SendData(const BinaryPage & page, FCGX_Stream * out)
|
||||
send_data_buf[s] = *i;
|
||||
|
||||
if( s > 0 )
|
||||
FCGX_PutStr(send_data_buf.c_str(), s, fcgi_request.out);
|
||||
FCGX_PutStr(send_data_buf.c_str(), s, out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1214,18 +1344,22 @@ int compress_encoding;
|
||||
if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP )
|
||||
header = h_403;
|
||||
|
||||
// !! IMPROVE ME add header: content-size
|
||||
|
||||
SendHeaders(compressing, compress_encoding, header);
|
||||
// !! IMPROVE ME add header: content-length (size from Item struct)
|
||||
// warning: if someone changed a file on the disk (in the real os)
|
||||
// then winix would send an incorrect content-lenght header,
|
||||
// we are waiting for the fsck winix function to be implemented
|
||||
PrepareHeaders(compressing, compress_encoding, header, static_cast<size_t>(-1));
|
||||
SendHeaders();
|
||||
SendCookies();
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
|
||||
if( CanSendContent(header) )
|
||||
if( CanSendContent() )
|
||||
{
|
||||
if( compressing )
|
||||
{
|
||||
out_bin_stream_compressed.clear(); // !! IMPROVE ME add to the end of a request
|
||||
compress.Compressing(source, out_bin_stream_compressed, compress_encoding);
|
||||
SendData(out_bin_stream_compressed, fcgi_request.out);
|
||||
out_bin_stream_compressed.clear();
|
||||
compress.Compressing(source, compressed_output, compress_encoding);
|
||||
SendData(compressed_output, fcgi_request.out);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1508,10 +1642,7 @@ void App::Unlock()
|
||||
|
||||
void App::WaitForThreads()
|
||||
{
|
||||
// special thread hangs on fetchStatURL -- I don't know why
|
||||
// but it doesn't matter, don't use pthread_join on it
|
||||
//pthread_join(signal_thread, 0);
|
||||
|
||||
pthread_join(signal_thread, 0);
|
||||
system.thread_manager.StopAll();
|
||||
}
|
||||
|
||||
@@ -1524,8 +1655,17 @@ void App::FetchPageOnExit()
|
||||
// doesn't want to break on a signal
|
||||
// so we request one page from the server for exiting from FCGX_Accept_r
|
||||
|
||||
url_stat url;
|
||||
fetchStatURL(url_to_fetch_on_exit.c_str(), &url, "");
|
||||
Lock();
|
||||
CURL * curl = curl_easy_init();
|
||||
Unlock();
|
||||
|
||||
if( curl )
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url_to_fetch_on_exit.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
|
||||
curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1551,8 +1691,6 @@ sigset_t set;
|
||||
PT::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit, false);
|
||||
app->Unlock();
|
||||
|
||||
// this thread will hang on this method
|
||||
// but will be terminated when the main thread exits
|
||||
app->FetchPageOnExit();
|
||||
|
||||
pthread_exit(0);
|
||||
@@ -1593,3 +1731,8 @@ void App::CreateStaticTree()
|
||||
|
||||
CreateDirs(config.upload_dir.c_str(), L"tmp", config.upload_dirs_chmod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
62
core/app.h
62
core/app.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -37,6 +37,12 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class App
|
||||
{
|
||||
public:
|
||||
@@ -87,7 +93,7 @@ public:
|
||||
Functions functions;
|
||||
|
||||
// false at the beginning
|
||||
// !! moze to do loggera dac?
|
||||
// !! IMPROVE ME moze to do loggera dac?
|
||||
bool stdout_is_closed;
|
||||
|
||||
|
||||
@@ -112,19 +118,18 @@ private:
|
||||
CookieParser cookie_parser;
|
||||
AcceptEncodingParser accept_encoding_parser;
|
||||
Compress compress;
|
||||
std::wstring clean_html, html_with_debug;
|
||||
FCGX_Request fcgi_request;
|
||||
int fcgi_socket;
|
||||
Synchro synchro;
|
||||
pthread_t signal_thread;
|
||||
std::string url_to_fetch_on_exit;
|
||||
std::string source_a;
|
||||
std::string sendh_t, sendh_t2, sendh_t3;
|
||||
std::string sendfilea, sendfile2a;
|
||||
std::string send_data_buf;
|
||||
PT::SpaceToJSON json_generic_serializer;
|
||||
TextStream<std::wstring> json_out_stream;
|
||||
BinaryPage out_bin_stream_compressed;
|
||||
std::string aheader_name, aheader_value;
|
||||
std::wstring html_filtered;
|
||||
std::string output_8bit;
|
||||
BinaryPage compressed_output;
|
||||
|
||||
bool CheckAccessFromPlugins();
|
||||
void ProcessRequestThrow();
|
||||
@@ -136,7 +141,7 @@ private:
|
||||
void CheckPostRedirect();
|
||||
void MakePage();
|
||||
void Make();
|
||||
void SaveSessionsIfNeeded(); // !! wywalic do menagera sesji??
|
||||
void SaveSessionsIfNeeded(); // !! IMPROVE ME wywalic do menagera sesji??
|
||||
void LogAccess();
|
||||
void SendData(const BinaryPage & page, FCGX_Stream * out);
|
||||
void CreateJSONAnswer();
|
||||
@@ -146,7 +151,7 @@ private:
|
||||
void SendBinaryAnswer();
|
||||
void SendAnswer();
|
||||
|
||||
void PrintEnv();
|
||||
void LogEnvironmentVariables();
|
||||
|
||||
void SetEnv(const char * & env, const char * name);
|
||||
void ReadEnvVariables();
|
||||
@@ -155,26 +160,32 @@ private:
|
||||
void CheckIE();
|
||||
void CheckKonqueror();
|
||||
void CheckRequestMethod();
|
||||
void CheckFCGIRole();
|
||||
void CheckSSL();
|
||||
void SetSubdomain();
|
||||
|
||||
|
||||
Header GetHTTPStatusCode();
|
||||
void PrepareSessionCookie();
|
||||
void AddDebugInfo(std::wstring & out);
|
||||
void FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref);
|
||||
bool SendHeadersStaticCreateResource();
|
||||
void SendHeadersStatic();
|
||||
void SendHeaderContentType();
|
||||
void SendHeadersForbidden();
|
||||
void SendHeadersRedirect();
|
||||
void SendHeadersSendFile();
|
||||
void SendHeadersCompression(int compress_encoding);
|
||||
void SendHeadersNormal(Header header);
|
||||
void SendHeaders(bool compressing, int compress_encoding, Header header);
|
||||
void FilterContent();
|
||||
void SendHeaders();
|
||||
void SendCookies();
|
||||
bool AddHeader(const wchar_t * name, const wchar_t * value);
|
||||
bool AddHeader(const std::wstring & name, const std::wstring & value);
|
||||
bool AddHeader(const wchar_t * name, const PT::WTextStream & value);
|
||||
bool AddHeader(const std::wstring & name, const PT::WTextStream & value);
|
||||
bool PrepareHeadersStaticCreateResource(PT::WTextStream & out_path);
|
||||
void PrepareHeadersStatic();
|
||||
void PrepareHeaderContentType();
|
||||
void PrepareHeadersForbidden();
|
||||
void PrepareHeadersRedirect();
|
||||
void PrepareHeadersSendFile();
|
||||
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);
|
||||
int SelectDeflateVersion();
|
||||
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding);
|
||||
bool CanSendContent(Header header);
|
||||
bool CanSendContent();
|
||||
void ClearAfterRequest();
|
||||
|
||||
void LogUser(const char * msg, uid_t id);
|
||||
void LogGroup(const char * msg, gid_t id, bool put_logend = true);
|
||||
@@ -188,10 +199,15 @@ private:
|
||||
|
||||
void CreateStaticTree();
|
||||
|
||||
// !! dodac do session managera?
|
||||
// !! IMPROVE ME
|
||||
// !! move to the session manager?
|
||||
time_t last_sessions_save;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "basethread.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER)
|
||||
{
|
||||
@@ -237,3 +240,7 @@ pthread_attr_t attr;
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,11 @@
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class BaseThread
|
||||
{
|
||||
@@ -120,6 +125,9 @@ protected:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "bbcodeparser.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
|
||||
@@ -590,3 +594,8 @@ void BBCODEParser::Uninit()
|
||||
if( has_open_ul_tag )
|
||||
(*out_string) += L"</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "htmlfilter.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class BBCODEParser : public HTMLFilter
|
||||
@@ -90,4 +93,8 @@ class BBCODEParser : public HTMLFilter
|
||||
bool has_open_li_tag; // has open html <li> tag
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,10 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Compress::Compress()
|
||||
@@ -153,7 +157,9 @@ return 0;
|
||||
|
||||
|
||||
|
||||
int Compress::MakeCompress(z_stream & strm, const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding)
|
||||
|
||||
|
||||
int Compress::MakeCompress(z_stream & strm, const char * source, size_t source_len, BinaryPage & out_stream, int encoding)
|
||||
{
|
||||
int ret, flush;
|
||||
size_t have;
|
||||
@@ -180,7 +186,7 @@ size_t have;
|
||||
|
||||
have = buffer_max_len - strm.avail_out;
|
||||
last_out_size += have;
|
||||
FCGX_PutStr(buffer_out, have, out_stream);
|
||||
out_stream.write(buffer_out, have);
|
||||
}
|
||||
while( strm.avail_out == 0 );
|
||||
|
||||
@@ -203,6 +209,7 @@ return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Compress::CopyToInputBuffer(BinaryPage::const_iterator & i, size_t len)
|
||||
{
|
||||
for(size_t a=0 ; a<len ; ++a, ++i)
|
||||
@@ -331,12 +338,13 @@ void Compress::PutLog(size_t source_len, int encoding)
|
||||
3 - not inited (use Init() first)
|
||||
100 - unknown
|
||||
*/
|
||||
int Compress::CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding)
|
||||
int Compress::Compressing(const char * source, size_t source_len, BinaryPage & out_stream, int encoding)
|
||||
{
|
||||
int ret;
|
||||
z_stream * pstrm;
|
||||
|
||||
last_out_size = 0;
|
||||
out_stream.clear();
|
||||
|
||||
if( !ready_for_compress )
|
||||
{
|
||||
@@ -344,6 +352,8 @@ z_stream * pstrm;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// !! CHECK ME
|
||||
// it is correct to immediately return? what about headers in the compressed page?
|
||||
if( source_len == 0 )
|
||||
return 0;
|
||||
|
||||
@@ -379,6 +389,8 @@ z_stream * pstrm;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// !! CHECK ME
|
||||
// it is correct to immediately return? what about headers in the compressed page?
|
||||
if( in.empty() )
|
||||
return 0;
|
||||
|
||||
@@ -390,3 +402,7 @@ z_stream * pstrm;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,11 +11,14 @@
|
||||
#define headerfile_winix_core_compress
|
||||
|
||||
#include <cstring>
|
||||
#include <fcgiapp.h>
|
||||
#include <zlib.h>
|
||||
#include "requesttypes.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class Compress
|
||||
{
|
||||
@@ -34,7 +37,7 @@ public:
|
||||
1 - deflate
|
||||
2 - gzip
|
||||
*/
|
||||
int CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding = 2);
|
||||
int Compressing(const char * source, size_t source_len, BinaryPage & out_stream, int encoding = 2);
|
||||
int Compressing(const BinaryPage & in, BinaryPage & out, int encoding = 2);
|
||||
|
||||
|
||||
@@ -45,7 +48,7 @@ private:
|
||||
bool InitDeflate();
|
||||
bool InitGzip();
|
||||
|
||||
int MakeCompress(z_stream & strm, const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding);
|
||||
int MakeCompress(z_stream & strm, const char * source, size_t source_len, BinaryPage & out_stream, int encoding);
|
||||
int MakeCompress(z_stream & strm, const BinaryPage & page, BinaryPage & out, int encoding);
|
||||
z_stream * SelectStream(int encoding);
|
||||
void ResetStream(z_stream * pstrm, int encoding);
|
||||
@@ -67,4 +70,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,10 @@
|
||||
#include "crypt.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
@@ -118,6 +122,8 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
log_db_query = Bool(L"log_db_query", false);
|
||||
log_plugin_call = Bool(L"log_plugin_call", false);
|
||||
log_post_value_size = Size(L"log_post_value_size", 80);
|
||||
log_env_variables = Bool(L"log_env_variables", false);
|
||||
log_http_answer_headers = Bool(L"log_http_answer_headers", false);
|
||||
|
||||
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
|
||||
|
||||
@@ -151,7 +157,7 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
templates_index = Text(L"templates_index", L"index.html");
|
||||
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
||||
|
||||
http_session_id_name = AText(L"http_session_id_name");
|
||||
http_session_id_name = Text(L"http_session_id_name", L"session_id");
|
||||
db_database = AText(L"db_database");
|
||||
db_user = AText(L"db_user");
|
||||
db_pass = AText(L"db_pass");
|
||||
@@ -206,7 +212,6 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
title_separator = Text(L"title_separator", L" / ");
|
||||
|
||||
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file");
|
||||
debug_info = Bool(L"debug_info", false);
|
||||
|
||||
editors_html_safe_mode = Bool(L"editors_html_safe_mode", true);
|
||||
editors_html_safe_mode_skip_root = Bool(L"editors_html_safe_mode_skip_root", true);
|
||||
@@ -237,6 +242,7 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
|
||||
ezc_max_elements = Size(L"ezc_max_elements", 50000);
|
||||
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000);
|
||||
ezc_out_streams_size = Size(L"ezc_out_streams_size", 16);
|
||||
|
||||
account_need_email_verification = Bool(L"account_need_email_verification", true);
|
||||
reset_password_code_expiration_time = Long(L"reset_password_code_expiration_time", 86400);
|
||||
@@ -259,6 +265,7 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
incorrect_login_cannot_login_mode = Int(L"incorrect_login_cannot_login_mode", 0);
|
||||
incorrect_login_cannot_login_treshold = Size(L"incorrect_login_cannot_login_treshold", 20);
|
||||
incorrect_login_cannot_login_delay = Size(L"incorrect_login_cannot_login_delay", 1800);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -465,5 +472,8 @@ void Config::Print(std::wostream & out)
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "htmlfilter.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -91,6 +95,14 @@ public:
|
||||
// request delimiter in the log file, default "---------"
|
||||
std::wstring log_delimiter;
|
||||
|
||||
// log environment variables (fastcgi environment)
|
||||
bool log_env_variables;
|
||||
|
||||
// log headers (+cookies) which are returned to the client
|
||||
// this is what winix has generated -- the web server can change or add other headers
|
||||
// default: false
|
||||
bool log_http_answer_headers;
|
||||
|
||||
// fast cgi: socket (unix domain)
|
||||
std::string fcgi_socket;
|
||||
|
||||
@@ -128,7 +140,7 @@ public:
|
||||
std::string db_user;
|
||||
std::string db_pass;
|
||||
|
||||
std::string http_session_id_name;
|
||||
std::wstring http_session_id_name;
|
||||
|
||||
// string used in a place where is a user (or group) selected
|
||||
std::wstring priv_no_user;
|
||||
@@ -389,9 +401,6 @@ public:
|
||||
// default: X-LIGHTTPD-send-file
|
||||
std::wstring http_header_send_file;
|
||||
|
||||
// prints additional information (in the end of the html page as a commentary)
|
||||
bool debug_info;
|
||||
|
||||
// in editors (emacs, ckeditor,...) the html will be filtered and unsafe tags
|
||||
// will be dropped (script, frame, etc.)
|
||||
// default: true;
|
||||
@@ -485,6 +494,10 @@ public:
|
||||
// default: 5000 (from ezc generator)
|
||||
size_t ezc_max_loop_elements;
|
||||
|
||||
// how many output streams do we have in Request class
|
||||
// default: 16 (64 maximum)
|
||||
size_t ezc_out_streams_size;
|
||||
|
||||
// when true then when a user want to create a new account
|
||||
// he has to provide his email and a message will be sent back to him
|
||||
// with a link to activate the account
|
||||
@@ -591,6 +604,7 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
Config();
|
||||
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);
|
||||
|
||||
@@ -644,6 +658,9 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,12 +16,18 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class CookieParser : public HttpSimpleParser
|
||||
{
|
||||
|
||||
const char * cookie_string;
|
||||
CookieTab * cookie_tab;
|
||||
std::wstring temp_name, temp_value;
|
||||
bool input_as_utf8;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -35,19 +41,29 @@ protected:
|
||||
return (int)(unsigned char)*(cookie_string++);
|
||||
}
|
||||
|
||||
void ConvStr(const std::string & src, std::wstring & dst)
|
||||
{
|
||||
if( input_as_utf8 )
|
||||
PT::UTF8ToWide(src, dst);
|
||||
else
|
||||
AssignString(src, dst);
|
||||
}
|
||||
|
||||
virtual void Parameter(std::string & name, std::string & value)
|
||||
{
|
||||
// Cookie names are case insensitive according to section 3.1 of RFC 2965
|
||||
// (we don't use locale here)
|
||||
ToLower(name);
|
||||
|
||||
std::pair<CookieTab::iterator, bool> res = cookie_tab->insert( std::make_pair(name, value) );
|
||||
ConvStr(name, temp_name);
|
||||
ConvStr(value, temp_value);
|
||||
|
||||
log << log2 << "Cookie, name: \"" << name << "\", value: \"" << value << "\"";
|
||||
std::pair<CookieTab::iterator, bool> res = cookie_tab->insert( std::make_pair(temp_name, temp_value) );
|
||||
log << log2 << "Cookie, name: \"" << temp_name << "\", value: \"" << temp_value << "\"";
|
||||
|
||||
if( res.second == false )
|
||||
{
|
||||
res.first->second = value;
|
||||
res.first->second = temp_value;
|
||||
log << " (overwritten)";
|
||||
}
|
||||
|
||||
@@ -60,6 +76,7 @@ public:
|
||||
|
||||
CookieParser()
|
||||
{
|
||||
input_as_utf8 = false;
|
||||
HttpSimpleParser::separator = ';';
|
||||
HttpSimpleParser::value_can_be_quoted = true;
|
||||
HttpSimpleParser::skip_white_chars = true;
|
||||
@@ -67,6 +84,11 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void UTF8(bool utf)
|
||||
{
|
||||
input_as_utf8 = utf;
|
||||
}
|
||||
|
||||
// cookie_string can be null
|
||||
void Parse(const char * cookie_string_, CookieTab & cookie_tab_)
|
||||
{
|
||||
@@ -80,4 +102,7 @@ public:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
void Crypt::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
@@ -312,3 +317,7 @@ void Crypt::PassHashCrypt(UserPass & up)
|
||||
PassCrypt(config->pass_rsa_private_key, up);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
11
core/crypt.h
11
core/crypt.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,13 +10,17 @@
|
||||
#ifndef headerfile_winix_core_crypt
|
||||
#define headerfile_winix_core_crypt
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "run.h"
|
||||
#include "config.h"
|
||||
#include "user.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*
|
||||
the kind of hashes we are able to obtain in winix
|
||||
*/
|
||||
@@ -258,5 +262,8 @@ void Crypt::ConvertToHexForm(const std::string & in, StringType & out)
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,11 @@
|
||||
#include "mount.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*
|
||||
current request and session
|
||||
*/
|
||||
@@ -31,6 +36,8 @@ struct Cur
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,11 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
std::wstring DirContainer::dir_etc = L"etc";
|
||||
std::wstring DirContainer::dir_var = L"var";
|
||||
|
||||
@@ -328,3 +333,8 @@ bool DirContainer::DelById(long id)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "item.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class DirContainer
|
||||
{
|
||||
@@ -92,4 +96,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,9 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
void Dirs::SetDb(Db * pdb)
|
||||
@@ -517,7 +520,11 @@ void Dirs::CopyDirTab(const std::vector<Item*> & in, std::vector<Item*> & out)
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
!! IMPROVE ME
|
||||
may dir_tab can be empty when link_to is not relative?
|
||||
and now the algorith doesn't check if link_to is not relative (it only uses dir_tab)
|
||||
*/
|
||||
bool Dirs::AnalyzeDir(std::vector<Item*> & dir_tab, const std::wstring & link_to, size_t & i)
|
||||
{
|
||||
size_t old_i;
|
||||
@@ -752,3 +759,6 @@ void Dirs::LogDir(const std::vector<Item*> & dir_tab)
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
11
core/dirs.h
11
core/dirs.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -22,7 +22,13 @@
|
||||
#include "notify/notify.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// we do not support '..' in a path (for simplicity and security reasons)
|
||||
// (we will support '..' in the future)
|
||||
|
||||
|
||||
class Dirs
|
||||
@@ -115,4 +121,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,9 @@
|
||||
#define headerfile_winix_core_error
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
#define WINIX_ERR_OK 0
|
||||
@@ -77,4 +80,7 @@ typedef int Error;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,10 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Group
|
||||
{
|
||||
@@ -38,6 +42,8 @@ struct Group
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,9 @@
|
||||
#include "groups.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Groups::Groups()
|
||||
@@ -94,23 +97,5 @@ bool Groups::Remove(long group_id)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,10 @@
|
||||
#include "db/db.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class Groups
|
||||
{
|
||||
@@ -45,8 +49,7 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,11 @@
|
||||
#include "htmlfilter.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void HTMLFilter::Item::Clear()
|
||||
{
|
||||
@@ -1397,4 +1402,5 @@ void HTMLFilter::Read()
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// max length of a name of a html tag (with terminating null)
|
||||
@@ -295,5 +299,8 @@ protected:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,12 @@
|
||||
#include "httpsimpleparser.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void HttpSimpleParser::ToLower(std::string & s)
|
||||
{
|
||||
std::string::iterator i;
|
||||
@@ -223,13 +229,5 @@ void HttpSimpleParser::Parse()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,10 +10,13 @@
|
||||
#ifndef headerfile_winix_core_httpsimpleparser
|
||||
#define headerfile_winix_core_httpsimpleparser
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class HttpSimpleParser
|
||||
{
|
||||
@@ -65,4 +68,7 @@ public:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void Image::SetDb(Db * pdb)
|
||||
{
|
||||
@@ -520,7 +525,7 @@ void Image::SaveImage()
|
||||
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str()
|
||||
<< ", to: " << dst_path << logend;
|
||||
|
||||
::RemoveFile(stream_tmp_path.Str());
|
||||
Winix::RemoveFile(stream_tmp_path.Str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -592,3 +597,7 @@ void Image::CreateThumbnail()
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
10
core/image.h
10
core/image.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -19,6 +19,11 @@
|
||||
#include "core/config.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class System;
|
||||
|
||||
|
||||
@@ -179,4 +184,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
12
core/ipban.h
12
core/ipban.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012-2013, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,12 @@
|
||||
#include <ctime>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// telling if the IPBan record is active
|
||||
// we have two records: active and non active
|
||||
// non active records is something like a history
|
||||
@@ -147,4 +153,8 @@ struct IPBan
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
IPBanContainer::IPBanContainer()
|
||||
{
|
||||
@@ -216,6 +220,9 @@ bool IPBanContainer::SortIPBansFunction(const IPBan & ip1, const IPBan & ip2)
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,10 @@
|
||||
#include "ipban.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class IPBanContainer
|
||||
{
|
||||
@@ -54,5 +58,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,11 @@
|
||||
#include "crypt.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Item::Item()
|
||||
{
|
||||
@@ -80,3 +85,6 @@ void Item::Clear()
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
10
core/item.h
10
core/item.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
#define WINIX_ITEM_FILETYPE_NONE 0
|
||||
#define WINIX_ITEM_FILETYPE_IMAGE 1
|
||||
@@ -76,7 +79,7 @@ struct Item
|
||||
|
||||
// used when type is symlink or to a directory too (function 'default')
|
||||
std::wstring link_to;
|
||||
int link_redirect;
|
||||
int link_redirect; // !! IMPROVE ME should it be 'bool'?
|
||||
|
||||
|
||||
// static file (if exists)
|
||||
@@ -118,5 +121,8 @@ friend struct DbItemColumns;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
10
core/job.cpp
10
core/job.cpp
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,11 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Job::Job()
|
||||
{
|
||||
@@ -162,4 +167,7 @@ void Job::DoWinixJob(PT::Space & job)
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
10
core/job.h
10
core/job.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,10 @@
|
||||
#include "space/space.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
#define WINIX_JOBS_HOW_MANY_PRIORITIES 32
|
||||
|
||||
@@ -78,5 +82,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,12 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
LastItem::LastItem()
|
||||
{
|
||||
user_id = 0;
|
||||
@@ -106,3 +112,8 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
<< user_id << " ses_id: " << session_id << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -18,6 +18,11 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
// how many items we store in the 'last' function
|
||||
#define WINIX_LASTCONTAINER_TABLE_SIZE 100
|
||||
|
||||
@@ -75,4 +80,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,10 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
LoadAvg::LoadAvg()
|
||||
{
|
||||
@@ -370,3 +374,8 @@ double LoadAvg::ReqPerSec15()
|
||||
|
||||
return cache_req_per_sec15;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,10 @@
|
||||
#include <ctime>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// in seconds
|
||||
@@ -110,5 +114,8 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,11 @@
|
||||
#include "lock.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Lock::Lock()
|
||||
{
|
||||
@@ -47,3 +52,6 @@ void Lock::Unlock()
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
11
core/lock.h
11
core/lock.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,11 @@
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class Lock
|
||||
{
|
||||
public:
|
||||
@@ -34,4 +39,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
32
core/log.cpp
32
core/log.cpp
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,11 @@
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
log_level = 1;
|
||||
@@ -453,28 +458,5 @@ void Log::SaveLog()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
13
core/log.h
13
core/log.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -20,6 +20,11 @@
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class TimeZones;
|
||||
|
||||
|
||||
@@ -155,6 +160,12 @@ return *this;
|
||||
extern Log log;
|
||||
extern Log nlog;
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
// for convenience, we have to use only #include "log.h" in the winix
|
||||
#include "slog.h"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,12 @@
|
||||
#define headerfile_winix_core_logmanipulators
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
log1 - the first level
|
||||
log2
|
||||
@@ -44,5 +50,9 @@ enum LogManipulators
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,11 @@
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
namespace misc_private
|
||||
{
|
||||
@@ -1156,3 +1161,6 @@ void RemovePostFileTmp(PostFileTab & post_file_tab)
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,7 +10,6 @@
|
||||
#ifndef headerfile_winix_core_misc
|
||||
#define headerfile_winix_core_misc
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
@@ -22,6 +21,10 @@
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -1042,6 +1045,7 @@ void JSONescape(Stream & out, const StringType & str)
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009-2010, Tomasz Sowa
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,11 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Mount::Mount()
|
||||
{
|
||||
@@ -109,3 +114,7 @@ const std::wstring & Mount::FirstArg(int code) const
|
||||
return Arg(code, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009-2010, Tomasz Sowa
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class Mount
|
||||
{
|
||||
@@ -67,5 +71,8 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,11 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
MountParser::MountParser()
|
||||
{
|
||||
dirs = 0;
|
||||
@@ -494,9 +499,5 @@ void MountParser::Parse(const std::wstring & input, std::map<long, Mount> & outp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -22,6 +22,11 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class MountParser
|
||||
{
|
||||
public:
|
||||
@@ -82,4 +87,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009-2012, Tomasz Sowa
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Mounts::Mounts()
|
||||
{
|
||||
@@ -321,3 +325,8 @@ Mount * Mounts::GetEmptyMount()
|
||||
{
|
||||
return &empty_mount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009-2012, Tomasz Sowa
|
||||
* Copyright (c) 2009-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -23,6 +23,11 @@
|
||||
#include "mountparser.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class Mounts
|
||||
{
|
||||
@@ -165,5 +170,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,9 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
void Plugin::UnloadPlugins()
|
||||
@@ -500,3 +503,6 @@ const Plugin::Plugins * Plugin::GetPlugins()
|
||||
return &plugins;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef headerfile_winix_core_plugin
|
||||
#define headerfile_winix_core_plugin
|
||||
@@ -26,6 +25,12 @@
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
all your plugin functions can have signature either:
|
||||
void my_function(PluginInfo & info); or
|
||||
@@ -246,5 +251,9 @@ private:
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "session.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
PluginData::PluginData()
|
||||
@@ -153,3 +157,8 @@ size_t old_size = table.size();
|
||||
for(size_t i = old_size ; i<new_size ; ++i)
|
||||
table[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,11 @@
|
||||
#define headerfile_winix_core_plugindata
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Session;
|
||||
@@ -65,5 +70,8 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,12 @@
|
||||
#define headerfile_winix_core_pluginmsg
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// here you can add your own EZC functions ([function])
|
||||
// PluginInfo.p1 is a pointer to Ezc::Functions object
|
||||
// session pointer is null
|
||||
@@ -255,6 +261,15 @@
|
||||
// to the resource
|
||||
#define WINIX_CHECK_PLUGIN_ACCESS 31060
|
||||
|
||||
// http headers (without cookies) were created and are ready to send
|
||||
// here you can make some changes to them
|
||||
// in p1 you have a pointer to the PT::Space (Request::out_headers)
|
||||
#define WINIX_PREPARE_TO_SEND_HTTP_HEADERS 31070
|
||||
|
||||
// http cookies were created and are ready to send
|
||||
// here you can make some changes to them
|
||||
// in p1 you have a pointer to the PT::Space (Request::out_cookies)
|
||||
#define WINIX_PREPARE_TO_SEND_HTTP_COOKIES 31080
|
||||
|
||||
|
||||
/*
|
||||
@@ -283,5 +298,9 @@
|
||||
// see plugins/ticket/pluginmsg.h
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,12 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
PostMultiParser::PostMultiParser()
|
||||
{
|
||||
in_buffer = new unsigned char[WINIX_POSTMULTI_INPUT_BUFFER];
|
||||
@@ -586,3 +592,8 @@ Error PostMultiParser::Parse(FCGX_Stream * in_, PostTab & post_tab_, PostFileTab
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -19,6 +19,11 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
// 2 MB
|
||||
#define WINIX_POSTMULTI_INPUT_BUFFER 2097152
|
||||
#define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152
|
||||
@@ -128,5 +133,8 @@ return added;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class PostParser : public HttpSimpleParser
|
||||
{
|
||||
@@ -148,4 +152,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,11 @@
|
||||
#include "cur.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void Rebus::SetCur(Cur * pcur)
|
||||
{
|
||||
@@ -162,9 +167,5 @@ return false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
13
core/rebus.h
13
core/rebus.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,11 +10,15 @@
|
||||
#ifndef headerfile_winix_core_rebus
|
||||
#define headerfile_winix_core_rebus
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Cur;
|
||||
|
||||
|
||||
@@ -48,4 +52,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -14,6 +14,9 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +24,7 @@
|
||||
Request::Request() : char_empty(0)
|
||||
{
|
||||
id = 0;
|
||||
config = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +38,22 @@ void Request::SetConfig(Config * pconfig)
|
||||
|
||||
void Request::ClearOutputStreams()
|
||||
{
|
||||
out_streams.resize(16); // !! IMPROVE ME add as a constant somewhere
|
||||
size_t len = 16;
|
||||
|
||||
if( config )
|
||||
len = config->ezc_out_streams_size;
|
||||
|
||||
if( len < 1 || len > 64 )
|
||||
len = 16;
|
||||
|
||||
out_streams.resize(len);
|
||||
use_html_filter.resize(len);
|
||||
|
||||
for(size_t i=0 ; i<out_streams.size() ; ++i)
|
||||
{
|
||||
out_streams[i].Clear();
|
||||
use_html_filter[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,16 +70,12 @@ void Request::Clear()
|
||||
post_file_tab.clear();
|
||||
cookie_tab.clear();
|
||||
|
||||
method = none;
|
||||
role = responder;
|
||||
method = unknown_method;
|
||||
|
||||
headers.Clear();
|
||||
|
||||
|
||||
debug.Clear();
|
||||
out_headers.Clear();
|
||||
out_cookies.Clear();
|
||||
|
||||
page_generated = false;
|
||||
use_html_filter = true;
|
||||
|
||||
env_request_method = &char_empty;
|
||||
env_request_uri = &char_empty;
|
||||
@@ -81,7 +93,7 @@ void Request::Clear()
|
||||
dir_tab.clear();
|
||||
last_item = &item;
|
||||
is_item = false;
|
||||
function = 0; // !! dodac jakas empty funkcje
|
||||
function = 0;
|
||||
param_tab.clear();
|
||||
anchor.clear();
|
||||
|
||||
@@ -128,43 +140,6 @@ void Request::RequestStarts()
|
||||
|
||||
|
||||
|
||||
// value can be null
|
||||
void Request::SetCookie(const char * name, const char * value, PT::Date * expires)
|
||||
{
|
||||
headers << "Set-Cookie: " << name << "=";
|
||||
|
||||
if( value && value[0]!=0 )
|
||||
headers << value;
|
||||
else
|
||||
headers << "\"\"";
|
||||
|
||||
if( expires )
|
||||
headers << "; expires=" << DateToStrCookie(*expires) << " GMT";
|
||||
|
||||
headers << "; path=/; domain=" << config->base_url << "\r\n";
|
||||
|
||||
/*
|
||||
don't use '; secure' flag if you are using both sites (with SSL
|
||||
and without SSL) -- with secure flag the cookie is sent only through
|
||||
SSL and if you accidentally open a new window without SSL (http://)
|
||||
then winix will create a new session for you and the previous session (https://)
|
||||
will be lost (cookie is overwritten on the client browser)
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::SetCookie(const char * name, long value, PT::Date * expires)
|
||||
{
|
||||
headers << "Set-Cookie: " << name << "=" << value;
|
||||
|
||||
if( expires )
|
||||
headers << "; expires=" << DateToStrCookie(*expires) << " GMT";
|
||||
|
||||
headers << "; path=/; domain=" << config->base_url << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Request::IsPostVar(const wchar_t * var)
|
||||
{
|
||||
@@ -335,4 +310,7 @@ const std::wstring & Request::ParamValue(const std::wstring & param_name)
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
375
core/request.h
375
core/request.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -22,6 +22,12 @@
|
||||
#include "date/date.h"
|
||||
#include "space/space.h"
|
||||
#include "space/spacetojson.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,45 +38,185 @@ class FunctionBase;
|
||||
|
||||
struct Request
|
||||
{
|
||||
// request id
|
||||
// is incremented for each request and is never 0
|
||||
// (from -1 will be incremented twice)
|
||||
// it's used for some optimalizations e.g. in templates
|
||||
/*
|
||||
request id
|
||||
is incremented for each request and is never 0
|
||||
(from -1 will be incremented to one)
|
||||
it's used for some optimizations e.g. in templates
|
||||
*/
|
||||
size_t id;
|
||||
|
||||
// !! moze pozbyc sie tego none?
|
||||
enum Method { get, post, head, none } method;
|
||||
enum Role { responder, authorizer } role;
|
||||
|
||||
// headers, page and debug
|
||||
//std::ostringstream headers, page, debug;
|
||||
// !! IMPROVE ME change headers to some kind of a map, may PT::Space ?
|
||||
TextStream<std::string> headers;
|
||||
HtmlTextStream debug;
|
||||
/*
|
||||
request start time
|
||||
Time() methods are very slow so it is better to directly use those two values
|
||||
they are set when a request starts
|
||||
*/
|
||||
time_t start_time;
|
||||
PT::Date start_date;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
* variables representing input from client's browser
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
the HTTP method
|
||||
!! IMPROVE ME add the rest methods here
|
||||
*/
|
||||
enum Method { get, post, head, unknown_method } method;
|
||||
|
||||
|
||||
/*
|
||||
subdomain
|
||||
subdomain = HTTP_HOST environment variable - config->base_url
|
||||
*/
|
||||
std::wstring subdomain;
|
||||
|
||||
|
||||
/*
|
||||
raw parameters
|
||||
!! CHECK ME may post_tab and cookie_tab should be changed to PT::Space now?
|
||||
or may change the name to cookie_in? or in_cookie?
|
||||
*/
|
||||
PostTab post_tab;
|
||||
PostFileTab post_file_tab;
|
||||
CookieTab cookie_tab;
|
||||
|
||||
|
||||
/*
|
||||
html anchor (those part of URI after '#' character)
|
||||
*/
|
||||
std::wstring anchor;
|
||||
|
||||
|
||||
// environment variables
|
||||
// they are not null -- when the server doesn't have such a variable
|
||||
// it will be pointing into 'char_empty' which is default '\0'
|
||||
// !! IMPROVE ME change it to std::wstring, or may PT::Space too?
|
||||
const char * env_request_method;
|
||||
const char * env_request_uri;
|
||||
const char * env_http_cookie;
|
||||
const char * env_remote_addr;
|
||||
const char * env_http_host;
|
||||
const char * env_http_user_agent;
|
||||
const char * env_http_accept_encoding;
|
||||
const char * env_fcgi_role;
|
||||
const char * env_content_type;
|
||||
const char * env_https;
|
||||
|
||||
// current IP address of the remote host (read from REMOTE_ADDR environment variable)
|
||||
// (at the moment only IPv4 are supported)
|
||||
int ip;
|
||||
|
||||
// true if the browser is Microsoft Internet Explorer
|
||||
bool browser_msie;
|
||||
|
||||
// true if the browser is Konqueror
|
||||
bool browser_konqueror;
|
||||
|
||||
// true if we are using an encrypted connection (SSL)
|
||||
bool using_ssl;
|
||||
|
||||
|
||||
/*
|
||||
request input variables representing the winix filesystem
|
||||
*/
|
||||
|
||||
// current directory
|
||||
std::vector<Item*> dir_tab;
|
||||
|
||||
// true if a file exists
|
||||
bool is_item;
|
||||
|
||||
// current file (valid if is_item is true)
|
||||
Item item;
|
||||
|
||||
// current winix function
|
||||
// null if there is no a function
|
||||
FunctionBase * function;
|
||||
|
||||
// parameters (name:value)
|
||||
ParamTab param_tab;
|
||||
|
||||
// this is a pointer either to the item (if exists) or to the last directory
|
||||
Item * last_item;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
* variables for generating output to the client's browser
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// request status
|
||||
// !! CHANGE ME it'll be better to use ordinary http result codes
|
||||
Error status;
|
||||
|
||||
// if not empty means an address for redirecting to
|
||||
// it should be url-encoded
|
||||
std::wstring redirect_to;
|
||||
|
||||
// a redirect type
|
||||
// following redirect types are supported:
|
||||
// 300 Multiple Choices
|
||||
// 301 Moved Permanently
|
||||
// 302 Found
|
||||
// 303 See Other (default)
|
||||
// 307 Temporary Redirect
|
||||
int redirect_type;
|
||||
|
||||
// send header X-LIGHTTPD-send-file with path to a file
|
||||
std::wstring x_sendfile;
|
||||
|
||||
// send as attachment (causes generating header: content-disposition: attachment)
|
||||
bool send_as_attachment;
|
||||
|
||||
// headers send to the client (without cookies)
|
||||
PT::Space out_headers;
|
||||
|
||||
// cookies send to the client
|
||||
// a value can be either a cookie value or the whole cookie string (with domain, date etc)
|
||||
PT::Space out_cookies;
|
||||
|
||||
// winix can return either a text answer or a binary answer
|
||||
// if send_bin_stream is true then the binary answer is sent (out_bin_stream)
|
||||
// or if send_bin_stream is false then the text answer is sent
|
||||
// default: false
|
||||
//
|
||||
//
|
||||
//
|
||||
// winix answer send to the client's browser
|
||||
// |
|
||||
// |
|
||||
// depending on send_bin_stream
|
||||
// -------------------------------------------------
|
||||
// (if false) ------------------------------------------------- (if true)
|
||||
// | |
|
||||
// text answer binary answer
|
||||
// | |
|
||||
// depending on return_json sending out_bin_stream
|
||||
// ------------------------------------
|
||||
// (if false) ------------------------------------ (if true)
|
||||
// | |
|
||||
// normal request ajax request
|
||||
// | |
|
||||
// sending out_streams[0] depending on return_info_only
|
||||
// ------------------------------------------------------
|
||||
// sending out_streams[0] |
|
||||
// |
|
||||
// |
|
||||
// depending on return_info_only
|
||||
// (if false) ------------------------------------------------------ (if true)
|
||||
// | |
|
||||
// generating JSON object from: generating JSON object only from info
|
||||
// out_streams and info, e.g.: e.g.:
|
||||
@@ -85,24 +231,9 @@ struct Request
|
||||
//
|
||||
bool send_bin_stream;
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// binary answer
|
||||
//
|
||||
|
||||
// binary page sent to the client if send_bin_stream is true
|
||||
BinaryPage out_bin_stream;
|
||||
|
||||
//
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// text answer
|
||||
//
|
||||
|
||||
// when returning the text answer we can either return the whole html page (normal requests)
|
||||
// or a JSON object (for requests generated from AJAX)
|
||||
// if return_json is false then we return the whole html page (which is in out_streams[0])
|
||||
@@ -135,111 +266,20 @@ struct Request
|
||||
// default: null (json_generic_serializer used)
|
||||
PT::SpaceToJSON * info_serializer;
|
||||
|
||||
//
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// if set to true then the standard template system will not be generated
|
||||
|
||||
// if set to true then the standard template system will not be used
|
||||
// default: false
|
||||
bool page_generated;
|
||||
|
||||
// whether or not the html filter should be used
|
||||
// default: true
|
||||
bool use_html_filter;
|
||||
// the size of the table is the same as out_streams
|
||||
// default: all items true
|
||||
std::vector<bool> use_html_filter;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// raw parameters
|
||||
PostTab post_tab;
|
||||
PostFileTab post_file_tab;
|
||||
CookieTab cookie_tab;
|
||||
|
||||
// html anchor (those part of URI after '#' character)
|
||||
std::wstring anchor;
|
||||
|
||||
// environment variables
|
||||
// they are not null -- when the server doesn't have such a variable
|
||||
// it will be pointing into 'char_empty' which is default '\0'
|
||||
const char * env_request_method;
|
||||
const char * env_request_uri;
|
||||
const char * env_http_cookie;
|
||||
const char * env_remote_addr;
|
||||
const char * env_http_host;
|
||||
const char * env_http_user_agent;
|
||||
const char * env_http_accept_encoding;
|
||||
const char * env_fcgi_role;
|
||||
const char * env_content_type;
|
||||
const char * env_https;
|
||||
|
||||
// current IP address of the remote host (read from REMOTE_ADDR environment variable)
|
||||
// (at the moment only IPv4 are supported)
|
||||
int ip;
|
||||
|
||||
// true if the browser is Microsoft Internet Explorer
|
||||
bool browser_msie;
|
||||
|
||||
// true if the browser is Konqueror
|
||||
bool browser_konqueror;
|
||||
|
||||
// true if we are using encrypted connection (SSL)
|
||||
bool using_ssl;
|
||||
|
||||
// current directory
|
||||
std::vector<Item*> dir_tab;
|
||||
|
||||
// true if a file exists
|
||||
bool is_item;
|
||||
|
||||
// current file (if exists)
|
||||
Item item;
|
||||
|
||||
// current winix function
|
||||
// null if there is no a function
|
||||
FunctionBase * function;
|
||||
|
||||
// parameters (name:value)
|
||||
ParamTab param_tab;
|
||||
|
||||
// request status
|
||||
Error status;
|
||||
|
||||
// usually items in the current directory (depends on the function)
|
||||
std::vector<Item> item_tab;
|
||||
|
||||
// if not empty means an address for redirecting to
|
||||
// it should be url-encoded
|
||||
std::wstring redirect_to;
|
||||
std::string aredirect_to;
|
||||
|
||||
// a redirect type
|
||||
// following redirect types are supported:
|
||||
// 300 Multiple Choices
|
||||
// 301 Moved Permanently
|
||||
// 302 Found
|
||||
// 303 See Other (default)
|
||||
// 307 Temporary Redirect
|
||||
int redirect_type;
|
||||
|
||||
// send header X-LIGHTTPD-send-file with path to a file
|
||||
std::wstring x_sendfile;
|
||||
|
||||
// send as attachment (causes header: content-disposition: attachment)
|
||||
bool send_as_attachment;
|
||||
|
||||
// this is a pointer either to the item (if exists) or to the last directory
|
||||
Item * last_item;
|
||||
|
||||
// request start time
|
||||
// Time() methods are very slow so it is better to directly use those two values
|
||||
// they are set when a request starts
|
||||
time_t start_time;
|
||||
PT::Date start_date;
|
||||
|
||||
// a subdomain
|
||||
// subdomain = HTTP_HOST environment variable - config->base_url
|
||||
std::wstring subdomain;
|
||||
|
||||
// if this variable is true then winix always return 200 OK header
|
||||
// when the status would be 404 (not found) or 403 (permission denied)
|
||||
@@ -252,8 +292,27 @@ struct Request
|
||||
bool gen_use_special_chars;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
additional variables used for common uses
|
||||
*/
|
||||
|
||||
// usually items in the current directory (depends on the function)
|
||||
std::vector<Item> item_tab;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Request();
|
||||
void SetConfig(Config * pconfig);
|
||||
|
||||
void RequestStarts();
|
||||
void Clear();
|
||||
|
||||
@@ -261,29 +320,32 @@ struct Request
|
||||
|
||||
bool IsParam(const wchar_t * param_name);
|
||||
bool IsParam(const std::wstring & param_name);
|
||||
|
||||
const std::wstring & ParamValue(const wchar_t * param_name); // returns an empty string if there is no such a parameter
|
||||
const std::wstring & ParamValue(const std::wstring & param_name); // returns an empty string if there is no such a parameter
|
||||
|
||||
void SetCookie(const char * name, const char * value, PT::Date * expires = 0);
|
||||
void SetCookie(const char * name, long value, PT::Date * expires = 0);
|
||||
|
||||
bool IsPostVar(const wchar_t * var);
|
||||
bool IsPostVar(const std::wstring & var);
|
||||
|
||||
const std::wstring & PostVar(const wchar_t * var); // returns an empty string if there is no such a parameter
|
||||
const std::wstring & PostVar(const std::wstring & var); // returns an empty string if there is no such a parameter
|
||||
|
||||
|
||||
bool PostVar(const wchar_t * var, std::wstring & result);
|
||||
bool PostVar(const std::wstring & var, std::wstring & result);
|
||||
|
||||
std::wstring * PostVarp(const wchar_t * var);
|
||||
std::wstring * PostVarp(const std::wstring & var);
|
||||
|
||||
bool AllPostVarEmpty(); // returning true if all post vars are empty
|
||||
|
||||
void SendAll();
|
||||
|
||||
// setting a cookie
|
||||
// name - cookie name (either const wchar_t, or std::wstring or PT::WTextStream)
|
||||
// value - cookie value (can be everything which can be put to PT::WTextStream stream)
|
||||
// the return std::wstring reference is a reference to the cookie inserted value (in out_cookies structure)
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & AddCookie(const NameType & name, const ValueType & value, PT::Date * expires = 0);
|
||||
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & AddCookie(const NameType & name, const ValueType & value, PT::Date & expires);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
@@ -303,8 +365,45 @@ private:
|
||||
|
||||
|
||||
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & Request::AddCookie(const NameType & name, const ValueType & value, PT::Date * expires)
|
||||
{
|
||||
PT::WTextStream cookie;
|
||||
|
||||
cookie << value;
|
||||
|
||||
if( cookie.empty() )
|
||||
cookie << L"\"\""; // cookie empty value
|
||||
|
||||
if( expires )
|
||||
cookie << L"; expires=" << DateToStrCookie(*expires) << L" GMT";
|
||||
|
||||
cookie << L"; path=/; domain=" << config->base_url;
|
||||
|
||||
/*
|
||||
!! IMPROVE ME add an option to the config
|
||||
|
||||
don't use '; secure' flag if you are using both sites (with SSL
|
||||
and without SSL) -- with secure flag the cookie is sent only through
|
||||
SSL and if you accidentally open a new window without SSL (http://)
|
||||
then winix will create a new session for you and the previous session (https://)
|
||||
will be lost (the session cookie will be overwritten in the client's browser)
|
||||
*/
|
||||
|
||||
return out_cookies.Add(name, cookie);
|
||||
}
|
||||
|
||||
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & Request::AddCookie(const NameType & name, const ValueType & value, PT::Date & expires)
|
||||
{
|
||||
return AddCookie(name, value, &expires);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,12 @@
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// !! narazie uzywane tylko w post multi parserze
|
||||
// dodac do zwyklego parsera post
|
||||
#define WINIX_POSTTABLE_MAXSIZE 50
|
||||
@@ -43,10 +49,14 @@ typedef std::map<std::wstring, std::wstring> PostTab;
|
||||
typedef std::map<std::wstring, PostFile> PostFileTab;
|
||||
typedef std::vector<Param> ParamTab;
|
||||
|
||||
typedef std::map<std::string, std::string> CookieTab;
|
||||
typedef std::map<std::wstring, std::wstring> CookieTab;
|
||||
|
||||
|
||||
typedef PT::TextStreamBase<char, 1, 4096> BinaryPage;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
11
core/run.cpp
11
core/run.cpp
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,11 +11,17 @@
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <cstring>
|
||||
#include "run.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Run::Run()
|
||||
{
|
||||
@@ -384,3 +390,6 @@ int Run::Go(std::string & out)
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
11
core/run.h
11
core/run.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2013, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,11 @@
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*
|
||||
how many parameters and environment variables can be passed to a program
|
||||
*/
|
||||
@@ -160,5 +165,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Session::Session()
|
||||
@@ -86,9 +89,13 @@ void Session::Clear(bool clear_plugin_data)
|
||||
|
||||
|
||||
// clearing some variables when a request is ended (just for safety)
|
||||
void Session::ClearOnEndRequest()
|
||||
void Session::ClearAfterRequest()
|
||||
{
|
||||
// ip_ban list can be sorted by SessionManager (in the special thread)
|
||||
ip_ban = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -23,6 +23,10 @@
|
||||
#include "ipban.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Session
|
||||
{
|
||||
@@ -32,7 +36,7 @@ struct Session
|
||||
|
||||
void SetTimesTo(time_t time);
|
||||
void Clear(bool clear_plugin_data = true);
|
||||
void ClearOnEndRequest();
|
||||
void ClearAfterRequest();
|
||||
|
||||
|
||||
// 0 - means that there is a temporary session
|
||||
@@ -95,6 +99,9 @@ struct Session
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,11 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
SessionContainer::SessionContainer()
|
||||
{
|
||||
@@ -207,5 +212,8 @@ return false;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -19,6 +19,11 @@
|
||||
#include "config.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class SessionContainer
|
||||
{
|
||||
@@ -71,4 +76,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +160,7 @@ void SessionManager::SetTemporarySession()
|
||||
|
||||
|
||||
|
||||
bool SessionManager::SetSessionFromCookie(const std::string & cookie)
|
||||
bool SessionManager::SetSessionFromCookie(const std::wstring & cookie)
|
||||
{
|
||||
long id = Tol(cookie.c_str());
|
||||
SessionContainer::Iterator s = session_tab.FindById(id);
|
||||
@@ -603,3 +606,6 @@ void SessionManager::DeleteSession(Session * del_session)
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -24,6 +24,11 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class SessionManager : public BaseThread
|
||||
{
|
||||
public:
|
||||
@@ -88,7 +93,7 @@ private:
|
||||
|
||||
long CreateSessionId();
|
||||
void CreateSession();
|
||||
bool SetSessionFromCookie(const std::string & cookie);
|
||||
bool SetSessionFromCookie(const std::wstring & cookie);
|
||||
void SetTemporarySession();
|
||||
|
||||
// second thread
|
||||
@@ -102,4 +107,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,10 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
bool SessionParser::Parse(const std::string & path, SessionContainer & container)
|
||||
{
|
||||
@@ -166,3 +170,7 @@ bool is_sign = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,10 @@
|
||||
#include "users.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class SessionParser
|
||||
{
|
||||
@@ -46,5 +50,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "slog.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
SLog::SLog()
|
||||
@@ -222,3 +226,6 @@ SLog & SLog::operator<<(TranslateTextHelper<std::wstring> raw)
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
11
core/slog.h
11
core/slog.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,11 @@
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
#define WINIX_SLOG_MAX_LOG_SIZE 10240
|
||||
|
||||
|
||||
@@ -137,5 +142,9 @@ return *this;
|
||||
extern SLog slog;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,11 @@
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Synchro::Synchro() : mutex(PTHREAD_MUTEX_INITIALIZER)
|
||||
{
|
||||
was_stop_signal = false;
|
||||
@@ -54,4 +59,5 @@ void Synchro::Unlock()
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,10 @@
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Synchro
|
||||
{
|
||||
@@ -38,6 +42,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,12 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void System::SetCur(Cur * pcur)
|
||||
{
|
||||
cur = pcur;
|
||||
@@ -1207,6 +1213,8 @@ int System::FollowAllLinks(const std::vector<Item*> & current_dir_tab, const std
|
||||
}
|
||||
else
|
||||
{
|
||||
// !! CHECK ME
|
||||
// FollowLink is using link_to_temp temporary variable too
|
||||
res = FollowLink(current_dir_tab, link_to_temp, out_dir_tab, out_item);
|
||||
link_to_temp.clear();
|
||||
|
||||
@@ -1367,3 +1375,7 @@ bool System::AddCommonFileToVar(const wchar_t * file_path, const wchar_t * url,
|
||||
return AddFile(file_content_item, false) == WINIX_ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -29,6 +29,11 @@
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class Functions;
|
||||
class SessionManager;
|
||||
|
||||
@@ -211,5 +216,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -18,6 +18,11 @@
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
a special class representing a stream buffer
|
||||
@@ -42,6 +47,9 @@ public:
|
||||
const StringType & Str() const;
|
||||
const CharType * CStr() const;
|
||||
|
||||
void Str(const StringType & str);
|
||||
void Str(const StringType && str);
|
||||
|
||||
CharType operator[](size_t index);
|
||||
|
||||
TextStream & operator<<(const char * str);
|
||||
@@ -71,6 +79,7 @@ public:
|
||||
TextStream & write(const char * buf, size_t len); // for compatibility with standard library (Ezc uses it)
|
||||
TextStream & write(const wchar_t * buf, size_t len);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
StringType buffer;
|
||||
@@ -118,6 +127,21 @@ const typename TextStream<StringType>::CharType * TextStream<StringType>::CStr()
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Str(const StringType & str)
|
||||
{
|
||||
buffer = str;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Str(const StringType && str)
|
||||
{
|
||||
buffer = str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
typename TextStream<StringType>::CharType TextStream<StringType>::operator[](size_t index)
|
||||
{
|
||||
@@ -345,5 +369,11 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,12 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
ThreadManager::ThreadManager()
|
||||
{
|
||||
were_started = false;
|
||||
@@ -134,3 +140,6 @@ void ThreadManager::StopAll()
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,11 @@
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class ThreadManager
|
||||
{
|
||||
@@ -61,5 +66,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,6 +11,10 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
TimeZone::Dst::Dst()
|
||||
@@ -287,3 +291,7 @@ return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,12 @@
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class TimeZone
|
||||
{
|
||||
public:
|
||||
@@ -132,10 +138,7 @@ private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,10 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
TimeZones::TimeZones()
|
||||
{
|
||||
@@ -174,5 +178,5 @@ bool TimeZones::ReadTimeZones(const std::wstring & path)
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,11 @@
|
||||
#include "space/spaceparser.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class TimeZones
|
||||
{
|
||||
@@ -77,5 +82,8 @@ private:
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
class UGContainer
|
||||
@@ -274,4 +278,8 @@ return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,11 @@
|
||||
#include "user.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
User::User()
|
||||
{
|
||||
Clear();
|
||||
@@ -47,19 +52,6 @@ return false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
10
core/user.h
10
core/user.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,6 +16,11 @@
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
#define WINIX_ACCOUNT_MAX_LOGIN_SIZE 250
|
||||
#define WINIX_ACCOUNT_MAX_PASSWORD_SIZE 250
|
||||
#define WINIX_ACCOUNT_MAX_EMAIL_SIZE 250
|
||||
@@ -105,4 +110,7 @@ struct User
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Users::Users()
|
||||
{
|
||||
@@ -292,3 +296,6 @@ long Users::HowManyLogged()
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
10
core/users.h
10
core/users.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,12 @@
|
||||
#include "cur.h"
|
||||
#include "db/db.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class SessionManager;
|
||||
|
||||
|
||||
@@ -71,7 +77,7 @@ private:
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,9 +11,17 @@
|
||||
#define headerfile_winix_core_version
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
#define WINIX_VER_MAJOR 0
|
||||
#define WINIX_VER_MINOR 5
|
||||
#define WINIX_VER_REVISION 6
|
||||
#define WINIX_VER_MINOR 6
|
||||
#define WINIX_VER_REVISION 0
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,9 @@
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1732,3 +1735,6 @@ void Db::GetGroups(UGContainer<Group> & group_tab)
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user