25 Commits
0.4.5 ... 0.4.7

Author SHA1 Message Date
18ecd46a01 changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added:   DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
         it reads binary (bytea) data
added:   DbTextStream can handle 'bool' types now
         (is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
         with RSA
         currently we have following hashes:
         md4, md5, sha1, sha224, sha256, sha384, sha512
         we are using openssl to manage them
         (look at config options for more info)
changed: winix version to 0.4.7         
added:   class Run - you can run any program from os and send a buffer to its standard input
         and read what the program put on its standard output
added:   class Crypt (in System) - calculating hashes, and crypting/decrypting




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 21:22:08 +00:00
af8fbdae72 added: now winix will not log post parameters with 'pass' in names (at the beginning)
changed: only first few characters are logged (from POST)


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@733 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-06 22:47:34 +00:00
c84997be30 small changes in Makefiles
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@731 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-06 20:35:56 +00:00
06551d6084 added: "str" "strnc" ezc functions
changed: ezc functions:
         "winix_false" to "false"
         "winix_true"  to "true"


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@730 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-04-26 17:19:08 +00:00
84145d7cc8 fixed: BBCODEParser incorrectly worked with the latest changes in HTMLFilter
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@729 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-04-16 11:27:54 +00:00
426beae796 renamed: config option 'html_filter_break_lines' to 'html_filter_break_word'
added:   config option 'html_filter_wrap_line'
         this wraps the whole line (line calculated with html tags as well)
changed: orphans (for html filter) are read from locale files now
         ('language_orphans' value )



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@728 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-04-16 08:42:22 +00:00
aadf12c7b3 added support for gzip compression
new config option: compression_encoding (integer)
 1  - use deflate if available (or raw deflate for Internet Explorer) or don't compress
 2  - use gzip if available or don't compress
 10 - prefer deflate -- use deflate (or raw deflate for IE) if both deflate and gzip are available
 20 - prefer gzip    -- use gzip if both deflate and gzip are available
 default: 20

		   


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@727 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-04-02 00:10:16 +00:00
1b60935d08 updated 'galleria' js plugin
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@726 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-04-01 16:30:14 +00:00
d68731fd55 fixed: thread plugin didn't correctly set the last item and replies (in 'thread' table)
when deleting an answer
added: ThreadInfo::Repair() method
       will be used by 'fsck' winix function       
added: plugins/groupitem 
       directory for a new plugin: 'groupitem'
       


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@725 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-03-23 17:54:53 +00:00
ba63c8c661 changed: removed Languages::Land enum
now we set the languages in the config file: option locale_files, sample:
  locale_files = ( en, pl )
it represents the name of locale files (those from locale_dir directory)
renamed config option: locale to locale_default


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@722 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-24 17:06:12 +00:00
15487b347f added ezc function: winix_function_param_is_not
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@721 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-22 04:14:26 +00:00
e7e90c6527 txt templates (a new line was missing)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@720 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-18 09:35:35 +00:00
ca5421347a fixed: a new created session doesn't have a correct time set
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@719 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-18 09:33:15 +00:00
c8a57f2046 added: to gallery plugin: gallery_theme() mount option
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@718 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-15 23:20:12 +00:00
583df13139 added: mount options: thumb_size(cx, cy)
size of a generated thumbnail (size in pixels)
added: plugin gallery: mount option gallery_type
       it can be:
       "lightbox"
       "galleria"
       "galleriathumb"


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@717 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-11 21:37:28 +00:00
5049961e17 added a new plugin: "gallery"
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@716 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-31 15:51:53 +00:00
18492e5d61 changed templates
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@715 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-27 14:35:25 +00:00
d4d9f89d1d changed: ticket templates
added: new plugin message (WINIX_END_REQUEST)


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@714 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-27 12:24:45 +00:00
ecf19034ae added: winix uses now [filter] statement from ezc
added: notifications to threads (were temporarily disabled)
changed: templates in notifications



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@712 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-26 12:45:38 +00:00
00521c490e added: Q encoding in misc: QEncode()
for mails headers encoding



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@711 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-25 11:54:46 +00:00
3071df227a fixed: find_ticket_value (in plugins/ticket/templates.cpp)
should find the first item (can be more than one item with the same 'param')

fixed: added sorting tickets params in ReadTicketParams() (in plugins/ticket/ticketinfo.cpp)

fixed: plugin should have its own 'PluginInfo info' struct
a plugin's function can call another plugin's functions

added: removing tickets files/images

added: removing threads

changed: rm function will call WINIX_FILE_REMOVED now when deleting directories





git-svn-id: svn://ttmath.org/publicrep/winix/trunk@710 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-23 23:23:24 +00:00
915cabdf97 changed: added Cur structure
we have there two pointers: 
 Request * request;
 Session * session;
these are the current request and the current session


the session GC was moved to SessionManager (was in SessionContainer)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@708 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-23 14:15:30 +00:00
61ac29b2de added in ticket/templates.cpp binary search for tickets and tickets parameters
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@707 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-21 16:16:52 +00:00
ab84a5169e 'tickets' can use 'threads' now
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@706 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-20 18:37:51 +00:00
3fad25b8c8 moved some thread files to plugins/thread
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@705 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-05 21:44:19 +00:00
271 changed files with 10572 additions and 5454 deletions

View File

@@ -1,67 +1,84 @@
# Makefile for GNU make
ifndef CXX
CXX = g++
endif
ifndef CXXFLAGS
CXXFLAGS = -fPIC -Wall -pedantic -O2 -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER
CXXFLAGS = -fPIC -Wall -pedantic -O2 -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
endif
export CXX
export CXXFLAGS
all: winix.so plugins winix
all: winix
winix: FORCE
winix.so: FORCE
@cd core ; $(MAKE) -e
@cd db ; $(MAKE) -e
@cd functions ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd templates ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd plugins/stats ; $(MAKE) -e
@cd plugins/ticket ; $(MAKE) -e
@cd ../ezc/src ; $(MAKE) -e
$(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread -lfetch
winix: FORCE
@cd main ; $(MAKE) -e
# use the full path with winix.so
$(CXX) -o winix $(CXXFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so
$(CXX) -o winix $(CXXFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so
clean:
@cd core ; $(MAKE) -e clean
@cd db ; $(MAKE) -e clean
@cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@cd ../ezc/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
rm -f winix
plugins: FORCE
@cd plugins/stats ; $(MAKE) -e
@cd plugins/thread ; $(MAKE) -e
@cd plugins/ticket ; $(MAKE) -e
@cd plugins/gallery ; $(MAKE) -e
@cd plugins/groupitem ; $(MAKE) -e
FORCE:
clean:
@cd core ; $(MAKE) -e clean
@cd db ; $(MAKE) -e clean
@cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@cd plugins/gallery ; $(MAKE) -e clean
@cd plugins/groupitem ; $(MAKE) -e clean
@cd ../ezc/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
rm -f winix
depend:
@cd core ; $(MAKE) -e depend
@cd db ; $(MAKE) -e depend
@cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd ../ezc/src ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend
@cd core ; $(MAKE) -e depend
@cd db ; $(MAKE) -e depend
@cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/groupitem ; $(MAKE) -e depend
@cd ../ezc/src ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend
install: all

View File

@@ -4,13 +4,10 @@ include Makefile.o.dep
all: $(o)
.SUFFIXES: .cpp .o
.cpp.o:
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $<
depend:
makedepend -Y. -I.. -I../../ezc/src -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep

View File

@@ -5,90 +5,89 @@ app.o: app.h config.h confparser.h htmlfilter.h system.h dirs.h item.h
app.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
app.o: ../db/dbtextstream.h ../core/textstream.h misc.h ../core/error.h log.h
app.o: textstream.h ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
app.o: ../core/user.h ../core/group.h ../core/thread.h ../core/dircontainer.h
app.o: ../core/ugcontainer.h request.h requesttypes.h session.h error.h
app.o: user.h plugindata.h rebus.h ../templates/htmltextstream.h
app.o: ../notify/notify.h ../notify/notifypool.h ../templates/locale.h
app.o: ../core/confparser.h ../templates/misc.h ../templates/localefilter.h
app.o: ../templates/locale.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
app.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
app.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
app.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
app.o: ../notify/notifythread.h ../core/basethread.h synchro.h
app.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
app.o: ugcontainer.h lastcontainer.h mounts.h mount.h mountparser.h users.h
app.o: groups.h group.h loadavg.h thumb.h basethread.h sessionmanager.h
app.o: sessioncontainer.h ../functions/functions.h
app.o: ../core/user.h ../core/group.h ../core/dircontainer.h
app.o: ../core/ugcontainer.h request.h requesttypes.h error.h
app.o: ../templates/htmltextstream.h ../notify/notify.h
app.o: ../notify/notifypool.h ../templates/locale.h ../core/confparser.h
app.o: ../templates/misc.h ../templates/localefilter.h ../templates/locale.h
app.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
app.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
app.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
app.o: ../templates/htmltextstream.h ../notify/notifythread.h
app.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
app.o: ../core/config.h ../core/users.h user.h ugcontainer.h lastcontainer.h
app.o: cur.h session.h plugindata.h rebus.h mounts.h mount.h mountparser.h
app.o: crypt.h run.h users.h groups.h group.h loadavg.h thumb.h basethread.h
app.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
app.o: ../functions/functionbase.h ../core/request.h ../core/system.h
app.o: ../core/synchro.h ../functions/functionparser.h ../functions/adduser.h
app.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
app.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
app.o: ../functions/createthread.h ../functions/functionbase.h
app.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
app.o: ../functions/last.h ../functions/login.h ../functions/logout.h
app.o: ../functions/ln.h ../functions/ls.h ../functions/mkdir.h
app.o: ../functions/mv.h ../functions/node.h ../functions/priv.h
app.o: ../functions/reload.h ../functions/rm.h ../functions/run.h
app.o: ../functions/specialdefault.h ../functions/stat.h
app.o: ../functions/subject.h ../functions/funthread.h
app.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h
app.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
app.o: ../functions/vim.h ../core/htmlfilter.h ../templates/templates.h
app.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
app.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
app.o: ../core/sessionmanager.h compress.h getparser.h httpsimpleparser.h
app.o: postparser.h cookieparser.h postmultiparser.h acceptencodingparser.h
app.o: acceptbaseparser.h plugin.h pluginmsg.h
app.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
app.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
app.o: ../functions/privchanger.h ../functions/chown.h
app.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
app.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
app.o: ../functions/login.h ../functions/logout.h ../functions/ln.h
app.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h
app.o: ../functions/node.h ../functions/priv.h ../functions/reload.h
app.o: ../functions/rm.h ../functions/specialdefault.h ../functions/stat.h
app.o: ../functions/subject.h ../functions/template.h ../functions/tinymce.h
app.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h
app.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
app.o: ../templates/templates.h ../templates/patterncacher.h
app.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
app.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h
app.o: compress.h getparser.h httpsimpleparser.h postparser.h cookieparser.h
app.o: postmultiparser.h acceptencodingparser.h acceptbaseparser.h plugin.h
app.o: pluginmsg.h
basethread.o: basethread.h log.h textstream.h
bbcodeparser.o: bbcodeparser.h htmlfilter.h
compress.o: compress.h log.h textstream.h
config.o: config.h confparser.h htmlfilter.h log.h textstream.h plugin.h
config.o: pluginmsg.h plugindata.h request.h requesttypes.h session.h item.h
config.o: error.h user.h rebus.h ../templates/htmltextstream.h
config.o: ../core/textstream.h misc.h system.h dirs.h dircontainer.h
config.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
config.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
config.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
config.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
config.o: ../notify/notify.h ../notify/notifypool.h ../templates/locale.h
config.o: ../core/confparser.h ../templates/misc.h
config.o: ../templates/localefilter.h ../templates/locale.h
config.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
config.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
config.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
config.o: ../templates/htmltextstream.h ../notify/notifythread.h
config.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
config.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
config.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.h
config.o: thumb.h basethread.h sessionmanager.h sessioncontainer.h
config.o: pluginmsg.h plugindata.h request.h requesttypes.h item.h error.h
config.o: ../templates/htmltextstream.h ../core/textstream.h misc.h system.h
config.o: dirs.h dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
config.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h
config.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
config.o: ../core/dircontainer.h ../core/ugcontainer.h ../notify/notify.h
config.o: ../notify/notifypool.h ../templates/locale.h ../core/confparser.h
config.o: ../templates/misc.h ../templates/localefilter.h
config.o: ../templates/locale.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
config.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
config.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
config.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
config.o: ../notify/notifythread.h ../core/basethread.h synchro.h
config.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h user.h
config.o: ugcontainer.h lastcontainer.h cur.h session.h rebus.h mounts.h
config.o: mount.h mountparser.h crypt.h run.h users.h groups.h group.h
config.o: loadavg.h thumb.h basethread.h sessionmanager.h sessioncontainer.h
config.o: ../functions/functions.h ../functions/functionbase.h
config.o: ../core/request.h ../core/system.h ../core/synchro.h
config.o: ../functions/functionparser.h ../functions/adduser.h
config.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
config.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
config.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
config.o: ../functions/createthread.h ../functions/functionbase.h
config.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
config.o: ../functions/last.h ../functions/login.h ../functions/logout.h
config.o: ../functions/ln.h ../functions/ls.h ../functions/mkdir.h
config.o: ../functions/mv.h ../functions/node.h ../functions/priv.h
config.o: ../functions/reload.h ../functions/rm.h ../functions/run.h
config.o: ../functions/reload.h ../functions/rm.h
config.o: ../functions/specialdefault.h ../functions/stat.h
config.o: ../functions/subject.h ../functions/funthread.h
config.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h
config.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
config.o: ../functions/vim.h ../core/htmlfilter.h ../templates/templates.h
config.o: ../functions/subject.h ../functions/template.h
config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
config.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
config.o: ../core/htmlfilter.h ../templates/templates.h
config.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
config.o: ../core/httpsimpleparser.h ../core/log.h
config.o: ../templates/indexpatterns.h ../core/sessionmanager.h
confparser.o: confparser.h misc.h item.h ../../ezc/src/utf8.h
crypt.o: crypt.h run.h config.h confparser.h htmlfilter.h user.h
crypt.o: ../../ezc/src/utf8.h misc.h item.h log.h textstream.h
dircontainer.o: dircontainer.h item.h log.h textstream.h
dirs.o: dirs.h item.h dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
dirs.o: ../db/dbtextstream.h ../core/textstream.h misc.h ../core/error.h
dirs.o: log.h textstream.h ../db/dbitemquery.h ../core/item.h
dirs.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
dirs.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
dirs.o: ../core/dircontainer.h ../core/ugcontainer.h request.h requesttypes.h
dirs.o: session.h error.h user.h plugindata.h rebus.h config.h confparser.h
dirs.o: htmlfilter.h ../templates/htmltextstream.h ../notify/notify.h
dirs.o: error.h config.h confparser.h htmlfilter.h
dirs.o: ../templates/htmltextstream.h ../notify/notify.h
dirs.o: ../notify/notifypool.h ../templates/locale.h ../core/confparser.h
dirs.o: ../templates/misc.h ../templates/localefilter.h ../templates/locale.h
dirs.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
@@ -96,12 +95,13 @@ dirs.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
dirs.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
dirs.o: ../templates/htmltextstream.h ../notify/notifythread.h
dirs.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
dirs.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
dirs.o: ../core/config.h ../core/users.h user.h ugcontainer.h lastcontainer.h
dirs.o: cur.h session.h plugindata.h rebus.h
groups.o: groups.h group.h ugcontainer.h ../db/db.h ../db/dbbase.h
groups.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
groups.o: item.h ../core/error.h log.h textstream.h ../db/dbitemquery.h
groups.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
groups.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
groups.o: ../core/dircontainer.h ../core/ugcontainer.h
htmlfilter.o: htmlfilter.h
httpsimpleparser.o: httpsimpleparser.h
item.o: item.h misc.h
@@ -116,20 +116,19 @@ misc.o: ../templates/patterncacher.h ../core/item.h
misc.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
misc.o: ../core/log.h ../templates/indexpatterns.h
misc.o: ../templates/localefilter.h ../templates/locale.h ../core/config.h
misc.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
misc.o: ../templates/htmltextstream.h ../core/cur.h ../core/system.h
misc.o: ../core/sessionmanager.h ../core/htmlfilter.h ../db/db.h
misc.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
misc.o: ../core/textstream.h ../core/error.h ../db/dbitemquery.h
misc.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
misc.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
misc.o: ../core/dircontainer.h ../core/ugcontainer.h
misc.o: ../templates/htmltextstream.h ../core/request.h ../core/system.h
misc.o: ../core/sessionmanager.h
mount.o: mount.h misc.h item.h
mountparser.o: mountparser.h mount.h item.h error.h dirs.h dircontainer.h
mountparser.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
mountparser.o: ../core/textstream.h misc.h ../core/error.h log.h textstream.h
mountparser.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
mountparser.o: ../core/user.h ../core/group.h ../core/thread.h
mountparser.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
mountparser.o: requesttypes.h session.h user.h plugindata.h rebus.h config.h
mountparser.o: ../core/user.h ../core/group.h ../core/dircontainer.h
mountparser.o: ../core/ugcontainer.h request.h requesttypes.h config.h
mountparser.o: confparser.h htmlfilter.h ../templates/htmltextstream.h
mountparser.o: ../notify/notify.h ../notify/notifypool.h
mountparser.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
@@ -140,14 +139,14 @@ mountparser.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
mountparser.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
mountparser.o: ../notify/notifythread.h ../core/basethread.h synchro.h
mountparser.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
mountparser.o: ugcontainer.h lastcontainer.h
mountparser.o: user.h ugcontainer.h lastcontainer.h cur.h session.h
mountparser.o: plugindata.h rebus.h
mounts.o: mounts.h mount.h error.h dirs.h item.h dircontainer.h ../db/db.h
mounts.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
mounts.o: ../core/textstream.h misc.h ../core/error.h log.h textstream.h
mounts.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
mounts.o: ../core/user.h ../core/group.h ../core/thread.h
mounts.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
mounts.o: requesttypes.h session.h user.h plugindata.h rebus.h config.h
mounts.o: ../core/user.h ../core/group.h ../core/dircontainer.h
mounts.o: ../core/ugcontainer.h request.h requesttypes.h config.h
mounts.o: confparser.h htmlfilter.h ../templates/htmltextstream.h
mounts.o: ../notify/notify.h ../notify/notifypool.h ../templates/locale.h
mounts.o: ../core/confparser.h ../templates/misc.h
@@ -157,77 +156,73 @@ mounts.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
mounts.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
mounts.o: ../templates/htmltextstream.h ../notify/notifythread.h
mounts.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
mounts.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
mounts.o: mountparser.h plugin.h pluginmsg.h system.h users.h groups.h
mounts.o: ../core/config.h ../core/users.h user.h ugcontainer.h
mounts.o: lastcontainer.h cur.h session.h plugindata.h rebus.h mountparser.h
mounts.o: plugin.h pluginmsg.h system.h crypt.h run.h users.h groups.h
mounts.o: group.h loadavg.h thumb.h basethread.h sessionmanager.h
mounts.o: sessioncontainer.h ../functions/functions.h
mounts.o: ../functions/functionbase.h ../core/request.h ../core/system.h
mounts.o: ../core/synchro.h ../functions/functionparser.h
mounts.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
mounts.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
mounts.o: ../functions/privchanger.h ../functions/chown.h
mounts.o: ../functions/ckeditor.h ../functions/cp.h
mounts.o: ../functions/createthread.h ../functions/functionbase.h
mounts.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
mounts.o: ../functions/last.h ../functions/login.h ../functions/logout.h
mounts.o: ../functions/ln.h ../functions/ls.h ../functions/mkdir.h
mounts.o: ../functions/mv.h ../functions/node.h ../functions/priv.h
mounts.o: ../functions/reload.h ../functions/rm.h ../functions/run.h
mounts.o: ../functions/specialdefault.h ../functions/stat.h
mounts.o: ../functions/subject.h ../functions/funthread.h
mounts.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h
mounts.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
mounts.o: ../functions/vim.h ../core/htmlfilter.h ../templates/templates.h
mounts.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
mounts.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
mounts.o: ../functions/login.h ../functions/logout.h ../functions/ln.h
mounts.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h
mounts.o: ../functions/node.h ../functions/priv.h ../functions/reload.h
mounts.o: ../functions/rm.h ../functions/specialdefault.h ../functions/stat.h
mounts.o: ../functions/subject.h ../functions/template.h
mounts.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
mounts.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
mounts.o: ../core/htmlfilter.h ../templates/templates.h
mounts.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
mounts.o: ../core/httpsimpleparser.h ../core/log.h
mounts.o: ../templates/indexpatterns.h ../core/sessionmanager.h
plugin.o: plugin.h pluginmsg.h log.h textstream.h plugindata.h config.h
plugin.o: confparser.h htmlfilter.h request.h requesttypes.h session.h item.h
plugin.o: error.h user.h rebus.h ../templates/htmltextstream.h
plugin.o: ../core/textstream.h misc.h system.h dirs.h dircontainer.h
plugin.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
plugin.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
plugin.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
plugin.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
plugin.o: ../notify/notify.h ../notify/notifypool.h ../templates/locale.h
plugin.o: ../core/confparser.h ../templates/misc.h
plugin.o: ../templates/localefilter.h ../templates/locale.h
plugin.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
plugin.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
plugin.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
plugin.o: ../templates/htmltextstream.h ../notify/notifythread.h
plugin.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
plugin.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
plugin.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.h
plugin.o: thumb.h basethread.h sessionmanager.h sessioncontainer.h
plugin.o: confparser.h htmlfilter.h request.h requesttypes.h item.h error.h
plugin.o: ../templates/htmltextstream.h ../core/textstream.h misc.h system.h
plugin.o: dirs.h dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
plugin.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h
plugin.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
plugin.o: ../core/dircontainer.h ../core/ugcontainer.h ../notify/notify.h
plugin.o: ../notify/notifypool.h ../templates/locale.h ../core/confparser.h
plugin.o: ../templates/misc.h ../templates/localefilter.h
plugin.o: ../templates/locale.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
plugin.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
plugin.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
plugin.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
plugin.o: ../notify/notifythread.h ../core/basethread.h synchro.h
plugin.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h user.h
plugin.o: ugcontainer.h lastcontainer.h cur.h session.h rebus.h mounts.h
plugin.o: mount.h mountparser.h crypt.h run.h users.h groups.h group.h
plugin.o: loadavg.h thumb.h basethread.h sessionmanager.h sessioncontainer.h
plugin.o: ../functions/functions.h ../functions/functionbase.h
plugin.o: ../core/request.h ../core/system.h ../core/synchro.h
plugin.o: ../functions/functionparser.h ../functions/adduser.h
plugin.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
plugin.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
plugin.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
plugin.o: ../functions/createthread.h ../functions/functionbase.h
plugin.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
plugin.o: ../functions/last.h ../functions/login.h ../functions/logout.h
plugin.o: ../functions/ln.h ../functions/ls.h ../functions/mkdir.h
plugin.o: ../functions/mv.h ../functions/node.h ../functions/priv.h
plugin.o: ../functions/reload.h ../functions/rm.h ../functions/run.h
plugin.o: ../functions/reload.h ../functions/rm.h
plugin.o: ../functions/specialdefault.h ../functions/stat.h
plugin.o: ../functions/subject.h ../functions/funthread.h
plugin.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h
plugin.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
plugin.o: ../functions/vim.h ../core/htmlfilter.h ../templates/templates.h
plugin.o: ../functions/subject.h ../functions/template.h
plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
plugin.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
plugin.o: ../core/htmlfilter.h ../templates/templates.h
plugin.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
plugin.o: ../core/httpsimpleparser.h ../core/log.h
plugin.o: ../templates/indexpatterns.h ../core/sessionmanager.h
plugindata.o: plugindata.h plugin.h pluginmsg.h log.h textstream.h config.h
plugindata.o: confparser.h htmlfilter.h request.h requesttypes.h session.h
plugindata.o: item.h error.h user.h rebus.h ../templates/htmltextstream.h
plugindata.o: ../core/textstream.h misc.h system.h dirs.h dircontainer.h
plugindata.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
plugindata.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
plugindata.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
plugindata.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
plugindata.o: ../notify/notify.h ../notify/notifypool.h ../templates/locale.h
plugindata.o: ../core/confparser.h ../templates/misc.h
plugindata.o: confparser.h htmlfilter.h request.h requesttypes.h item.h
plugindata.o: error.h ../templates/htmltextstream.h ../core/textstream.h
plugindata.o: misc.h system.h dirs.h dircontainer.h ../db/db.h ../db/dbbase.h
plugindata.o: ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
plugindata.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
plugindata.o: ../core/user.h ../core/group.h ../core/dircontainer.h
plugindata.o: ../core/ugcontainer.h ../notify/notify.h ../notify/notifypool.h
plugindata.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
plugindata.o: ../templates/localefilter.h ../templates/locale.h
plugindata.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h
plugindata.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
@@ -235,23 +230,22 @@ plugindata.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
plugindata.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
plugindata.o: ../notify/notifythread.h ../core/basethread.h synchro.h
plugindata.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
plugindata.o: ugcontainer.h lastcontainer.h mounts.h mount.h mountparser.h
plugindata.o: users.h groups.h group.h loadavg.h thumb.h basethread.h
plugindata.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
plugindata.o: user.h ugcontainer.h lastcontainer.h cur.h session.h rebus.h
plugindata.o: mounts.h mount.h mountparser.h crypt.h run.h users.h groups.h
plugindata.o: group.h loadavg.h thumb.h basethread.h sessionmanager.h
plugindata.o: sessioncontainer.h ../functions/functions.h
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/system.h
plugindata.o: ../core/synchro.h ../functions/functionparser.h
plugindata.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
plugindata.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
plugindata.o: ../functions/privchanger.h ../functions/chown.h
plugindata.o: ../functions/ckeditor.h ../functions/cp.h
plugindata.o: ../functions/createthread.h ../functions/functionbase.h
plugindata.o: ../functions/default.h ../functions/download.h
plugindata.o: ../functions/emacs.h ../functions/last.h ../functions/login.h
plugindata.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
plugindata.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h
plugindata.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h
plugindata.o: ../functions/run.h ../functions/specialdefault.h
plugindata.o: ../functions/stat.h ../functions/subject.h
plugindata.o: ../functions/funthread.h ../functions/template.h
plugindata.o: ../functions/specialdefault.h ../functions/stat.h
plugindata.o: ../functions/subject.h ../functions/template.h
plugindata.o: ../functions/tinymce.h ../functions/uname.h
plugindata.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
plugindata.o: ../functions/vim.h ../core/htmlfilter.h
@@ -262,112 +256,110 @@ plugindata.o: ../core/sessionmanager.h
postmultiparser.o: postmultiparser.h error.h requesttypes.h config.h
postmultiparser.o: confparser.h htmlfilter.h log.h textstream.h
postmultiparser.o: ../../ezc/src/utf8.h misc.h item.h
rebus.o: log.h textstream.h rebus.h misc.h item.h request.h requesttypes.h
rebus.o: session.h error.h user.h plugindata.h config.h confparser.h
rebus.o: htmlfilter.h ../templates/htmltextstream.h ../core/textstream.h
request.o: request.h requesttypes.h session.h item.h error.h user.h
request.o: plugindata.h rebus.h config.h confparser.h htmlfilter.h
request.o: textstream.h ../templates/htmltextstream.h ../core/textstream.h
request.o: misc.h log.h plugin.h pluginmsg.h system.h dirs.h dircontainer.h
request.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
request.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
request.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
request.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
request.o: ../notify/notify.h ../notify/notifypool.h ../templates/locale.h
request.o: ../core/confparser.h ../templates/misc.h
rebus.o: log.h textstream.h rebus.h misc.h item.h cur.h request.h
rebus.o: requesttypes.h error.h config.h confparser.h htmlfilter.h
rebus.o: ../templates/htmltextstream.h ../core/textstream.h session.h user.h
rebus.o: plugindata.h
request.o: request.h requesttypes.h item.h error.h config.h confparser.h
request.o: htmlfilter.h textstream.h ../templates/htmltextstream.h
request.o: ../core/textstream.h misc.h log.h plugin.h pluginmsg.h
request.o: plugindata.h system.h dirs.h dircontainer.h ../db/db.h
request.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
request.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
request.o: ../core/user.h ../core/group.h ../core/dircontainer.h
request.o: ../core/ugcontainer.h ../notify/notify.h ../notify/notifypool.h
request.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
request.o: ../templates/localefilter.h ../templates/locale.h
request.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
request.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
request.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
request.o: ../templates/htmltextstream.h ../notify/notifythread.h
request.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
request.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
request.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.h
request.o: ../core/config.h ../core/users.h user.h ugcontainer.h
request.o: lastcontainer.h cur.h session.h rebus.h mounts.h mount.h
request.o: mountparser.h crypt.h run.h users.h groups.h group.h loadavg.h
request.o: thumb.h basethread.h sessionmanager.h sessioncontainer.h
request.o: ../functions/functions.h ../functions/functionbase.h
request.o: ../core/request.h ../core/system.h ../core/synchro.h
request.o: ../functions/functionparser.h ../functions/adduser.h
request.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
request.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
request.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
request.o: ../functions/createthread.h ../functions/functionbase.h
request.o: ../functions/default.h ../functions/download.h
request.o: ../functions/emacs.h ../functions/last.h ../functions/login.h
request.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
request.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h
request.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h
request.o: ../functions/run.h ../functions/specialdefault.h
request.o: ../functions/stat.h ../functions/subject.h
request.o: ../functions/funthread.h ../functions/template.h
request.o: ../functions/specialdefault.h ../functions/stat.h
request.o: ../functions/subject.h ../functions/template.h
request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
request.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
request.o: ../core/htmlfilter.h ../templates/templates.h
request.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
request.o: ../core/httpsimpleparser.h ../core/log.h
request.o: ../templates/indexpatterns.h ../core/sessionmanager.h
run.o: run.h log.h textstream.h
session.o: session.h item.h error.h user.h plugindata.h rebus.h misc.h
sessioncontainer.o: sessioncontainer.h session.h item.h error.h user.h
sessioncontainer.o: plugindata.h rebus.h lastcontainer.h request.h
sessioncontainer.o: requesttypes.h config.h confparser.h htmlfilter.h
sessioncontainer.o: textstream.h ../templates/htmltextstream.h
sessioncontainer.o: ../core/textstream.h misc.h basethread.h log.h
sessioncontainer.o: plugindata.h rebus.h cur.h request.h requesttypes.h
sessioncontainer.o: config.h confparser.h htmlfilter.h textstream.h
sessioncontainer.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
sessioncontainer.o: log.h
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h
sessionmanager.o: error.h user.h plugindata.h rebus.h lastcontainer.h
sessionmanager.o: request.h requesttypes.h config.h confparser.h htmlfilter.h
sessionmanager.o: error.h user.h plugindata.h rebus.h cur.h request.h
sessionmanager.o: requesttypes.h config.h confparser.h htmlfilter.h
sessionmanager.o: textstream.h ../templates/htmltextstream.h
sessionmanager.o: ../core/textstream.h misc.h basethread.h system.h dirs.h
sessionmanager.o: ../core/textstream.h misc.h lastcontainer.h system.h dirs.h
sessionmanager.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
sessionmanager.o: ../db/dbtextstream.h ../core/error.h log.h
sessionmanager.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
sessionmanager.o: ../core/user.h ../core/group.h ../core/thread.h
sessionmanager.o: ../core/dircontainer.h ../core/ugcontainer.h
sessionmanager.o: ../notify/notify.h ../notify/notifypool.h
sessionmanager.o: ../templates/locale.h ../core/confparser.h
sessionmanager.o: ../templates/misc.h ../templates/localefilter.h
sessionmanager.o: ../templates/locale.h ../../ezc/src/ezc.h
sessionmanager.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
sessionmanager.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
sessionmanager.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
sessionmanager.o: ../templates/htmltextstream.h ../notify/notifythread.h
sessionmanager.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
sessionmanager.o: ../core/config.h ../core/users.h ugcontainer.h mounts.h
sessionmanager.o: mount.h mountparser.h users.h groups.h group.h loadavg.h
sessionmanager.o: thumb.h sessionparser.h plugin.h pluginmsg.h
sessionmanager.o: ../functions/functions.h ../functions/functionbase.h
sessionmanager.o: ../core/request.h ../core/system.h ../core/synchro.h
sessionmanager.o: ../functions/functionparser.h ../functions/adduser.h
sessionmanager.o: ../functions/cat.h ../functions/chmod.h
sessionmanager.o: ../functions/privchanger.h ../functions/chown.h
sessionmanager.o: ../functions/ckeditor.h ../functions/cp.h
sessionmanager.o: ../functions/createthread.h ../functions/functionbase.h
sessionmanager.o: ../functions/default.h ../functions/download.h
sessionmanager.o: ../functions/emacs.h ../functions/last.h
sessionmanager.o: ../functions/login.h ../functions/logout.h
sessionmanager.o: ../functions/ln.h ../functions/ls.h ../functions/mkdir.h
sessionmanager.o: ../functions/mv.h ../functions/node.h ../functions/priv.h
sessionmanager.o: ../functions/reload.h ../functions/rm.h ../functions/run.h
sessionmanager.o: ../core/user.h ../core/group.h ../core/dircontainer.h
sessionmanager.o: ../core/ugcontainer.h ../notify/notify.h
sessionmanager.o: ../notify/notifypool.h ../templates/locale.h
sessionmanager.o: ../core/confparser.h ../templates/misc.h
sessionmanager.o: ../templates/localefilter.h ../templates/locale.h
sessionmanager.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h
sessionmanager.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
sessionmanager.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
sessionmanager.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
sessionmanager.o: ../notify/notifythread.h ../core/basethread.h synchro.h
sessionmanager.o: ../notify/templatesnotify.h ../core/config.h
sessionmanager.o: ../core/users.h ugcontainer.h mounts.h mount.h
sessionmanager.o: mountparser.h crypt.h run.h users.h groups.h group.h
sessionmanager.o: loadavg.h thumb.h basethread.h sessionparser.h plugin.h
sessionmanager.o: pluginmsg.h ../functions/functions.h
sessionmanager.o: ../functions/functionbase.h ../core/request.h
sessionmanager.o: ../core/system.h ../core/synchro.h
sessionmanager.o: ../functions/functionparser.h ../core/cur.h
sessionmanager.o: ../functions/adduser.h ../functions/cat.h
sessionmanager.o: ../functions/chmod.h ../functions/privchanger.h
sessionmanager.o: ../functions/chown.h ../functions/ckeditor.h
sessionmanager.o: ../functions/cp.h ../functions/default.h
sessionmanager.o: ../functions/download.h ../functions/emacs.h
sessionmanager.o: ../functions/last.h ../functions/login.h
sessionmanager.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
sessionmanager.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h
sessionmanager.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h
sessionmanager.o: ../functions/specialdefault.h ../functions/stat.h
sessionmanager.o: ../functions/subject.h ../functions/funthread.h
sessionmanager.o: ../functions/template.h ../functions/tinymce.h
sessionmanager.o: ../functions/uname.h ../functions/upload.h
sessionmanager.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
sessionmanager.o: ../core/htmlfilter.h ../templates/templates.h
sessionmanager.o: ../templates/patterncacher.h
sessionmanager.o: ../functions/subject.h ../functions/template.h
sessionmanager.o: ../functions/tinymce.h ../functions/uname.h
sessionmanager.o: ../functions/upload.h ../functions/uptime.h
sessionmanager.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
sessionmanager.o: ../templates/templates.h ../templates/patterncacher.h
sessionmanager.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
sessionmanager.o: ../core/log.h ../templates/indexpatterns.h
sessionmanager.o: ../core/sessionmanager.h
sessionparser.o: sessionparser.h session.h item.h error.h user.h plugindata.h
sessionparser.o: rebus.h sessioncontainer.h lastcontainer.h request.h
sessionparser.o: requesttypes.h config.h confparser.h htmlfilter.h
sessionparser.o: textstream.h ../templates/htmltextstream.h
sessionparser.o: ../core/textstream.h misc.h basethread.h users.h log.h
sessionparser.o: rebus.h sessioncontainer.h cur.h request.h requesttypes.h
sessionparser.o: config.h confparser.h htmlfilter.h textstream.h
sessionparser.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
sessionparser.o: users.h log.h
synchro.o: synchro.h
system.o: system.h dirs.h item.h dircontainer.h ../db/db.h ../db/dbbase.h
system.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
system.o: ../core/error.h log.h textstream.h ../db/dbitemquery.h
system.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
system.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
system.o: request.h requesttypes.h session.h error.h user.h plugindata.h
system.o: rebus.h config.h confparser.h htmlfilter.h
system.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
system.o: requesttypes.h error.h config.h confparser.h htmlfilter.h
system.o: ../templates/htmltextstream.h ../notify/notify.h
system.o: ../notify/notifypool.h ../templates/locale.h ../core/confparser.h
system.o: ../templates/misc.h ../templates/localefilter.h
@@ -376,23 +368,23 @@ system.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
system.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
system.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
system.o: ../notify/notifythread.h ../core/basethread.h synchro.h
system.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
system.o: ugcontainer.h lastcontainer.h mounts.h mount.h mountparser.h
system.o: users.h groups.h group.h loadavg.h thumb.h basethread.h
system.o: ../templates/templates.h ../templates/patterncacher.h
system.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
system.o: ../core/log.h ../templates/indexpatterns.h ../core/request.h
system.o: ../core/system.h ../core/sessionmanager.h
system.o: ../functions/functionbase.h
system.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h user.h
system.o: ugcontainer.h lastcontainer.h cur.h session.h plugindata.h rebus.h
system.o: mounts.h mount.h mountparser.h crypt.h run.h users.h groups.h
system.o: group.h loadavg.h thumb.h basethread.h ../templates/templates.h
system.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
system.o: ../core/httpsimpleparser.h ../core/log.h
system.o: ../templates/indexpatterns.h ../core/cur.h ../core/system.h
system.o: ../core/sessionmanager.h ../core/htmlfilter.h
system.o: ../functions/functionbase.h ../core/request.h ../core/synchro.h
textstream.o: textstream.h misc.h item.h
thumb.o: thumb.h basethread.h textstream.h ../db/db.h ../db/dbbase.h
thumb.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
thumb.o: item.h ../core/error.h log.h ../db/dbitemquery.h ../core/item.h
thumb.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
thumb.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
thumb.o: ../core/config.h ../../ezc/src/utf8.h system.h dirs.h dircontainer.h
thumb.o: request.h requesttypes.h session.h error.h user.h plugindata.h
thumb.o: rebus.h config.h confparser.h htmlfilter.h
thumb.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/config.h
thumb.o: ../../ezc/src/utf8.h system.h dirs.h dircontainer.h request.h
thumb.o: requesttypes.h error.h config.h confparser.h htmlfilter.h
thumb.o: ../templates/htmltextstream.h ../notify/notify.h
thumb.o: ../notify/notifypool.h ../templates/locale.h ../core/confparser.h
thumb.o: ../templates/misc.h ../templates/localefilter.h
@@ -401,6 +393,7 @@ thumb.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
thumb.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
thumb.o: ../templates/htmltextstream.h ../notify/notifythread.h
thumb.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
thumb.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h mount.h
thumb.o: mountparser.h users.h groups.h group.h loadavg.h
thumb.o: ../core/users.h user.h ugcontainer.h lastcontainer.h cur.h session.h
thumb.o: plugindata.h rebus.h mounts.h mount.h mountparser.h crypt.h run.h
thumb.o: users.h groups.h group.h loadavg.h
users.o: users.h

View File

@@ -1 +1 @@
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o confparser.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o item.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o session.o sessioncontainer.o sessionmanager.o sessionparser.o synchro.o system.o textstream.o thumb.o users.o
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o confparser.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o item.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionmanager.o sessionparser.o synchro.o system.o textstream.o thumb.o users.o

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoreacceptbaseparser
#define headerfilecmslucoreacceptbaseparser
#ifndef headerfile_winix_core_acceptbaseparser
#define headerfile_winix_core_acceptbaseparser
#include <string>

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoreacceptencodingparser
#define headerfilecmslucoreacceptencodingparser
#ifndef headerfile_winix_core_acceptencodingparser
#define headerfile_winix_core_acceptencodingparser
#include "acceptbaseparser.h"
#include "log.h"
@@ -24,24 +24,60 @@ public:
}
bool AcceptGzip()
{
return accept_gzip;
}
void ParseAndLog(const char * str)
{
Parse(str);
if( accept_deflate || accept_gzip )
{
log << log3 << "AEP: ";
if( accept_deflate )
{
log << "accept deflate";
if( accept_gzip )
log << ", ";
}
if( accept_gzip )
log << "accept gzip";
log << logend;
}
}
private:
void Init()
{
accept_deflate = false;
accept_gzip = false;
}
void Param(const std::string & param, double q)
{
if( param=="deflate" && q!=0 )
if( param=="deflate" && q!=0.0 )
{
accept_deflate = true;
log << log3 << "AEP: accept deflate" << logend;
}
if( param=="gzip" && q!=0.0 )
{
accept_gzip = true;
}
}
bool accept_deflate;
bool accept_gzip;
};

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -31,33 +31,37 @@ App::App()
last_sessions_save = std::time(0);
fcgi_socket = -1;
// temporary there is only one request
cur.request = &req;
cur.session = session_manager.GetTmpSession();
db.SetConn(db_conn);
plugin.SetDb(&db);
plugin.SetConfig(&config);
plugin.SetRequest(&request);
plugin.SetCur(&cur);
plugin.SetSystem(&system);
plugin.SetFunctions(&functions);
plugin.SetTemplates(&templates);
plugin.SetSynchro(&synchro);
plugin.SetSessionManager(&session_manager);
request.SetConfig(&config);
req.SetConfig(&config);
functions.SetConfig(&config);
functions.SetRequest(&request);
functions.SetCur(&cur);
functions.SetDb(&db);
functions.SetSystem(&system);
functions.SetTemplates(&templates);
functions.SetSynchro(&synchro);
system.SetConfig(&config);
system.SetRequest(&request);
system.SetCur(&cur);
system.SetDb(&db);
system.SetSynchro(&synchro);
templates.SetConfig(&config);
templates.SetRequest(&request);
templates.SetCur(&cur);
templates.SetDb(&db);
templates.SetSystem(&system);
templates.SetFunctions(&functions);
@@ -65,7 +69,7 @@ App::App()
session_manager.SetLastContainer(&system.users.last);
session_manager.SetConfig(&config);
session_manager.SetRequest(&request);
session_manager.SetCur(&cur);
session_manager.SetSystem(&system);
session_manager.SetSynchro(&synchro);
@@ -131,7 +135,7 @@ bool App::Init()
db_conn.WaitForConnection();
db.LogQueries(config.log_db_query);
request.Clear();
cur.request->Clear();
compress.Init();
system.Init();
functions.Init();
@@ -143,10 +147,16 @@ bool App::Init()
// init notify after templates (it uses locales from templates)
system.notify.ReadTemplates();
session_manager.InitTmpSession();
session_manager.LoadSessions();
CreateStaticTree();
get_parser.UTF8(config.utf8);
post_parser.UTF8(config.utf8);
post_parser.LogValueSize(config.log_post_value_size);
// post_multi_parser has a pointer to the config
plugin.Call(WINIX_PLUGIN_INIT);
return true;
@@ -158,7 +168,8 @@ void App::Close()
{
session_manager.SaveSessions();
session_manager.DeleteSessions();
request.Clear();
cur.request->Clear();
session_manager.UninitTmpSession();
}
@@ -168,13 +179,13 @@ bool App::BaseUrlRedirect()
if( config.base_url_http_host.empty() )
return false;
if( Equal(config.base_url_http_host.c_str(), request.env_http_host) )
if( Equal(config.base_url_http_host.c_str(), cur.request->env_http_host) )
return false;
request.redirect_to = config.base_url;
AssignString(request.env_request_uri, request.redirect_to, false);
cur.request->redirect_to = config.base_url;
AssignString(cur.request->env_request_uri, cur.request->redirect_to, false);
log << log3 << "RC: BaseUrlRedirect from: " << request.env_http_host << logend;
log << log3 << "RC: BaseUrlRedirect from: " << cur.request->env_http_host << logend;
return true;
}
@@ -184,19 +195,23 @@ void App::ProcessRequestThrow()
{
ReadRequest();
// when BaseUrlRedirect() return true we didn't have to set everything in request.Read()
// in the future request.Read() can be split and at the beginning only environment variables will be read
// when BaseUrlRedirect() return true we didn't have to set everything in cur.request->Read()
// in the future cur.request->Read() can be split and at the beginning only environment variables will be read
// and then BaseUrlRedirect() will be called (for performance)
if( !BaseUrlRedirect() )
{
session_manager.SetSession(); // set request.session as well
// !! dac zeby zwracalo wskaznik (zawsze prawidlowy) na sesje
// i tutaj przypisanie do request.session
session_manager.SetSession();
cur.session = session_manager.GetCurSession();
// !! tutaj dodac to ustawianie request.session
if( cur.session->new_session )
{
cur.session->plugin_data.Resize(plugin.Size());
plugin.Call(WINIX_SESSION_CREATED);
}
plugin.Call(WINIX_SESSION_CHANGED);
functions.Parse();
system.mounts.CalcCurMount();
Make();
@@ -216,7 +231,6 @@ void App::ProcessRequest()
ProcessRequestThrow();
SaveSessionsIfNeeded(); // !! przerzucic to na watek sesji
request.Clear();
system.load_avg.StopRequest();
log << logendrequest;
}
@@ -232,6 +246,20 @@ void App::ProcessRequest()
{
log << log1 << "App: there was an unknown exception" << logend;
}
try
{
plugin.Call(WINIX_END_REQUEST);
}
catch(...)
{
log << log1 << "App: an exception when clearing the request (from a plugin)" << logend;
}
cur.request->Clear();
cur.session = session_manager.GetTmpSession();
}
@@ -270,20 +298,20 @@ void App::MakePage()
bool sent = false;
if( !request.redirect_to.empty() || !request.x_sendfile.empty() )
if( !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
return;
if( request.is_item && request.item.file_type == WINIX_ITEM_FILETYPE_NONE &&
request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.function )
if( cur.request->is_item && cur.request->item.file_type == WINIX_ITEM_FILETYPE_NONE &&
cur.request->item.content_type == Item::ct_raw && cur.request->status == WINIX_ERR_OK && cur.request->function )
{
if( request.function == &functions.fun_cat )
if( cur.request->function == &functions.fun_cat )
{
request.page << request.item.content;
cur.request->page << cur.request->item.content;
sent = true;
}
else
if( request.function == &functions.fun_run )
if( cur.request->function == &functions.fun_run )
{
templates.GenerateRunRaw();
sent = true;
@@ -301,35 +329,35 @@ bool sent = false;
// !! ta nazwa chyba juz zajeta...
void App::Make()
{
if( request.dir_tab.empty() )
if( cur.request->dir_tab.empty() )
{
log << log1 << "Content: there is no a root dir (dir_tab is empty)" << logend;
return;
}
// request.status can be changed by function_parser
if( request.status == WINIX_ERR_OK )
// cur.request->status can be changed by function_parser
if( cur.request->status == WINIX_ERR_OK )
plugin.Call(WINIX_PREPARE_REQUEST);
if( request.status == WINIX_ERR_OK )
if( cur.request->status == WINIX_ERR_OK )
functions.CheckFunctionAndSymlink();
if( request.status == WINIX_ERR_OK )
if( cur.request->status == WINIX_ERR_OK )
functions.MakeFunction();
if( request.session->spam_score > 0 )
log << log1 << "App: spam score: " << request.session->spam_score << logend;
if( cur.session->spam_score > 0 )
log << log1 << "App: spam score: " << cur.session->spam_score << logend;
if( request.IsParam(L"noredirect") )
request.redirect_to.clear();
if( cur.request->IsParam(L"noredirect") )
cur.request->redirect_to.clear();
if( request.status == WINIX_ERR_OK )
if( cur.request->status == WINIX_ERR_OK )
plugin.Call(WINIX_PROCESS_REQUEST);
if( !request.redirect_to.empty() )
if( !cur.request->redirect_to.empty() )
return;
if( request.dir_tab.empty() )
if( cur.request->dir_tab.empty() )
{
log << log1 << "App: there is no a root dir (dir_tab is empty -- after calling a function)" << logend;
return;
@@ -342,8 +370,8 @@ void App::Make()
{
// !! dodac inne informacje (get, post, itp)
// jesli jest debug_info wlaczone to nie robic przekierowan
request.PrintGetTab();
//request.PrintEnv(); // !! PrintEnv() mozna przeniesc tutaj (do klasy App)
cur.request->PrintGetTab();
//cur.request->PrintEnv(); // !! PrintEnv() mozna przeniesc tutaj (do klasy App)
}
}
@@ -361,13 +389,13 @@ void App::ReadRequest()
LogAccess();
ReadGetPostVars();
cookie_parser.Parse(request.env_http_cookie, request.cookie_tab);
accept_encoding_parser.Parse(request.env_http_accept_encoding);
cookie_parser.Parse(cur.request->env_http_cookie, cur.request->cookie_tab);
accept_encoding_parser.ParseAndLog(cur.request->env_http_accept_encoding);
CheckIE();
CheckKonqueror();
if( request.role == Request::authorizer )
if( cur.request->role == Request::authorizer )
log << log3 << "Request: fast cgi role: authorizer" << logend;
}
@@ -380,7 +408,7 @@ const char * v = FCGX_GetParam(name, fcgi_request.envp);
if( v )
env = v;
// by default env is set to an empty string (in request.Clear() method)
// by default env is set to an empty string (in cur.request->Clear() method)
}
@@ -390,41 +418,41 @@ void App::ReadEnvVariables()
// we store that values because FCGX_GetParam has O(n) complexity
// with this variables (env_*) we have O(1)
SetEnv(request.env_request_method, "REQUEST_METHOD"); // !! mozna nie uzywac tego, teraz mamy w strukturze fcgi_request
SetEnv(request.env_request_uri, "REQUEST_URI");
SetEnv(request.env_http_cookie, "HTTP_COOKIE");
SetEnv(request.env_remote_addr, "REMOTE_ADDR");
SetEnv(request.env_http_host, "HTTP_HOST");
SetEnv(request.env_http_user_agent, "HTTP_USER_AGENT");
SetEnv(request.env_fcgi_role, "FCGI_ROLE");
SetEnv(request.env_content_type, "CONTENT_TYPE");
SetEnv(request.env_http_accept_encoding,"HTTP_ACCEPT_ENCODING");
SetEnv(cur.request->env_request_method, "REQUEST_METHOD"); // !! mozna nie uzywac tego, teraz mamy w strukturze fcgi_request
SetEnv(cur.request->env_request_uri, "REQUEST_URI");
SetEnv(cur.request->env_http_cookie, "HTTP_COOKIE");
SetEnv(cur.request->env_remote_addr, "REMOTE_ADDR");
SetEnv(cur.request->env_http_host, "HTTP_HOST");
SetEnv(cur.request->env_http_user_agent, "HTTP_USER_AGENT");
SetEnv(cur.request->env_fcgi_role, "FCGI_ROLE");
SetEnv(cur.request->env_content_type, "CONTENT_TYPE");
SetEnv(cur.request->env_http_accept_encoding,"HTTP_ACCEPT_ENCODING");
}
void App::CheckRequestMethod()
{
request.method = Request::none;
cur.request->method = Request::none;
if( ToSmall(request.env_request_method[0]) == 'g' )
request.method = Request::get;
if( ToSmall(cur.request->env_request_method[0]) == 'g' )
cur.request->method = Request::get;
else
if( ToSmall(request.env_request_method[0]) == 'p' )
request.method = Request::post;
if( ToSmall(cur.request->env_request_method[0]) == 'p' )
cur.request->method = Request::post;
else
if( ToSmall(request.env_request_method[0]) == 'h' )
request.method = Request::head;
if( ToSmall(cur.request->env_request_method[0]) == 'h' )
cur.request->method = Request::head;
}
void App::CheckFCGIRole()
{
// default we assume 'responder'
request.role = Request::responder;
cur.request->role = Request::responder;
if( ToSmall(request.env_fcgi_role[0]) == 'a' )
request.role = Request::authorizer;
if( ToSmall(cur.request->env_fcgi_role[0]) == 'a' )
cur.request->role = Request::authorizer;
}
@@ -433,11 +461,11 @@ void App::LogAccess()
{
log.PutDate(log1);
log << request.env_remote_addr << ' '
<< request.env_request_method << ' '
<< request.env_http_host
<< request.env_request_uri << ' '
<< request.env_http_user_agent << logend;
log << cur.request->env_remote_addr << ' '
<< cur.request->env_request_method << ' '
<< cur.request->env_http_host
<< cur.request->env_request_uri << ' '
<< cur.request->env_http_user_agent << logend;
}
@@ -446,23 +474,18 @@ void App::LogAccess()
void App::ReadGetPostVars()
{
// get parameters we have always
get_parser.UTF8(config.utf8);
get_parser.Parse(request.env_request_uri, request.get_tab);
get_parser.Parse(cur.request->env_request_uri, cur.request->get_tab);
if( request.method == Request::post )
if( cur.request->method == Request::post )
{
if( IsSubStringNoCase("multipart/form-data", request.env_content_type) )
if( IsSubStringNoCase("multipart/form-data", cur.request->env_content_type) )
{
log << log3 << "Request: post content type: multipart/form-data" << logend;
// !! dodac metode UTF8 do post_multi_parsera
// (narazie bierze bezposrednio z konfigu)
// w ogole wywalic zaleznosc od konfiga
post_multi_parser.Parse(fcgi_request.in, request.post_tab, request.post_file_tab);
post_multi_parser.Parse(fcgi_request.in, cur.request->post_tab, cur.request->post_file_tab);
}
else
{
post_parser.UTF8(config.utf8);
post_parser.Parse(fcgi_request.in, request.post_tab);
post_parser.Parse(fcgi_request.in, cur.request->post_tab);
}
}
}
@@ -472,24 +495,24 @@ void App::ReadGetPostVars()
void App::CheckIE()
{
char * msie = strstr(request.env_http_user_agent, "MSIE");
char * msie = strstr(cur.request->env_http_user_agent, "MSIE");
if( msie )
request.browser_msie = true;
cur.request->browser_msie = true;
else
request.browser_msie = false;
cur.request->browser_msie = false;
}
void App::CheckKonqueror()
{
char * kon = strstr(request.env_http_user_agent, "Konqueror");
char * kon = strstr(cur.request->env_http_user_agent, "Konqueror");
if( kon )
request.browser_konqueror = true;
cur.request->browser_konqueror = true;
else
request.browser_konqueror = false;
cur.request->browser_konqueror = false;
}
@@ -499,49 +522,49 @@ void App::CheckKonqueror()
void App::PrepareSessionCookie()
{
if( !request.session || request.session->id==0 )
if( !cur.session || cur.session->id==0 )
return;
if( !request.session->puser || !request.session->remember_me )
if( !cur.session->puser || !cur.session->remember_me )
{
request.SetCookie(config.http_session_id_name.c_str(), request.session->id);
cur.request->SetCookie(config.http_session_id_name.c_str(), cur.session->id);
}
else
{
time_t t = std::time(0) + config.session_remember_max_idle;
tm expires = Time(t);
request.SetCookie(config.http_session_id_name.c_str(), request.session->id, &expires);
cur.request->SetCookie(config.http_session_id_name.c_str(), cur.session->id, &expires);
}
}
void App::SendHeaders(bool compressing, Header header)
void App::SendHeaders(bool compressing, int compress_encoding, Header header)
{
PrepareSessionCookie();
if( request.send_as_attachment )
if( cur.request->send_as_attachment )
FCGX_PutS("Content-Disposition: attachment\r\n", fcgi_request.out);
if( !request.redirect_to.empty() )
if( !cur.request->redirect_to.empty() )
{
FCGX_PutS("Status: 301 Moved Permanently\r\n", fcgi_request.out);
UrlEncode(request.redirect_to, request.aredirect_to);
FCGX_FPrintF(fcgi_request.out, "Location: %s\r\n", request.aredirect_to.c_str());
log << log2 << "Redirect to: " << request.aredirect_to << logend;
UrlEncode(cur.request->redirect_to, cur.request->aredirect_to);
FCGX_FPrintF(fcgi_request.out, "Location: %s\r\n", cur.request->aredirect_to.c_str());
log << log2 << "Redirect to: " << cur.request->aredirect_to << logend;
}
else
if( !request.x_sendfile.empty() )
if( !cur.request->x_sendfile.empty() )
{
static std::string temp, temp2; // !! wrzucic gdzies to
Ezc::WideToUTF8(config.http_header_send_file, temp);
Ezc::WideToUTF8(request.x_sendfile, temp2);
Ezc::WideToUTF8(cur.request->x_sendfile, temp2);
FCGX_FPrintF(fcgi_request.out, "%s: %s\r\n", temp.c_str(), temp2.c_str());
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
log << log2 << "Sending file: " << request.x_sendfile << logend;
log << log2 << "Sending file: " << cur.request->x_sendfile << logend;
}
else
{
@@ -562,44 +585,36 @@ void App::SendHeaders(bool compressing, Header header)
default:
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
if( request.role != Request::authorizer )
if( cur.request->role != Request::authorizer )
FCGX_PutS("Content-Type: text/html\r\n", fcgi_request.out);
}
}
if( compressing )
FCGX_PutS("Content-Encoding: deflate\r\n", fcgi_request.out);
if( compressing )
{
if( compress_encoding == 0 || compress_encoding == 1 )
FCGX_PutS("Content-Encoding: deflate\r\n", fcgi_request.out);
else
FCGX_PutS("Content-Encoding: gzip\r\n", fcgi_request.out);
}
FCGX_PutS(request.headers.CStr(), fcgi_request.out);
FCGX_PutS(cur.request->headers.CStr(), fcgi_request.out);
FCGX_PutS("\r\n", fcgi_request.out);
}
void App::SetHtmlFilterConf()
{
html_filter.TrimWhite(config.html_filter_trim_white);
html_filter.BreakLines(config.html_filter_break_lines);
html_filter.InsertTabs(config.html_filter_tabs);
if( config.html_filter_orphans )
html_filter.CheckOrphans(config.html_filter_orphans_lang, config.html_filter_orphans_mode);
}
// !! kopiowanie tych stringow bedzie zmienione
// gdy bedziemy korzystac w przyszlosci z wlasnego stringstream
void App::FilterCompressSend(bool compressing, const std::wstring & source_ref)
void App::FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref)
{
const std::wstring * source = &source_ref;
bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK &&
request.function && (request.function == &functions.fun_cat || request.function == &functions.fun_run);
bool raw = cur.request->is_item && cur.request->item.content_type == Item::ct_raw && cur.request->status == WINIX_ERR_OK &&
cur.request->function && (cur.request->function == &functions.fun_cat || cur.request->function == &functions.fun_run);
if( config.html_filter && !raw )
{
SetHtmlFilterConf();
html_filter.Filter(*source, clean_html);
TemplatesFunctions::html_filter.Filter(*source, clean_html);
AddDebugInfo(clean_html);
source = &clean_html;
}
@@ -610,39 +625,83 @@ void App::FilterCompressSend(bool compressing, const std::wstring & source_ref)
source = &html_with_debug;
}
// !! zrobic z tym porzadek
std::string temp;
Ezc::WideToUTF8(*source, temp);
if( config.utf8 )
Ezc::WideToUTF8(*source, source_a);
else
AssignString(*source, source_a);
if( compressing )
compress.CompressAndPut(temp.c_str(), temp.length(), fcgi_request.out);
compress.CompressAndPut(source_a.c_str(), source_a.length(), fcgi_request.out, compress_encoding);
else
FCGX_PutS(temp.c_str(), fcgi_request.out);
FCGX_PutS(source_a.c_str(), fcgi_request.out);
}
bool App::IsCompressionAllowed(const std::wstring & source)
int App::SelectDeflateVersion()
{
return( config.compression &&
request.role == Request::responder &&
request.redirect_to.empty() &&
request.x_sendfile.empty() &&
!request.browser_msie &&
!request.browser_konqueror &&
accept_encoding_parser.AcceptDeflate() &&
source.size() >= (size_t)config.compression_page_min_size );
if( cur.request->browser_msie )
return 0; // raw deflate
else
return 1; // deflate
}
void App::SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding)
{
compression_allowed = false;
compression_encoding = 0;
if( config.compression &&
cur.request->role == Request::responder &&
cur.request->redirect_to.empty() &&
cur.request->x_sendfile.empty() &&
!cur.request->browser_konqueror && /* !! sprawdzic czy Konqueror bedzie obslugiwal raw deflate */
source_len >= config.compression_page_min_size )
{
if( config.compression_encoding == 1 || config.compression_encoding == 10 )
{
if( accept_encoding_parser.AcceptDeflate() )
{
compression_allowed = true;
compression_encoding = SelectDeflateVersion();
}
else
if( config.compression_encoding == 10 && accept_encoding_parser.AcceptGzip() )
{
compression_allowed = true;
compression_encoding = 2; // gzip
}
}
if( config.compression_encoding == 2 || config.compression_encoding == 20 )
{
if( accept_encoding_parser.AcceptGzip() )
{
compression_allowed = true;
compression_encoding = 2; // gzip
}
else
if( config.compression_encoding == 20 && accept_encoding_parser.AcceptDeflate() )
{
compression_allowed = true;
compression_encoding = SelectDeflateVersion();
}
}
}
}
bool App::CanSendContent(Header header)
{
if( !request.redirect_to.empty() || !request.x_sendfile.empty() )
if( !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
// if there is a redirect or a file to send then we do not send a content
return false;
if( header == h_200 && request.role == Request::authorizer && request.is_item && request.item.file_type != WINIX_ITEM_FILETYPE_NONE )
if( header == h_200 && cur.request->role == Request::authorizer && cur.request->is_item && cur.request->item.file_type != WINIX_ITEM_FILETYPE_NONE )
// if there is an item and the item has 'file' storage we do not send a content
return false;
@@ -650,7 +709,7 @@ bool App::CanSendContent(Header header)
we don't have to check the HEAD method
the server (lighttpd) doesn't send the body of its own
*/
if( request.method == Request::head )
if( cur.request->method == Request::head )
return false;
return true;
@@ -661,10 +720,10 @@ void App::AddDebugInfo(std::wstring & out)
{
if( config.debug_info )
{
if( !request.debug.Empty() )
if( !cur.request->debug.Empty() )
{
out += L"\n<!--\n";
out += request.debug.Str();
out += cur.request->debug.Str();
out += L"\n-->\n";
}
}
@@ -674,10 +733,13 @@ void App::AddDebugInfo(std::wstring & out)
void App::SendAnswer()
{
const std::wstring & source = request.page.Str();
Header header = h_200;
bool compressing = IsCompressionAllowed(source);
Error status = request.status;
const std::wstring & source = cur.request->page.Str();
Header header = h_200;
Error status = cur.request->status;
bool compressing;
int compress_encoding;
SelectCompression(source.length(), compressing, compress_encoding);
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
header = h_404;
@@ -685,12 +747,12 @@ Error status = request.status;
if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP )
header = h_403;
SendHeaders(compressing, header);
SendHeaders(compressing, compress_encoding, header);
if( CanSendContent(header) )
{
// filtering (html), compressing (deflate) and sending back to the web browser
FilterCompressSend(compressing, source);
// filtering (html), compressing and sending back to the web browser
FilterCompressSend(compressing, compress_encoding, source);
}
}
@@ -964,7 +1026,7 @@ void App::WaitForThreads()
//pthread_join(signal_thread, 0);
system.notify.WaitForThread();
session_manager.WaitForGC();
session_manager.WaitForThread();
system.thumb.WaitForThread();
}
@@ -1000,7 +1062,7 @@ sigset_t set;
FCGX_ShutdownPending();
Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit);
app->system.notify.PrepareToStopThread();
app->session_manager.PrepareToStopGC();
app->session_manager.WakeUpThread();
app->system.thumb.WakeUpThread();
app->Unlock();
@@ -1033,7 +1095,7 @@ sigset_t set;
system.notify.StartThread();
// gc for sessions
session_manager.StartGC();
session_manager.StartThread();
// thumbnails
system.thumb.StartThread();

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoreapp
#define headerfilecmslucoreapp
#ifndef headerfile_winix_core_app
#define headerfile_winix_core_app
#include <iostream>
#include <ctime>
@@ -30,7 +30,6 @@
#include "functions/functions.h"
#include "templates/templates.h"
#include "compress.h"
#include "htmlfilter.h"
#include "getparser.h"
#include "postparser.h"
#include "cookieparser.h"
@@ -63,8 +62,12 @@ public:
// configuration read from a config file
Config config;
// pointers to the current request and a session
Cur cur;
// temporary one request object
// current request
Request request;
Request req;
// users sessions
SessionManager session_manager;
@@ -120,13 +123,13 @@ private:
CookieParser cookie_parser;
AcceptEncodingParser accept_encoding_parser;
Compress compress;
HTMLFilter html_filter;
std::wstring clean_html, html_with_debug;
FCGX_Request fcgi_request;
int fcgi_socket;
Synchro synchro;
pthread_t signal_thread;
std::string url_to_fetch_on_exit;
std::string source_a;
void ProcessRequestThrow();
void ProcessRequest();
@@ -148,12 +151,12 @@ private:
void CheckRequestMethod();
void CheckFCGIRole();
void SetHtmlFilterConf();
void PrepareSessionCookie();
void AddDebugInfo(std::wstring & out);
void FilterCompressSend(bool compressing, const std::wstring & source_ref);
void SendHeaders(bool compressing, Header header);
bool IsCompressionAllowed(const std::wstring & source);
void FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref);
void SendHeaders(bool compressing, int compress_encoding, Header header);
int SelectDeflateVersion();
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding);
bool CanSendContent(Header header);
void LogUser(const char * msg, uid_t id);

View File

@@ -145,6 +145,9 @@ bool BaseThread::WaitForSignalSleep(time_t second)
timespec t;
int res;
if( synchro->was_stop_signal )
return true;
t.tv_sec = time(0) + second;
t.tv_nsec = 0;

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucorebasethread
#define headerfilecmslucorebasethread
#ifndef headerfile_winix_core_basethread
#define headerfile_winix_core_basethread
#include <pthread.h>
#include "synchro.h"

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -10,6 +10,8 @@
#include "bbcodeparser.h"
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
{
while( *str1 == *str2 && *str1 != 0 )
@@ -67,6 +69,10 @@ bool BBCODEParser::IsClosingXmlSimpleTagMark()
// one enter will generate one <br>
// two enters or more will generate only two br (<br><br>)
void BBCODEParser::PutNormalText(const wchar_t * str, const wchar_t * end)
@@ -116,12 +122,6 @@ int br_len;
}
void BBCODEParser::PutNormalTextTrim(const wchar_t * str, const wchar_t * end)
{
// we don't use trimming in bbcode parser
PutNormalText(str, end);
}
void BBCODEParser::ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white)
{
@@ -201,6 +201,12 @@ const BBCODEParser::Tags * BBCODEParser::FindTag(const wchar_t * tag)
return 0;
}
const BBCODEParser::Tags * BBCODEParser::FindTag(const std::wstring & tag)
{
return FindTag(tag.c_str());
}
void BBCODEParser::PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end)
{
@@ -361,19 +367,21 @@ void BBCODEParser::PrintEncode(const wchar_t * start, const wchar_t * end)
void BBCODEParser::PutOpeningTagFromEzc(const wchar_t * start, const wchar_t * end)
void BBCODEParser::PutOpeningTagFromEzc()
{
// this can be a tag from Ezc templates system
(*out_string) += '[';
(*out_string) += LastItem().name;
if( start != end )
{
(*out_string) += ' ';
PrintEscape(start, end);
}
const wchar_t * start = pchar;
(*out_string) += ']';
while( *pchar && *pchar!=']' )
++pchar;
if( *pchar == ']' )
++pchar;
Put(start, pchar);
}
@@ -489,33 +497,40 @@ bool has_u;
}
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag, const wchar_t * start, const wchar_t * end)
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag)
{
CheckOpeningTag(tag);
PutOpeningTagMark();
(*out_string) += tag->html_tag;
PutHtmlArgument(tag, start, end);
Put(tag->html_tag);
const wchar_t * start = pchar;
while( *pchar && *pchar != ']' )
++pchar;
PutHtmlArgument(tag, start, pchar);
if( *pchar == ']' )
++pchar;
if( !tag->inline_tag )
{
(*out_string) += L"\n";
Put(10);
SkipWhiteLines();
}
}
void BBCODEParser::PutOpeningTag(const wchar_t * start, const wchar_t * end)
bool BBCODEParser::PutOpeningTag()
{
const Tags * tag = FindTag(LastItem().name);
if( !tag )
{
PutOpeningTagFromEzc(start, end);
}
PutOpeningTagFromEzc();
else
{
PutOpeningTagFromBBCode(tag, start, end);
}
PutOpeningTagFromBBCode(tag);
return false;
}
@@ -564,7 +579,7 @@ void BBCODEParser::Init()
}
void BBCODEParser::Deinit()
void BBCODEParser::Uninit()
{
if( has_open_li_tag )
(*out_string) += L"</li>\n";

View File

@@ -2,65 +2,71 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorebbcodeparser
#define headerfilecmslucorebbcodeparser
#ifndef headerfile_winix_core_bbcodeparser
#define headerfile_winix_core_bbcodeparser
#include "htmlfilter.h"
class BBCODEParser : public HTMLFilter
{
//using HTMLFilter::pchar;
struct Tags
{
/*
const wchar_t * bbcode;
const wchar_t * html_tag;
const wchar_t * html_arg_prefix;
const wchar_t * html_arg_postfix;
const wchar_t * additional_html_tag_prefix;
const wchar_t * additional_html_tag_postfix;
bool inline_tag;
*/
const wchar_t * bbcode;
const wchar_t * html_tag;
const wchar_t * html_argument; // with closing '>'
bool inline_tag;
};
bool Equal(const wchar_t * str1, const wchar_t * str2);
virtual bool IsValidCharForName(int c);
/*
virtual methods
(from HTMLFilter class)
*/
virtual void Init();
virtual void Uninit();
virtual bool IsOpeningTagMark();
virtual bool IsOpeningCommentaryTagMark();
virtual bool SkipCommentaryTagIfExists();
virtual bool IsClosingTagMark();
virtual bool IsClosingXmlSimpleTagMark();
virtual bool IsValidCharForName(int c);
virtual void CheckExceptions();
virtual bool SkipCommentaryTagIfExists();
virtual bool PutOpeningTag();
virtual void PutClosingTag(const wchar_t * tag);
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
/*
others
*/
bool Equal(const wchar_t * str1, const wchar_t * str2);
void PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u);
void PutHtmlArgument2(const Tags * tag, bool has_u);
void PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end);
void PutOpeningTagFromEzc(const wchar_t * start, const wchar_t * end);
void PutOpeningTagFromBBCode(const Tags * tag, const wchar_t * start, const wchar_t * end);
virtual void PutOpeningTag(const wchar_t * start, const wchar_t * end);
virtual void PutClosingTag(const wchar_t * tag);
void PutOpeningTagFromEzc();
void PutOpeningTagFromBBCode(const Tags * tag);
const Tags * FindTag(const wchar_t * tag);
const Tags * FindTag(const std::wstring & tag);
void PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end);
void PrintEscape(int c, bool change_quote = false);
void PrintEncode(int c);
@@ -70,28 +76,18 @@ class BBCODEParser : public HTMLFilter
void PrintArgumentEncode(const wchar_t * start, const wchar_t * end);
void PrintArgumentEscape(const wchar_t * start, const wchar_t * end);
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
virtual void PutNormalTextTrim(const wchar_t * str, const wchar_t * end);
virtual void CheckExceptions();
virtual void Init();
virtual void Deinit();
void PutClosingTag(const Tags * tag);
void CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition);
void CheckOpeningTag(const Tags * tag);
void TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end);
bool has_open_ol_tag; // has open html <ol> tag
bool has_open_ul_tag; // has open html <ul> tag
bool has_open_li_tag; // has open html <li> tag
};
#endif

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -15,9 +15,13 @@
Compress::Compress()
{
buffer = 0;
buffer_max_len = 65536; // 64KB
buffer = 0;
buffer_max_len = 65536; // 64KB
ready_for_compress = false;
compress_level = 6;
raw_deflate_inited = false;
deflate_inited = false;
gzip_inited = false;
}
@@ -25,6 +29,15 @@ Compress::~Compress()
{
if( buffer )
delete [] buffer;
if( raw_deflate_inited )
deflateEnd(&strm_raw_deflate);
if( deflate_inited )
deflateEnd(&strm_deflate);
if( gzip_inited )
deflateEnd(&strm_gzip);
}
@@ -33,7 +46,6 @@ bool Compress::AllocateMemory()
if( buffer )
delete [] buffer;
try
{
buffer = new char[buffer_max_len];
@@ -41,7 +53,6 @@ bool Compress::AllocateMemory()
catch(const std::bad_alloc &)
{
log << log1 << "Compress: can't allocate memory" << logend;
buffer = 0;
return false;
}
@@ -50,39 +61,93 @@ return true;
}
bool Compress::InitRawDeflate()
{
raw_deflate_inited = false;
strm_raw_deflate.next_in = 0;
strm_raw_deflate.zalloc = Z_NULL;
strm_raw_deflate.zfree = Z_NULL;
strm_raw_deflate.opaque = Z_NULL;
int ret = deflateInit2(&strm_raw_deflate, compress_level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
if( ret != Z_OK )
log << log1 << "Compress: problem with deflateInit2() for raw deflate" << logend;
else
raw_deflate_inited = true;
return ret == Z_OK;
}
bool Compress::InitDeflate()
{
deflate_inited = false;
strm_deflate.next_in = 0;
strm_deflate.zalloc = Z_NULL;
strm_deflate.zfree = Z_NULL;
strm_deflate.opaque = Z_NULL;
int ret = deflateInit2(&strm_deflate, compress_level, Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
if( ret != Z_OK )
log << log1 << "Compress: problem with deflateInit2() for deflate" << logend;
else
deflate_inited = true;
return ret == Z_OK;
}
bool Compress::InitGzip()
{
gzip_inited = false;
strm_gzip.next_in = 0;
strm_gzip.zalloc = Z_NULL;
strm_gzip.zfree = Z_NULL;
strm_gzip.opaque = Z_NULL;
int ret = deflateInit2(&strm_gzip, compress_level, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY);
if( ret != Z_OK )
log << log1 << "Compress: problem with deflateInit2() for gzip" << logend;
else
gzip_inited = true;
return ret == Z_OK;
}
/*
return:
0 - ok;
1 - can't allocate memory
100 - unknown
0 - ok
1 - can't allocate memory
100 - unknown error
*/
int Compress::Init(int compress_level)
int Compress::Init(int compress_level_)
{
compress_level = compress_level_;
if( buffer == 0 )
if( !AllocateMemory() )
return 1;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
int ret = deflateInit(&strm, compress_level);
if( ret != Z_OK )
log << log1 << "Compress: problem with deflateInit()" << logend;
if( ret == Z_MEM_ERROR )
return 1;
if( ret != Z_OK )
return 100;
ready_for_compress = true;
if( InitRawDeflate() && InitDeflate() && InitGzip() )
ready_for_compress = true;
else
return 100;
return 0;
}
int Compress::MakeCompress(const char * source, size_t source_len, FCGX_Stream * out_stream)
int Compress::MakeCompress(z_stream & strm, const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding)
{
int ret, flush;
size_t have;
@@ -133,6 +198,62 @@ return 0;
z_stream * Compress::SelectStream(int encoding)
{
z_stream * pstrm;
if( encoding == 0 )
pstrm = &strm_raw_deflate;
else
if( encoding == 1 )
pstrm = &strm_deflate;
else
pstrm = &strm_gzip;
return pstrm;
}
void Compress::ResetStream(z_stream * pstrm, int encoding)
{
if( deflateReset(pstrm) != Z_OK )
{
log << log1 << "Compress: problem with deflateReset()" << logend;
deflateEnd(pstrm);
if( encoding == 0 )
InitRawDeflate();
else
if( encoding == 1 )
InitDeflate();
else
InitGzip();
}
}
void Compress::PutLog(size_t source_len, int encoding)
{
double ratio = 100.0 - (double(last_out_size) / double(source_len) * 100.0);
char buffer[30];
sprintf(buffer, "%.1f", ratio);
log << log2 << "Compress: ";
if( encoding == 0 )
log << "raw deflate";
else
if( encoding == 1 )
log << "deflate";
else
log << "gzip";
log << ", original size: " << source_len << ", size after compressing: "
<< (int)last_out_size << ", ratio: " << buffer << "%" << logend;
}
/*
return:
@@ -142,10 +263,11 @@ return 0;
3 - not inited (use Init() first)
100 - unknown
*/
int Compress::CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int level)
int Compress::CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding)
{
int ret;
z_stream * pstrm;
last_out_size = 0;
if( !ready_for_compress )
@@ -156,17 +278,11 @@ int ret;
if( source_len == 0 )
return 0;
ret = MakeCompress(source, source_len, out_stream);
if( deflateReset(&strm) != Z_OK )
log << log1 << "Compress: problem with deflateReset()" << logend;
double ratio = 100.0 - (double(last_out_size) / double(source_len) * 100.0);
char buffer[30];
sprintf(buffer, "%.1f", ratio);
log << log2 << "Compress: original size: " << source_len << ", compress size: " << (int)last_out_size << ", ratio: " << buffer << "%" << logend;
pstrm = SelectStream(encoding);
ret = MakeCompress(*pstrm, source, source_len, out_stream, encoding);
ResetStream(pstrm, encoding);
PutLog(source_len, encoding);
return ret;
}

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorecompress
#define headerfilecmslucorecompress
#ifndef headerfile_winix_core_compress
#define headerfile_winix_core_compress
#include <cstring>
#include <fcgiapp.h>
@@ -23,18 +23,35 @@ public:
Compress();
~Compress();
int Init(int compress_level = 6);
int CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int level = 6);
int Init(int compress_level_ = 6);
/*
encoding:
0 - raw deflate data with no zlib header or trailer, and will not compute an adler32 check value
(for Internet Explorer)
1 - deflate
2 - gzip
*/
int CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding = 2);
size_t last_out_size;
private:
bool AllocateMemory();
int MakeCompress(const char * source, size_t source_len, FCGX_Stream * out_stream);
bool InitRawDeflate();
bool InitDeflate();
bool InitGzip();
int MakeCompress(z_stream & strm, const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding);
z_stream * SelectStream(int encoding);
void ResetStream(z_stream * pstrm, int encoding);
void PutLog(size_t source_len, int encoding);
int compress_level;
size_t buffer_max_len;
char * buffer;
z_stream strm;
z_stream strm_raw_deflate, strm_deflate, strm_gzip;
bool raw_deflate_inited, deflate_inited, gzip_inited;
bool ready_for_compress;
};

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -11,6 +11,7 @@
#include "log.h"
#include "plugin.h"
#include "misc.h"
#include "crypt.h"
@@ -109,7 +110,8 @@ void Config::AssignValues(bool stdout_is_closed)
log_stdout = Bool(L"log_stdout", false);
log_db_query = Bool(L"log_db_query", false);
log_plugin_call = Bool(L"log_plugin_call", false);
log_post_value_size = Size(L"log_post_value_size", 80);
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
upload_dir = Text(L"upload_dir");
upload_dirs_chmod = Int(L"upload_dirs_chmod", 0750);
@@ -153,25 +155,26 @@ void Config::AssignValues(bool stdout_is_closed)
session_file = AText(L"session_file");
session_max = Size(L"session_max", 1000000);
compression = Bool(L"compression", true);
compression_page_min_size = Int(L"compression_page_min_size", 512);
compression = Bool(L"compression", true);
compression_page_min_size = Size(L"compression_page_min_size", 512);
compression_encoding = Int(L"compression_encoding", 20);
html_filter = Bool(L"html_filter", true);
html_filter_trim_white = Bool(L"html_filter_trim_white", true);
html_filter_break_lines = Int(L"html_filter_break_lines", 60);
html_filter_break_word = Int(L"html_filter_break_word", 60);
html_filter_wrap_line = Int(L"html_filter_wrap_line", 110);
html_filter_tabs = Size(L"html_filter_tabs", 2);
html_filter_orphans = Bool(L"html_filter_orphans", false);
html_filter_orphans_lang_str = AText(L"html_filter_orphans_lang", L"pl");
html_filter_orphans = Bool(L"html_filter_orphans", true);
html_filter_orphans_mode_str = AText(L"html_filter_orphans_mode_str", L"nbsp");
locale_str = Text(L"locale", L"en");
locale_dir = Text(L"locale_dir");
locale_dir_default = Text(L"locale_dir_default");
locale_default = Text(L"locale_default");
ListText(L"locale_files", locale_files);
title_separator = Text(L"title_separator", L" / ");
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file");
password_min_size = Size(L"password_min_size", 5);
debug_info = Bool(L"debug_info", false);
editors_html_safe_mode = Bool(L"editors_html_safe_mode", true);
@@ -179,7 +182,7 @@ void Config::AssignValues(bool stdout_is_closed)
plugins_dir = Text(L"plugins_dir", L"/usr/local/winix/plugins");
NoLastSlash(plugins_dir);
parser.ListText(L"plugins", plugin_file);
ListText(L"plugins", plugin_file);
time_zone_offset = Int(L"time_zone_offset", 0);
time_zone_offset_guest = Int(L"time_zone_offset_guest", 0);
@@ -188,32 +191,84 @@ void Config::AssignValues(bool stdout_is_closed)
symlinks_follow_max = Size(L"symlinks_follow_max", 20);
ticket_form_prefix = Text(L"ticket_form_prefix", L"ticketparam");
pass_min_size = Size(L"pass_min_size", 5);
pass_type = Int(L"pass_type", 12);
pass_hash_use_salt = Bool(L"pass_hash_use_salt", false);
pass_hash_salt = Text(L"pass_hash_salt");
pass_use_rsa = Bool(L"pass_use_rsa", false);
pass_rsa_private_key = Text(L"pass_rsa_private_key");
opensll_path = Text(L"opensll_path", L"/usr/bin/openssl");
}
void Config::SetAdditionalVariables()
{
SetHttpHost(base_url, base_url_http_host);
if( html_filter_orphans_lang_str == "pl" )
html_filter_orphans_lang = HTMLFilter::lang_pl;
else
if( html_filter_orphans_lang_str == "cz" )
html_filter_orphans_lang = HTMLFilter::lang_cz;
else
if( html_filter_orphans_lang_str == "sk" )
html_filter_orphans_lang = HTMLFilter::lang_sk;
else
html_filter_orphans_lang = HTMLFilter::lang_none;
if( html_filter_orphans_mode_str == "160" )
html_filter_orphans_mode = HTMLFilter::orphan_160space;
else
html_filter_orphans_mode = HTMLFilter::orphan_nbsp;
CheckLocale();
CheckPasswd();
}
void Config::CheckLocale()
{
bool found = false;
if( locale_files.empty() )
locale_files.push_back(L"en");
if( locale_default.empty() )
locale_default = locale_files[0];
for(size_t i=0 ; i<locale_files.size() ; ++i)
{
if( locale_files[i] == locale_default )
{
locale_default_index = i;
found = true;
break;
}
}
if( !found )
{
// we have at least one item
locale_default = locale_files[0];
locale_default_index = 0;
}
}
void Config::CheckPasswd()
{
switch(pass_type)
{
case WINIX_CRYPT_HASH_PLAIN:
case WINIX_CRYPT_HASH_MD4:
case WINIX_CRYPT_HASH_MD5:
case WINIX_CRYPT_HASH_SHA1:
case WINIX_CRYPT_HASH_SHA224:
case WINIX_CRYPT_HASH_SHA256:
case WINIX_CRYPT_HASH_SHA384:
case WINIX_CRYPT_HASH_SHA512:
break;
default:
pass_type = WINIX_CRYPT_HASH_SHA256;
}
}
void Config::SetHttpHost(const std::wstring & in, std::wstring & out)
{

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoreconfig
#define headerfilecmslucoreconfig
#ifndef headerfile_winix_core_config
#define headerfile_winix_core_config
#include <string>
#include "confparser.h"
@@ -72,6 +72,11 @@ public:
// default: false
bool log_plugin_call;
// how many characters in values should be logged from POST parameters
// default: 80
// set to 0 to turn off
size_t log_post_value_size;
// request delimiter in the log file, default "---------"
std::wstring log_delimiter;
@@ -137,11 +142,20 @@ public:
// default: 1000000 (one milion)
size_t session_max;
// allow the html ouput to be compressed
// allow the html output to be compressed
// default: true
bool compression;
// if the output is shorter than this value then it will not be compressed
int compression_page_min_size;
// default: 512 bytes
size_t compression_page_min_size;
// 1 - use deflate if available (or raw deflate for Internet Explorer) or don't compress
// 2 - use gzip if available or don't compress
// 10 - prefer deflate -- use deflate (or raw deflate for IE) if both deflate and gzip are available
// 20 - prefer gzip -- use gzip if both deflate and gzip are available
// default: 20
int compression_encoding;
// plugins directory
// default: /usr/local/winix/plugins
@@ -158,25 +172,24 @@ public:
// should white characters be trimmed
bool html_filter_trim_white;
// when long lines (lines without a white character) should be break (inserted a space)
// when long words should be broken (a space will be inserted)
// default: after 60 non white characters will be put a space
// set zero to turn off
int html_filter_break_lines;
size_t html_filter_break_word;
// when long lines should be broken (a new line character will be inserted)
// default: 80
// set zero to turn off
size_t html_filter_wrap_line;
// how many spaces will be put at one tree level
// default: 2
size_t html_filter_tabs;
// use checking for 'orphans' for a specicic language
// default: false
// default: true
bool html_filter_orphans;
// language for html orphans
// default: pl
// can be either: "pl" or "cz" or "sk"
std::string html_filter_orphans_lang_str;
HTMLFilter::Lang html_filter_orphans_lang;
// orphans mode
// either: "nbsp" or "160"
// default: "nbsp"
@@ -229,16 +242,24 @@ public:
// default: /usr/local/bin/convert
std::wstring convert_cmd;
// locale: en, pl
// default: en
std::wstring locale_str;
// directory with locale files
std::wstring locale_dir;
// directory with default locale files (those from winix)
std::wstring locale_dir_default;
// locale files (e.g. "en", "pl")
// default: only one item: en
std::vector<std::wstring> locale_files;
// default locale
// default: the first item from locale_files
std::wstring locale_default;
// default locale - index to locale_files
// not available in config -- set automatically based on locale_default
size_t locale_default_index;
// the main address of the server (e.g. someserver.com) (without the 'www' part etc)
std::wstring base_server;
@@ -258,10 +279,6 @@ public:
// default: X-LIGHTTPD-send-file
std::wstring http_header_send_file;
// the minimum size of a password for new users (function: adduser)
// default: 5
size_t password_min_size;
// prints additional information (in the end of the html page as a commentary)
bool debug_info;
@@ -298,6 +315,48 @@ public:
// default: ticketparam
std::wstring ticket_form_prefix;
// the minimal size of a user's password
// default: 5
size_t pass_min_size;
// how passwords should be stored
// 0 - plain text
// 1 - md4 hash
// 2 - md5 hash
// 10 - sha1 hash
// 11 - sha224 hash
// 12 - sha256 hash (default)
// 13 - sha384 hash
// 14 - sha512 hash
int pass_type;
// whether the passwords' hashes should be salted or not
// this affects newly created accounts
// default: false
bool pass_hash_use_salt;
// salt to a password's hash
// default empty
// !! once you set this salt don't change it any more (people wouldn't be allowed to login)
std::wstring pass_hash_salt;
// whether the passwords' hashes should be encrypted
// this affects newly created accounts
// default: false
bool pass_use_rsa;
// path to a RSA private key
// this is actually private + public key in one file
// generated by "openssl genrsa"
// default empty which means encryption will not be used
// !! once you set these keys don't change it any more (people wouldn't be allowed to login)
std::wstring pass_rsa_private_key;
// path to 'openssl'
// default: /usr/bin/openssl
std::wstring opensll_path;
/*
*/
@@ -337,6 +396,8 @@ private:
void AssignValues(bool stdout_is_closed);
void SetHttpHost(const std::wstring & in, std::wstring & out);
void SetAdditionalVariables();
void CheckLocale();
void CheckPasswd();
ConfParser parser;

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucorecookieparser
#define headerfilecmslucorecookieparser
#ifndef headerfile_winix_core_cookieparser
#define headerfile_winix_core_cookieparser
#include <fcgiapp.h>
#include "httpsimpleparser.h"

273
core/crypt.cpp Executable file
View File

@@ -0,0 +1,273 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include <cstring>
#include "crypt.h"
#include "utf8.h"
#include "misc.h"
#include "log.h"
void Crypt::SetConfig(Config * pconfig)
{
config = pconfig;
}
void Crypt::TrimLastWhite(std::string & str)
{
if( str.empty() )
return;
size_t i = str.size();
while( i > 0 && (IsWhite(str[i-1]) || str[i-1]==10) )
i -= 1;
if( i < str.size() )
str.erase(i);
}
bool Crypt::Hash(int hash, const char * in, size_t inlen, std::string & out)
{
out.clear();
if( !config )
return false;
run.Clear();
Ezc::WideToUTF8(config->opensll_path, command);
run.Cmd(command);
run.Par("dgst");
switch(hash)
{
case WINIX_CRYPT_HASH_MD4: run.Par("-md4"); break;
case WINIX_CRYPT_HASH_MD5: run.Par("-md5"); break;
case WINIX_CRYPT_HASH_SHA1: run.Par("-sha1"); break;
case WINIX_CRYPT_HASH_SHA224: run.Par("-sha224"); break;
case WINIX_CRYPT_HASH_SHA256: run.Par("-sha256"); break;
case WINIX_CRYPT_HASH_SHA384: run.Par("-sha384"); break;
case WINIX_CRYPT_HASH_SHA512: run.Par("-sha512"); break;
default:
return false;
}
bool result = run.Go(in, inlen, out) == 0;
TrimLastWhite(out);
return result;
}
bool Crypt::Hash(int hash, const char * in, std::string & out)
{
size_t len = strlen(in);
return Hash(hash, in, len, out);
}
bool Crypt::Hash(int hash, const std::string & in, std::string & out)
{
return Hash(hash, in.c_str(), in.size(), out);
}
bool Crypt::Hash(int hash, const wchar_t * in, size_t inlen, std::wstring & out)
{
Ezc::WideToUTF8(in, inlen, bufina);
int res = Hash(hash, bufina.c_str(), bufina.size(), bufouta);
// the output hash is not a UTF8 string
// it consists only from ascii letters
AssignString(bufouta, out);
return res;
}
bool Crypt::Hash(int hash, const wchar_t * in, std::wstring & out)
{
size_t len = wcslen(in);
return Hash(hash, in, len, out);
}
bool Crypt::Hash(int hash, const std::wstring & in, std::wstring & out)
{
return Hash(hash, in.c_str(), in.size(), out);
}
bool IsAllWhite(const char * str)
{
for( ; *str ; ++str)
{
if( !(IsWhite(*str) || *str==10) )
return false;
}
return true;
}
bool Crypt::RSA(bool encrypt, const char * keypath, const char * in, size_t inlen, std::string & out)
{
out.clear();
if( !config || IsAllWhite(keypath) )
return false;
run.Clear();
Ezc::WideToUTF8(config->opensll_path, command);
run.Cmd(command);
run.Par("rsautl");
run.Par("-inkey");
run.Par(keypath);
if(encrypt)
run.Par("-encrypt");
else
run.Par("-decrypt");
return run.Go(in, inlen, out) == 0;
}
bool Crypt::RSA(bool encrypt, const char * keypath, const std::string & in, std::string & out)
{
return RSA(encrypt, keypath, in.c_str(), in.size(), out);
}
bool Crypt::RSA(bool encrypt, const std::string & keypath, const std::string & in, std::string & out)
{
return RSA(encrypt, keypath.c_str(), in.c_str(), in.size(), out);
}
bool Crypt::RSA(bool encrypt, const wchar_t * keypath, const char * in, size_t inlen, std::string & out)
{
Ezc::WideToUTF8(keypath, keypatha);
return RSA(encrypt, keypatha.c_str(), in, inlen, out);
}
bool Crypt::RSA(bool encrypt, const wchar_t * keypath, const std::string & in, std::string & out)
{
return RSA(encrypt, keypath, in.c_str(), in.size(), out);
}
bool Crypt::RSA(bool encrypt, const std::wstring & keypath, const std::string & in, std::string & out)
{
return RSA(encrypt, keypath.c_str(), in.c_str(), in.size(), out);
}
bool Crypt::PassHash(const std::wstring & salt, UserPass & up)
{
bool result = true;
up.pass_hash_salted = false;
if( up.pass_type != WINIX_CRYPT_HASH_PLAIN )
{
pass_org = up.pass;
pass_salted = up.pass;
pass_salted += salt;
if( Hash(up.pass_type, pass_salted, up.pass) )
{
if( !salt.empty() )
up.pass_hash_salted = true;
}
else
{
log << log1 << "Crypt: problem with generating a hash, the password will not be hashed" << logend;
up.pass = pass_org;
up.pass_type = WINIX_CRYPT_HASH_PLAIN;
result = false;
}
ClearString(pass_salted);
ClearString(pass_org);
}
return result;
}
bool Crypt::PassCrypt(const std::wstring & path_to_rsa_private_key, UserPass & up)
{
bool result = false;
ClearString(up.pass_encrypted);
if( !path_to_rsa_private_key.empty() )
{
Ezc::WideToUTF8(up.pass, passa);
if( RSA(true, path_to_rsa_private_key, passa, up.pass_encrypted) )
{
result = true;
}
else
{
ClearString(up.pass_encrypted);
log << log1 << "AddUser: problem with encrypting, the password will not be encrypted!" << logend;
}
ClearString(passa);
}
return result;
}
void Crypt::PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, UserPass & up)
{
PassHash(salt, up);
PassCrypt(path_to_rsa_private_key, up);
}
void Crypt::PassHashCrypt(UserPass & up)
{
up.pass_type = config->pass_type;
empty.clear();
if( config->pass_hash_use_salt && !config->pass_hash_salt.empty() )
PassHash(config->pass_hash_salt, up);
else
PassHash(empty, up);
if( config->pass_use_rsa && !config->pass_rsa_private_key.empty() )
PassCrypt(config->pass_rsa_private_key, up);
}

209
core/crypt.h Executable file
View File

@@ -0,0 +1,209 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_crypt
#define headerfile_winix_core_crypt
#include <string>
#include "run.h"
#include "config.h"
#include "user.h"
/*
the kind of hashes we are able to obtain in winix
*/
#define WINIX_CRYPT_HASH_PLAIN 0
#define WINIX_CRYPT_HASH_MD4 1
#define WINIX_CRYPT_HASH_MD5 2
#define WINIX_CRYPT_HASH_SHA1 10
#define WINIX_CRYPT_HASH_SHA224 11
#define WINIX_CRYPT_HASH_SHA256 12
#define WINIX_CRYPT_HASH_SHA384 13
#define WINIX_CRYPT_HASH_SHA512 14
/*
calculating hashes, encrypting and decrypting with RSA
*/
class Crypt
{
public:
void SetConfig(Config * pconfig);
/*
calculating a hash from a given input
input:
hash - the kind of the hash - WINIX_CRYPT_HASH_*
in - input buffer
inlen - the length of the buffer
output:
out - the hash
*/
bool Hash(int hash, const char * in, size_t inlen, std::string & out);
bool Hash(int hash, const char * in, std::string & out);
bool Hash(int hash, const std::string & in, std::string & out);
/*
calculating a hash from a given input
the input string is first changed to UTF8 and then hash is calculated
input:
hash - the kind of the hash - WINIX_CRYPT_HASH_*
in - input buffer
inlen - the length of the buffer
output:
out - the hash
*/
bool Hash(int hash, const wchar_t * in, size_t inlen, std::wstring & out);
bool Hash(int hash, const wchar_t * in, std::wstring & out);
bool Hash(int hash, const std::wstring & in, std::wstring & out);
/*
encrypt/decrypt by using RSA algorithm
input:
encrypt - true means encrypting, false means decrypting
keypath - path to a RSA private key (this is a private and public key in one file)
in - input buffer
inlen - the size of the buffer
output:
out - encrypted or decrypted buffer
*/
bool RSA(bool encrypt, const char * keypath, const char * in, size_t inlen, std::string & out);
bool RSA(bool encrypt, const char * keypath, const std::string & in, std::string & out);
bool RSA(bool encrypt, const std::string & keypath, const std::string & in, std::string & out);
bool RSA(bool encrypt, const wchar_t * keypath, const char * in, size_t inlen, std::string & out);
bool RSA(bool encrypt, const wchar_t * keypath, const std::string & in, std::string & out);
bool RSA(bool encrypt, const std::wstring & keypath, const std::string & in, std::string & out);
/*
this method creates a hash from the given plain text password
input.
salt - salt for the hash
up.pass_type - what kind of hash do you want - look at WINIX_CRYPT_HASH_* macros (in crypt.h)
up.pass - plain text password
if salt is empty then the hash will not be salted
output:
up.pass_type - (can be changed to 0 when there is a problem with generating a hash)
up.pass - hash from the password (or plain text if up.pass_type was zero)
up.pass_hash_salted (true if the hash is salted - when salt was not empty)
if there is a problem with generating a hash the method stores a plain text password
and changes up.pass_type to zero (plain text passwords are not salted)
*/
bool PassHash(const std::wstring & salt, UserPass & up);
/*
this method encrypts the given password
input:
path_to_rsa_private_key - a path to rsa private key (this are a private and public keys both in one file)
up.pass - given password (can be a plain text or a hash)
if path_to_rsa_private_key is empty then the password will not be encrypted
output:
up.pass_encrypted
if there is a problem (or the path to the key is empty) then up.pass_encrypted will be empty
and the method returns false
*/
bool PassCrypt(const std::wstring & path_to_rsa_private_key, UserPass & up);
/*
this method creates a hash from the given plain text password and then encrypts it
input:
salt - salt for the hash
path_to_rsa_private_key - a path to rsa private key (this are a private and public keys both in one file)
up.pass_type - what kind of hash do you want - look at WINIX_CRYPT_HASH_* macros (in crypt.h)
up.pass - plain text password
if salt is empty then the hash will not be salted
if path_to_rsa_private_key is empty then the password will not be encrypted
output:
up.pass_type - (can be changed to 0 when there is a problem with generating a hash)
up.pass - hash from the password (or plain text if up.pass_type was zero)
up.pass_hash_salted (true if the hash is salted - when salt was not empty)
up.pass_encrypted - encrypted password (if not empty)
*/
void PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, UserPass & up);
/*
this method creates a hash from the given plain text password and then encrypts it
input:
up.pass - plain text password
output:
up.pass_type - what kind of hash there is in up.pass
up.pass - hash from the password (or plain text if up.pass_type is zero)
up.pass_hash_salted - true if the hash is salted (plain text are never salted)
up.pass_encrypted - encrypted password (if not empty)
*/
void PassHashCrypt(UserPass & up);
/*
putting some characters into the string and then calling clear()
*/
template<class StringType>
void ClearString(StringType & str);
private:
void TrimLastWhite(std::string & str);
Config * config;
Run run;
std::string command, bufina, bufouta, keypatha;
//std::wstring pass_salted;//, pass_hashed;
//std::string pass_hasheda, pass_encrypteda;
std::wstring pass_salted, pass_org;
std::string passa;
std::wstring empty;
};
template<class StringType>
void Crypt::ClearString(StringType & str)
{
for(size_t i=0 ; i<str.size() ; ++i)
str[i] = 0x0c;
str.clear();
}
#endif

34
core/cur.h Executable file
View File

@@ -0,0 +1,34 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_cur
#define headerfile_winix_core_cur
#include "request.h"
#include "session.h"
/*
current request and session
*/
struct Cur
{
Request * request;
Session * session;
// those pointers are never null, if there is no a session for the user
// the 'session' pointer pointers at a special temporary session
};
#endif

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoredircontainer
#define headerfilecmslucoredircontainer
#ifndef headerfile_winix_core_dircontainer
#define headerfile_winix_core_dircontainer
#include <list>
#include <map>

View File

@@ -13,15 +13,16 @@
void Dirs::SetDb(Db * pdb)
{
db = pdb;
}
void Dirs::SetRequest(Request * prequest)
void Dirs::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -603,8 +604,8 @@ Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int not
{
Item * d = AddDir(item);
if( add_to_dir_tab && !request->dir_tab.empty() && request->dir_tab.back()->id == item.parent_id )
request->dir_tab.push_back(d);
if( add_to_dir_tab && !cur->request->dir_tab.empty() && cur->request->dir_tab.back()->id == item.parent_id )
cur->request->dir_tab.push_back(d);
if( pdir )
*pdir = d;

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoredirs
#define headerfilecmslucoredirs
#ifndef headerfile_winix_core_dirs
#define headerfile_winix_core_dirs
#include <vector>
@@ -32,7 +32,7 @@ public:
void Clear();
void ReadDirs();
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
void SetDb(Db * pdb);
void SetNotify(Notify * pnotify);
@@ -55,9 +55,9 @@ public:
std::vector<Item*> & out_dir_tab, std::wstring & out_item);
static void SplitPath(const std::wstring & path, std::wstring & dir, std::wstring & file);
DirContainer::ParentIterator FindFirstChild(long parent_id); // !! zmienic w koncu nazwe na FindFirstChild
DirContainer::ParentIterator FindFirstChild(long parent_id);
DirContainer::ParentIterator NextChild(DirContainer::ParentIterator i);
DirContainer::ParentIterator ParentEnd();
DirContainer::ParentIterator ParentEnd(); // !! pozostalo do zamiany na child
// these methods return null if there is no such a dir
@@ -79,8 +79,8 @@ public:
private:
Request * request;
Db * db;
Cur * cur;
Db * db;
Notify * notify;
DirContainer dir_tab;

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoreerror
#define headerfilecmslucoreerror
#ifndef headerfile_winix_core_error
#define headerfile_winix_core_error
#include <iostream>
#include "log.h"

View File

@@ -7,13 +7,14 @@
*
*/
#ifndef headerfilecmslucoregetparser
#define headerfilecmslucoregetparser
#ifndef headerfile_winix_core_getparser
#define headerfile_winix_core_getparser
#include "httpsimpleparser.h"
#include "requesttypes.h"
#include "misc.h"
#include "utf8.h"
#include "log.h"
class GetParser : public HttpSimpleParser

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoregroup
#define headerfilecmslucoregroup
#ifndef headerfile_winix_core_group
#define headerfile_winix_core_group
#include <string>
#include <vector>

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoregroups
#define headerfilecmslucoregroups
#ifndef headerfile_winix_core_groups
#define headerfile_winix_core_groups
#include <map>

File diff suppressed because it is too large Load Diff

View File

@@ -2,27 +2,40 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorehtmlfilter
#define headerfilecmslucorehtmlfilter
#ifndef headerfile_winix_core_htmlfilter
#define headerfile_winix_core_htmlfilter
#include <string>
#include <map>
#include <vector>
#include <algorithm>
// max length of a name of a html tag (with terminating null)
#define WINIX_HTMLFILTER_ITEM_MAXLEN 30
#define WINIX_HTMLFILTER_ITEM_NAME_MAXLEN 30
// max length of a html lang attribute (e.g. "en", "pl")
#define WINIX_HTMLFILTER_ITEM_LANG_MAXLEN 10
#define WINIX_HTMLFILTER_ATTR_NAME_MAXLEN 40
#define WINIX_HTMLFILTER_ATTR_VALUE_MAXLEN 500
// depth of the html tree
#define WINIX_HTMLFILTER_STACK_MAXLEN 100
#define WINIX_HTMLFILTER_STACK_MAXLEN 100
// length of a buffer used for printing
// it should be at least: WINIX_HTMLFILTER_ITEM_MAXLEN+3
// it should be at least: WINIX_HTMLFILTER_ITEM_NAME_MAXLEN+3
#define WINIX_HTMLFILTER_BUFFER_MAXLEN 2048
@@ -48,23 +61,12 @@ class HTMLFilter
{
public:
// for checking orphans
enum Lang
{
lang_pl,
lang_cz,
lang_sk,
lang_none
};
enum OrphanMode
{
orphan_nbsp, // putting "&nbsp;" string
orphan_160space // putting 160 ascii code
};
HTMLFilter();
HTMLFilter(const HTMLFilter & f);
HTMLFilter & operator=(const HTMLFilter & f);
@@ -76,12 +78,18 @@ public:
void Filter(const std::wstring & in, std::wstring & out);
// insert a white space into long lines
// only between html tags
// insert a white space into long words
// (only between html tags)
// skipped in such tags: script, pre, textarea
// break_after - after how many characters insert a space (0 - off)
void BreakLines(size_t break_after_);
void BreakWord(size_t break_after_);
// insert a new line character into long lines
// (only between html tags)
// skipped in such tags: script, pre, textarea
// wrap_line - after how many characters wrap a line (0 - off)
// lines are wrapped only in 'body' tag (useful for text in 'title' tag which is in 'head' section)
void WrapLine(size_t wrap_line_);
// trimming white characters (with new lines)
// at the beginning, at the end and in the middle of a string
@@ -98,10 +106,16 @@ public:
void InsertTabs(size_t tabsize);
// orphans are checked only in 'body' tag
void AssignOrphans(const wchar_t * lang_code, const std::vector<std::wstring> & otab);
void AssignOrphans(const std::wstring & lang_code, const std::vector<std::wstring> & otab);
void ClearOrphans();
// check 'orphans' for the specicic language
// if an orphan is detected then the non-break space ("&nbsp;" or ascii 160 code) will be put
// default disable (lang_none)
void CheckOrphans(Lang lang_, OrphanMode mode = orphan_nbsp);
void OrphansMode(OrphanMode mode = orphan_nbsp);
// skipping some unsafe tags
@@ -112,107 +126,171 @@ public:
protected:
// orphans for one language
struct Orphans
{
std::vector<std::wstring> tab;
size_t max_len;
};
// orphans for all languages
// map<language_code, Orphans>
typedef std::map<std::wstring, Orphans> OrphansTab;
OrphansTab orphans_tab;
struct Item
{
wchar_t name[WINIX_HTMLFILTER_ITEM_MAXLEN];
size_t name_len;
std::wstring name; // max size: WINIX_HTMLFILTER_ITEM_NAME_MAXLEN
enum Type
{
opening,
closing,
simple,
special,
opening, /* sample: <h1> */
closing, /* sample: </h1> */
simple, /* sample: <br/> */
special, /* sample: <!doctype> */
none
} type;
// is there a new line after this tag
bool new_line;
// current orphans table
// (will be propagated)
Orphans * porphans;
// this item or one from its parents is a 'body' html tag
// (will be propagated)
bool has_body_tag;
void Clear();
Item();
};
// only this method have direct access to the output string
// you can easily change the output from a std::wstring to something else
/*
virtual methods
*/
virtual void Init();
virtual void Uninit();
virtual bool IsOpeningTagMark();
virtual bool IsOpeningCommentaryTagMark();
virtual bool IsClosingTagMark();
virtual bool IsClosingXmlSimpleTagMark();
virtual bool IsValidCharForName(int c);
virtual bool IsValidCharForAttrName(int c);
virtual void CheckExceptions();
virtual bool SkipCommentaryTagIfExists();
virtual void Put(wchar_t c);
virtual void Put(const wchar_t * str);
virtual void Put(const wchar_t * str, const wchar_t * end);
virtual void Put(const std::wstring & str);
virtual void PutOpeningTagMark();
virtual void PutClosingTagMark();
virtual bool PutOpeningTag();
virtual void PutClosingTag(const wchar_t * tag);
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
/*
others
*/
Item & GetItem(size_t i);
Item & LastItem();
wchar_t ToLower(wchar_t c);
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2);
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2, size_t len);
void ToLower(std::wstring & str);
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2);
bool IsNameEqual(const wchar_t * name1, const std::wstring & name2);
bool IsNameEqual(const std::wstring & name1, const wchar_t * name2);
bool IsNameEqual(const std::wstring & name1, const std::wstring & name2);
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2, size_t len);
bool IsNameEqual(const wchar_t * name1, const std::wstring & name2, size_t len);
bool IsNameEqual(const std::wstring & name1, const wchar_t * name2, size_t len);
bool IsNameEqual(const std::wstring & name1, const std::wstring & name2, size_t len);
bool IsLastTag(const wchar_t * name);
bool IsTagSafe(const wchar_t * tag);
bool IsTagSafe(const std::wstring & tag);
int CheckOrphan(const wchar_t * str, const wchar_t * end, const wchar_t * orphan);
bool CheckOrphanTable(const wchar_t * str, const wchar_t * end, const wchar_t ** table, size_t o1, size_t o2);
bool CheckOrphanLangPl(const wchar_t * str, const wchar_t * end);
bool CheckOrphanLangCz(const wchar_t * str, const wchar_t * end);
int CheckOrphan(const wchar_t * str, const wchar_t * end, const std::wstring & orphan_str);
bool CheckOrphan(const wchar_t * str, const wchar_t * end, const std::vector<std::wstring> & orphans);
bool CheckOrphan(const wchar_t * str, const wchar_t * end);
bool IsWhite(int c);
void SkipWhite();
void SkipWhiteLines();
void SkipWhiteWithFirstNewLine();
void SkipWhiteLines(const wchar_t * & str, const wchar_t * end);
bool IsClosingTagForLastItem();
virtual bool IsOpeningTagMark();
virtual bool IsOpeningCommentaryTagMark();
size_t OpeningCommentaryTagMarkSize();
virtual bool IsClosingTagMark();
virtual bool IsClosingXmlSimpleTagMark();
bool SkipCommentaryTagIfExists();
const wchar_t * SkipItemCheckXmlSimple();
void SkipAndCheckClosingTag();
void PopStack();
bool PushStack();
virtual bool IsValidCharForName(int c);
void CheckNewLine();
virtual void CheckExceptions();
void CheckStackPrintRest();
void AddForgottenTags();
void CheckClosingTags();
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
void ReadNormalText();
bool PrintRest();
void PrintItem(const wchar_t * start, const wchar_t * end);
bool PrintOpeningItem();
void ReadItemName();
void ReadItemAttrName();
void ReadItemAttrValue(bool has_quote);
bool ReadItemAttr();
bool CheckItemAttr();
void PrinItemAttr();
void ReadItemClosing();
void ReadItemSpecial();
void ReadItemOpening();
bool ReadItem();
virtual void Init();
virtual void Deinit();
void ReadLoop();
void Read();
size_t PutNormalTextTrimFillBuffer(const wchar_t * & str, const wchar_t * & end);
size_t PutNormalTextFillBuffer(const wchar_t * & str, const wchar_t * & end);
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
virtual void PutNormalTextTrim(const wchar_t * str, const wchar_t * end);
void CheckChar(wchar_t c);
void CheckLineWrap();
bool HasSemiloconAround(const wchar_t * str, const wchar_t * end);
void PutNormalNonWhite(const wchar_t * & str, const wchar_t * end);
void PutNormalWhite(const wchar_t * & str, const wchar_t * end);
void PutLastTagWithClosingTag();
virtual void PutOpeningTagMark();
virtual void PutClosingTagMark();
virtual void PutTagName(const wchar_t * name);
virtual void PutOpeningTag(const wchar_t * start, const wchar_t * end);
virtual void PutClosingTag(const wchar_t * tag);
size_t PutTabsToBuffer(size_t index, size_t len);
size_t PutNonBreakSpaceToBuffer(size_t index);
void PutTabs(size_t len);
void PutNonBreakingSpace();
void PutNewLine();
void CalcOrphansMaxLen(Orphans & orphans);
const wchar_t * pchar;
Item empty;
Item * pstack; // stack pointer
size_t stack_len; // length of the stack
Item * pstack; // stack pointer
size_t stack_len; // length of the stack
wchar_t * buffer; // buffer used when printing
std::wstring * out_string;
bool last_new_line;
size_t break_after; // insert a space into long lines after break_after characters
bool trim_white; // trimming white characters
size_t break_after; // insert a space into long words after 'break_after' characters
size_t wrap_line; // insert a new line character into long lines
bool trim_white; // trimming white characters
size_t tab_size;
Lang lang; // current language for checking orphans
OrphanMode orphan_mode;
bool safe_mode; // skipping some unsafe tags
std::wstring attr_name;
std::wstring attr_value;
std::wstring attr_value_lower;
bool attr_has_value;
std::wstring lang_code_lower;
size_t line_len; //length of the current line (without first spaces which create the html tree)
bool safe_mode; // skipping some unsafe tags
Orphans orphans_temp;
};

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucorehttpsimpleparser
#define headerfilecmslucorehttpsimpleparser
#ifndef headerfile_winix_core_httpsimpleparser
#define headerfile_winix_core_httpsimpleparser
#include <string>

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoreitem
#define headerfilecmslucoreitem
#ifndef headerfile_winix_core_item
#define headerfile_winix_core_item
#include <string>

View File

@@ -78,7 +78,7 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
return;
}
if( last_tab.size() >= LAST_TABLE_SIZE ) // last_tab has O(n) complexity
if( last_tab.size() >= WINIX_LASTCONTAINER_TABLE_SIZE ) // last_tab has O(n) complexity
last_tab.erase(last_tab.begin());
LastItem li;
@@ -107,6 +107,6 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
}
else
{
log << log1 << "LC: there is no such a user to log out" << logend;
log << log4 << "LC: there is no such a user to log out" << logend;
}
}

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucorelastcontainer
#define headerfilecmslucorelastcontainer
#ifndef headerfile_winix_core_lastcontainer
#define headerfile_winix_core_lastcontainer
#include <string>
#include <list>
@@ -18,7 +18,7 @@
// how many items we store in the 'last' function
#define LAST_TABLE_SIZE 100
#define WINIX_LASTCONTAINER_TABLE_SIZE 100

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoreloadavg
#define headerfilecmslucoreloadavg
#ifndef headerfile_winix_core_loadavg
#define headerfile_winix_core_loadavg
#include <ctime>

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -199,6 +199,16 @@ Log & Log::operator<<(char s)
}
Log & Log::operator<<(wchar_t s)
{
if( current_level <= log_level )
{
buffer << s;
}
return *this;
}
Log & Log::operator<<(size_t s)
{
@@ -269,6 +279,7 @@ return *this;
}
void Log::SystemErr(int err)
{
(*this) << "errno: " << err;

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorelog
#define headerfilecmslucorelog
#ifndef headerfile_winix_core_log
#define headerfile_winix_core_log
#include <sstream>
@@ -48,10 +48,14 @@ public:
Log & operator<<(int s);
Log & operator<<(long s);
Log & operator<<(char s);
Log & operator<<(wchar_t s);
Log & operator<<(size_t s);
Log & operator<<(double s);
Log & operator<<(Manipulators m);
template<class StringType>
void LogString(const StringType & value, size_t max_size);
void SystemErr(int err);
void SaveLog();
void SaveLogAndClear();
@@ -100,6 +104,25 @@ private:
template<class StringType>
void Log::LogString(const StringType & value, size_t max_size)
{
size_t min_size = value.size() < max_size ? value.size() : max_size;
if( current_level <= log_level )
{
for(size_t i=0 ; i<min_size ; ++i)
{
if( value[i] < 32 )
buffer << '.';
else
buffer << value[i];
}
}
}
extern Log log;
extern Log nlog;

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -952,3 +952,67 @@ static std::string ain;
UrlEncode(ain, out, clear_out);
}
void QEncodeAddChar(wchar_t c, std::string & out)
{
if( (c>='A' && c<='Z') ||
(c>='a' && c<='z') ||
(c>='0' && c<='9') )
{
out += char(c);
}
else
{
char buf1[10];
char buf2[10];
size_t len1 = sizeof(buf1) / sizeof(char);
size_t len2 = sizeof(buf2) / sizeof(char);
size_t len = Ezc::IntToUTF8(int(c), buf1, len1);
for(size_t i=0 ; i<len ; ++i)
{
// make sure that it produces *capital* letters (ABC...)
Toa((unsigned long)(unsigned char)buf1[i], buf2, len2, 16);
out += '=';
out += buf2;
}
}
}
/*
this encoding is used in mails headers
encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
http://www.faqs.org/rfcs/rfc1522.html
we have:
charset = UTF-8
encoding = Q
current limitation:
we do not support checking the maximum length:
"An encoded-word may not be more than 75 characters long, including
charset, encoding, encoded-text, and delimiters."
*/
void QEncode(const std::wstring & in, std::string & out, bool clear)
{
if( clear )
out.clear();
out += "=?UTF-8?Q?";
for(size_t i=0 ; i<in.size() ; ++i)
QEncodeAddChar(in[i], out);
out += "?=";
}

View File

@@ -2,13 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoremisc
#define headerfilecmslucoremisc
#ifndef headerfile_winix_core_misc
#define headerfile_winix_core_misc
#include <string>
@@ -426,5 +426,8 @@ tm Time(time_t par);
void UrlEncode(const std::string & in, std::string & out, bool clear_out = true);
void UrlEncode(const std::wstring & in, std::string & out, bool clear_out = true);
void QEncode(const std::wstring & in, std::string & out, bool clear = true);
#endif

View File

@@ -8,8 +8,8 @@
*/
#ifndef headerfilecmslucoremount
#define headerfilecmslucoremount
#ifndef headerfile_winix_core_mount
#define headerfile_winix_core_mount
#include <map>
#include <string>

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoremountparser
#define headerfilecmslucoremountparser
#ifndef headerfile_winix_core_mountparser
#define headerfile_winix_core_mountparser
#include <map>
#include <string>

View File

@@ -18,14 +18,13 @@
Mounts::Mounts()
{
pmount = 0;
pmount = &empty_mount;
}
void Mounts::CreateMountType()
{
mount_type_cms = AddMountType(L"cms");
mount_type_thread = AddMountType(L"thread");
mount_type_cms = AddMountType(L"cms");
}
@@ -39,8 +38,10 @@ void Mounts::CreateMountFs()
void Mounts::CreateMountPar()
{
mount_par_page = AddMountPar(L"page");
mount_par_thread = AddMountPar(L"thread");
mount_par_createthread_on = AddMountPar(L"createthread_on");
mount_par_thumb_size = AddMountPar(L"thumb_size");
mount_par_thumb_mode = AddMountPar(L"thumb_mode");
//mount_par_thread = AddMountPar(L"thread");
//mount_par_createthread_on = AddMountPar(L"createthread_on");
mount_par_only_root_remove = AddMountPar(L"only_root_remove");
mount_par_emacs_on = AddMountPar(L"emacs_on");
mount_par_mkdir_on = AddMountPar(L"mkdir_on");
@@ -56,6 +57,9 @@ void Mounts::CreateMounts()
CreateMountPar();
plugin.Call(WINIX_ADD_MOUNTS);
empty_mount.param.resize(mount_par_tab.size());
empty_mount.ClearParams();
}
@@ -71,9 +75,9 @@ void Mounts::SetDb(Db * pdb)
db = pdb;
}
void Mounts::SetRequest(Request * prequest)
void Mounts::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -246,12 +250,14 @@ void Mounts::CalcCurMount()
{
std::vector<Item*>::reverse_iterator i;
pmount = &empty_mount;
// when the program starts (when the dir_tab is empty()
// we don't want to call MountCmsForRoot()
if( request->dir_tab.empty() )
if( cur->request->dir_tab.empty() )
return;
for(i = request->dir_tab.rbegin() ; i!=request->dir_tab.rend() ; ++i)
for(i = cur->request->dir_tab.rbegin() ; i!=cur->request->dir_tab.rend() ; ++i)
{
std::map<long, Mount>::iterator m = mount_tab.find( (*i)->id );

View File

@@ -8,8 +8,8 @@
*/
#ifndef headerfilecmslucorecoremounts
#define headerfilecmslucorecoremounts
#ifndef headerfile_winix_core_mounts
#define headerfile_winix_core_mounts
#include <map>
@@ -37,7 +37,6 @@ public:
// id of a specific mount type (the id is always valid)
int MountTypeCms() { return mount_type_cms; }
int MountTypeThread() { return mount_type_thread; }
// return -1 if there is no such a mount type
// or index otherwhise
@@ -64,8 +63,10 @@ public:
const std::wstring & GetMountPar(int id);
int MountParPage() { return mount_par_page; }
int MountParThread() { return mount_par_thread; }
int MountParCreatethreadOn() { return mount_par_createthread_on; }
int MountParThumbSize() { return mount_par_thumb_size; }
int MountParThumbMode() { return mount_par_thumb_mode; }
//int MountParThread() { return mount_par_thread; }
//int MountParCreatethreadOn() { return mount_par_createthread_on; }
int MountParOnlyRootRemove() { return mount_par_only_root_remove; }
int MountParEmacsOn() { return mount_par_emacs_on; }
int MountParMkdirOn() { return mount_par_mkdir_on; }
@@ -75,7 +76,7 @@ public:
void SetDirs(Dirs * pdirs);
void SetDb(Db * pdb);
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
// dir_id, mount_point
typedef std::map<long, Mount> MountTab;
@@ -98,20 +99,18 @@ public:
private:
Db * db;
Db * db;
Dirs * dirs;
Request * request;
Cur * cur;
Mount empty_mount;
const std::wstring empty_str;
MountParser mount_parser;
// cms
// thread
std::vector<std::wstring> mount_type_tab;
int mount_type_cms;
int mount_type_thread;
// simplefs
// hashfs
@@ -120,13 +119,13 @@ private:
int mount_fs_simplefs;
int mount_fs_hashfs;
// page
// thread
std::vector<std::wstring> mount_par_tab;
int mount_par_page;
int mount_par_thread;
int mount_par_createthread_on;
int mount_par_thumb_size;
int mount_par_thumb_mode;
//int mount_par_thread;
//int mount_par_createthread_on;
int mount_par_only_root_remove;
int mount_par_emacs_on;
int mount_par_mkdir_on;

View File

@@ -31,17 +31,19 @@ size_t i;
Plugin::Plugin()
{
current_plugin = -1;
request = 0;
current_plugin = -1;
db = 0;
config = 0;
request = 0;
cur = 0;
system = 0;
functions = 0;
templates = 0;
synchro = 0;
session_manager = 0;
ret_false = 0;
ret_true = 0;
}
@@ -62,9 +64,9 @@ void Plugin::SetConfig(Config * pconfig)
}
void Plugin::SetRequest(Request * prequest)
void Plugin::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -103,14 +105,14 @@ void Plugin::SetSessionManager(SessionManager * psession_manager)
bool Plugin::SetPointers(PluginInfo & info)
{
// for safety we call a plugin function only when all our pointers are not null
bool res = (db && config && request && system && functions && templates && synchro && session_manager);
bool res = (db && config && cur && system && functions && templates && synchro && session_manager);
if( !res )
log << log1 << "Plugin: cannot call a function - some of the winix pointers are null" << logend;
info.db = db;
info.config = config;
info.request = request;
info.cur = cur;
info.system = system;
info.functions = functions;
info.templates = templates;
@@ -146,6 +148,7 @@ void Plugin::LoadPlugin(const std::string & filename)
}
void * Plugin::LoadInitFun(const char * filename, Fun1 & fun_init)
{
void * p = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
@@ -182,6 +185,7 @@ void Plugin::LoadPlugin(const char * filename)
Fun1 fun_init;
void * plugin_handle;
int old_current_plugin;
PluginInfo info;
if( !SetPointers(info) )
return;
@@ -242,7 +246,7 @@ bool Plugin::HasPlugin(const std::wstring & name)
void Plugin::Call(int message, Slots::iterator & slot)
void Plugin::Call(int message, Slots::iterator & slot, PluginInfo & info)
{
if( !SetPointers(info) )
return;
@@ -250,8 +254,8 @@ void Plugin::Call(int message, Slots::iterator & slot)
current_plugin = slot->second.index;
info.plugin_id = current_plugin;
if( request && request->session && current_plugin != -1 )
info.plugin_data_base = request->session->plugin_data.Get(current_plugin);
if( current_plugin != -1 )
info.plugin_data_base = cur->session->plugin_data.Get(current_plugin);
else
info.plugin_data_base = 0;
@@ -284,10 +288,18 @@ void Plugin::Call(int message, Slots::iterator & slot)
void Plugin::Call(int message, void * p1_, void * p2_, long l1_, long l2_)
{
// how many plugins return 'false' and 'true'
// we are using local variables because Call() method can be called
// from a plugin too (one Call() can execute another Call())
int ret_false_loc = 0;
int ret_true_loc = 0;
int old_current_plugin = current_plugin;
PluginInfo info;
Slots::iterator i = slots.lower_bound(message);
int old_current_plugin = current_plugin;
for( ; i!=slots.end() && i->first==message ; ++i )
{
@@ -297,10 +309,17 @@ void Plugin::Call(int message, void * p1_, void * p2_, long l1_, long l2_)
info.l1 = l1_;
info.l2 = l2_;
Call(message, i);
Call(message, i, info);
if( info.res )
++ret_true_loc;
else
++ret_false_loc;
}
current_plugin = old_current_plugin;
ret_false = ret_false_loc;
ret_true = ret_true_loc;
}
@@ -352,8 +371,6 @@ void Plugin::Call(int message, void * p1_, void * p2_, long l1_)
}
size_t Plugin::Size()
{
return plugins.size();
@@ -361,6 +378,19 @@ size_t Plugin::Size()
int Plugin::True()
{
return ret_true;
}
int Plugin::False()
{
return ret_false;
}
void Plugin::Assign(int message, Fun1 fun1)
{
Slot s;

View File

@@ -8,8 +8,8 @@
*/
#ifndef headerfilecmsluplugin
#define headerfilecmsluplugin
#ifndef headerfile_winix_core_plugin
#define headerfile_winix_core_plugin
#include <vector>
#include <string>
@@ -60,7 +60,7 @@ struct PluginInfo
// objects from winix which are accessible from a plugin
Db * db;
Config * config;
Request * request;
Cur * cur;
System * system;
Functions * functions;
Templates * templates;
@@ -74,7 +74,7 @@ struct PluginInfo
// function return status
// default: false (if not set by the plugin)
bool ret;
bool res;
void Clear()
@@ -89,7 +89,7 @@ struct PluginInfo
plugin_id = -1;
plugin_data_base = 0;
ret = false;
res = false;
}
};
@@ -130,7 +130,7 @@ public:
void SetDb(Db * pdb);
void SetConfig(Config * pconfig);
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
void SetSystem(System * psystem);
void SetFunctions(Functions * pfunctions);
void SetTemplates(Templates * ptemplates);
@@ -161,6 +161,14 @@ public:
// how many plugins there are
size_t Size();
// how many plugins returned 'true'
// from last Call()
int True();
// how many plugins returned 'false'
// from last Call()
int False();
// assign a function to a message
// you can assign more than one function to a specific message
void Assign(int message, Fun1);
@@ -170,13 +178,16 @@ private:
Db * db;
Config * config;
Request * request;
Cur * cur;
System * system;
Functions * functions;
Templates * templates;
Synchro * synchro;
SessionManager * session_manager;
int ret_false;
int ret_true;
std::wstring temp_path;
struct PluginsItem
@@ -191,12 +202,10 @@ private:
typedef std::multimap<int, Slot> Slots;
Slots slots;
PluginInfo info;
std::string afilename;
void * LoadInitFun(const char * filename, Fun1 & fun_init);
void Call(int message, Slots::iterator & slot);
void Call(int message, Slots::iterator & slot, PluginInfo & info);
bool SetPointers(PluginInfo & info);
};

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoreplugindata
#define headerfilecmslucoreplugindata
#ifndef headerfile_winix_core_plugindata
#define headerfile_winix_core_plugindata
#include <vector>

View File

@@ -2,14 +2,14 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslupluginmsg
#define headerfilecmslupluginmsg
#ifndef headerfile_winix_core_pluginmsg
#define headerfile_winix_core_pluginmsg
// here you can add your own EZC functions ([function])
// PluginInfo.p1 is a pointer to Ezc::Functions object
@@ -53,11 +53,12 @@
#define WINIX_SESSION_CHANGED 3002
// the winix is closing
// the is not any session available (request->session is null)
// the is not any session available (cur->session is null)
#define WINIX_CLOSE 3004
// item was removed (rm function)
// a file or symlink was removed (rm function)
// PluginInfo::l1 is the file (item) id
// !! moze zmienic nazwe i dodac symlink w nazwie?
#define WINIX_FILE_REMOVED 3005
// directory was removed (rm function)
@@ -93,4 +94,16 @@
#define WINIX_NOTIFY_ADD_TEMPLATE 3013
// the request is ended
// you can clear some of your object here
#define WINIX_END_REQUEST 3014
// values from 4000 - 4099 reserved for 'thread' plugin
// see plugins/thread/pluginmsg.h
// values from 4100 - 4199 reserved for 'ticket' plugin
// see plugins/ticket/pluginmsg.h
#endif

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -211,8 +211,6 @@ return true;
void PostMultiParser::LogFirst(const std::string & to_log, size_t len)
{
size_t i;
if( len > to_log.size() )
len = to_log.size();
@@ -224,15 +222,7 @@ size_t i;
log << "empty";
log << "): \"";
for(i=0 ; i<len ; ++i)
{
if( to_log[i] < 32 )
log << '.';
else
log << to_log[i];
}
log.LogString(to_log, len);
log << "\"" << logend;
}
@@ -312,7 +302,7 @@ time_t t1, t2;
content.clear();
content.reserve(WINIX_POSTMULTI_OUTPUT_BUFFER);
content_len = 0;
t1 = time(0);
t1 = time(0);
ReadContentToFileLoop();
@@ -357,7 +347,9 @@ void PostMultiParser::ReadContent()
ReadContentLoop();
log << log2 << "PMP: content size: " << content_len << " bytes" << logend;
LogFirst(content, 200);
if( !IsSubStringNoCase("pass", name.c_str()) )
LogFirst(content, config->log_post_value_size);
}

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucorepostmultiparser
#define headerfilecmslucorepostmultiparser
#ifndef headerfile_winix_core_postmultiparser
#define headerfile_winix_core_postmultiparser
#include <string>
#include <fcgiapp.h>

View File

@@ -2,19 +2,22 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorepostparser
#define headerfilecmslucorepostparser
#ifndef headerfile_winix_core_postparser
#define headerfile_winix_core_postparser
#include <fcgiapp.h>
#include <string>
#include "httpsimpleparser.h"
#include "requesttypes.h"
#include "misc.h"
#include "utf8.h"
#include "log.h"
#include "config.h"
@@ -25,6 +28,8 @@ class PostParser : public HttpSimpleParser
PostTab * post_tab;
std::wstring temp_name, temp_value;
bool input_as_utf8;
size_t log_value_size;
protected:
@@ -35,6 +40,29 @@ protected:
}
void CreateLog(bool param_added)
{
log << log2 << "Method POST, name: \"" << temp_name << "\"";
if( log_value_size > 0 && !IsSubStringNoCase(L"pass", temp_name.c_str()) )
{
log << ", value: ";
if( temp_value.size() > log_value_size )
log << "(first " << log_value_size << " characters) ";
log << "\"";
log.LogString(temp_value, log_value_size);
log << "\" (size: " << temp_value.size() << ")";
}
if( param_added == false )
log << log2 << " (skipped)";
log << log2 << logend;
}
virtual void Parameter(std::string & name, std::string & value)
{
if( input_as_utf8 )
@@ -49,13 +77,7 @@ protected:
}
std::pair<PostTab::iterator, bool> res = post_tab->insert( std::make_pair(temp_name, temp_value) );
log << log2 << "Method POST, name: \"" << temp_name << "\", value: \"" << temp_value << "\"";
if( res.second == false )
log << log2 << " (skipped)";
log << log2 << logend;
CreateLog(res.second);
}
@@ -63,7 +85,8 @@ public:
PostParser()
{
input_as_utf8 = false;
input_as_utf8 = false;
log_value_size = 0;
}
@@ -72,6 +95,10 @@ public:
input_as_utf8 = utf;
}
void LogValueSize(size_t s)
{
log_value_size = s;
}
void Parse(FCGX_Stream * in_, PostTab & post_tab_)
{

View File

@@ -12,13 +12,13 @@
#include "log.h"
#include "rebus.h"
#include "misc.h"
#include "request.h"
#include "cur.h"
void Rebus::SetRequest(Request * prequest)
void Rebus::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -128,29 +128,29 @@ return result;
bool Rebus::CheckRebus()
{
if( !request->session )
if( !cur->session )
return false;
if( request->session->puser )
if( cur->session->puser )
// logged users don't have to use the rebus
return true;
if( request->session->rebus_checked )
if( cur->session->rebus_checked )
return true;
request->session->rebus_checked = true;
cur->session->rebus_checked = true;
if( !request->session->rebus_item )
if( !cur->session->rebus_item )
{
log << log1 << "Rebus: rebus not set" << logend;
return false;
}
if( IsAnswerOk(request->session->rebus_item, request->PostVar(L"rebus")) )
if( IsAnswerOk(cur->session->rebus_item, cur->request->PostVar(L"rebus")) )
return true;
log << log1 << "Rebus: rebus has an incorrect answer" << logend;
// don't add request->session->spam_score when the rebus has incorrect answer
// don't add cur->session->spam_score when the rebus has incorrect answer
// a user could have made a mistake
return false;

View File

@@ -7,15 +7,15 @@
*
*/
#ifndef headerfilecmslucorerebus
#define headerfilecmslucorerebus
#ifndef headerfile_winix_core_rebus
#define headerfile_winix_core_rebus
#include <string>
#include <vector>
class Request;
struct Cur;
class Rebus
@@ -31,7 +31,7 @@ public:
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
void Init();
Item * Rand();
bool IsAnswerOk(Item * item, const std::wstring & answer);
@@ -39,7 +39,7 @@ public:
private:
Request * request;
Cur * cur;
bool InitPair(int a, int b, Item & item);

View File

@@ -50,8 +50,6 @@ void Request::ClearPostFileTmp()
void Request::Clear()
{
// warning: don't clear: in, out, err, env
// id is never 0
if( ++id == 0 )
++id;
@@ -80,15 +78,12 @@ void Request::Clear()
env_content_type = &char_empty;
env_http_accept_encoding = &char_empty;
session = 0;
item_tab.clear();
item.Clear();
dir_tab.clear();
last_item = 0;
last_item = &item;
is_item = false;
function = 0;
function = 0; // !! dodac jakas empty funkcje
param_tab.clear();
status = WINIX_ERR_OK;
@@ -266,6 +261,11 @@ return str_empty;
}
const std::wstring & Request::ParamValue(const std::wstring & param_name)
{
return ParamValue(param_name.c_str());
}

View File

@@ -7,14 +7,13 @@
*
*/
#ifndef headerfilecmslucorerequest
#define headerfilecmslucorerequest
#ifndef headerfile_winix_core_request
#define headerfile_winix_core_request
#include <fcgiapp.h>
#include <sstream>
#include <vector>
#include "requesttypes.h"
#include "session.h"
#include "item.h"
#include "error.h"
#include "config.h"
@@ -69,9 +68,6 @@ struct Request
// true if the browser is Konqueror
bool browser_konqueror;
// current session
Session * session;
// current directory
std::vector<Item*> dir_tab;
@@ -119,7 +115,8 @@ struct Request
bool IsParam(const wchar_t * param_name);
bool IsParam(const std::wstring & param_name);
const std::wstring & ParamValue(const wchar_t * param_name); // returns empty string if there is no such a parameter
const std::wstring & ParamValue(const wchar_t * param_name); // returns empty string if there is no such a parameter
const std::wstring & ParamValue(const std::wstring & param_name); // returns empty string if there is no such a parameter
void SetCookie(const char * name, const char * value, tm * expires = 0);
void SetCookie(const char * name, long value, tm * expires = 0);

View File

@@ -7,15 +7,17 @@
*
*/
#ifndef headerfilecmslucorerequesttypes
#define headerfilecmslucorerequesttypes
#ifndef headerfile_winix_core_requesttypes
#define headerfile_winix_core_requesttypes
#include <string>
#include <vector>
#include <map>
#define WINIX_POSTTABLE_MAXSIZE 20
// !! narazie uzywane tylko w post multi parserze
// dodac do zwyklego parsera post
#define WINIX_POSTTABLE_MAXSIZE 50
struct PostFile

385
core/run.cpp Executable file
View File

@@ -0,0 +1,385 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <sys/wait.h>
#include "run.h"
#include "log.h"
Run::Run()
{
Clear();
}
void Run::Clear()
{
parlen = 0;
envlen = 0;
command = 0;
last_status = 0;
last_return = 255;
}
void Run::SetName()
{
size_t i=0;
while( command[i] )
i += 1;
while( i>0 && command[i-1]!='/' )
i -= 1;
par[0] = const_cast<char*>(command + i);
}
void Run::Par(const char * p)
{
if( parlen < WINIX_RUN_MAX_PARAMETERS )
{
// they will be copied (fork)
// the first (zero) parameter is a program name
par[1 + parlen++] = const_cast<char*>(p);
}
}
void Run::Env(const char * e)
{
if( envlen < WINIX_RUN_MAX_PARAMETERS )
{
// they will be copied (fork)
env[envlen++] = const_cast<char*>(e);
}
}
void Run::Cmd(const char * c)
{
command = c;
SetName();
}
void Run::Par(const std::string & p)
{
Par(p.c_str());
}
void Run::Env(const std::string & e)
{
Env(e.c_str());
}
void Run::Cmd(const std::string & c)
{
Cmd(c.c_str());
}
int Run::LastStatus()
{
return last_status;
}
int Run::LastReturn()
{
return last_return;
}
void Run::Write(const char * in, size_t inlen)
{
ssize_t len;
while( inlen > 0 )
{
len = write(desout[1], in, inlen);
if( len < 0 || len > (ssize_t)inlen )
{
// something wrong
last_status = 3;
break;
}
in += len;
inlen -= len;
}
}
void Run::Read(std::string & out)
{
char buf[1024];
size_t buflen = sizeof(buf) / sizeof(char);
ssize_t len;
do
{
len = read(desin[0], buf, buflen);
if( len < 0 || len > (ssize_t)buflen )
{
// something wrong
last_status = 4;
break;
}
if( len > 0 )
out.append(buf, len);
}
while( len > 0 );
}
void Run::ChildThrow()
{
if( dup2(desout[0], 0) == -1 )
return;
if( dup2(desin[1], 1) == -1 )
return;
close(2);
close(desin[0]);
close(desout[1]);
par[parlen+1] = 0;
env[envlen] = 0;
execve(command, par, env);
// if we are here then there is something wrong (execve failed)
}
void Run::Child()
{
try
{
ChildThrow();
}
catch(...)
{
}
exit(255);
}
bool Run::CreatePipes()
{
int res = pipe(desin);
if( res != 0 )
{
log << log1 << "Run: pipe failed (desin)" << logend;
last_status = 1;
return false;
}
res = pipe(desout);
if( res != 0 )
{
log << log1 << "Run: pipe failed (desout)" << logend;
last_status = 1;
close(desin[0]);
close(desin[1]);
return false;
}
return true;
}
bool Run::Fork()
{
childpid = fork();
if( childpid == -1 )
{
log << log1 << "Run: fork failed" << logend;
last_status = 2;
close(desin[0]);
close(desin[1]);
close(desout[0]);
close(desout[1]);
return false;
}
if( childpid == 0 )
Child();
return true;
}
void Run::WriteRead(const char * in, size_t inlen, std::string * out)
{
if( in && inlen>0 )
Write(in, inlen);
close(desout[1]);
if( out )
Read(*out);
close(desin[0]);
}
void Run::CheckStatus()
{
int status;
pid_t res = waitpid(childpid, &status, 0);
if( res == -1 )
{
log << log1 << "Run: waitpid failed" << logend;
last_status = 6;
}
else
{
if( WIFEXITED(status) )
{
last_return = WEXITSTATUS(status);
}
else
{
if( WIFCONTINUED(status) )
log << log1 << "Run: child error: WIFCONTINUED" << logend;
else
if( WIFSIGNALED(status) )
log << log1 << "Run: child error: WIFSIGNALED" << logend;
else
if( WIFSTOPPED(status) )
log << log1 << "Run: child error: WIFSTOPPED" << logend;
last_status = 5;
}
}
}
int Run::Go(const char * in, size_t inlen, std::string * out)
{
last_status = 0;
last_return = 255;
if( out )
out->clear();
if( !command )
{
last_status = 7;
return last_return;
}
if( !CreatePipes() )
return last_return;
if( !Fork() )
return last_return;
// here goes the parent
close(desin[1]);
close(desout[0]);
WriteRead(in, inlen, out);
CheckStatus();
if( last_status != 0 )
log << log1 << "Run: a problem with the command, last_status: " << last_status << logend;
return last_return;
}
int Run::Go(const char * in, size_t inlen, std::string & out)
{
return Go(in, inlen, &out);
}
int Run::Go(const char * in, std::string & out)
{
size_t len = strlen(in);
return Go(in, len, &out);
}
int Run::Go(const char * in, size_t inlen)
{
return Go(in, inlen, 0);
}
int Run::Go(const char * in)
{
size_t len = strlen(in);
return Go(in, len, 0);
}
int Run::Go()
{
return Go(0, 0, 0);
}
int Run::Go(const std::string in, std::string & out)
{
return Go(in.c_str(), in.size(), &out);
}
int Run::Go(const std::string in)
{
return Go(in.c_str(), in.size(), 0);
}
int Run::Go(std::string & out)
{
return Go(0, 0, &out);
}

163
core/run.h Executable file
View File

@@ -0,0 +1,163 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_run
#define headerfile_winix_core_run
#include <string>
#include <cstdio>
/*
how many parameters and environment variables can be passed to a program
*/
#define WINIX_RUN_MAX_PARAMETERS 30
/*
objects of this class allows you to run an external program
when you call Go() then:
1. winix creates pipes for communicating with a child process
2. then winix fork()
3. the child process execve() the specified command
4. winix (parent) sends 'in' to the standard input of the child process
5. after sending it closes the descriptor so the child sees it as end-of-file
6. now winix reads what the child sends to standard output (until EOF)
7. winix waitpid() for the child
8. Go() returns
*/
class Run
{
public:
Run();
/*
clearing parameters, environment variables and the command
(and clearing LastStatus and LastResult)
so you can call another different program now
*/
void Clear();
/*
setting parameters
each parameter should be passed in different call to Par() method
sample:
if you want to call from your shell:
$ myprog -a -b -f "test file"
you should call Par() in this way:
Par("-a");
Par("-b");
Par("test file"); // apostrophes are not needed here
arguments passed to Par() should not be changed afterwards, this method does not copy them anywhere
it uses only the pointer
*/
void Par(const char * p);
void Par(const std::string & p);
/*
setting environment variables
one variable per one Env() call
arguments passed to Env() should not be changed afterwards, this method does not copy them anywhere
it uses only the pointer
*/
void Env(const char * e);
void Env(const std::string & e);
/*
full path to command you want to execute
arguments passed to Cmd() should not be changed afterwards, this method does not copy them anywhere
it uses only the pointer
*/
void Cmd(const char * c);
void Cmd(const std::string & c);
/*
executing the command
you should call Par(), Env() and Cmd() beforehand
*/
int Go(const char * in, size_t inlen, std::string & out);
int Go(const char * in, std::string & out);
int Go(const char * in, size_t inlen);
int Go(const char * in);
int Go(const std::string in, std::string & out);
int Go(const std::string in);
int Go(std::string & out);
int Go();
/*
last status:
0 - ok (program was successfully called)
1 - pipe failed
2 - fork failed
3 - write failed
4 - read failed
5 - child process has done something wrong (caught a signal etc.)
6 - waitpid failed
7 - the command is not set (call Cmd method first)
*/
int LastStatus();
/*
the code which the command returned (usually "0" means no errors found)
if LastStatus is different from zero then LastReturn always returns 255
(so you don't have to check LastStatus() first)
*/
int LastReturn();
private:
int Go(const char * in, size_t inlen, std::string * out);
void SetName();
void CheckStatus();
void WriteRead(const char * in, size_t inlen, std::string * out);
bool CreatePipes();
bool Fork();
void ChildThrow();
void Child();
void Write(const char * in, size_t inlen);
void Read(std::string & out);
int last_status;
// the return code returned by a program (if last_status==0)
// if last_status!=0 then last_return is 255
int last_return;
int desin[2];
int desout[2];
char * par[WINIX_RUN_MAX_PARAMETERS + 2];
char * env[WINIX_RUN_MAX_PARAMETERS + 1];
const char * command;
size_t parlen;
size_t envlen;
pid_t childpid;
};
#endif

View File

@@ -15,8 +15,13 @@
Session::Session()
{
SetTimeToNow();
Clear();
}
void Session::SetTimeToNow()
{
time = std::time(0);
tm_time = Time(time);
@@ -28,16 +33,18 @@ Session::Session()
}
// this doesn't clear times
void Session::Clear()
{
id = 0;
time = 0;
puser = 0;
rebus_item = 0;
id = 0;
time = 0;
puser = 0;
rebus_item = 0;
rebus_checked = false;
remember_me = false;
new_session = true;
spam_score = 0;
remember_me = false;
new_session = true;
spam_score = 0;
plugin_data.Resize(0);
}

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoresession
#define headerfilecmslucoresession
#ifndef headerfile_winix_core_session
#define headerfile_winix_core_session
#include <ctime>
#include "item.h"
@@ -65,6 +65,7 @@ struct Session
Session();
void SetTimeToNow();
void Clear();
};

View File

@@ -15,17 +15,13 @@
SessionContainer::SessionContainer()
{
request = 0;
table_size = 0;
work_mode = 1; // threading work mode
}
void SessionContainer::SetRequest(Request * prequest)
void SessionContainer::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -35,32 +31,55 @@ void SessionContainer::SetConfig(Config * pconfig)
}
void SessionContainer::SetTmpSession(Session * psession)
{
tmp_session = psession;
}
void SessionContainer::Clear()
{
Table::iterator i = table.begin();
log << log3 << "SC: deleting all sessions" << logend;
// don't use table.clear();
// because plugins session data would not be erased
// we must set cur->session for each session and then delete it
while( i != table.end() )
{
request->session = &(*i);
cur->session = &(*i);
table.erase(i++);
}
// erasing indexes
index_id.clear();
table_size = 0;
request->session = 0;
cur->session = tmp_session;
}
void SessionContainer::SetLastContainer(LastContainer * plast_container)
void SessionContainer::EraseById(IdIterator i)
{
last_container = plast_container;
Session * old_session = tmp_session;
if( cur->session != &(*i->second) )
old_session = cur->session;
cur->session = &(*i->second);
log << log4 << "SC: deleting session, id: " << i->second->id << logend;
table.erase(i->second);
index_id.erase(i);
table_size -= 1;
cur->session = old_session;
}
size_t SessionContainer::Size()
{
// don't use table.size() as it has O(n) complexity on FreeBSD
@@ -86,6 +105,18 @@ Session & SessionContainer::Back()
}
SessionContainer::IdIterator SessionContainer::IdBegin()
{
return index_id.begin();
}
SessionContainer::IdIterator SessionContainer::IdEnd()
{
return index_id.end();
}
bool SessionContainer::PushBack(const Session & session)
{
@@ -128,87 +159,3 @@ return i->second;
/*
*
*
* sessions gc (another thread)
*
*
*/
void SessionContainer::Work()
{
bool exit = false;
IndexId::iterator i;
Lock();
i = index_id.begin();
Unlock();
while( !exit )
{
Lock();
if( i == index_id.end() )
{
i = index_id.begin();
WaitForSignalSleep(30);
}
else
{
if( IsSessionOutdated(*i->second) )
DeleteSession(i++);
else
++i;
}
exit = synchro->was_stop_signal;
Unlock();
}
}
// it's called from the other thread (with Lock and Unlock)
bool SessionContainer::IsSessionOutdated(const Session & s) const
{
bool outdated;
if( s.remember_me )
outdated = s.last_time < std::time(0) - config->session_remember_max_idle;
else
outdated = s.last_time < std::time(0) - config->session_max_idle;
return outdated;
}
// it's called from the other thread (with Lock and Unlock)
void SessionContainer::DeleteSession(SessionContainer::IndexId::iterator i)
{
Session * old_session = request->session;
request->session = &(*i->second);
//log << log3 << "SessionContainer: deleting outdated session, id: " << i->second->id << logend;
if( i->second->puser )
last_container->UserLogout(i->second->puser->id, i->second->id);
table.erase(i->second);
index_id.erase(i);
table_size -= 1;
request->session = old_session;
}
/*
*
*
* end of sessions gc
*
*
*/

View File

@@ -7,22 +7,20 @@
*
*/
#ifndef headerfilecmslucoresessioncontainer
#define headerfilecmslucoresessioncontainer
#ifndef headerfile_winix_core_sessioncontainer
#define headerfile_winix_core_sessioncontainer
#include <list>
#include <map>
#include <ctime>
#include "session.h"
#include "lastcontainer.h"
#include "request.h"
#include "basethread.h"
#include "cur.h"
#include "config.h"
class SessionContainer : public BaseThread
class SessionContainer
{
public:
@@ -33,13 +31,14 @@ public:
typedef std::list<Session> Table;
typedef Table::iterator Iterator;
typedef std::map<long, Iterator> IndexId;
typedef IndexId::iterator IdIterator;
SessionContainer();
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
void SetConfig(Config * pconfig);
void SetLastContainer(LastContainer * plast_container);
void SetTmpSession(Session * psession);
void Clear();
@@ -50,20 +49,19 @@ public:
bool PushBack(const Session & session);
Iterator FindById(long);
IdIterator IdBegin();
IdIterator IdEnd();
void EraseById(IdIterator i);
private:
LastContainer * last_container;
Table table;
IndexId index_id;
Request * request;
Config * config;
//void DelFromIdIndex(Iterator iter);
virtual void Work();
bool IsSessionOutdated(const Session & s) const;
void DeleteSession(IndexId::iterator i);
Cur * cur;
Config * config;
Session * tmp_session;
// in FreeBSD implementation (GCC) list::size() has linear complexity
// so we use our own table_size with O(1)

View File

@@ -22,13 +22,19 @@
SessionManager::SessionManager()
{
temporary_session.id = 0;
session = &temporary_session;
session_tab.SetTmpSession(&temporary_session);
// thread work mode
work_mode = 1;
}
void SessionManager::SetRequest(Request * prequest)
void SessionManager::SetCur(Cur * pcur)
{
request = prequest;
session_tab.SetRequest(prequest);
cur = pcur;
session_tab.SetCur(pcur);
}
@@ -44,17 +50,13 @@ void SessionManager::SetSystem(System * psystem)
system = psystem;
}
void SessionManager::SetLastContainer(LastContainer * plast_container)
{
session_tab.SetLastContainer(plast_container);
last_container = plast_container;
}
void SessionManager::SetSynchro(Synchro * psynchro)
{
session_tab.SetSynchro(psynchro);
}
size_t SessionManager::Size()
{
@@ -103,52 +105,21 @@ return id;
void SessionManager::CreateTemporarySession()
{
SessionContainer::Iterator i = session_tab.FindById( 0 );
if( i == session_tab.End() )
{
Session s;
s.id = 0;
s.new_session = true;
session_tab.PushBack(s);
request->session = &session_tab.Back();
}
else
{
request->session = &(*i);
request->session->Clear(); // !! what about session.plugin_data?
request->session->id = 0;
request->session->new_session = false;
}
}
void SessionManager::CreateSession()
{
Session s;
int attempts = 100;
int attempts = 100;
bool added = false;
if( config->session_max == 0 || session_tab.Size() < config->session_max - 1 ) // -1 for the temporary session
new_session.SetTimeToNow();
new_session.Clear();
if( config->session_max == 0 || session_tab.Size() < config->session_max )
{
for( ; attempts > 0 ; --attempts )
for( ; !added && attempts > 0 ; --attempts )
{
s.id = CreateSessionId();
bool added = session_tab.PushBack(s);
if( added )
{
request->session = &session_tab.Back();
request->session->new_session = true;
log << log2 << "SM: created a new session: " << request->session->id << logend;
return;
}
new_session.id = CreateSessionId();
added = session_tab.PushBack(new_session);
}
}
else
@@ -156,10 +127,22 @@ int attempts = 100;
log << log2 << "SM: sessions limit exceeded (" << config->session_max << ")" << logend;
}
// there is a problem with generating a new session id
// we do not set a session cookie
CreateTemporarySession();
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
if( added )
{
session = &session_tab.Back();
session->new_session = true;
log << log2 << "SM: created a new session: " << session->id << logend;
}
else
{
// there is a problem with generating a new session id
// we do not set a session cookie
session = &temporary_session;
session->SetTimeToNow();
session->Clear(); // !! uwaga ten Clear wyczysci plugins data
session->new_session = false; // temporary session was initialized at the beginning
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
}
}
@@ -174,18 +157,18 @@ bool SessionManager::SetSessionFromCookie(const std::string & cookie)
return false;
// that session is in the table
request->session = &(*s);
request->session->new_session = false;
request->session->last_time = std::time(0);
request->session->tm_last_time = Time(request->session->last_time);
session = &(*s);
session->new_session = false;
session->last_time = std::time(0);
session->tm_last_time = Time(session->last_time);
if( request->method == Request::get )
request->session->last_time_get = request->session->last_time;
if( cur->request->method == Request::get )
session->last_time_get = session->last_time;
log << log2 << "SM: session: " << s->id;
log << log2 << "SM: session: " << session->id;
if( request->session->puser )
log << log2 << ", user: " << request->session->puser->name << ", id: " << request->session->puser->id;
if( session->puser )
log << log2 << ", user: " << session->puser->name << ", id: " << session->puser->id;
log << log2 << logend;
@@ -196,9 +179,9 @@ return true;
void SessionManager::SetSession()
{
CookieTab::iterator i = request->cookie_tab.find(config->http_session_id_name);
CookieTab::iterator i = cur->request->cookie_tab.find(config->http_session_id_name);
if( i == request->cookie_tab.end() )
if( i == cur->request->cookie_tab.end() )
{
CreateSession();
}
@@ -208,22 +191,12 @@ void SessionManager::SetSession()
{
// there is no such a session
// deleting the old cookie
request->cookie_tab.erase(i);
cur->request->cookie_tab.erase(i);
// and creating a new one
CreateSession();
}
}
// request->session is set now
if( request->session->new_session )
{
request->session->plugin_data.Resize(plugin.Size());
plugin.Call(WINIX_SESSION_CREATED);
}
plugin.Call(WINIX_SESSION_CHANGED);
}
@@ -252,6 +225,31 @@ void SessionManager::DeleteSessions()
void SessionManager::InitTmpSession()
{
Session * old_session = cur->session;
log << log4 << "SM: initializing temporary session" << logend;
cur->session = &temporary_session;
plugin.Call(WINIX_SESSION_CREATED);
cur->session = old_session;
}
void SessionManager::UninitTmpSession()
{
Session * old_session = cur->session;
log << log4 << "SM: uninitializing temporary session" << logend;
cur->session = &temporary_session;
cur->session->plugin_data.DeleteAll(); // this will call plugin.Call(WINIX_SESSION_REMOVE);
cur->session->plugin_data.Resize(0);
cur->session = old_session;
}
void SessionManager::LoadSessions()
@@ -259,20 +257,20 @@ void SessionManager::LoadSessions()
SessionParser sp;
SessionContainer::Iterator i;
// sessions will be overwritten (pointers are invalidated)
cur->session = &temporary_session;
sp.SetUsers(&system->users);
Session * old_session = request->session;
sp.Parse(config->session_file, session_tab);
i = session_tab.Begin();
for( ; i!=session_tab.End() ; ++i )
for(i=session_tab.Begin() ; i != session_tab.End() ; ++i)
{
i->plugin_data.Resize(plugin.Size());
request->session = &(*i);
cur->session = &(*i);
plugin.Call(WINIX_SESSION_CREATED);
}
request->session = old_session;
cur->session = &temporary_session;
}
@@ -316,24 +314,125 @@ void SessionManager::SaveSessions()
void SessionManager::StartGC()
Session * SessionManager::GetTmpSession()
{
session_tab.StartThread();
return &temporary_session;
}
// use it with Lock() and Unlock();
void SessionManager::PrepareToStopGC()
Session * SessionManager::GetCurSession()
{
session_tab.WakeUpThread();
}
void SessionManager::WaitForGC()
{
session_tab.WaitForThread();
return session;
}
/*
*
*
* sessions gc (second thread)
*
*
*/
void SessionManager::Work()
{
bool exit = false;
SessionContainer::IndexId::iterator i;
deleted = 0;
Lock();
i = session_tab.IdBegin();
Unlock();
while( !exit )
{
Lock();
CheckSession(i);
exit = synchro->was_stop_signal;
Unlock();
}
}
// it's called from the other thread (with Lock and Unlock)
void SessionManager::CheckSession(SessionContainer::IndexId::iterator & i)
{
const int deleted_max_at_once = 10;
if( i == session_tab.IdEnd() )
{
if( deleted > 0 )
{
deleted = 0;
log << logsave;
}
i = session_tab.IdBegin();
WaitForSignalSleep(10);
}
else
{
if( IsSessionOutdated(*i->second) )
{
DeleteSession(i++);
++deleted;
}
else
{
++i;
}
if( deleted >= deleted_max_at_once )
{
log << logsave;
WaitForSignalSleep(1);
deleted = 0;
}
}
}
// it's called from the other thread (with Lock and Unlock)
bool SessionManager::IsSessionOutdated(const Session & s) const
{
bool outdated;
if( s.remember_me )
outdated = s.last_time < std::time(0) - config->session_remember_max_idle;
else
outdated = s.last_time < std::time(0) - config->session_max_idle;
return outdated;
}
// it's called from the other thread (with Lock and Unlock)
void SessionManager::DeleteSession(SessionContainer::IdIterator i)
{
Session * del_session = &(*i->second);
if( del_session->puser )
last_container->UserLogout(del_session->puser->id, del_session->id);
session_tab.EraseById(i);
}
/*
*
*
* end of sessions gc
*
*
*/

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoresessionmanager
#define headerfilecmslucoresessionmanager
#ifndef headerfile_winix_core_sessionmanager
#define headerfile_winix_core_sessionmanager
#include <set>
#include <ctime>
@@ -19,39 +19,29 @@
#include "lastcontainer.h"
#include "system.h"
#include "synchro.h"
#include "basethread.h"
class SessionManager
class SessionManager : public BaseThread
{
Config * config;
Request * request;
System * system;
SessionContainer session_tab;
bool IsSession(long s);
long CreateSessionId();
void CreateTemporarySession();
void CreateSession();
bool SetSessionFromCookie(const std::string & cookie);
public:
SessionManager();
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
void SetConfig(Config * pconfig);
void SetSystem(System * psystem);
void SetLastContainer(LastContainer * plast_container);
void SetSynchro(Synchro * psynchro);
void SetSession();
void DeleteSessions(); // deleting all sessions
void StartGC();
void PrepareToStopGC();
void WaitForGC();
void InitTmpSession();
void UninitTmpSession();
Session * GetTmpSession();
Session * GetCurSession();
void LoadSessions();
void SaveSessions();
@@ -60,6 +50,40 @@ public:
SessionContainer::Iterator SessionEnd();
size_t Size();
private:
Config * config;
Cur * cur;
System * system;
LastContainer * last_container;
// current session - set by SetSession()
Session * session;
SessionContainer session_tab;
// session with id 0
Session temporary_session;
// for adding a new session to the container
Session new_session;
bool IsSession(long s);
long CreateSessionId();
void CreateSession();
bool SetSessionFromCookie(const std::string & cookie);
// second thread
int deleted;
virtual void Work();
void CheckSession(SessionContainer::IndexId::iterator & i);
bool IsSessionOutdated(const Session & s) const;
void DeleteSession(SessionContainer::IdIterator i);
};

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoresessionparser
#define headerfilecmslucoresessionparser
#ifndef headerfile_winix_core_sessionparser
#define headerfile_winix_core_sessionparser
#include <fstream>
#include <string>

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoresynchro
#define headerfilecmslucoresynchro
#ifndef headerfile_winix_core_synchro
#define headerfile_winix_core_synchro
#include <pthread.h>

View File

@@ -15,9 +15,9 @@
void System::SetRequest(Request * prequest)
void System::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -44,26 +44,26 @@ void System::SetSynchro(Synchro * psynchro)
void System::Init()
{
dirs.SetDb(db);
dirs.SetRequest(request);
dirs.SetCur(cur);
dirs.SetNotify(&notify);
dirs.ReadDirs();
mounts.SetDirs(&dirs);
mounts.SetDb(db);
mounts.SetRequest(request);
mounts.SetCur(cur);
mounts.CreateMounts();
mounts.ReadMounts();
users.SetRequest(request);
users.SetCur(cur);
users.ReadUsers(db);
users.SetTimeZoneOffset(config->time_zone_offset);
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
rebus.SetRequest(request);
rebus.SetCur(cur);
rebus.Init();
notify.SetSynchro(synchro);
notify.SetRequest(request);
notify.SetCur(cur);
notify.SetConfig(config);
notify.SetUsers(&users);
notify.SetDirs(&dirs);
@@ -73,6 +73,8 @@ void System::Init()
thumb.SetDb(db);
thumb.SetConfig(config);
thumb.SetSystem(this);
crypt.SetConfig(config);
}
@@ -80,35 +82,35 @@ void System::Init()
// !! moze zwracac jakas wartosc?
void System::RedirectTo(const Item & item, const wchar_t * postfix)
{
request->redirect_to = config->base_url;
cur->request->redirect_to = config->base_url;
if( item.type == Item::dir )
{
// item_id is pointing to a directory
dirs.MakePath(item.id, request->redirect_to, false);
dirs.MakePath(item.id, cur->request->redirect_to, false);
}
else
{
// item_id is pointing to a file or a symlink
if( dirs.MakePath(item.parent_id, request->redirect_to, false) )
request->redirect_to += item.url;
if( dirs.MakePath(item.parent_id, cur->request->redirect_to, false) )
cur->request->redirect_to += item.url;
}
if( postfix )
request->redirect_to += postfix;
cur->request->redirect_to += postfix;
}
void System::RedirectTo(long item_id, const wchar_t * postfix)
{
request->redirect_to = config->base_url;
cur->request->redirect_to = config->base_url;
Item * pdir = dirs.GetDir(item_id);
if( pdir )
{
// item_id is pointing to a directory
dirs.MakePath(pdir->id, request->redirect_to, false);
dirs.MakePath(pdir->id, cur->request->redirect_to, false);
}
else
{
@@ -122,8 +124,8 @@ void System::RedirectTo(long item_id, const wchar_t * postfix)
if( db->GetItem(item_temp, iq) == WINIX_ERR_OK )
{
if( dirs.MakePath(item_temp.parent_id, request->redirect_to, false) )
request->redirect_to += item_temp.url;
if( dirs.MakePath(item_temp.parent_id, cur->request->redirect_to, false) )
cur->request->redirect_to += item_temp.url;
}
else
{
@@ -132,31 +134,31 @@ void System::RedirectTo(long item_id, const wchar_t * postfix)
}
if( postfix )
request->redirect_to += postfix;
cur->request->redirect_to += postfix;
}
void System::RedirectTo(const std::wstring & url)
{
request->redirect_to = config->base_url;
cur->request->redirect_to = config->base_url;
if( !url.empty() && url[0] == '/' )
{
// absolute path
request->redirect_to += url;
cur->request->redirect_to += url;
}
else
{
// relative path
if( !request->dir_tab.empty() )
if( !cur->request->dir_tab.empty() )
{
if( dirs.MakePath(request->dir_tab.back()->id, request->redirect_to, false) )
request->redirect_to += url;
if( dirs.MakePath(cur->request->dir_tab.back()->id, cur->request->redirect_to, false) )
cur->request->redirect_to += url;
}
else
{
request->redirect_to += '/';
request->redirect_to += url;
cur->request->redirect_to += '/';
cur->request->redirect_to += url;
}
}
}
@@ -186,38 +188,38 @@ void System::RedirectWithFunctionAndParamsTo(const std::wstring & url)
{
RedirectTo(url);
if( !request->function )
if( !cur->request->function )
return;
request->redirect_to += '/';
request->redirect_to += request->function->fun.url;
cur->request->redirect_to += '/';
cur->request->redirect_to += cur->request->function->fun.url;
AddParams(request->param_tab, request->redirect_to, false);
AddParams(cur->request->param_tab, cur->request->redirect_to, false);
}
void System::RedirectToLastDir()
{
if( !request->dir_tab.empty() )
RedirectTo( *request->dir_tab.back() );
if( !cur->request->dir_tab.empty() )
RedirectTo( *cur->request->dir_tab.back() );
}
void System::RedirectToLastItem()
{
if( request->last_item )
RedirectTo( *request->last_item );
if( cur->request->last_item )
RedirectTo( *cur->request->last_item );
}
bool System::CanChangeUser(const Item & item, long new_user_id)
{
if( !request->session )
if( !cur->session )
// session must be set
return false;
if( request->session->puser && request->session->puser->super_user )
if( cur->session->puser && cur->session->puser->super_user )
// super user is allowed everything
return true;
@@ -233,11 +235,11 @@ return true;
bool System::CanChangeGroup(const Item & item, long new_group_id)
{
if( !request->session )
if( !cur->session )
// session must be set
return false;
if( request->session->puser && request->session->puser->super_user )
if( cur->session->puser && cur->session->puser->super_user )
// super user is allowed everything
return true;
@@ -246,16 +248,16 @@ bool System::CanChangeGroup(const Item & item, long new_group_id)
// user is allowed to change the group only if he is an owner of the item
// he can change only into a group in which he is a member of, or into a 'no_group'
if( !request->session->puser )
if( !cur->session->puser )
return false;
if( request->session->puser->id != item.user_id )
if( cur->session->puser->id != item.user_id )
return false;
if( new_group_id == -1 )
return true;
if( !request->session->puser->IsMemberOf(new_group_id) )
if( !cur->session->puser->IsMemberOf(new_group_id) )
return false;
// is logged, is the owner of the item, is the member of the new group
@@ -267,11 +269,11 @@ return true;
bool System::CanChangePrivileges(const Item & item, int new_priv)
{
if( !request->session )
if( !cur->session )
// session must be set
return false;
if( request->session->puser && request->session->puser->super_user )
if( cur->session->puser && cur->session->puser->super_user )
// super user is allowed everything
return true;
@@ -279,10 +281,10 @@ bool System::CanChangePrivileges(const Item & item, int new_priv)
{
// the owner of an item is allowed to change the privileges
if( !request->session->puser )
if( !cur->session->puser )
return false;
if( request->session->puser->id != item.user_id )
if( cur->session->puser->id != item.user_id )
return false;
}
@@ -293,21 +295,21 @@ return true;
bool System::HasAccess(const Item & item, int mask)
{
if( !request->session )
if( !cur->session )
// session must be set
return false;
if( request->session->puser && request->session->puser->super_user )
if( cur->session->puser && cur->session->puser->super_user )
// super user is allowed everything
return true;
if( request->session->puser && request->session->puser->id == item.user_id )
if( cur->session->puser && cur->session->puser->id == item.user_id )
{
// the owner
return ((item.privileges >> 6) & mask) == mask;
}
if( request->session->puser && request->session->puser->IsMemberOf(item.group_id) )
if( cur->session->puser && cur->session->puser->IsMemberOf(item.group_id) )
{
// group
return ((item.privileges >> 3) & mask) == mask;
@@ -339,7 +341,7 @@ bool System::HasReadWriteAccess(const Item & item)
bool System::HasReadExecAccess(const Item & item)
{
if( request->session && request->session->puser && request->session->puser->super_user )
if( cur->session && cur->session->puser && cur->session->puser->super_user )
{
// there must be at least one 'x' (for the root)
@@ -387,7 +389,7 @@ return true;
bool System::DirsHaveReadExecPerm()
{
return HasReadExecAccessToPath(request->dir_tab);
return HasReadExecAccessToPath(cur->request->dir_tab);
}
@@ -642,10 +644,10 @@ Error System::EditFile(Item & item, bool with_url, int notify_code)
if( item.type != Item::file )
return WINIX_ERR_FILE_EXPECTED;
if( request->session && request->session->puser )
request->item.modification_user_id = request->session->puser->id;
if( cur->session && cur->session->puser )
cur->request->item.modification_user_id = cur->session->puser->id;
else
request->item.modification_user_id = -1;
cur->request->item.modification_user_id = -1;
item.SetDateModifyToNow();
Error status = db->EditItemById(item, with_url);
@@ -669,8 +671,8 @@ time_t System::LocalTime(time_t gmt_time)
{
int time_offset;
if( request->session && request->session->puser )
time_offset = request->session->puser->time_zone_offset;
if( cur->session && cur->session->puser )
time_offset = cur->session->puser->time_zone_offset;
else
time_offset = config->time_zone_offset_guest;
@@ -909,40 +911,40 @@ int System::FollowAllLinks(const std::wstring & link_to,
// the same as FollowAllLinks but operates on request->dir_tab and request->item
// the same as FollowAllLinks but operates on cur->request->dir_tab and cur->request->item
// and returns bool
// the method is making a redirection if needed
bool System::FollowAllLinks(const std::wstring & link_to,
bool follow_dir_default, bool stop_on_link_redirect, bool check_access)
{
int res = FollowAllLinks(request->dir_tab, link_to, temp_follow_dir_tab, temp_follow_item,
int res = FollowAllLinks(cur->request->dir_tab, link_to, temp_follow_dir_tab, temp_follow_item,
follow_dir_default, stop_on_link_redirect, check_access);
bool ok = (res == 0 || res == 1);
if( ok )
{
request->dir_tab = temp_follow_dir_tab;
cur->request->dir_tab = temp_follow_dir_tab;
if( res == 0 )
{
request->is_item = false;
request->item.Clear();
request->last_item = request->dir_tab.back();
cur->request->is_item = false;
cur->request->item.Clear();
cur->request->last_item = cur->request->dir_tab.back();
if( !request->dir_tab.back()->link_to.empty() )
RedirectTo(request->dir_tab.back()->link_to);
if( !cur->request->dir_tab.back()->link_to.empty() )
RedirectTo(cur->request->dir_tab.back()->link_to);
log << log3 << "System: current directory changed" << logend;
}
else
{
request->is_item = true;
request->item = temp_follow_item;
request->last_item = &request->item;
cur->request->is_item = true;
cur->request->item = temp_follow_item;
cur->request->last_item = &cur->request->item;
if( request->item.type == Item::symlink )
RedirectTo(request->item.link_to); // request->item.link_to is not empty
if( cur->request->item.type == Item::symlink )
RedirectTo(cur->request->item.link_to); // cur->request->item.link_to is not empty
log << log3 << "System: current directory changed and the new file loaded" << logend;
}
@@ -952,9 +954,9 @@ bool System::FollowAllLinks(const std::wstring & link_to,
else
{
if( res == 5 || res == 6 )
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
else
request->status = WINIX_ERR_NO_ITEM;
cur->request->status = WINIX_ERR_NO_ITEM;
}
return ok;

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoresystem
#define headerfilecmslucoresystem
#ifndef headerfile_winix_core_system
#define headerfile_winix_core_system
#include <ctime>
#include "dirs.h"
@@ -16,6 +16,7 @@
#include "db/db.h"
#include "request.h"
#include "config.h"
#include "crypt.h"
#include "users.h"
#include "groups.h"
#include "rebus.h"
@@ -59,8 +60,10 @@ public:
// the time when the winix starts
time_t system_start;
// cryptography and hashes
Crypt crypt;
void SetRequest(Request * prequest);
void SetCur(Cur * pcur);
void SetConfig(Config * pconfig);
void SetDb(Db * pdb);
void SetSynchro(Synchro * psynchro);
@@ -120,15 +123,16 @@ public:
std::vector<Item*> & out_dir_tab, Item & out_item,
bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true);
// using request->dir_tab and request->item
// using cur->request->dir_tab and cur->request->item
bool FollowAllLinks(const std::wstring & link_to,
bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true);
private:
Request * request;
Config * config;
Db * db;
Synchro * synchro;
Cur * cur;
Db * db;
Config * config;
Synchro * synchro;
Item item_temp;
std::wstring link_to_temp, name_temp;

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucorethumb
#define headerfilecmslucorethumb
#ifndef headerfile_winix_core_thumb
#define headerfile_winix_core_thumb
#include <string>
#include <list>

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucoreugcontainer
#define headerfilecmslucoreugcontainer
#ifndef headerfile_winix_core_ugcontainer
#define headerfile_winix_core_ugcontainer
#include <vector>
#include <map>

View File

@@ -2,18 +2,32 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoreuser
#define headerfilecmslucoreuser
#ifndef headerfile_winix_core_user
#define headerfile_winix_core_user
#include <string>
#include <vector>
/*
a temporary struct used for hashing and encrypting a user's password
*/
struct UserPass
{
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::string pass_encrypted; // password encrypted
bool pass_hash_salted; // true when the hash was salted (plain text passwords are never salted)
};
struct User
{
long id;

View File

@@ -19,9 +19,9 @@ Users::Users()
}
void Users::SetRequest(Request * prequest)
void Users::SetCur(Cur * pcur)
{
request = prequest;
cur = pcur;
}
@@ -128,30 +128,30 @@ User & Users::operator[](Users::SizeType pos)
void Users::LoginUser(long user_id, bool remember_me)
{
if( !request->session )
if( !cur->session )
return;
if( request->session->id == 0 )
if( cur->session->id == 0 )
{
log << log1 << "Users: cannot login a user on a temporary session" << logend;
return;
}
request->session->puser = GetUser(user_id);
request->session->spam_score = 0;
cur->session->puser = GetUser(user_id);
cur->session->spam_score = 0;
if( !request->session->puser )
if( !cur->session->puser )
{
log << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend;
return;
}
request->session->remember_me = remember_me;
cur->session->remember_me = remember_me;
last.UserLogin(user_id, request->session->puser->name, inet_addr(request->env_remote_addr), request->session->id);
last.UserLogin(user_id, cur->session->puser->name, inet_addr(cur->request->env_remote_addr), cur->session->id);
how_many_logged += 1;
log << log2 << "User " << request->session->puser->name << " (id: " << user_id << ") logged" << logend;
log << log2 << "User " << cur->session->puser->name << " (id: " << user_id << ") logged" << logend;
}
@@ -159,19 +159,19 @@ void Users::LoginUser(long user_id, bool remember_me)
void Users::LogoutCurrentUser()
{
if( !request->session || !request->session->puser )
if( !cur->session || !cur->session->puser )
return;
log << log2 << "Users: user " << request->session->puser->name << ", id: "
<< request->session->puser->id << " logged out" << logend;
log << log2 << "Users: user " << cur->session->puser->name << ", id: "
<< cur->session->puser->id << " logged out" << logend;
last.UserLogout(request->session->puser->id, request->session->id);
last.UserLogout(cur->session->puser->id, cur->session->id);
if( how_many_logged > 0 ) // for safety
how_many_logged -= 1;
request->session->puser = 0;
request->session->remember_me = 0;
cur->session->puser = 0;
cur->session->remember_me = 0;
}

View File

@@ -7,14 +7,14 @@
*
*/
#ifndef headerfilecmslucoreusers
#define headerfilecmslucoreusers
#ifndef headerfile_winix_core_users
#define headerfile_winix_core_users
#include <map>
#include "user.h"
#include "ugcontainer.h"
#include "lastcontainer.h"
#include "request.h"
#include "cur.h"
#include "db/db.h"
@@ -23,7 +23,7 @@ class Users
typedef UGContainer<User> Table;
Table table;
Request * request;
Cur * cur;
long how_many_logged;
public:
@@ -35,7 +35,7 @@ public:
Users();
void SetRequest(Request * request);
void SetCur(Cur * pcur);
void Clear();
void ReadUsers(Db * db);

View File

@@ -2,18 +2,18 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoreversion
#define headerfilecmslucoreversion
#ifndef headerfile_winix_core_version
#define headerfile_winix_core_version
#define WINIX_VER_MAJOR 0
#define WINIX_VER_MINOR 4
#define WINIX_VER_REVISION 5
#define WINIX_VER_REVISION 7
#endif

View File

@@ -4,13 +4,10 @@ include Makefile.o.dep
all: $(o)
.SUFFIXES: .cpp .o
.cpp.o:
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $<
depend:
makedepend -Y. -I.. -I../../ezc/src -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep

View File

@@ -3,11 +3,12 @@
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
db.o: ../core/misc.h ../core/item.h ../core/error.h ../core/log.h
db.o: ../core/textstream.h dbitemquery.h ../core/item.h dbitemcolumns.h
db.o: ../core/user.h ../core/group.h ../core/thread.h ../core/dircontainer.h
db.o: ../core/user.h ../core/group.h ../core/dircontainer.h
db.o: ../core/ugcontainer.h ../core/log.h ../core/misc.h
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
dbbase.o: ../core/misc.h ../core/item.h ../core/error.h ../core/log.h
dbbase.o: ../core/textstream.h ../core/log.h ../../ezc/src/utf8.h
dbbase.o: ../core/textstream.h ../core/log.h ../core/misc.h
dbbase.o: ../../ezc/src/utf8.h
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/misc.h
dbconn.o: ../core/item.h ../core/log.h ../core/error.h ../core/log.h
dbconn.o: ../core/textstream.h

104
db/db.cpp
View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -15,18 +15,17 @@
bool Db::CheckUser(const std::wstring & login, const std::wstring & password, long & user_id)
bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
{
PGresult * r = 0;
bool user_ok = false;
user_id = -1;
try
{
query.Clear();
query << R("select id from core.user where login=")
query << R("select id, password, pass_encrypted, pass_type, pass_hash_salted from core.user where login=")
<< login
<< R(" and password=")
<< password
<< R(";");
r = AssertQuery(query);
@@ -39,13 +38,22 @@ bool Db::CheckUser(const std::wstring & login, const std::wstring & password, lo
if( rows > 1 )
{
log << log1 << "Db: there is more than one user: " << login << " (with the same password)" << logend;
log << log1 << "Db: there is more than one user: " << login << logend;
throw Error(WINIX_ERR_DB_MORE_THAN_ONE_LOGIN);
}
int cuser_id = AssertColumn(r, "id");
user_id = AssertValueLong(r, 0, cuser_id);
int cuser_id = AssertColumn(r, "id");
int cpass_type = AssertColumn(r, "pass_type");
int csalted = AssertColumn(r, "pass_hash_salted");
int cpassword = AssertColumn(r, "password");
int cpass_encrypted = AssertColumn(r, "pass_encrypted");
user_ok = true;
user_id = AssertValueLong(r, 0, cuser_id);
up.pass_type = AssertValueInt(r, 0, cpass_type);
up.pass_hash_salted = AssertValueBool(r, 0, csalted);
AssertValueWide(r, 0, cpassword, up.pass);
AssertValueBin(r, 0, cpass_encrypted, up.pass_encrypted);
}
catch(const Error &)
{
@@ -60,7 +68,8 @@ return user_ok;
Error Db::AddUser(User & user, const std::wstring & password)
Error Db::AddUser(User & user, const std::wstring & password, const std::string & password_encrypted,
int pass_type, bool pass_hash_salted)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
@@ -68,12 +77,23 @@ Error Db::AddUser(User & user, const std::wstring & password)
try
{
query.Clear();
query << R("insert into core.user (login, password, super_user, email, notify) values (")
<< user.name
<< password
<< static_cast<int>(user.super_user)
query << R("insert into core.user (login, password, pass_encrypted, super_user, email,"
"notify, pass_type, pass_hash_salted) values (")
<< user.name;
// for safety
if( password_encrypted.empty() )
query << password;
else
query << "";
query.EPutBin(password_encrypted);
query << user.super_user
<< user.email
<< user.notify
<< pass_type
<< pass_hash_salted
<< R(");");
r = AssertQuery(query);
@@ -433,9 +453,8 @@ long Db::GetContentId(long item_id)
if( Rows(r) == 1 && Cols(r) == 1 )
result = AssertValueLong(r, 0, 0);
}
catch(const Error & e)
catch(const Error)
{
result = e;
}
ClearResult(r);
@@ -626,6 +645,14 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
const char * if_and = "";
if( iq.where_id ) { query << R(if_and) << R("item.id=") << iq.id ; if_and = add_and; }
if( iq.id_tab && !iq.id_tab->empty() )
{
CreateIdList(*iq.id_tab, iq_id_list);
query << R(if_and) << R("item.id in ") << R(iq_id_list);
if_and = add_and;
}
if( iq.where_parent_id ){ query << R(if_and) << R("parent_id=") << iq.parent_id ; if_and = add_and; }
if( iq.where_type )
@@ -1196,16 +1223,18 @@ return EndTrans(result);
Error Db::DelItemDelItem(const Item & item)
Error Db::DelItemDelItem(long item_id, int type)
{
PGresult * r = 0;
PGresult * r = 0;
Error result = WINIX_ERR_OK;
try
{
query.Clear();
query << R("delete from core.item where id=")
<< item.id
<< item_id
<< R(" and type=")
<< type
<< R(";");
r = AssertQuery(query);
@@ -1226,20 +1255,20 @@ return result;
Error Db::DelItemDelContent(const Item & item)
Error Db::DelItemDelContent(long content_id)
{
PGresult * r = 0;
Error result = WINIX_ERR_OK;
try
{
result = DecrementContentRef(item.content_id);
result = DecrementContentRef(content_id);
if( result == WINIX_ERR_OK )
{
query.Clear();
query << R("delete from core.content where ref=0 and id=")
<< item.content_id
<< content_id
<< R(";");
r = AssertQuery(query);
@@ -1270,17 +1299,17 @@ Error result = WINIX_ERR_NO_ITEM;
if( item.type == Item::file )
{
BeginTrans();
result = DelItemDelContent(item);
result = DelItemDelContent(item.content_id);
if( result == WINIX_ERR_OK )
result = DelItemDelItem(item);
result = DelItemDelItem(item.id, 1);
result = EndTrans(result);
}
else
if( item.type == Item::symlink )
{
result = DelItemDelItem(item);
result = DelItemDelItem(item.id, 2);
}
else
if( item.type == Item::dir )
@@ -1294,6 +1323,33 @@ return result;
Error Db::DelFileById(long file_id)
{
Error result = WINIX_ERR_NO_ITEM;
BeginTrans();
long content_id = GetContentId(file_id);
if( content_id != -1 )
{
result = DelItemDelContent(content_id);
if( result == WINIX_ERR_OK )
result = DelItemDelItem(file_id, 1);
}
result = EndTrans(result);
return result;
}
Error Db::DelSymlinkById(long symlink_id)
{
return DelItemDelItem(symlink_id, 2);
}
void Db::GetDirs(DirContainer & dir_tab)

15
db/db.h
View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -23,7 +23,6 @@
#include "core/item.h"
#include "core/user.h"
#include "core/group.h"
#include "core/thread.h"
#include "core/dircontainer.h"
#include "core/ugcontainer.h"
@@ -42,8 +41,8 @@ public:
bool CheckUser(const std::wstring & login, const std::wstring & password, long & user_id);
Error AddUser(User & user, const std::wstring & password);
bool GetUserPass(const std::wstring & login, long & user_id, UserPass & up);
Error AddUser(User & user, const std::wstring & password, const std::string & password_encrypted, int pass_type, bool pass_hash_salted);
Error AddItem(Item & item);
Error EditItemById(Item & item, bool with_url = true);
@@ -61,7 +60,10 @@ public:
Error EditParentUrlById(Item & item, long id);
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
Error EditHasThumbById(bool has_thumb, long id);
Error DelDirById(long id);
Error DelFileById(long file_id);
Error DelSymlinkById(long symlink_id);
Error EditSubjectById(Item & item, long id);
@@ -93,6 +95,7 @@ protected:
DbTextStream query, query_create_url;
std::wstring temp_url;
Item dir_temp;
std::wstring iq_id_list;
bool AddItemCreateUrlSubject(Item & item);
@@ -106,8 +109,8 @@ protected:
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
Error DelItemDelItem(const Item & item);
Error DelItemDelContent(const Item & item);
Error DelItemDelItem(long item_id, int type);
Error DelItemDelContent(long content_id);
Error IncrementContentRef(long content_id);
Error DecrementContentRef(long content_id);

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -13,9 +13,11 @@
#include "dbbase.h"
#include "core/log.h"
#include "core/error.h"
#include "core/misc.h"
#include "utf8.h"
DbBase::DbBase()
{
db_conn = 0;
@@ -149,6 +151,21 @@ return temp_wide_value;
}
void DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
{
result.clear();
const char * res = AssertValue(r, row, col);
int len = PQgetlength(r, row, col);
if( len <= 0 )
return;
UnescapeBin(res, len, result);
}
void DbBase::AssertValueWide(PGresult * r, int row, int col, std::wstring & result)
{
const char * res = AssertValue(r, row, col);
@@ -170,7 +187,8 @@ int DbBase::AssertValueInt(PGresult * r, int row, int col)
bool DbBase::AssertValueBool(PGresult * r, int row, int col)
{
return strtol( AssertValue(r, row, col), 0, 10 ) != 0;
const char * s = AssertValue(r, row, col);
return (s[0]=='t' || s[0]=='y' || s[0]=='1');
}
@@ -283,7 +301,7 @@ tm t;
if( len != 19 )
{
// the format must be like this: 2008-12-31 22:30:00
log << log1 << "DbBase: ConvertTime: unknown time format: \"" << str << "\"";
log << log1 << "DbBase: ConvertTime: unknown time format: \"" << str << "\"" << logend;
return t;
}
@@ -333,7 +351,7 @@ size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
for(size_t i=0 ; i<id_tab.size() ; ++i)
{
swprintf(buffer, buffer_len, L"%lu", (unsigned long)id_tab[i]);
Toa((unsigned long)id_tab[i], buffer, buffer_len);
list += buffer;
if( i+1 < id_tab.size() )
@@ -420,10 +438,92 @@ Error DbBase::EndTrans(Error err)
}
else
{
// we returned the old err code
// we return the old err code
RollbackTrans();
}
return err;
}
/*
converting from a bytea
*/
int DbBase::CharToInt(char c)
{
return (int)(unsigned char)(c-'0');
}
bool DbBase::IsCorrectOctalDigit(char c)
{
return c>='0' && c<='7';
}
// moves 'i' at least once
// return -1 if there is en error
int DbBase::UnescapeBin(const char * str, size_t & i, size_t len)
{
if( str[i] != '\\' )
return str[i++];
i += 1;
if( i >= len )
return -1;
if( str[i] == '\\' )
return str[i++];
if( i+2 >= len )
{
i = len;
return -1;
}
if( !IsCorrectOctalDigit(str[i]) ||
!IsCorrectOctalDigit(str[i+1]) ||
!IsCorrectOctalDigit(str[i+2]) )
{
i += 3;
return -1;
}
int c = 8*8*CharToInt(str[i]) + 8*CharToInt(str[i+1]) + CharToInt(str[i+2]);
i += 3;
if( c<0 || c>255 )
return -1;
return c;
}
void DbBase::UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out)
{
int c;
size_t i = 0;
if( clear_out )
out.clear();
while( i < len )
{
c = UnescapeBin(str, i, len);
if( c != -1 )
out += c;
}
}
/*
end of converting from bytea
*/

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -39,6 +39,7 @@ public:
static const char * AssertValue(PGresult * r, int row, int col);
static const std::wstring & AssertValueWide(PGresult * r, int row, int col); // warning: this method uses a static buffer
static void AssertValueWide(PGresult * r, int row, int col, std::wstring & result);
static void AssertValueBin(PGresult * r, int row, int col, std::string & result);
static long AssertValueLong(PGresult * r, int row, int col);
static int AssertValueInt(PGresult * r, int row, int col);
static bool AssertValueBool(PGresult * r, int row, int col);
@@ -65,6 +66,9 @@ public:
Error CommitTrans();
Error EndTrans(Error err);
static void UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out = true);
protected:
// a helper method for escaping strings
@@ -77,10 +81,14 @@ protected:
DbConn * db_conn;
bool log_queries;
private:
DbTextStream bquery;
static int CharToInt(char c);
static bool IsCorrectOctalDigit(char c);
static int UnescapeBin(const char * str, size_t & i, size_t len);
DbTextStream bquery;
};

View File

@@ -14,12 +14,19 @@
DbItemQuery::DbItemQuery()
{
Clear();
}
void DbItemQuery::Clear()
{
sort_asc = true;
SetAll(true, false);
id = -1;
id_tab = 0;
parent_id = -1;
type = Item::none;
file_type = WINIX_ITEM_FILETYPE_NONE;
@@ -29,6 +36,7 @@ DbItemQuery::DbItemQuery()
limit = 0; // limit and offset not used by default
offset = 0;
}
@@ -77,6 +85,11 @@ void DbItemQuery::WhereId(long id_)
}
void DbItemQuery::WhereIdIn(const std::vector<long> & id_tab_list)
{
id_tab = &id_tab_list;
}
void DbItemQuery::WhereParentId(long parent_id_)
{

View File

@@ -11,11 +11,11 @@
#define headerfile_winix_db_dbitemquery
#include <vector>
#include "core/item.h"
struct DbItemQuery
{
// id and content_id is selected always
@@ -33,7 +33,7 @@ struct DbItemQuery
bool sel_file; // file_path, file_fs, file_type, has_thumb
bool sel_html_template; // template
bool where_id; //
bool where_id; //
bool where_parent_id; //
bool where_type;
bool where_file_type;
@@ -46,16 +46,20 @@ struct DbItemQuery
bool file_type_equal; // if true means file_type should be equal
bool sort_asc;
const std::vector<long> * id_tab; // != 0 if WhereIdIn was used
long limit;
long offset;
DbItemQuery();
void Clear();
void SetAllSel(bool sel);
void SetAllWhere(bool where_);
void SetAll(bool sel, bool where_);
void WhereId(long id_);
void WhereIdIn(const std::vector<long> & id_tab_list);
void WhereParentId(long parent_id_);
void WhereType(Item::Type type_, bool equal = true);
void WhereFileType(int file_t, bool equal = true);

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -111,6 +111,17 @@ DbTextStream & DbTextStream::operator<<(RawText<std::wstring> raw)
}
DbTextStream & DbTextStream::operator<<(RawText<bool> raw)
{
if( raw.par )
PutText("true");
else
PutText("false");
return *this;
}
DbTextStream & DbTextStream::operator<<(RawText<char> raw)
{
TextStream<std::string>::operator<<(raw.par);
@@ -201,14 +212,13 @@ return *this;
*/
// !! sprawdzic jej dzialanie dla kolumn bytea (binarnych)
DbTextStream & DbTextStream::EBinPutChar(char c_)
{
char buf[10];
char buf[20];
int c = (unsigned char)c_;
if( (c>=0 && c<=31) || c>=127 || c==39 || c==92 )
if( (c>=0 && c<=31) || c>=127 || c=='\'' || c=='\\' )
{
sprintf(buf, "\\\\%03o", c);
buffer += buf;
@@ -391,6 +401,16 @@ DbTextStream & DbTextStream::operator<<(const std::wstring & str)
DbTextStream & DbTextStream::operator<<(bool v)
{
if( v )
EPutText("true");
else
EPutText("false");
return *this;
}
DbTextStream & DbTextStream::operator<<(char v)
{

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -104,6 +104,7 @@ public:
DbTextStream & operator<<(RawText<const std::wstring*> raw);
DbTextStream & operator<<(RawText<std::string> raw);
DbTextStream & operator<<(RawText<std::wstring> raw);
DbTextStream & operator<<(RawText<bool> raw);
DbTextStream & operator<<(RawText<char> raw);
DbTextStream & operator<<(RawText<wchar_t> raw);
DbTextStream & operator<<(RawText<int> raw);
@@ -140,6 +141,7 @@ public:
DbTextStream & operator<<(const wchar_t * str);
DbTextStream & operator<<(const std::wstring * str);
DbTextStream & operator<<(const std::wstring & str);
DbTextStream & operator<<(bool);
DbTextStream & operator<<(char);
DbTextStream & operator<<(wchar_t);
DbTextStream & operator<<(int);

View File

@@ -4,13 +4,10 @@ include Makefile.o.dep
all: $(o)
.SUFFIXES: .cpp .o
.cpp.o:
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $<
depend:
makedepend -Y. -I.. -I../../ezc/src -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o createthread.o default.o download.o emacs.o functionbase.o functionparser.o functions.o funthread.o last.o ln.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o reload.o rm.o run.o specialdefault.o stat.o subject.o template.o tinymce.o uname.o upload.o uptime.o vim.o who.o
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o functionbase.o functionparser.o functions.o last.o ln.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o reload.o rm.o run.o specialdefault.o stat.o subject.o template.o tinymce.o uname.o upload.o uptime.o vim.o who.o

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -25,25 +25,25 @@ bool AddUser::CheckAddUserVars(const std::wstring & login, const std::wstring &
{
if( login.empty() )
{
request->status = WINIX_ERR_LOGIN_EMPTY;
cur->request->status = WINIX_ERR_LOGIN_EMPTY;
return false;
}
if( pass != conf_pass )
{
request->status = WINIX_ERR_PASSWORDS_DIFFERENT;
cur->request->status = WINIX_ERR_PASSWORDS_DIFFERENT;
return false;
}
if( pass.size() < config->password_min_size )
if( pass.size() < config->pass_min_size )
{
request->status = WINIX_ERR_PASSWORD_TOO_SHORT;
cur->request->status = WINIX_ERR_PASSWORD_TOO_SHORT;
return false;
}
if( system->users.IsUser(login) )
{
request->status = WINIX_ERR_USER_EXISTS;
cur->request->status = WINIX_ERR_USER_EXISTS;
return false;
}
@@ -59,23 +59,26 @@ void AddUser::MakePost()
{
User user;
const std::wstring & login = request->PostVar(L"login");
const std::wstring & pass = request->PostVar(L"password");
const std::wstring & conf_pass = request->PostVar(L"confirmpassword");
const std::wstring & login = cur->request->PostVar(L"login");
const std::wstring & pass = cur->request->PostVar(L"password");
const std::wstring & conf_pass = cur->request->PostVar(L"passwordconfirm");
if( !CheckAddUserVars(login, pass, conf_pass) )
return;
user.name = login;
user.email = request->PostVar(L"email");
user.email = cur->request->PostVar(L"email");
request->status = db->AddUser(user, pass);
up.pass = pass;
system->crypt.PassHashCrypt(up);
if( request->status == WINIX_ERR_OK )
cur->request->status = db->AddUser(user, up.pass, up.pass_encrypted, up.pass_type, up.pass_hash_salted);
if( cur->request->status == WINIX_ERR_OK )
{
if( system->users.AddUser(user) )
{
if( !request->session->puser )
if( !cur->session->puser )
system->users.LoginUser(user.id, false);
log << log2 << "Adduser: added a new user: " << user.name << logend;
@@ -91,6 +94,36 @@ User user;
}
void AddUser::MakeGet()
{
Run s;
std::string out;
/*
s.Env("PATH=/home/tomek/mybin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin");
s.Env("PWD=/home/tomek");
s.Env("SHELL=/bin/tcsh");
s.Env("USER=tomek");
s.Env("GROUP=wheel");
s.Env("HOME=/home/tomek");
*/
s.Par("dgst");
s.Par("-sha512");
s.Cmd("/usr/bin/openssl");
if( s.Go("swinka", out) == 0 )
log << log1 << "odpowiedz: " << out << logend;
if( s.Go("cosik", out) == 0 )
log << log1 << "odpowiedz: " << out << logend;
if( s.Go("ktosik", out) == 0 )
log << log1 << "odpowiedz: " << out << logend;
if( s.Go("", out) == 0 )
log << log1 << "odpowiedz: " << out << logend;
}
} // namespace

View File

@@ -2,16 +2,16 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucontentadduser
#define headerfilecmslucontentadduser
#ifndef headerfile_winix_functions_adduser
#define headerfile_winix_functions_adduser
#include "functionbase.h"
#include "core/user.h"
namespace Fun
@@ -24,11 +24,12 @@ public:
AddUser();
void MakePost();
void MakeGet();
private:
bool CheckAddUserVars(const std::wstring & login, const std::wstring & pass, const std::wstring & conf_pass);
UserPass up;
};

View File

@@ -22,21 +22,21 @@ Cat::Cat()
void Cat::MakeGet()
{
if( !request->is_item )
if( !cur->request->is_item )
{
log << log1 << "Content: cat function requires an item" << logend;
request->status = WINIX_ERR_NO_ITEM;
cur->request->status = WINIX_ERR_NO_ITEM;
return;
}
if( !system->HasReadAccess(request->item) )
if( !system->HasReadAccess(cur->request->item) )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return;
}
request->send_as_attachment = request->IsParam(L"attachment");
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
}

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucontentfuncatcat
#define headerfilecmslucontentfuncatcat
#ifndef headerfile_winix_functions_cat
#define headerfile_winix_functions_cat
#include "functionbase.h"

View File

@@ -23,7 +23,7 @@ Chmod::Chmod()
void Chmod::MakePost()
{
priv_changer.SetRequest(request);
priv_changer.SetCur(cur);
priv_changer.SetSystem(system);
priv_changer.SetDb(db);
@@ -33,7 +33,7 @@ void Chmod::MakePost()
void Chmod::MakeGet()
{
priv_changer.SetRequest(request);
priv_changer.SetCur(cur);
priv_changer.SetSystem(system);
priv_changer.SetDb(db);

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucontentchmod
#define headerfilecmslucontentchmod
#ifndef headerfile_winix_functions_chmod
#define headerfile_winix_functions_chmod
#include "functionbase.h"
#include "privchanger.h"

View File

@@ -23,7 +23,7 @@ Chown::Chown()
void Chown::MakePost()
{
priv_changer.SetRequest(request);
priv_changer.SetCur(cur);
priv_changer.SetSystem(system);
priv_changer.SetDb(db);
@@ -33,7 +33,7 @@ void Chown::MakePost()
void Chown::MakeGet()
{
priv_changer.SetRequest(request);
priv_changer.SetCur(cur);
priv_changer.SetSystem(system);
priv_changer.SetDb(db);

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucontentchown
#define headerfilecmslucontentchown
#ifndef headerfile_winix_functions_chown
#define headerfile_winix_functions_chown
#include "functionbase.h"
#include "privchanger.h"

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucontentckeditor
#define headerfilecmslucontentckeditor
#ifndef headerfile_winix_functions_ckeditor
#define headerfile_winix_functions_ckeditor
#include "functionbase.h"

View File

@@ -29,19 +29,19 @@ bool Cp::HasAccess()
bool Cp::CheckAccessFrom()
{
if( request->is_item )
if( cur->request->is_item )
{
if( !system->HasReadAccess(request->item) || request->item.type == Item::symlink )
if( !system->HasReadAccess(cur->request->item) || cur->request->item.type == Item::symlink )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
else
if( !request->IsParam(L"r") )
if( !cur->request->IsParam(L"r") )
{
// directories need 'r' parameter
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
}
return true;
@@ -54,7 +54,7 @@ bool Cp::CheckAccessTo()
!system->HasReadExecAccessToPath(dir_tab) ||
!system->HasWriteAccess(*dir_tab.back()) )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@@ -65,14 +65,14 @@ return true;
bool Cp::ParseDir()
{
const std::wstring & new_dir = request->PostVar(L"to");
int res = system->dirs.FollowLink(request->dir_tab, new_dir, dir_tab, file);
const std::wstring & new_dir = cur->request->PostVar(L"to");
int res = system->dirs.FollowLink(cur->request->dir_tab, new_dir, dir_tab, file);
if( res == 3 )
request->status = WINIX_ERR_NO_ROOT_DIR;
cur->request->status = WINIX_ERR_NO_ROOT_DIR;
else
if( res != 0 && res != 1 )
request->status = WINIX_ERR_INCORRECT_DIR;
cur->request->status = WINIX_ERR_INCORRECT_DIR;
return res == 0 || res == 1;
}
@@ -94,7 +94,7 @@ bool Cp::CopyStaticFile(const std::wstring & from, const std::wstring & to)
else
{
log << log1 << "Cp: can't copy a file from: " << from << ", to: " << to << logend;
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
@@ -113,13 +113,13 @@ bool res1, res2, res3, res4, res5;
if( !res1 || !res2 || !res3 || !res4 || !res5 )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return;
}
if( CopyStaticFile(old_path, new_path) )
{
request->status = db->EditFileById(item, item.id);
cur->request->status = db->EditFileById(item, item.id);
if( item.has_thumb )
CopyStaticFile(old_path_thumb, new_path_thumb);
@@ -142,9 +142,9 @@ void Cp::CopyFile(Item & item, long dst_dir_id)
SetNewAttributes(item);
item.parent_id = dst_dir_id;
request->status = db->AddItem(item);
cur->request->status = db->AddItem(item);
if( request->status == WINIX_ERR_OK )
if( cur->request->status == WINIX_ERR_OK )
{
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
CopyStaticFile(item);
@@ -187,8 +187,8 @@ void Cp::Prepare()
new_user = -1;
new_group = dir_tab.back()->group_id;
if( request->session->puser )
new_user = request->session->puser->id;
if( cur->session->puser )
new_user = cur->session->puser->id;
loop_checker.clear();
}
@@ -261,7 +261,7 @@ long Cp::CopyDirTree(const Item & dir, long dst_dir_id)
temp.link_redirect = 0;
}
request->status = system->dirs.AddDirectory(temp);
cur->request->status = system->dirs.AddDirectory(temp);
loop_checker.push_back(temp.id);
// remember the new dir_id because temp can be changed
@@ -311,7 +311,7 @@ void Cp::PostCopyFile(Item & item, bool redirect)
CopyFileOrSymlink(item, dir_tab.back()->id);
if( request->status == WINIX_ERR_OK && redirect )
if( cur->request->status == WINIX_ERR_OK && redirect )
system->RedirectTo(item);
}
@@ -323,7 +323,7 @@ void Cp::PostCopyDirContent(const Item & dir, bool redirect)
{
if( !file.empty() )
{
request->status = WINIX_ERR_INCORRECT_DIR;
cur->request->status = WINIX_ERR_INCORRECT_DIR;
return;
}
@@ -332,7 +332,7 @@ void Cp::PostCopyDirContent(const Item & dir, bool redirect)
CopyDirContentTree(dir, dir_tab.back()->id);
if( request->status == WINIX_ERR_OK && redirect )
if( cur->request->status == WINIX_ERR_OK && redirect )
system->RedirectTo(dir_tab.back()->id);
}
@@ -347,7 +347,7 @@ void Cp::PostCopyDir(const Item & dir, bool redirect)
long new_dir_id = CopyDirTree(dir, dir_id);
if( new_dir_id != -1 && request->status == WINIX_ERR_OK && redirect )
if( new_dir_id != -1 && cur->request->status == WINIX_ERR_OK && redirect )
system->RedirectTo(new_dir_id);
}
@@ -367,20 +367,20 @@ void Cp::MakePost()
{
Prepare();
preserve_attr = request->IsPostVar(L"preserveattr");
remove_defaults = request->IsPostVar(L"removedefaults");
follow_symlinks = request->IsPostVar(L"followsymlinks");
preserve_attr = cur->request->IsPostVar(L"preserveattr");
remove_defaults = cur->request->IsPostVar(L"removedefaults");
follow_symlinks = cur->request->IsPostVar(L"followsymlinks");
if( request->is_item )
if( cur->request->is_item )
{
PostCopyFile(request->item);
PostCopyFile(cur->request->item);
}
else
{
if( request->IsPostVar(L"onlycontent") )
PostCopyDirContent(*request->dir_tab.back());
if( cur->request->IsPostVar(L"onlycontent") )
PostCopyDirContent(*cur->request->dir_tab.back());
else
PostCopyDir(*request->dir_tab.back());
PostCopyDir(*cur->request->dir_tab.back());
}
Clear();

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucontentcp
#define headerfilecmslucontentcp
#ifndef headerfile_winix_functions_cp
#define headerfile_winix_functions_cp
#include "functionbase.h"

View File

@@ -1,154 +0,0 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
#include "createthread.h"
#include "functions.h"
namespace Thread
{
CreateThread::CreateThread()
{
fun.url = L"createthread";
}
// returning true if we can create a thread in the current directory
bool CreateThread::HasAccess(bool check_root)
{
if( request->dir_tab.empty() )
return false;
if( request->is_item )
return false;
if( !system->HasWriteAccess(*request->dir_tab.back()) )
return false;
if( !system->mounts.pmount || system->mounts.pmount->type != system->mounts.MountTypeThread() )
return false;
if( !check_root && request->session && request->session->puser && request->session->puser->super_user )
// super can create thread regardless of the restrictcreatethread option
return true;
if( !system->mounts.pmount->IsPar(system->mounts.MountParCreatethreadOn()) )
return true;
if( system->mounts.pmount->IsArg(system->mounts.MountParCreatethreadOn(), request->dir_tab.size()) )
return true;
return false;
}
bool CreateThread::HasAccess()
{
return HasAccess(false);
}
bool CreateThread::FunCreateThreadCheckAbuse()
{
if( !system->rebus.CheckRebus() )
{
request->status = WINIX_ERR_INCORRECT_REBUS;
return false;
}
functions->CheckGetPostTimes();
if( request->session->spam_score > 0 )
{
request->status = WINIX_ERR_SPAM;
log << log1 << "Content: ignoring due to suspected spamming" << logend;
return false;
}
return true;
}
void CreateThread::ReadThread()
{
thread.parent_id = request->dir_tab.back()->id;
}
void CreateThread::AddThread()
{
thread.dir_id = request->dir_tab.back()->id;
thread.closed = false;
thread.items = 1;
thread.last_item = request->item; // set by PostFunEmacsAdd()
request->status = db->AddThread(thread);
}
void CreateThread::PostFunCreateThreadLogAndRedirect()
{
if( request->status == WINIX_ERR_OK )
{
log << log2 << "Content: added a new thread" << logend;
system->RedirectToLastDir();
}
else
{
log << log1 << "Content: problem with adding a new thread, error code: "
<< request->status << logend;
}
}
void CreateThread::MakePost()
{
functions->ReadItem(request->item, Item::dir);
functions->SetUser(request->item);
ReadThread();
request->item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
if( !FunCreateThreadCheckAbuse() )
{
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
return;
}
request->status = system->dirs.AddDirectory(request->item, true, 0, WINIX_NOTIFY_CODE_THREAD_ADD);
if( request->status == WINIX_ERR_OK )
{
functions->ReadItemContentWithType(request->item);
request->item.type = Item::file;
request->item.privileges = 0644; // !! tymczasowo
request->item.parent_id = request->dir_tab.back()->id;
request->status = system->AddFile(request->item);
if( request->status == WINIX_ERR_OK )
AddThread();
}
PostFunCreateThreadLogAndRedirect();
}
} // namespace

View File

@@ -22,24 +22,24 @@ Default::Default()
bool Default::HasAccess()
{
return !request->is_item && system->HasWriteAccess(*request->dir_tab.back());
return !cur->request->is_item && system->HasWriteAccess(*cur->request->dir_tab.back());
}
void Default::MakePost()
{
Item & dir = *request->dir_tab.back();
Item & dir = *cur->request->dir_tab.back();
dir.link_to = request->PostVar(L"linkto");
dir.link_redirect = request->IsPostVar(L"makeredirect") ? 1 : 0;
dir.link_to = cur->request->PostVar(L"linkto");
dir.link_redirect = cur->request->IsPostVar(L"makeredirect") ? 1 : 0;
TrimWhite(dir.link_to);
// !! dodac sprawdzenie czy link_to jest pusty teraz
request->status = db->EditLinkItem(dir.id, dir.link_to, dir.link_redirect);
cur->request->status = db->EditLinkItem(dir.id, dir.link_to, dir.link_redirect);
if( request->status == WINIX_ERR_OK )
if( cur->request->status == WINIX_ERR_OK )
{
log << log2 << "Default: changed link_to: " << dir.link_to << ", for dir_id: " << dir.id << logend;
system->RedirectToLastDir();

View File

@@ -7,8 +7,8 @@
*
*/
#ifndef headerfilecmslucontentdefault
#define headerfilecmslucontentdefault
#ifndef headerfile_winix_functions_default
#define headerfile_winix_functions_default
#include "functionbase.h"

Some files were not shown because too many files have changed in this diff Show More