Compare commits

17 Commits

Author SHA1 Message Date
tomasz.sowa 01892d2766 added: flag has_pass to User structure
if false that means the user has not set a password yet 
       (this can be used by a plugins to create a new account without a password set)
       in order to login the user first has to set a new password
       (this can be done from a some kind of activation link send via email etc)
       



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@954 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-06-07 11:20:44 +00:00
tomasz.sowa 222955a2e7 fixed: in Synchro: we should have a table (map) of reference counters
each one for each thread
fixed: on Linux: pthread mutexes by default behaves differently than on FreeBSD
       we have to set PTHREAD_MUTEX_ERRORCHECK attribute 
       when creating a mutex
       



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@953 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-14 11:20:22 +00:00
tomasz.sowa 37b22c3559 added: some debug logs to export plugin
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@952 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-12 22:32:06 +00:00
tomasz.sowa afbd522362 fixed: in Makefile: 'cp' in Linux behaves differently
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@951 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-12 20:49:50 +00:00
tomasz.sowa a4bed3ab14 fixed: compiling on Debian with GCC 4.8
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@950 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-12 17:21:42 +00:00
tomasz.sowa 7468e7a36c added: namespace Winix over all *.h/*.cpp files
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@948 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-12 16:30:49 +00:00
tomasz.sowa 145445c713 changed: now we use curl to fetch a page from the special thread when winix quits
(before we were using BSD's fetch)
fixed:   we didn't use FCGX_Finish_r() on the request made from the special thread
         so the thread hangs (now we can use pthread_join correctly from the main thread)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@947 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-11 21:00:32 +00:00
tomasz.sowa 7fa9314c6b changed: in ClearOutputStreams() referencing 'config' only if not null
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@946 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-12-23 03:29:33 +00:00
tomasz.sowa 5d37b6c6ae fixed: winix incorrectly sent the binary stream
headers and cookies were not sent
       (instead of headers the content was sent, so the client's browser was unable to open it correctly)
added: standard http headers are added by winix only if there are not such headers already
       e.g. if a plugin adds "Content-Type" header then winix will not overwrite it 
       (headers names are case sensitive)


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@945 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-12-19 17:19:47 +00:00
tomasz.sowa fe1f84e29d added: -O0 -g for CXXFLAGS for temporarily debugging
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@944 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-12-18 12:13:28 +00:00
tomasz.sowa 83e27a6653 fixed: problem with building
added #include <utility> to App (for std::move)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@943 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-12-09 16:03:45 +00:00
tomasz.sowa ee9c68b04e added: generating Content-Length header when text answer is sent to the client
added:   now we are able to use the html filter for the whole out_streams (when ajax is used the output is filtered too)
         splitted FilterCompressSend() function -- first we are making the filtering
         (after filtering we know the size of the content to send)
added:   to Compress:
         Compressing(const char * source, size_t source_len, BinaryPage & out_stream, int encoding);
changed: some refactoring in App




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@942 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-12-04 01:21:57 +00:00
tomasz.sowa c04874397b fixed: security vulnerability in 'ln' winix function
a user could create a hardlink to any file and the new link 
       had user_id, group_id and permissions the same as for new generated files,
       this allowes to overwrite any existing file in the filesystem,
       now user_id, group_id, permissions are the same as from the oryginal file



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@941 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-12-03 12:33:41 +00:00
tomasz.sowa 375604edd6 removed: Request::debug all stream used for debugging info
some environment variables were put there
removed: config variable: debug_info
removed: Request::role (responder, authorizer)
         now we have only one role: responder
added:   new config variables:
         log_env_variables (default false) - when true then fastcgi environment
         variables are logged to the log file
         log_http_answer_headers (default false) - when true all http headers
         created by winix ale logged (note that the www server can add/adjust other headers)
changed: some refactoring in Request struct
changed: CookieTab to std::map<std::wstring, std::wstring>
         beforehand std::string was used
         (changed CookieParser as well)
changed: Request::SetCookie() to AddCookie()
added:   Request::out_headers (a PT::Space struct)
         http headers (without cookies) send back to the client
added:   Request::out_cookies (a PT::Space struct)
         cookies send to the client
changed: App class to use Request::out_headers and Request::out_cookies
         some SendHeaders...() methods were renamed to PrepareHeaders...()
         and they create output in Request::out_headers first (and out_cookies)
         and later it is sent
added:   two plugin messages:
         // 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
added:   config variable:
         // how many output streams do we have in Request class
         // default: 16 (64 maximum)
         size_t ezc_out_streams_size;




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@940 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-29 21:39:23 +00:00
tomasz.sowa 3e32f3784f removed: -O0 -g from production Makefile
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@939 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-25 23:44:01 +00:00
tomasz.sowa 5c4a54d998 added: -O0 -g to the production Makefile
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@938 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-25 23:37:52 +00:00
tomasz.sowa 3af3ac3f6f removed: ezn patterns for rawcontent and ajaxcontent:
index_rawcontent.html, index_ajaxcontent.html
         now we have out_streams in Request and some special
         keyword in ezc templates for sending content to the 
         specified streams
changed: the way how winix answers to the client's browsers:
         info from Request class:
	                                   winix answer send to the client's browser
	                                                       |
	                                                       |
	                                          depending on send_bin_stream
	                               -------------------------------------------------
	                               |                                               |
	                          text answer                                     binary answer
	                               |                                               |
	                   depending on return_json                          sending out_bin_stream
	             ------------------------------------
	             |                                  |
	       normal request                     ajax request
	             |                                  |
	   sending out_streams[0]           depending on return_info_only
	                              ------------------------------------------------------
	                              |                                                    |
	                 generating JSON object from:                   generating JSON object only from info
	                 out_streams and info, e.g.:                    e.g.:
	                 {                                              { info object serialized here }
	                  "stream_1": "some html content",
	                  "stream_2": "some other html content",
	                  "info": { info object serialized here }
	                 }
	                 note that out_streams[0] is not sent
	                 in JSON answers
	
	




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@937 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-14 20:59:23 +00:00
339 changed files with 3544 additions and 1026 deletions
+14 -11
View File
@@ -3,13 +3,16 @@
include Makefile.dep include Makefile.dep
#ifndef CXX ifeq ($(OSTYPE), FreeBSD)
# temporarily workaround: forcing using clang (CXX is defined by the OS and is equal to g++) CXX = clang++
CXX = clang++ else
#endif CXX = g++-4.8
endif
ifndef CXXFLAGS 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 -I/usr/include/postgresql -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
endif endif
@@ -51,12 +54,12 @@ winix.so: $(winix.src.files)
@cd ../ezc/src ; $(MAKE) -e @cd ../ezc/src ; $(MAKE) -e
@cd ../tito/src ; $(MAKE) -e @cd ../tito/src ; $(MAKE) -e
@cd ../pikotools ; $(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 -lpthread -lcurl -Wl,-no-whole-archive
winix: winix.so $(winix.src.files) winix: winix.so $(winix.src.files)
@cd main ; $(MAKE) -e @cd main ; $(MAKE) -e
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so $(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so -lfcgi
@@ -131,19 +134,19 @@ install: all
# etc configs # etc configs
rm -Rf $(winix_install_dir)/etc rm -Rf $(winix_install_dir)/etc
mkdir -p $(winix_install_dir)/etc mkdir -p $(winix_install_dir)/etc
cp -rf etc/ $(winix_install_dir)/etc/ cp -rf etc/* $(winix_install_dir)/etc/
# html templates # html templates
rm -Rf $(winix_install_dir)/html rm -Rf $(winix_install_dir)/html
mkdir -p $(winix_install_dir)/html mkdir -p $(winix_install_dir)/html
cp -rf html/ $(winix_install_dir)/html/ cp -rf html/* $(winix_install_dir)/html/
# txt templates # txt templates
rm -Rf $(winix_install_dir)/txt rm -Rf $(winix_install_dir)/txt
mkdir -p $(winix_install_dir)/txt mkdir -p $(winix_install_dir)/txt
cp -rf txt/ $(winix_install_dir)/txt/ cp -rf txt/* $(winix_install_dir)/txt/
# locales # locales
rm -Rf $(winix_install_dir)/locale rm -Rf $(winix_install_dir)/locale
mkdir -p $(winix_install_dir)/locale mkdir -p $(winix_install_dir)/locale
cp -rf locale/ $(winix_install_dir)/locale/ cp -rf locale/* $(winix_install_dir)/locale/
# plugins # plugins
rm -Rf $(winix_install_dir)/plugins rm -Rf $(winix_install_dir)/plugins
mkdir -p $(winix_install_dir)/plugins mkdir -p $(winix_install_dir)/plugins
+1 -1
View File
File diff suppressed because one or more lines are too long
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,11 @@
#include "acceptbaseparser.h" #include "acceptbaseparser.h"
namespace Winix
{
bool AcceptBaseParser::IsWhite(int c) bool AcceptBaseParser::IsWhite(int c)
{ {
@@ -112,3 +117,7 @@ void AcceptBaseParser::Parse(const char * str)
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,11 @@
#include <string> #include <string>
namespace Winix
{
// sample (you must create your own class derived from this one): // 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 "); // 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 #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,11 @@
#include "log.h" #include "log.h"
namespace Winix
{
class AcceptEncodingParser : public AcceptBaseParser class AcceptEncodingParser : public AcceptBaseParser
{ {
public: public:
@@ -82,4 +87,7 @@ private:
} // namespace Winix
#endif #endif
+412 -225
View File
File diff suppressed because it is too large Load Diff
+43 -23
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2013, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -37,6 +37,12 @@
namespace Winix
{
class App class App
{ {
public: public:
@@ -87,7 +93,7 @@ public:
Functions functions; Functions functions;
// false at the beginning // false at the beginning
// !! moze to do loggera dac? // !! IMPROVE ME moze to do loggera dac?
bool stdout_is_closed; bool stdout_is_closed;
@@ -112,17 +118,18 @@ private:
CookieParser cookie_parser; CookieParser cookie_parser;
AcceptEncodingParser accept_encoding_parser; AcceptEncodingParser accept_encoding_parser;
Compress compress; Compress compress;
std::wstring clean_html, html_with_debug;
FCGX_Request fcgi_request; FCGX_Request fcgi_request;
int fcgi_socket; int fcgi_socket;
Synchro synchro; Synchro synchro;
pthread_t signal_thread; pthread_t signal_thread;
std::string url_to_fetch_on_exit; 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; std::string send_data_buf;
PT::SpaceToJSON ajax_generic_serializer; PT::SpaceToJSON json_generic_serializer;
TextStream<std::wstring> json_out_stream;
std::string aheader_name, aheader_value;
std::wstring html_filtered;
std::string output_8bit;
BinaryPage compressed_output;
bool CheckAccessFromPlugins(); bool CheckAccessFromPlugins();
void ProcessRequestThrow(); void ProcessRequestThrow();
@@ -134,16 +141,17 @@ private:
void CheckPostRedirect(); void CheckPostRedirect();
void MakePage(); void MakePage();
void Make(); void Make();
void SaveSessionsIfNeeded(); // !! wywalic do menagera sesji?? void SaveSessionsIfNeeded(); // !! IMPROVE ME wywalic do menagera sesji??
void LogAccess(); void LogAccess();
void SendData(const BinaryPage & page, FCGX_Stream * out); void SendData(const BinaryPage & page, FCGX_Stream * out);
void CreateJSONAnswer();
void ReadRequest(); void ReadRequest();
void SendTextAnswer(); void SendTextAnswer();
void SendBinaryAnswer(); void SendBinaryAnswer();
void SendAnswer(); void SendAnswer();
void PrintEnv(); void LogEnvironmentVariables();
void SetEnv(const char * & env, const char * name); void SetEnv(const char * & env, const char * name);
void ReadEnvVariables(); void ReadEnvVariables();
@@ -152,25 +160,32 @@ private:
void CheckIE(); void CheckIE();
void CheckKonqueror(); void CheckKonqueror();
void CheckRequestMethod(); void CheckRequestMethod();
void CheckFCGIRole();
void CheckSSL(); void CheckSSL();
void SetSubdomain(); void SetSubdomain();
Header GetHTTPStatusCode();
void PrepareSessionCookie(); void PrepareSessionCookie();
void AddDebugInfo(std::wstring & out); void FilterContent();
void FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref); void SendHeaders();
bool SendHeadersStaticCreateResource(); void SendCookies();
void SendHeadersStatic(); bool AddHeader(const wchar_t * name, const wchar_t * value);
void SendHeaderContentType(); bool AddHeader(const std::wstring & name, const std::wstring & value);
void SendHeadersForbidden(); bool AddHeader(const wchar_t * name, const PT::WTextStream & value);
void SendHeadersRedirect(); bool AddHeader(const std::wstring & name, const PT::WTextStream & value);
void SendHeadersSendFile(); bool PrepareHeadersStaticCreateResource(PT::WTextStream & out_path);
void SendHeadersCompression(int compress_encoding); void PrepareHeadersStatic();
void SendHeadersNormal(Header header); void PrepareHeaderContentType();
void SendHeaders(bool compressing, int compress_encoding, Header header); 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(); int SelectDeflateVersion();
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding); 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 LogUser(const char * msg, uid_t id);
void LogGroup(const char * msg, gid_t id, bool put_logend = true); void LogGroup(const char * msg, gid_t id, bool put_logend = true);
@@ -184,10 +199,15 @@ private:
void CreateStaticTree(); void CreateStaticTree();
// !! dodac do session managera? // !! IMPROVE ME
// !! move to the session manager?
time_t last_sessions_save; time_t last_sessions_save;
}; };
} // namespace Winix
#endif #endif
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2011, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,9 @@
#include "basethread.h" #include "basethread.h"
namespace Winix
{
BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER) BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER)
{ {
@@ -237,3 +240,7 @@ pthread_attr_t attr;
return res == 0; return res == 0;
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,11 @@
#include "synchro.h" #include "synchro.h"
namespace Winix
{
class BaseThread class BaseThread
{ {
@@ -120,6 +125,9 @@ protected:
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,10 @@
#include "bbcodeparser.h" #include "bbcodeparser.h"
namespace Winix
{
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2) bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
@@ -590,3 +594,8 @@ void BBCODEParser::Uninit()
if( has_open_ul_tag ) if( has_open_ul_tag )
(*out_string) += L"</ul>\n"; (*out_string) += L"</ul>\n";
} }
} // namespace Winix
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,9 @@
#include "htmlfilter.h" #include "htmlfilter.h"
namespace Winix
{
class BBCODEParser : public HTMLFilter class BBCODEParser : public HTMLFilter
@@ -90,4 +93,8 @@ class BBCODEParser : public HTMLFilter
bool has_open_li_tag; // has open html <li> tag bool has_open_li_tag; // has open html <li> tag
}; };
} // namespace Winix
#endif #endif
+20 -4
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,10 @@
#include "log.h" #include "log.h"
namespace Winix
{
Compress::Compress() 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; int ret, flush;
size_t have; size_t have;
@@ -180,7 +186,7 @@ size_t have;
have = buffer_max_len - strm.avail_out; have = buffer_max_len - strm.avail_out;
last_out_size += have; last_out_size += have;
FCGX_PutStr(buffer_out, have, out_stream); out_stream.write(buffer_out, have);
} }
while( strm.avail_out == 0 ); while( strm.avail_out == 0 );
@@ -203,6 +209,7 @@ return 0;
} }
void Compress::CopyToInputBuffer(BinaryPage::const_iterator & i, size_t len) void Compress::CopyToInputBuffer(BinaryPage::const_iterator & i, size_t len)
{ {
for(size_t a=0 ; a<len ; ++a, ++i) 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) 3 - not inited (use Init() first)
100 - unknown 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; int ret;
z_stream * pstrm; z_stream * pstrm;
last_out_size = 0; last_out_size = 0;
out_stream.clear();
if( !ready_for_compress ) if( !ready_for_compress )
{ {
@@ -344,6 +352,8 @@ z_stream * pstrm;
return 3; return 3;
} }
// !! CHECK ME
// it is correct to immediately return? what about headers in the compressed page?
if( source_len == 0 ) if( source_len == 0 )
return 0; return 0;
@@ -379,6 +389,8 @@ z_stream * pstrm;
return 3; return 3;
} }
// !! CHECK ME
// it is correct to immediately return? what about headers in the compressed page?
if( in.empty() ) if( in.empty() )
return 0; return 0;
@@ -390,3 +402,7 @@ z_stream * pstrm;
return ret; return ret;
} }
} // namespace Winix
+10 -4
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,11 +11,14 @@
#define headerfile_winix_core_compress #define headerfile_winix_core_compress
#include <cstring> #include <cstring>
#include <fcgiapp.h>
#include <zlib.h> #include <zlib.h>
#include "requesttypes.h" #include "requesttypes.h"
namespace Winix
{
class Compress class Compress
{ {
@@ -34,7 +37,7 @@ public:
1 - deflate 1 - deflate
2 - gzip 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); int Compressing(const BinaryPage & in, BinaryPage & out, int encoding = 2);
@@ -45,7 +48,7 @@ private:
bool InitDeflate(); bool InitDeflate();
bool InitGzip(); 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); int MakeCompress(z_stream & strm, const BinaryPage & page, BinaryPage & out, int encoding);
z_stream * SelectStream(int encoding); z_stream * SelectStream(int encoding);
void ResetStream(z_stream * pstrm, int encoding); void ResetStream(z_stream * pstrm, int encoding);
@@ -67,4 +70,7 @@ private:
}; };
} // namespace Winix
#endif #endif
+13 -3
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,10 @@
#include "crypt.h" #include "crypt.h"
namespace Winix
{
Config::Config() Config::Config()
{ {
@@ -118,6 +122,8 @@ void Config::AssignValues(bool stdout_is_closed)
log_db_query = Bool(L"log_db_query", false); log_db_query = Bool(L"log_db_query", false);
log_plugin_call = Bool(L"log_plugin_call", false); log_plugin_call = Bool(L"log_plugin_call", false);
log_post_value_size = Size(L"log_post_value_size", 80); 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 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"); templates_index = Text(L"templates_index", L"index.html");
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false); 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_database = AText(L"db_database");
db_user = AText(L"db_user"); db_user = AText(L"db_user");
db_pass = AText(L"db_pass"); db_pass = AText(L"db_pass");
@@ -206,7 +212,6 @@ void Config::AssignValues(bool stdout_is_closed)
title_separator = Text(L"title_separator", L" / "); title_separator = Text(L"title_separator", L" / ");
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file"); 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 = Bool(L"editors_html_safe_mode", true);
editors_html_safe_mode_skip_root = Bool(L"editors_html_safe_mode_skip_root", 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_elements = Size(L"ezc_max_elements", 50000);
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000); 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); account_need_email_verification = Bool(L"account_need_email_verification", true);
reset_password_code_expiration_time = Long(L"reset_password_code_expiration_time", 86400); 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_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_treshold = Size(L"incorrect_login_cannot_login_treshold", 20);
incorrect_login_cannot_login_delay = Size(L"incorrect_login_cannot_login_delay", 1800); 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
+47 -18
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,10 @@
#include "htmlfilter.h" #include "htmlfilter.h"
namespace Winix
{
@@ -30,11 +34,11 @@ public:
// default: true // default: true
bool demonize; bool demonize;
// system user name (to which drop privileges) // system user's name to whom winix should drop privileges
// used only if winix is started as the root // used only if winix is started as the root
std::string user; std::string user;
// system group name (to which drop privileges) // system group's name to which drop privileges
// used only if winix is started as the root // used only if winix is started as the root
std::string group; std::string group;
@@ -47,21 +51,23 @@ public:
// log file name, log file name for notifications (sending emails, etc) // log file name, log file name for notifications (sending emails, etc)
std::string log_file, log_notify_file; std::string log_file, log_notify_file;
// the log level (how much info should be inserted to logs)
// 1 - minimum // 1 - minimum
// 2 - (default) // 2 - (default)
// 3 - maximum - all logs // 3 - maximum - all logs
int log_level; int log_level;
// logging to stdout too // logging to stdout too
// only if demonize is 'false' // this option is valid only if 'demonize' option is set to 'false'
// default: false // default: false
bool log_stdout; bool log_stdout;
// how many requests should be saved in the same time // how many requests should be saved in the same time
// if you have a very busy server you can incrase this value
// default: 1 // default: 1
int log_request; int log_request;
// whether to save each line of the config (use it for debug purposes) // whether to save each line of the config (used for debugging purposes)
// default: false // default: false
bool log_save_each_line; bool log_save_each_line;
@@ -76,6 +82,7 @@ public:
bool log_server_answer; bool log_server_answer;
// logging db queries // logging db queries
// warning: use it only on a developer's server as it logs the hashes of passwords too
// default: false // default: false
bool log_db_query; bool log_db_query;
@@ -85,12 +92,20 @@ public:
// how many characters in values should be logged from POST parameters // how many characters in values should be logged from POST parameters
// default: 80 // default: 80
// set to 0 to turn off // set to 0 to turn it off
size_t log_post_value_size; size_t log_post_value_size;
// request delimiter in the log file, default "---------" // request delimiter in the log file, default "---------"
std::wstring log_delimiter; 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) // fast cgi: socket (unix domain)
std::string fcgi_socket; std::string fcgi_socket;
@@ -120,39 +135,46 @@ public:
// default: index.html // default: index.html
std::wstring templates_index; std::wstring templates_index;
// if true then only root can use 'template' function // if true then only root can use 'template' winix function
// default: false // default: false
bool template_only_root_use_template_fun; bool template_only_root_use_template_fun;
// the database name, user name and a password for the PostgreSQL database
std::string db_database; std::string db_database;
std::string db_user; std::string db_user;
std::string db_pass; std::string db_pass;
std::string http_session_id_name; // the name of the cookie which has the session identifier
std::wstring http_session_id_name;
// string used in a place where is a user (or group) selected // string used in a place where is a user (or group) selected
// !! IMPROVE ME should be moved to locales
std::wstring priv_no_user; std::wstring priv_no_user;
std::wstring priv_no_group; std::wstring priv_no_group;
// time in seconds when the user will be automatically logged out (iddle time) // time in seconds when a user will be automatically logged out (iddle time)
// default: 10800 = 3 hours
int session_max_idle; int session_max_idle;
// time in seconds when the user will be automatically logged out (when he selected 'remember me' option) // time in seconds when a user will be automatically logged out
// when he has selected the 'remember me' option when logging in
// this time is usually greater than session_max_idle // this time is usually greater than session_max_idle
// default: 16070400 = 3 months
int session_remember_max_idle; int session_remember_max_idle;
// this file is used when the program is starting and ending // a file to which winix stores sessions info
// it is used when winix starts (boots) and quits
std::string session_file; std::string session_file;
// how many sessions can be (zero turn off this checking) // how many sessions can be (zero turn off this checking)
// default: 1000000 (one milion) // default: 1000000 (one milion)
size_t session_max; size_t session_max;
// allow the html output to be compressed // allow the winix output to be compressed
// default: true // default: true
bool compression; bool compression;
// if the output is shorter than this value then it will not be compressed // compress only if the output is greater or equal to this value
// default: 512 bytes // default: 512 bytes
size_t compression_page_min_size; size_t compression_page_min_size;
@@ -179,12 +201,12 @@ public:
bool html_filter_trim_white; bool html_filter_trim_white;
// when long words should be broken (a space will be inserted) // when long words should be broken (a space will be inserted)
// default: after 60 non white characters will be put a space // default: after 60 non white characters there will be put a space
// set zero to turn off // set zero to turn off
size_t html_filter_break_word; size_t html_filter_break_word;
// when long lines should be broken (a new line character will be inserted) // when long lines should be broken (a new line character will be inserted)
// default: 80 // default: 110
// set zero to turn off // set zero to turn off
size_t html_filter_wrap_line; size_t html_filter_wrap_line;
@@ -203,9 +225,11 @@ public:
HTMLFilter::OrphanMode html_filter_orphans_mode; HTMLFilter::OrphanMode html_filter_orphans_mode;
// the url of a new empty item (if there is not the subject too) // the url of a new empty item (if there is not the subject too)
// !! IMPROVE ME should be moved to locale
std::wstring item_url_empty; std::wstring item_url_empty;
// maximum length of a file send by post multipart form // maximum length of a file send by post multipart form
// default: 8388608 - 8MB
// 0 - not used // 0 - not used
size_t post_file_max; size_t post_file_max;
@@ -389,9 +413,6 @@ public:
// default: X-LIGHTTPD-send-file // default: X-LIGHTTPD-send-file
std::wstring http_header_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 // in editors (emacs, ckeditor,...) the html will be filtered and unsafe tags
// will be dropped (script, frame, etc.) // will be dropped (script, frame, etc.)
// default: true; // default: true;
@@ -485,6 +506,10 @@ public:
// default: 5000 (from ezc generator) // default: 5000 (from ezc generator)
size_t ezc_max_loop_elements; 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 // 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 // he has to provide his email and a message will be sent back to him
// with a link to activate the account // with a link to activate the account
@@ -591,6 +616,7 @@ public:
Config(); Config();
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true); bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);
@@ -644,6 +670,9 @@ private:
} // namespace Winix
#endif #endif
+29 -4
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,12 +16,18 @@
#include "log.h" #include "log.h"
namespace Winix
{
class CookieParser : public HttpSimpleParser class CookieParser : public HttpSimpleParser
{ {
const char * cookie_string; const char * cookie_string;
CookieTab * cookie_tab; CookieTab * cookie_tab;
std::wstring temp_name, temp_value;
bool input_as_utf8;
protected: protected:
@@ -35,19 +41,29 @@ protected:
return (int)(unsigned char)*(cookie_string++); 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) virtual void Parameter(std::string & name, std::string & value)
{ {
// Cookie names are case insensitive according to section 3.1 of RFC 2965 // Cookie names are case insensitive according to section 3.1 of RFC 2965
// (we don't use locale here)
ToLower(name); 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 ) if( res.second == false )
{ {
res.first->second = value; res.first->second = temp_value;
log << " (overwritten)"; log << " (overwritten)";
} }
@@ -60,6 +76,7 @@ public:
CookieParser() CookieParser()
{ {
input_as_utf8 = false;
HttpSimpleParser::separator = ';'; HttpSimpleParser::separator = ';';
HttpSimpleParser::value_can_be_quoted = true; HttpSimpleParser::value_can_be_quoted = true;
HttpSimpleParser::skip_white_chars = true; HttpSimpleParser::skip_white_chars = true;
@@ -67,6 +84,11 @@ public:
} }
void UTF8(bool utf)
{
input_as_utf8 = utf;
}
// cookie_string can be null // cookie_string can be null
void Parse(const char * cookie_string_, CookieTab & cookie_tab_) void Parse(const char * cookie_string_, CookieTab & cookie_tab_)
{ {
@@ -80,4 +102,7 @@ public:
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2012, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,11 @@
namespace Winix
{
void Crypt::SetConfig(Config * pconfig) void Crypt::SetConfig(Config * pconfig)
{ {
config = pconfig; config = pconfig;
@@ -312,3 +317,7 @@ void Crypt::PassHashCrypt(UserPass & up)
PassCrypt(config->pass_rsa_private_key, up); PassCrypt(config->pass_rsa_private_key, up);
} }
} // namespace Winix
+9 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2012, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,13 +10,17 @@
#ifndef headerfile_winix_core_crypt #ifndef headerfile_winix_core_crypt
#define headerfile_winix_core_crypt #define headerfile_winix_core_crypt
#include <string> #include <string>
#include "run.h" #include "run.h"
#include "config.h" #include "config.h"
#include "user.h" #include "user.h"
namespace Winix
{
/* /*
the kind of hashes we are able to obtain in 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 #endif
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2011, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,11 @@
#include "mount.h" #include "mount.h"
namespace Winix
{
/* /*
current request and session current request and session
*/ */
@@ -31,6 +36,8 @@ struct Cur
} // namespace Winix
#endif #endif
+11 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,11 @@
#include "log.h" #include "log.h"
namespace Winix
{
std::wstring DirContainer::dir_etc = L"etc"; std::wstring DirContainer::dir_etc = L"etc";
std::wstring DirContainer::dir_var = L"var"; std::wstring DirContainer::dir_var = L"var";
@@ -328,3 +333,8 @@ bool DirContainer::DelById(long id)
return true; return true;
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,10 @@
#include "item.h" #include "item.h"
namespace Winix
{
class DirContainer class DirContainer
{ {
@@ -92,4 +96,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+12 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,9 @@
#include "log.h" #include "log.h"
namespace Winix
{
void Dirs::SetDb(Db * pdb) 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) bool Dirs::AnalyzeDir(std::vector<Item*> & dir_tab, const std::wstring & link_to, size_t & i)
{ {
size_t old_i; size_t old_i;
@@ -752,3 +759,6 @@ void Dirs::LogDir(const std::vector<Item*> & dir_tab)
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -22,7 +22,13 @@
#include "notify/notify.h" #include "notify/notify.h"
namespace Winix
{
// !! IMPROVE ME
// we do not support '..' in a path (for simplicity and security reasons) // we do not support '..' in a path (for simplicity and security reasons)
// (we will support '..' in the future)
class Dirs class Dirs
@@ -115,4 +121,7 @@ private:
}; };
} // namespace Winix
#endif #endif
+7 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,9 @@
#define headerfile_winix_core_error #define headerfile_winix_core_error
namespace Winix
{
#define WINIX_ERR_OK 0 #define WINIX_ERR_OK 0
@@ -77,4 +80,7 @@ typedef int Error;
} // namespace Winix
#endif #endif
+7 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,10 @@
#include <vector> #include <vector>
namespace Winix
{
struct Group struct Group
{ {
@@ -38,6 +42,8 @@ struct Group
} // namespace Winix
#endif #endif
+5 -20
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,9 @@
#include "groups.h" #include "groups.h"
namespace Winix
{
Groups::Groups() Groups::Groups()
@@ -94,23 +97,5 @@ bool Groups::Remove(long group_id)
} // namespace Winix
+6 -3
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -17,6 +17,10 @@
#include "db/db.h" #include "db/db.h"
namespace Winix
{
class Groups class Groups
{ {
@@ -45,8 +49,7 @@ public:
} // namespace Winix
+7 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,11 @@
#include "htmlfilter.h" #include "htmlfilter.h"
namespace Winix
{
void HTMLFilter::Item::Clear() void HTMLFilter::Item::Clear()
{ {
@@ -1397,4 +1402,5 @@ void HTMLFilter::Read()
} // namespace Winix
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,10 @@
#include <algorithm> #include <algorithm>
namespace Winix
{
// max length of a name of a html tag (with terminating null) // max length of a name of a html tag (with terminating null)
@@ -295,5 +299,8 @@ protected:
} // namespace Winix
#endif #endif
+8 -10
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,12 @@
#include "httpsimpleparser.h" #include "httpsimpleparser.h"
namespace Winix
{
void HttpSimpleParser::ToLower(std::string & s) void HttpSimpleParser::ToLower(std::string & s)
{ {
std::string::iterator i; std::string::iterator i;
@@ -223,13 +229,5 @@ void HttpSimpleParser::Parse()
} // namespace Winix
+8 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,10 +10,13 @@
#ifndef headerfile_winix_core_httpsimpleparser #ifndef headerfile_winix_core_httpsimpleparser
#define headerfile_winix_core_httpsimpleparser #define headerfile_winix_core_httpsimpleparser
#include <string> #include <string>
namespace Winix
{
class HttpSimpleParser class HttpSimpleParser
{ {
@@ -65,4 +68,7 @@ public:
} // namespace Winix
#endif #endif
+11 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2013, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -17,6 +17,11 @@
namespace Winix
{
void Image::SetDb(Db * pdb) void Image::SetDb(Db * pdb)
{ {
@@ -520,7 +525,7 @@ void Image::SaveImage()
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str() log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str()
<< ", to: " << dst_path << logend; << ", to: " << dst_path << logend;
::RemoveFile(stream_tmp_path.Str()); Winix::RemoveFile(stream_tmp_path.Str());
} }
} }
else else
@@ -592,3 +597,7 @@ void Image::CreateThumbnail()
*/ */
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2013, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -19,6 +19,11 @@
#include "core/config.h" #include "core/config.h"
namespace Winix
{
class System; class System;
@@ -179,4 +184,7 @@ private:
}; };
} // namespace Winix
#endif #endif
+11 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012-2013, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,12 @@
#include <ctime> #include <ctime>
namespace Winix
{
// telling if the IPBan record is active // telling if the IPBan record is active
// we have two records: active and non active // we have two records: active and non active
// non active records is something like a history // non active records is something like a history
@@ -147,4 +153,8 @@ struct IPBan
}; };
} // namespace Winix
#endif #endif
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,10 @@
#include "date/date.h" #include "date/date.h"
namespace Winix
{
IPBanContainer::IPBanContainer() IPBanContainer::IPBanContainer()
{ {
@@ -216,6 +220,9 @@ bool IPBanContainer::SortIPBansFunction(const IPBan & ip1, const IPBan & ip2)
} // namespace Winix
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,10 @@
#include "ipban.h" #include "ipban.h"
namespace Winix
{
class IPBanContainer class IPBanContainer
{ {
@@ -54,5 +58,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,11 @@
#include "crypt.h" #include "crypt.h"
namespace Winix
{
Item::Item() Item::Item()
{ {
@@ -80,3 +85,6 @@ void Item::Clear()
} }
} // namespace Winix
+8 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,9 @@
#include "date/date.h" #include "date/date.h"
namespace Winix
{
#define WINIX_ITEM_FILETYPE_NONE 0 #define WINIX_ITEM_FILETYPE_NONE 0
#define WINIX_ITEM_FILETYPE_IMAGE 1 #define WINIX_ITEM_FILETYPE_IMAGE 1
@@ -76,7 +79,7 @@ struct Item
// used when type is symlink or to a directory too (function 'default') // used when type is symlink or to a directory too (function 'default')
std::wstring link_to; std::wstring link_to;
int link_redirect; int link_redirect; // !! IMPROVE ME should it be 'bool'?
// static file (if exists) // static file (if exists)
@@ -118,5 +121,8 @@ friend struct DbItemColumns;
}; };
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,11 @@
#include "log.h" #include "log.h"
namespace Winix
{
Job::Job() Job::Job()
{ {
@@ -162,4 +167,7 @@ void Job::DoWinixJob(PT::Space & job)
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,10 @@
#include "space/space.h" #include "space/space.h"
namespace Winix
{
#define WINIX_JOBS_HOW_MANY_PRIORITIES 32 #define WINIX_JOBS_HOW_MANY_PRIORITIES 32
@@ -78,5 +82,9 @@ private:
}; };
} // namespace Winix
#endif #endif
+12 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2009, Tomasz Sowa * Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,12 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
LastItem::LastItem() LastItem::LastItem()
{ {
user_id = 0; user_id = 0;
@@ -106,3 +112,8 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
<< user_id << " ses_id: " << session_id << logend; << user_id << " ses_id: " << session_id << logend;
} }
} }
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2009, Tomasz Sowa * Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -18,6 +18,11 @@
namespace Winix
{
// how many items we store in the 'last' function // how many items we store in the 'last' function
#define WINIX_LASTCONTAINER_TABLE_SIZE 100 #define WINIX_LASTCONTAINER_TABLE_SIZE 100
@@ -75,4 +80,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,10 @@
#include "log.h" #include "log.h"
namespace Winix
{
LoadAvg::LoadAvg() LoadAvg::LoadAvg()
{ {
@@ -370,3 +374,8 @@ double LoadAvg::ReqPerSec15()
return cache_req_per_sec15; return cache_req_per_sec15;
} }
} // namespace Winix
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,10 @@
#include <ctime> #include <ctime>
namespace Winix
{
// in seconds // in seconds
@@ -110,5 +114,8 @@ private:
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,11 @@
#include "lock.h" #include "lock.h"
namespace Winix
{
Lock::Lock() Lock::Lock()
{ {
@@ -47,3 +52,6 @@ void Lock::Unlock()
} }
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,11 @@
#include "synchro.h" #include "synchro.h"
namespace Winix
{
class Lock class Lock
{ {
public: public:
@@ -34,4 +39,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+7 -25
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,11 @@
#include "timezones.h" #include "timezones.h"
namespace Winix
{
Log::Log() Log::Log()
{ {
log_level = 1; log_level = 1;
@@ -453,28 +458,5 @@ void Log::SaveLog()
} // namespace Winix
+12 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -20,6 +20,11 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace Winix
{
class TimeZones; class TimeZones;
@@ -155,6 +160,12 @@ return *this;
extern Log log; extern Log log;
extern Log nlog; extern Log nlog;
} // namespace Winix
// for convenience, we have to use only #include "log.h" in the winix // for convenience, we have to use only #include "log.h" in the winix
#include "slog.h" #include "slog.h"
+11 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,12 @@
#define headerfile_winix_core_logmanipulators #define headerfile_winix_core_logmanipulators
namespace Winix
{
/* /*
log1 - the first level log1 - the first level
log2 log2
@@ -44,5 +50,9 @@ enum LogManipulators
}; };
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,11 @@
#include "templates/templates.h" #include "templates/templates.h"
namespace Winix
{
namespace misc_private namespace misc_private
{ {
@@ -1156,3 +1161,6 @@ void RemovePostFileTmp(PostFileTab & post_file_tab)
} // namespace Winix
+36 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,7 +10,6 @@
#ifndef headerfile_winix_core_misc #ifndef headerfile_winix_core_misc
#define headerfile_winix_core_misc #define headerfile_winix_core_misc
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <ctime> #include <ctime>
@@ -22,6 +21,10 @@
#include "utf8/utf8.h" #include "utf8/utf8.h"
namespace Winix
{
/* /*
@@ -1014,4 +1017,35 @@ void SetMinMax(IntType & val, IntType min_val, IntType max_val)
template<class Stream, class StringType>
void JSONescape(Stream & out, const StringType & str)
{
// !! IMPROVE ME (optimizing)
// it is better to not write one by one character
// but use write method insted
for(size_t i=0 ; i<str.size() ; ++i)
{
switch(str[i])
{
case 0: out << '\\'; out << '0'; break;
case '\r': out << '\\'; out << 'r'; break;
case '\n': out << '\\'; out << 'n'; break;
case '\t': out << '\\'; out << 't'; break;
case 0x08: out << '\\'; out << 'b'; break;
case 0x0c: out << '\\'; out << 'f'; break;
case '\\': out << '\\'; out << '\\'; break;
//case '/': out << '\\'; out << '/'; break; // slash doesn't have to be escaped
case '"': out << '\\'; out << '\"'; break;
default:
out << str[i];
}
}
}
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2009-2010, Tomasz Sowa * Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,11 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
Mount::Mount() Mount::Mount()
{ {
@@ -109,3 +114,7 @@ const std::wstring & Mount::FirstArg(int code) const
return Arg(code, 0); return Arg(code, 0);
} }
} // namespace Winix
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2009-2010, Tomasz Sowa * Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,10 @@
#include <vector> #include <vector>
namespace Winix
{
class Mount class Mount
{ {
@@ -67,5 +71,8 @@ private:
} // namespace Winix
#endif #endif
+7 -6
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2011, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,11 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
MountParser::MountParser() MountParser::MountParser()
{ {
dirs = 0; dirs = 0;
@@ -494,9 +499,5 @@ void MountParser::Parse(const std::wstring & input, std::map<long, Mount> & outp
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2011, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -22,6 +22,11 @@
namespace Winix
{
class MountParser class MountParser
{ {
public: public:
@@ -82,4 +87,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2009-2012, Tomasz Sowa * Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,10 @@
namespace Winix
{
Mounts::Mounts() Mounts::Mounts()
{ {
@@ -321,3 +325,8 @@ Mount * Mounts::GetEmptyMount()
{ {
return &empty_mount; return &empty_mount;
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2009-2012, Tomasz Sowa * Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -23,6 +23,11 @@
#include "mountparser.h" #include "mountparser.h"
namespace Winix
{
class Mounts class Mounts
{ {
@@ -165,5 +170,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+8 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,9 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
void Plugin::UnloadPlugins() void Plugin::UnloadPlugins()
@@ -177,7 +180,7 @@ void * Plugin::LoadInitFun(const char * filename, Fun1 & fun_init)
return 0; return 0;
} }
fun_init = (Fun1)dlfunc(p, "Init"); fun_init = (Fun1)dlsym(p, "Init");
if( !fun_init ) if( !fun_init )
{ {
@@ -500,3 +503,6 @@ const Plugin::Plugins * Plugin::GetPlugins()
return &plugins; return &plugins;
} }
} // namespace Winix
+11 -2
View File
@@ -2,11 +2,10 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
#ifndef headerfile_winix_core_plugin #ifndef headerfile_winix_core_plugin
#define headerfile_winix_core_plugin #define headerfile_winix_core_plugin
@@ -26,6 +25,12 @@
#include "templates/templates.h" #include "templates/templates.h"
namespace Winix
{
/* /*
all your plugin functions can have signature either: all your plugin functions can have signature either:
void my_function(PluginInfo & info); or void my_function(PluginInfo & info); or
@@ -246,5 +251,9 @@ private:
extern Plugin plugin; extern Plugin plugin;
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,10 @@
#include "session.h" #include "session.h"
namespace Winix
{
PluginData::PluginData() PluginData::PluginData()
@@ -153,3 +157,8 @@ size_t old_size = table.size();
for(size_t i = old_size ; i<new_size ; ++i) for(size_t i = old_size ; i<new_size ; ++i)
table[i] = 0; table[i] = 0;
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,11 @@
#define headerfile_winix_core_plugindata #define headerfile_winix_core_plugindata
#include <vector> #include <vector>
#include <cstddef>
namespace Winix
{
struct Session; struct Session;
@@ -65,5 +70,8 @@ private:
} // namespace Winix
#endif #endif
+20 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,12 @@
#define headerfile_winix_core_pluginmsg #define headerfile_winix_core_pluginmsg
namespace Winix
{
// here you can add your own EZC functions ([function]) // here you can add your own EZC functions ([function])
// PluginInfo.p1 is a pointer to Ezc::Functions object // PluginInfo.p1 is a pointer to Ezc::Functions object
// session pointer is null // session pointer is null
@@ -255,6 +261,15 @@
// to the resource // to the resource
#define WINIX_CHECK_PLUGIN_ACCESS 31060 #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 // see plugins/ticket/pluginmsg.h
} // namespace Winix
#endif #endif
+12 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,12 @@
namespace Winix
{
PostMultiParser::PostMultiParser() PostMultiParser::PostMultiParser()
{ {
in_buffer = new unsigned char[WINIX_POSTMULTI_INPUT_BUFFER]; 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; return err;
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -19,6 +19,11 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
// 2 MB // 2 MB
#define WINIX_POSTMULTI_INPUT_BUFFER 2097152 #define WINIX_POSTMULTI_INPUT_BUFFER 2097152
#define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152 #define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152
@@ -128,5 +133,8 @@ return added;
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -21,6 +21,10 @@
#include "plugin.h" #include "plugin.h"
namespace Winix
{
class PostParser : public HttpSimpleParser class PostParser : public HttpSimpleParser
{ {
@@ -148,4 +152,8 @@ public:
}; };
} // namespace Winix
#endif #endif
+7 -6
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,11 @@
#include "cur.h" #include "cur.h"
namespace Winix
{
void Rebus::SetCur(Cur * pcur) void Rebus::SetCur(Cur * pcur)
{ {
@@ -162,9 +167,5 @@ return false;
} // namespace Winix
+11 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,11 +10,15 @@
#ifndef headerfile_winix_core_rebus #ifndef headerfile_winix_core_rebus
#define headerfile_winix_core_rebus #define headerfile_winix_core_rebus
#include <string> #include <string>
#include <vector> #include <vector>
namespace Winix
{
struct Cur; struct Cur;
@@ -48,4 +52,9 @@ private:
}; };
} // namespace Winix
#endif #endif
+32 -71
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -14,6 +14,9 @@
namespace Winix
{
@@ -21,6 +24,7 @@
Request::Request() : char_empty(0) Request::Request() : char_empty(0)
{ {
id = 0; id = 0;
config = 0;
} }
@@ -30,36 +34,29 @@ void Request::SetConfig(Config * pconfig)
} }
void Request::ClearAjax()
void Request::ClearOutputStreams()
{ {
size_t i = ajax.spaces.size(); size_t len = 16;
while( i-- > 0 ) if( config )
ajax.RemoveSpace(i); len = config->ezc_out_streams_size;
ajax.table.clear(); if( len < 1 || len > 64 )
len = 16;
PT::Space::TableSingle::iterator s = ajax.table_single.begin(); out_streams.resize(len);
use_html_filter.resize(len);
while( s != ajax.table_single.end() ) for(size_t i=0 ; i<out_streams.size() ; ++i)
{ {
if( s->first != L"content" && s->first != L"http_status" ) out_streams[i].Clear();
{ use_html_filter[i] = true;
ajax.table_single.erase(s++);
}
else
{
// small optimization when deleting
// the memory for "content" and "http_status" will be reused
s->second.clear();
++s;
}
} }
} }
void Request::Clear() void Request::Clear()
{ {
// id is never 0 // id is never 0
@@ -67,21 +64,18 @@ void Request::Clear()
++id; ++id;
RemovePostFileTmp(post_file_tab); RemovePostFileTmp(post_file_tab);
ClearOutputStreams();
post_tab.clear(); post_tab.clear();
post_file_tab.clear(); post_file_tab.clear();
cookie_tab.clear(); cookie_tab.clear();
method = none; method = unknown_method;
role = responder;
headers.Clear(); out_headers.Clear();
page.Clear(); out_cookies.Clear();
ajaxpage.Clear();
debug.Clear();
page_generated = false; page_generated = false;
use_html_filter = true;
env_request_method = &char_empty; env_request_method = &char_empty;
env_request_uri = &char_empty; env_request_uri = &char_empty;
@@ -99,7 +93,7 @@ void Request::Clear()
dir_tab.clear(); dir_tab.clear();
last_item = &item; last_item = &item;
is_item = false; is_item = false;
function = 0; // !! dodac jakas empty funkcje function = 0;
param_tab.clear(); param_tab.clear();
anchor.clear(); anchor.clear();
@@ -117,12 +111,13 @@ void Request::Clear()
start_date.Clear(); start_date.Clear();
subdomain.clear(); subdomain.clear();
ClearAjax(); return_info_only = false;
ajax_serializer = 0; info.Clear();
info_serializer = 0;
return_json = false;
binary_page.clear(); out_bin_stream.clear();
compressed_page.clear(); send_bin_stream = false;
use_text_page = true;
gen_trim_white = false; gen_trim_white = false;
gen_skip_new_line = false; gen_skip_new_line = false;
@@ -145,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) bool Request::IsPostVar(const wchar_t * var)
{ {
@@ -352,4 +310,7 @@ const std::wstring & Request::ParamValue(const std::wstring & param_name)
} // namespace Winix
+242 -68
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -22,6 +22,12 @@
#include "date/date.h" #include "date/date.h"
#include "space/space.h" #include "space/space.h"
#include "space/spacetojson.h" #include "space/spacetojson.h"
#include "textstream/textstream.h"
namespace Winix
{
@@ -32,52 +38,69 @@ class FunctionBase;
struct Request struct Request
{ {
// request id /*
// is incremented for each request and is never 0 request id
// (from -1 will be incremented twice) is incremented for each request and is never 0
// it's used for some optimalizations e.g. in templates (from -1 will be incremented to one)
it's used for some optimizations e.g. in templates
*/
size_t id; 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; request start time
TextStream<std::string> headers; Time() methods are very slow so it is better to directly use those two values
HtmlTextStream page, debug; they are set when a request starts
TextStream<std::wstring> ajaxpage; */
time_t start_time;
PT::Date start_date;
// binary page
BinaryPage binary_page;
// a compressed page ready to send to the client
BinaryPage compressed_page;
// if true then either page or ajaxpage will be sent to the client /*
// if false then binary_page is sent *
// default: true *
bool use_text_page; *
* variables representing input from client's browser
*
*
*
*/
// if set to true then the standard template system will not be generated /*
// default: false the HTTP method
bool page_generated; !! IMPROVE ME add the rest methods here
*/
enum Method { get, post, head, unknown_method } method;
// whether or not the html filter should be used
// default: true
bool use_html_filter;
// raw parameters /*
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; PostTab post_tab;
PostFileTab post_file_tab; PostFileTab post_file_tab;
CookieTab cookie_tab; CookieTab cookie_tab;
// html anchor (those part of URI after '#' character)
/*
html anchor (those part of URI after '#' character)
*/
std::wstring anchor; std::wstring anchor;
// environment variables // environment variables
// they are not null -- when the server doesn't have such a variable // they are not null -- when the server doesn't have such a variable
// it will be pointing into 'char_empty' which is default '\0' // 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_method;
const char * env_request_uri; const char * env_request_uri;
const char * env_http_cookie; const char * env_http_cookie;
@@ -88,46 +111,65 @@ struct Request
const char * env_fcgi_role; const char * env_fcgi_role;
const char * env_content_type; const char * env_content_type;
const char * env_https; const char * env_https;
// current IP address of the remote host (read from REMOTE_ADDR environment variable) // current IP address of the remote host (read from REMOTE_ADDR environment variable)
// (at the moment only IPv4 are supported) // (at the moment only IPv4 are supported)
int ip; int ip;
// true if the browser is Microsoft Internet Explorer // true if the browser is Microsoft Internet Explorer
bool browser_msie; bool browser_msie;
// true if the browser is Konqueror // true if the browser is Konqueror
bool browser_konqueror; bool browser_konqueror;
// true if we are using encrypted connection (SSL) // true if we are using an encrypted connection (SSL)
bool using_ssl; bool using_ssl;
/*
request input variables representing the winix filesystem
*/
// current directory // current directory
std::vector<Item*> dir_tab; std::vector<Item*> dir_tab;
// true if a file exists // true if a file exists
bool is_item; bool is_item;
// current file (if exists) // current file (valid if is_item is true)
Item item; Item item;
// current winix function // current winix function
// null if there is no a function // null if there is no a function
FunctionBase * function; FunctionBase * function;
// parameters (name:value) // parameters (name:value)
ParamTab param_tab; 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 // request status
// !! CHANGE ME it'll be better to use ordinary http result codes
Error 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 // if not empty means an address for redirecting to
// it should be url-encoded // it should be url-encoded
std::wstring redirect_to; std::wstring redirect_to;
std::string aredirect_to;
// a redirect type // a redirect type
// following redirect types are supported: // following redirect types are supported:
@@ -141,30 +183,103 @@ struct Request
// send header X-LIGHTTPD-send-file with path to a file // send header X-LIGHTTPD-send-file with path to a file
std::wstring x_sendfile; std::wstring x_sendfile;
// send as attachment (causes header: content-disposition: attachment) // send as attachment (causes generating header: content-disposition: attachment)
bool send_as_attachment; bool send_as_attachment;
// this is a pointer either to the item (if exists) or to the last directory // headers send to the client (without cookies)
Item * last_item; PT::Space out_headers;
// request start time // cookies send to the client
// Time() methods are very slow so it is better to directly use those two values // a value can be either a cookie value or the whole cookie string (with domain, date etc)
// they are set when a request starts PT::Space out_cookies;
time_t start_time;
PT::Date start_date;
// a subdomain // winix can return either a text answer or a binary answer
// subdomain = HTTP_HOST environment variable - config->base_url // if send_bin_stream is true then the binary answer is sent (out_bin_stream)
std::wstring subdomain; // 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
// (if false) ------------------------------------------------------ (if true)
// | |
// generating JSON object from: generating JSON object only from info
// out_streams and info, e.g.: e.g.:
// { { info object serialized here }
// "stream_1": "some html content",
// "stream_2": "some other html content",
// "info": { info object serialized here }
// }
// note that out_streams[0] is not sent
// in JSON answers
//
//
bool send_bin_stream;
// used as a JSON output (when ajax_serializer is defined) // binary page sent to the client if send_bin_stream is true
// it will be serialized and have at least: BinaryPage out_bin_stream;
// 'content' string - the whole html content
// 'http_status' integer - http status code (e.g. 200) !! FIXME this is not added at the moment // when returning the text answer we can either return the whole html page (normal requests)
PT::Space ajax; // 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])
// if return_json is true we are creating an JSON object from out_streams
// (zero stream is ignored) and from info space (see above picture)
// (or just only from info if return_info_only is true)
// default: false
// return_json is set to true by App at the beginning of a request
// if reqtype:json parameter is present (in the url)
// note: return_json is only valid if send_bin_stream is false
bool return_json;
// main text output streams where the html otput is generated from ezc templates
// the zero stream (out_streams[0]) is used as the main stream
// to which the whole html page (with doctype, head, body) is generated
// the rest streams can be only used in ajax requests (send in JSON format to the client)
// in ezc templates you can use [ezc stream ...] keyword
// to switch between streams e.g. [ezc stream "0" "2"]
std::vector<HtmlTextStream> out_streams;
// if true the JSON object is generated only from info (out_streams are not used)
// default: false
bool return_info_only;
// additional info added when sending the JSON answer
PT::Space info;
// info serializer
// if not set then the json_generic_serializer from App will be used
// default: null (json_generic_serializer used)
PT::SpaceToJSON * info_serializer;
// 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
// the size of the table is the same as out_streams
// default: all items true
std::vector<bool> use_html_filter;
// if not null then the request will have a JSON as an output
PT::SpaceToJSON * ajax_serializer;
// if this variable is true then winix always return 200 OK header // if this variable is true then winix always return 200 OK header
// when the status would be 404 (not found) or 403 (permission denied) // when the status would be 404 (not found) or 403 (permission denied)
@@ -177,8 +292,27 @@ struct Request
bool gen_use_special_chars; 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(); Request();
void SetConfig(Config * pconfig); void SetConfig(Config * pconfig);
void RequestStarts(); void RequestStarts();
void Clear(); void Clear();
@@ -186,29 +320,32 @@ struct Request
bool IsParam(const wchar_t * param_name); bool IsParam(const wchar_t * param_name);
bool IsParam(const std::wstring & 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 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 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 wchar_t * var);
bool IsPostVar(const std::wstring & 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 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 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 wchar_t * var, std::wstring & result);
bool PostVar(const std::wstring & var, std::wstring & result); bool PostVar(const std::wstring & var, std::wstring & result);
std::wstring * PostVarp(const wchar_t * var); std::wstring * PostVarp(const wchar_t * var);
std::wstring * PostVarp(const std::wstring & var); std::wstring * PostVarp(const std::wstring & var);
bool AllPostVarEmpty(); // returning true if all post vars are empty 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: private:
@@ -222,14 +359,51 @@ private:
// used in ParamValue() and PostVar() when there is no such a param // used in ParamValue() and PostVar() when there is no such a param
const std::wstring str_empty; const std::wstring str_empty;
void ClearAjax(); void ClearOutputStreams();
}; };
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 #endif
+12 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2011, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,12 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace Winix
{
// !! IMPROVE ME
// !! narazie uzywane tylko w post multi parserze // !! narazie uzywane tylko w post multi parserze
// dodac do zwyklego parsera post // dodac do zwyklego parsera post
#define WINIX_POSTTABLE_MAXSIZE 50 #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::map<std::wstring, PostFile> PostFileTab;
typedef std::vector<Param> ParamTab; 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; typedef PT::TextStreamBase<char, 1, 4096> BinaryPage;
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,11 +11,17 @@
#include <sys/uio.h> #include <sys/uio.h>
#include <unistd.h> #include <unistd.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <cstring>
#include "run.h" #include "run.h"
#include "log.h" #include "log.h"
namespace Winix
{
Run::Run() Run::Run()
{ {
@@ -384,3 +390,6 @@ int Run::Go(std::string & out)
} }
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2013, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,11 @@
#include <unistd.h> #include <unistd.h>
namespace Winix
{
/* /*
how many parameters and environment variables can be passed to a program how many parameters and environment variables can be passed to a program
*/ */
@@ -160,5 +165,9 @@ private:
}; };
} // namespace Winix
#endif #endif
+9 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,9 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
Session::Session() Session::Session()
@@ -86,9 +89,13 @@ void Session::Clear(bool clear_plugin_data)
// clearing some variables when a request is ended (just for safety) // 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 list can be sorted by SessionManager (in the special thread)
ip_ban = 0; ip_ban = 0;
} }
} // namespace Winix
+9 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -23,6 +23,10 @@
#include "ipban.h" #include "ipban.h"
namespace Winix
{
struct Session struct Session
{ {
@@ -32,7 +36,7 @@ struct Session
void SetTimesTo(time_t time); void SetTimesTo(time_t time);
void Clear(bool clear_plugin_data = true); void Clear(bool clear_plugin_data = true);
void ClearOnEndRequest(); void ClearAfterRequest();
// 0 - means that there is a temporary session // 0 - means that there is a temporary session
@@ -95,6 +99,9 @@ struct Session
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,11 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
SessionContainer::SessionContainer() SessionContainer::SessionContainer()
{ {
@@ -207,5 +212,8 @@ return false;
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -19,6 +19,11 @@
#include "config.h" #include "config.h"
namespace Winix
{
class SessionContainer class SessionContainer
{ {
@@ -71,4 +76,8 @@ private:
}; };
} // namespace Winix
#endif #endif
+8 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * 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()); long id = Tol(cookie.c_str());
SessionContainer::Iterator s = session_tab.FindById(id); SessionContainer::Iterator s = session_tab.FindById(id);
@@ -603,3 +606,6 @@ void SessionManager::DeleteSession(Session * del_session)
} // namespace Winix
+10 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -24,6 +24,11 @@
namespace Winix
{
class SessionManager : public BaseThread class SessionManager : public BaseThread
{ {
public: public:
@@ -88,7 +93,7 @@ private:
long CreateSessionId(); long CreateSessionId();
void CreateSession(); void CreateSession();
bool SetSessionFromCookie(const std::string & cookie); bool SetSessionFromCookie(const std::wstring & cookie);
void SetTemporarySession(); void SetTemporarySession();
// second thread // second thread
@@ -102,4 +107,7 @@ private:
}; };
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,10 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
bool SessionParser::Parse(const std::string & path, SessionContainer & container) bool SessionParser::Parse(const std::string & path, SessionContainer & container)
{ {
@@ -166,3 +170,7 @@ bool is_sign = false;
return res; return res;
} }
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2010, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -17,6 +17,10 @@
#include "users.h" #include "users.h"
namespace Winix
{
class SessionParser class SessionParser
{ {
@@ -46,5 +50,9 @@ private:
}; };
} // namespace Winix
#endif #endif
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2012, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,10 @@
#include "slog.h" #include "slog.h"
namespace Winix
{
SLog::SLog() SLog::SLog()
@@ -222,3 +226,6 @@ SLog & SLog::operator<<(TranslateTextHelper<std::wstring> raw)
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2012, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,11 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace Winix
{
#define WINIX_SLOG_MAX_LOG_SIZE 10240 #define WINIX_SLOG_MAX_LOG_SIZE 10240
@@ -137,5 +142,9 @@ return *this;
extern SLog slog; extern SLog slog;
} // namespace Winix
#endif #endif
+35 -10
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,10 +11,29 @@
#include "synchro.h" #include "synchro.h"
Synchro::Synchro() : mutex(PTHREAD_MUTEX_INITIALIZER)
namespace Winix
{
Synchro::Synchro()
{ {
was_stop_signal = false; was_stop_signal = false;
ref = 0;
#ifdef __FreeBSD__
/*
* on FreeBSD a pthread's pthread_mutex_lock() is checking for deadlocks by default
*/
mutex = PTHREAD_MUTEX_INITIALIZER;
#else
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
pthread_mutex_init(&mutex, &attr);
pthread_mutexattr_destroy(&attr);
#endif
} }
@@ -23,29 +42,34 @@ bool Synchro::Lock()
{ {
int res = pthread_mutex_lock(&mutex); int res = pthread_mutex_lock(&mutex);
if( res == EDEADLK ) if( res == 0 )
{ {
// Lock() method in this thread was called before ref[pthread_self()] = 1;
ref += 1;
return true; return true;
} }
else else
if( res == EDEADLK )
{ {
ref = 0; // Lock() method in this thread was called before
ref[pthread_self()] += 1;
return true;
} }
return res == 0; return false;
} }
void Synchro::Unlock() void Synchro::Unlock()
{ {
if( ref > 0 ) int & r = ref[pthread_self()];
if( r > 1 )
{ {
ref -= 1; r -= 1;
} }
else else
if( r == 1 )
{ {
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
@@ -54,4 +78,5 @@ void Synchro::Unlock()
} // namespace Winix
+11 -3
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,11 @@
#define headerfile_winix_core_synchro #define headerfile_winix_core_synchro
#include <pthread.h> #include <pthread.h>
#include <map>
namespace Winix
{
@@ -31,13 +36,16 @@ struct Synchro
private: private:
// deadlock counter // deadlock counter for each thread
// we can call Lock() more than one in the same thread // we can call Lock() more than one in the same thread
int ref; std::map<pthread_t, int> ref;
}; };
} // namespace Winix
#endif #endif
+37 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,12 @@
namespace Winix
{
void System::SetCur(Cur * pcur) void System::SetCur(Cur * pcur)
{ {
cur = pcur; cur = pcur;
@@ -144,6 +150,30 @@ bool ssl = false;
} }
void System::CreateItemLink(long parent_id, const std::wstring & url, const std::wstring & subdomain,
std::wstring & link, bool clear_str)
{
PutUrlProto(config->use_ssl, link, clear_str);
if( !subdomain.empty() )
{
link += subdomain;
link += '.';
}
link += config->base_url;
dirs.MakePath(parent_id, link, false); // !! IMPROVE ME may some kind of error checks here?
link += url;
}
void System::CreateItemLink(const Item & item, std::wstring & link, bool clear_str)
{
CreateItemLink(item.parent_id, item.url, cur->request->subdomain, link, clear_str);
}
// !! IMPROVE ME // !! IMPROVE ME
// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad // !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad
// !! moze zwracac jakas wartosc? // !! moze zwracac jakas wartosc?
@@ -1183,6 +1213,8 @@ int System::FollowAllLinks(const std::vector<Item*> & current_dir_tab, const std
} }
else 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); res = FollowLink(current_dir_tab, link_to_temp, out_dir_tab, out_item);
link_to_temp.clear(); link_to_temp.clear();
@@ -1343,3 +1375,7 @@ bool System::AddCommonFileToVar(const wchar_t * file_path, const wchar_t * url,
return AddFile(file_content_item, false) == WINIX_ERR_OK; return AddFile(file_content_item, false) == WINIX_ERR_OK;
} }
} // namespace Winix
+17 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -29,6 +29,11 @@
#include "timezones.h" #include "timezones.h"
namespace Winix
{
class Functions; class Functions;
class SessionManager; class SessionManager;
@@ -171,6 +176,13 @@ public:
// reloading time zones // reloading time zones
void ReadTimeZones(); void ReadTimeZones();
void CreateItemLink(long parent_id, const std::wstring & url, const std::wstring & subdomain,
std::wstring & link, bool clear_str = true);
void CreateItemLink(const Item & item, std::wstring & link, bool clear_str = true);
private: private:
Cur * cur; Cur * cur;
@@ -204,5 +216,9 @@ private:
}; };
} // namespace Winix
#endif #endif
+31 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2010-2012, Tomasz Sowa * Copyright (c) 2010-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -18,6 +18,11 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace Winix
{
/* /*
a special class representing a stream buffer a special class representing a stream buffer
@@ -42,6 +47,9 @@ public:
const StringType & Str() const; const StringType & Str() const;
const CharType * CStr() const; const CharType * CStr() const;
void Str(const StringType & str);
void Str(const StringType && str);
CharType operator[](size_t index); CharType operator[](size_t index);
TextStream & operator<<(const char * str); 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 char * buf, size_t len); // for compatibility with standard library (Ezc uses it)
TextStream & write(const wchar_t * buf, size_t len); TextStream & write(const wchar_t * buf, size_t len);
protected: protected:
StringType buffer; 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> template<class StringType>
typename TextStream<StringType>::CharType TextStream<StringType>::operator[](size_t index) typename TextStream<StringType>::CharType TextStream<StringType>::operator[](size_t index)
{ {
@@ -345,5 +369,11 @@ return *this;
} }
} // namespace Winix
#endif #endif
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2012, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,12 @@
#include "log.h" #include "log.h"
namespace Winix
{
ThreadManager::ThreadManager() ThreadManager::ThreadManager()
{ {
were_started = false; were_started = false;
@@ -134,3 +140,6 @@ void ThreadManager::StopAll()
} // namespace Winix
+10 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2011-2012, Tomasz Sowa * Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,11 @@
#include "synchro.h" #include "synchro.h"
namespace Winix
{
class ThreadManager class ThreadManager
{ {
@@ -61,5 +66,9 @@ private:
}; };
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,6 +11,10 @@
#include "misc.h" #include "misc.h"
namespace Winix
{
TimeZone::Dst::Dst() TimeZone::Dst::Dst()
@@ -287,3 +291,7 @@ return result;
} }
} // namespace Winix
+8 -5
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -17,6 +17,12 @@
namespace Winix
{
class TimeZone class TimeZone
{ {
public: public:
@@ -132,10 +138,7 @@ private:
} // namespace Winix
+6 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,10 @@
#include "log.h" #include "log.h"
namespace Winix
{
TimeZones::TimeZones() TimeZones::TimeZones()
{ {
@@ -174,5 +178,5 @@ bool TimeZones::ReadTimeZones(const std::wstring & path)
} // namespace Winix
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,11 @@
#include "space/spaceparser.h" #include "space/spaceparser.h"
namespace Winix
{
class TimeZones class TimeZones
{ {
@@ -77,5 +82,8 @@ private:
} // namespace Winix
#endif #endif
+9 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -15,6 +15,10 @@
#include "log.h" #include "log.h"
namespace Winix
{
template<class Type> template<class Type>
class UGContainer class UGContainer
@@ -274,4 +278,8 @@ return result;
} }
} // namespace Winix
#endif #endif
+8 -15
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2012, Tomasz Sowa * Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -10,6 +10,11 @@
#include "user.h" #include "user.h"
namespace Winix
{
User::User() User::User()
{ {
Clear(); Clear();
@@ -32,6 +37,7 @@ void User::Clear()
} }
bool User::IsMemberOf(long group) bool User::IsMemberOf(long group)
{ {
std::vector<long>::iterator i; std::vector<long>::iterator i;
@@ -47,19 +53,6 @@ return false;
} // namespace Winix
+15 -3
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -16,6 +16,11 @@
#include "date/date.h" #include "date/date.h"
namespace Winix
{
#define WINIX_ACCOUNT_MAX_LOGIN_SIZE 250 #define WINIX_ACCOUNT_MAX_LOGIN_SIZE 250
#define WINIX_ACCOUNT_MAX_PASSWORD_SIZE 250 #define WINIX_ACCOUNT_MAX_PASSWORD_SIZE 250
#define WINIX_ACCOUNT_MAX_EMAIL_SIZE 250 #define WINIX_ACCOUNT_MAX_EMAIL_SIZE 250
@@ -27,6 +32,7 @@
#define WINIX_ACCOUNT_NOT_ACTIVATED 1 #define WINIX_ACCOUNT_NOT_ACTIVATED 1
// 2 - a user clicked on the link in the mail and now can normally use his account // 2 - a user clicked on the link in the mail and now can normally use his account
// (if has a password set too)
#define WINIX_ACCOUNT_READY 2 #define WINIX_ACCOUNT_READY 2
// 3 - account was suspended // 3 - account was suspended
@@ -36,6 +42,9 @@
#define WINIX_ACCOUNT_BLOCKED 4 #define WINIX_ACCOUNT_BLOCKED 4
/* /*
a user can login only to an account which status is equal to WINIX_ACCOUNT_READY a user can login only to an account which status is equal to WINIX_ACCOUNT_READY
@@ -57,6 +66,8 @@
*/ */
struct UserPass struct UserPass
{ {
bool has_pass; // true if the user has a password set
// if false the user cannot login
int pass_type; // the kind of hash (WINIX_CRYPT_HASH_* see crypt.h) int pass_type; // the kind of hash (WINIX_CRYPT_HASH_* see crypt.h)
std::wstring pass; // password hashed or plain text if pass_type==0 std::wstring pass; // password hashed or plain text if pass_type==0
std::string pass_encrypted; // password encrypted std::string pass_encrypted; // password encrypted
@@ -74,7 +85,6 @@ struct User
std::wstring email; std::wstring email;
int notify; int notify;
// environment variables which can be set by this user // environment variables which can be set by this user
// use 'env' winix function // use 'env' winix function
PT::Space env; PT::Space env;
@@ -94,7 +104,6 @@ struct User
// time zone identifier // time zone identifier
size_t time_zone_id; size_t time_zone_id;
User(); User();
void Clear(); void Clear();
@@ -105,4 +114,7 @@ struct User
}; };
} // namespace Winix
#endif #endif
+8 -1
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -13,6 +13,10 @@
#include "plugin.h" #include "plugin.h"
namespace Winix
{
Users::Users() Users::Users()
{ {
@@ -292,3 +296,6 @@ long Users::HowManyLogged()
} // namespace Winix
+8 -2
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -17,6 +17,12 @@
#include "cur.h" #include "cur.h"
#include "db/db.h" #include "db/db.h"
namespace Winix
{
class SessionManager; class SessionManager;
@@ -71,7 +77,7 @@ private:
} // namespace Winix
+11 -3
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2013, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -11,9 +11,17 @@
#define headerfile_winix_core_version #define headerfile_winix_core_version
namespace Winix
{
#define WINIX_VER_MAJOR 0 #define WINIX_VER_MAJOR 0
#define WINIX_VER_MINOR 5 #define WINIX_VER_MINOR 6
#define WINIX_VER_REVISION 5 #define WINIX_VER_REVISION 1
} // namespace Winix
#endif #endif
+16 -6
View File
@@ -2,7 +2,7 @@
* This file is a part of Winix * This file is a part of Winix
* and is not publicly distributed * and is not publicly distributed
* *
* Copyright (c) 2008-2012, Tomasz Sowa * Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
*/ */
@@ -12,6 +12,9 @@
#include "core/misc.h" #include "core/misc.h"
namespace Winix
{
@@ -24,7 +27,7 @@ bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
try try
{ {
query.Clear(); query.Clear();
query << R("select id, password, pass_encrypted, pass_type, pass_hash_salted from core.user where login=") query << R("select id, has_pass, password, pass_encrypted, pass_type, pass_hash_salted from core.user where login=")
<< login << login
<< R(";"); << R(";");
@@ -43,6 +46,7 @@ bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
} }
int cuser_id = AssertColumn(r, "id"); int cuser_id = AssertColumn(r, "id");
int chas_pass = AssertColumn(r, "has_pass");
int cpass_type = AssertColumn(r, "pass_type"); int cpass_type = AssertColumn(r, "pass_type");
int csalted = AssertColumn(r, "pass_hash_salted"); int csalted = AssertColumn(r, "pass_hash_salted");
int cpassword = AssertColumn(r, "password"); int cpassword = AssertColumn(r, "password");
@@ -50,6 +54,7 @@ bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
user_ok = true; user_ok = true;
user_id = AssertValueLong(r, 0, cuser_id); user_id = AssertValueLong(r, 0, cuser_id);
up.has_pass = AssertValueBool(r, 0, chas_pass);
up.pass_type = AssertValueInt(r, 0, cpass_type); up.pass_type = AssertValueInt(r, 0, cpass_type);
up.pass_hash_salted = AssertValueBool(r, 0, csalted); up.pass_hash_salted = AssertValueBool(r, 0, csalted);
AssertValueWide(r, 0, cpassword, up.pass); AssertValueWide(r, 0, cpassword, up.pass);
@@ -76,9 +81,10 @@ Error Db::AddUser(User & user, const UserPass & up)
try try
{ {
query.Clear(); query.Clear();
query << R("insert into core.user (login, password, pass_encrypted, super_user, email," query << R("insert into core.user (login, has_pass, password, pass_encrypted, super_user, email,"
"notify, pass_type, pass_hash_salted, env, aenv, status, locale_id, time_zone_id) values (") "notify, pass_type, pass_hash_salted, env, aenv, status, locale_id, time_zone_id) values (")
<< user.name; << user.name
<< up.has_pass;
// for safety we put up.pass only if there is not an encrypted version // for safety we put up.pass only if there is not an encrypted version
// someone could have forgotten to clear up.pass // someone could have forgotten to clear up.pass
@@ -122,8 +128,9 @@ return status;
Error Db::ChangeUserPass(long user_id, const UserPass & up) Error Db::ChangeUserPass(long user_id, const UserPass & up)
{ {
query.Clear(); query.Clear();
query << R("update core.user set(password, pass_encrypted," query << R("update core.user set(has_pass, password, pass_encrypted,"
"pass_type, pass_hash_salted) = ("); "pass_type, pass_hash_salted) = (")
<< up.has_pass;
// for safety // for safety
if( up.pass_encrypted.empty() ) if( up.pass_encrypted.empty() )
@@ -1732,3 +1739,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