diff --git a/Makefile b/Makefile index b393933..05ab6f4 100755 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ 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 +CXXFLAGS = -fPIC -Wall -pedantic -O0 -g -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER endif @@ -18,13 +19,12 @@ all: winix winix: FORCE @cd core ; $(MAKE) -e - @cd content ; $(MAKE) -e - @cd confparser ; $(MAKE) -e + @cd functions ; $(MAKE) -e @cd templates ; $(MAKE) -e @cd templatesnotify ; $(MAKE) -e @cd plugins/stats ; $(MAKE) -e @cd ../ezc/src ; $(MAKE) -e - $(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o content/*.o templates/*.o templatesnotify/*.o confparser/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread + $(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o functions/*.o templates/*.o templatesnotify/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread @cd main ; $(MAKE) -e # use the full path with winix.so $(CXX) -o winix $(CXXFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so @@ -32,8 +32,7 @@ winix: FORCE clean: @cd core ; $(MAKE) -e clean - @cd content ; $(MAKE) -e clean - @cd confparser ; $(MAKE) -e clean + @cd functions ; $(MAKE) -e clean @cd templates ; $(MAKE) -e clean @cd templatesnotify ; $(MAKE) -e clean @cd plugins/stats ; $(MAKE) -e clean @@ -48,11 +47,10 @@ FORCE: depend: @cd core ; $(MAKE) -e depend - @cd content ; $(MAKE) -e depend - @cd confparser ; $(MAKE) -e depend + @cd functions ; $(MAKE) -e depend @cd templates ; $(MAKE) -e depend @cd templatesnotify ; $(MAKE) -e depend - @cd plugins/stats ; $(MAKE) -e depend + @cd plugins/stats ; $(MAKE) -e depend @cd ../ezc/src ; $(MAKE) -e depend @cd main ; $(MAKE) -e depend diff --git a/confparser/Makefile.dep b/confparser/Makefile.dep index b0b3c30..3755e78 100755 --- a/confparser/Makefile.dep +++ b/confparser/Makefile.dep @@ -1,3 +1 @@ # DO NOT DELETE - -confparser.o: confparser.h diff --git a/confparser/Makefile.o.dep b/confparser/Makefile.o.dep index b91d287..b6628d8 100755 --- a/confparser/Makefile.o.dep +++ b/confparser/Makefile.o.dep @@ -1 +1 @@ -o = confparser.o +o = \ No newline at end of file diff --git a/content/Makefile.dep b/content/Makefile.dep deleted file mode 100755 index 27c45be..0000000 --- a/content/Makefile.dep +++ /dev/null @@ -1,455 +0,0 @@ -# DO NOT DELETE - -adduser.o: content.h ../core/item.h ../templates/templates.h -adduser.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -adduser.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -adduser.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -adduser.o: ../core/httpsimpleparser.h ../core/log.h -adduser.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -adduser.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -adduser.o: ../core/thread.h ../core/error.h ../core/log.h -adduser.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -adduser.o: ../core/request.h ../core/requesttypes.h ../core/session.h -adduser.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -adduser.o: ../core/compress.h ../core/acceptencodingparser.h -adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -adduser.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -adduser.o: ../core/users.h ../core/groups.h ../core/functions.h -adduser.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -adduser.o: ../core/loadavg.h -cat.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -cat.o: ../templates/patterncacher.h ../templates/misc.h -cat.o: ../templates/localefilter.h ../core/locale.h -cat.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -cat.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -cat.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -cat.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -cat.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -cat.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h -cat.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -cat.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h -cat.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -cat.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -cat.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -cat.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -cat.o: ../core/loadavg.h -content.o: content.h ../core/item.h ../templates/templates.h -content.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -content.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -content.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -content.o: ../core/httpsimpleparser.h ../core/log.h -content.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -content.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -content.o: ../core/thread.h ../core/error.h ../core/log.h -content.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -content.o: ../core/request.h ../core/requesttypes.h ../core/session.h -content.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -content.o: ../core/compress.h ../core/acceptencodingparser.h -content.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -content.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -content.o: ../core/dirs.h ../core/users.h ../core/groups.h -content.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -content.o: ../core/mount.h ../core/loadavg.h ../core/misc.h ../core/plugin.h -content.o: ../core/request.h ../core/data.h ../core/pluginmsg.h -cp.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -cp.o: ../templates/patterncacher.h ../templates/misc.h -cp.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h -cp.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -cp.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -cp.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -cp.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h -cp.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -cp.o: ../core/request.h ../core/requesttypes.h ../core/session.h -cp.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -cp.o: ../core/compress.h ../core/acceptencodingparser.h -cp.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -cp.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h ../core/users.h -cp.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h -cp.o: ../core/mounts.h ../core/mount.h ../core/loadavg.h ../core/misc.h -createthread.o: content.h ../core/item.h ../templates/templates.h -createthread.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -createthread.o: ../templates/misc.h ../templates/localefilter.h -createthread.o: ../core/locale.h ../confparser/confparser.h -createthread.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -createthread.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -createthread.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -createthread.o: ../core/group.h ../core/thread.h ../core/error.h -createthread.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -createthread.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h -createthread.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -createthread.o: ../core/function.h ../core/compress.h -createthread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -createthread.o: ../core/htmlfilter.h ../core/postmultiparser.h -createthread.o: ../core/error.h ../core/mount.h ../core/data.h ../core/dirs.h -createthread.o: ../core/users.h ../core/groups.h ../core/functions.h -createthread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -createthread.o: ../core/loadavg.h -createticket.o: content.h ../core/item.h ../templates/templates.h -createticket.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -createticket.o: ../templates/misc.h ../templates/localefilter.h -createticket.o: ../core/locale.h ../confparser/confparser.h -createticket.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -createticket.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -createticket.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -createticket.o: ../core/group.h ../core/thread.h ../core/error.h -createticket.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -createticket.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h -createticket.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -createticket.o: ../core/function.h ../core/compress.h -createticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -createticket.o: ../core/htmlfilter.h ../core/postmultiparser.h -createticket.o: ../core/error.h ../core/mount.h ../core/data.h ../core/dirs.h -createticket.o: ../core/users.h ../core/groups.h ../core/functions.h -createticket.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -createticket.o: ../core/loadavg.h -default.o: content.h ../core/item.h ../templates/templates.h -default.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -default.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -default.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -default.o: ../core/httpsimpleparser.h ../core/log.h -default.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -default.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -default.o: ../core/thread.h ../core/error.h ../core/log.h -default.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -default.o: ../core/request.h ../core/requesttypes.h ../core/session.h -default.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -default.o: ../core/compress.h ../core/acceptencodingparser.h -default.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -default.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -default.o: ../core/dirs.h ../core/users.h ../core/groups.h -default.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -default.o: ../core/mount.h ../core/loadavg.h -download.o: content.h ../core/item.h ../templates/templates.h -download.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -download.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -download.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -download.o: ../core/httpsimpleparser.h ../core/log.h -download.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -download.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -download.o: ../core/thread.h ../core/error.h ../core/log.h -download.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -download.o: ../core/request.h ../core/requesttypes.h ../core/session.h -download.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -download.o: ../core/compress.h ../core/acceptencodingparser.h -download.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -download.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -download.o: ../core/users.h ../core/groups.h ../core/functions.h -download.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -download.o: ../core/loadavg.h -editticket.o: content.h ../core/item.h ../templates/templates.h -editticket.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -editticket.o: ../templates/misc.h ../templates/localefilter.h -editticket.o: ../core/locale.h ../confparser/confparser.h -editticket.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -editticket.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -editticket.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -editticket.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h -editticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -editticket.o: ../core/request.h ../core/requesttypes.h ../core/session.h -editticket.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -editticket.o: ../core/compress.h ../core/acceptencodingparser.h -editticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -editticket.o: ../core/postmultiparser.h ../core/error.h ../core/mount.h -editticket.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h -editticket.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -editticket.o: ../core/mount.h ../core/loadavg.h -emacs.o: content.h ../core/item.h ../templates/templates.h -emacs.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h -emacs.o: ../templates/localefilter.h ../core/locale.h -emacs.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -emacs.o: ../core/httpsimpleparser.h ../core/log.h -emacs.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -emacs.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -emacs.o: ../core/thread.h ../core/error.h ../core/log.h -emacs.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -emacs.o: ../core/request.h ../core/requesttypes.h ../core/session.h -emacs.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -emacs.o: ../core/compress.h ../core/acceptencodingparser.h -emacs.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -emacs.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -emacs.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -emacs.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -emacs.o: ../core/loadavg.h ../core/notify.h -emacs.o: ../templatesnotify/templatesnotify.h ../core/mount.h -emacs.o: ../templates/misc.h ../core/misc.h -last.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -last.o: ../templates/patterncacher.h ../templates/misc.h -last.o: ../templates/localefilter.h ../core/locale.h -last.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -last.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -last.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -last.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -last.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -last.o: ../core/ticket.h -login.o: content.h ../core/item.h ../templates/templates.h -login.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h -login.o: ../templates/localefilter.h ../core/locale.h -login.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -login.o: ../core/httpsimpleparser.h ../core/log.h -login.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -login.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -login.o: ../core/thread.h ../core/error.h ../core/log.h -login.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -login.o: ../core/request.h ../core/requesttypes.h ../core/session.h -login.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -login.o: ../core/compress.h ../core/acceptencodingparser.h -login.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -login.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -login.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -login.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -login.o: ../core/loadavg.h -logout.o: content.h ../core/item.h ../templates/templates.h -logout.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -logout.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -logout.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -logout.o: ../core/httpsimpleparser.h ../core/log.h -logout.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -logout.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -logout.o: ../core/thread.h ../core/error.h ../core/log.h -logout.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -logout.o: ../core/request.h ../core/requesttypes.h ../core/session.h -logout.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -logout.o: ../core/compress.h ../core/acceptencodingparser.h -logout.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -logout.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -logout.o: ../core/users.h ../core/groups.h ../core/functions.h -logout.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -logout.o: ../core/loadavg.h -ls.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -ls.o: ../templates/patterncacher.h ../templates/misc.h -ls.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h -ls.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -ls.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -ls.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -ls.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h -ls.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -ls.o: ../core/request.h ../core/requesttypes.h ../core/session.h -ls.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -ls.o: ../core/compress.h ../core/acceptencodingparser.h -ls.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -ls.o: ../core/postmultiparser.h -misc_item.o: content.h ../core/item.h ../templates/templates.h -misc_item.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -misc_item.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -misc_item.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -misc_item.o: ../core/httpsimpleparser.h ../core/log.h -misc_item.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -misc_item.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -misc_item.o: ../core/thread.h ../core/error.h ../core/log.h -misc_item.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -misc_item.o: ../core/request.h ../core/requesttypes.h ../core/session.h -misc_item.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -misc_item.o: ../core/compress.h ../core/acceptencodingparser.h -misc_item.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -misc_item.o: ../core/postmultiparser.h ../core/misc.h -misc_specialfile.o: content.h ../core/item.h ../templates/templates.h -misc_specialfile.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -misc_specialfile.o: ../templates/misc.h ../templates/localefilter.h -misc_specialfile.o: ../core/locale.h ../confparser/confparser.h -misc_specialfile.o: ../templates/ckeditorgetparser.h -misc_specialfile.o: ../core/httpsimpleparser.h ../core/log.h -misc_specialfile.o: ../templates/indexpatterns.h ../core/thread.h -misc_specialfile.o: ../core/ticket.h ../core/db.h ../core/item.h -misc_specialfile.o: ../core/user.h ../core/group.h ../core/thread.h -misc_specialfile.o: ../core/error.h ../core/log.h ../core/dircontainer.h -misc_specialfile.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h -misc_specialfile.o: ../core/requesttypes.h ../core/session.h ../core/rebus.h -misc_specialfile.o: ../core/plugindata.h ../core/function.h -misc_specialfile.o: ../core/compress.h ../core/acceptencodingparser.h -misc_specialfile.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -misc_specialfile.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -misc_specialfile.o: ../core/users.h ../core/groups.h ../core/functions.h -misc_specialfile.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -misc_specialfile.o: ../core/loadavg.h -mkdir.o: content.h ../core/item.h ../templates/templates.h -mkdir.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h -mkdir.o: ../templates/localefilter.h ../core/locale.h -mkdir.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -mkdir.o: ../core/httpsimpleparser.h ../core/log.h -mkdir.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -mkdir.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -mkdir.o: ../core/thread.h ../core/error.h ../core/log.h -mkdir.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -mkdir.o: ../core/request.h ../core/requesttypes.h ../core/session.h -mkdir.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -mkdir.o: ../core/compress.h ../core/acceptencodingparser.h -mkdir.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -mkdir.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -mkdir.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -mkdir.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -mkdir.o: ../core/loadavg.h ../core/notify.h -mkdir.o: ../templatesnotify/templatesnotify.h ../core/mount.h -mkdir.o: ../templates/misc.h -mv.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -mv.o: ../templates/patterncacher.h ../templates/misc.h -mv.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h -mv.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -mv.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -mv.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -mv.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h -mv.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -mv.o: ../core/request.h ../core/requesttypes.h ../core/session.h -mv.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -mv.o: ../core/compress.h ../core/acceptencodingparser.h -mv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -mv.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h ../core/users.h -mv.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h -mv.o: ../core/mounts.h ../core/mount.h ../core/loadavg.h -node.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -node.o: ../templates/patterncacher.h ../templates/misc.h -node.o: ../templates/localefilter.h ../core/locale.h -node.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -node.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -node.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -node.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -node.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -node.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h -node.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -node.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h -node.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -node.o: ../core/postmultiparser.h -priv.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -priv.o: ../templates/patterncacher.h ../templates/misc.h -priv.o: ../templates/localefilter.h ../core/locale.h -priv.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -priv.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -priv.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -priv.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -priv.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -priv.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h -priv.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -priv.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h -priv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -priv.o: ../core/postmultiparser.h ../core/error.h ../core/data.h -priv.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -priv.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -priv.o: ../core/loadavg.h -reload.o: content.h ../core/item.h ../templates/templates.h -reload.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -reload.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -reload.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -reload.o: ../core/httpsimpleparser.h ../core/log.h -reload.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -reload.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -reload.o: ../core/thread.h ../core/error.h ../core/log.h -reload.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -reload.o: ../core/request.h ../core/requesttypes.h ../core/session.h -reload.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -reload.o: ../core/compress.h ../core/acceptencodingparser.h -reload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -reload.o: ../core/postmultiparser.h ../core/error.h ../core/notify.h -reload.o: ../templatesnotify/templatesnotify.h ../core/mount.h -reload.o: ../templates/misc.h -rm.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -rm.o: ../templates/patterncacher.h ../templates/misc.h -rm.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h -rm.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -rm.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h -rm.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h -rm.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h -rm.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -rm.o: ../core/request.h ../core/requesttypes.h ../core/session.h -rm.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -rm.o: ../core/compress.h ../core/acceptencodingparser.h -rm.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -rm.o: ../core/postmultiparser.h ../core/error.h ../core/data.h ../core/dirs.h -rm.o: ../core/users.h ../core/groups.h ../core/functions.h -rm.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -rm.o: ../core/loadavg.h ../core/plugin.h ../core/request.h ../core/data.h -rm.o: ../core/pluginmsg.h -run.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -run.o: ../templates/patterncacher.h ../templates/misc.h -run.o: ../templates/localefilter.h ../core/locale.h -run.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -run.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -run.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -run.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -run.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -run.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h -run.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -run.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h -run.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -run.o: ../core/postmultiparser.h ../core/error.h -subject.o: content.h ../core/item.h ../templates/templates.h -subject.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -subject.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -subject.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -subject.o: ../core/httpsimpleparser.h ../core/log.h -subject.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -subject.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -subject.o: ../core/thread.h ../core/error.h ../core/log.h -subject.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -subject.o: ../core/request.h ../core/requesttypes.h ../core/session.h -subject.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -subject.o: ../core/compress.h ../core/acceptencodingparser.h -subject.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -subject.o: ../core/postmultiparser.h -thread.o: content.h ../core/item.h ../templates/templates.h -thread.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -thread.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -thread.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -thread.o: ../core/httpsimpleparser.h ../core/log.h -thread.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -thread.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -thread.o: ../core/thread.h ../core/error.h ../core/log.h -thread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -thread.o: ../core/request.h ../core/requesttypes.h ../core/session.h -thread.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -thread.o: ../core/compress.h ../core/acceptencodingparser.h -thread.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -thread.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -thread.o: ../core/users.h ../core/groups.h ../core/functions.h -thread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -thread.o: ../core/loadavg.h ../core/mount.h -ticket.o: content.h ../core/item.h ../templates/templates.h -ticket.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -ticket.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -ticket.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -ticket.o: ../core/httpsimpleparser.h ../core/log.h -ticket.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -ticket.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -ticket.o: ../core/thread.h ../core/error.h ../core/log.h -ticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -ticket.o: ../core/request.h ../core/requesttypes.h ../core/session.h -ticket.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -ticket.o: ../core/compress.h ../core/acceptencodingparser.h -ticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -ticket.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -ticket.o: ../core/users.h ../core/groups.h ../core/functions.h -ticket.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -ticket.o: ../core/loadavg.h ../core/mount.h -uname.o: content.h ../core/item.h ../templates/templates.h -uname.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h -uname.o: ../templates/localefilter.h ../core/locale.h -uname.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -uname.o: ../core/httpsimpleparser.h ../core/log.h -uname.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -uname.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -uname.o: ../core/thread.h ../core/error.h ../core/log.h -uname.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -upload.o: content.h ../core/item.h ../templates/templates.h -upload.o: ../../ezc/src/ezc.h ../templates/patterncacher.h -upload.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h -upload.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -upload.o: ../core/httpsimpleparser.h ../core/log.h -upload.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h -upload.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h -upload.o: ../core/thread.h ../core/error.h ../core/log.h -upload.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -upload.o: ../core/request.h ../core/requesttypes.h ../core/session.h -upload.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -upload.o: ../core/compress.h ../core/acceptencodingparser.h -upload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -upload.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h -upload.o: ../core/users.h ../core/groups.h ../core/functions.h -upload.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -upload.o: ../core/loadavg.h ../core/misc.h -who.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h -who.o: ../templates/patterncacher.h ../templates/misc.h -who.o: ../templates/localefilter.h ../core/locale.h -who.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -who.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -who.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -who.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -who.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -who.o: ../core/ticket.h diff --git a/content/Makefile.o.dep b/content/Makefile.o.dep deleted file mode 100755 index d47e017..0000000 --- a/content/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = adduser.o cat.o content.o cp.o createthread.o createticket.o default.o download.o editticket.o emacs.o last.o login.o logout.o ls.o misc_item.o misc_specialfile.o mkdir.o mv.o node.o priv.o reload.o rm.o run.o subject.o thread.o ticket.o uname.o upload.o who.o diff --git a/content/adduser.cpp b/content/adduser.cpp deleted file mode 100755 index 541499b..0000000 --- a/content/adduser.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" -#include "../core/db.h" - - - - - - - -bool Content::CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass) -{ - if( !login || !pass || !conf_pass ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - - if( login->empty() ) - { - request.status = WINIX_ERR_LOGIN_EMPTY; - return false; - } - - if( *pass != *conf_pass ) - { - request.status = WINIX_ERR_PASSWORDS_DIFFERENT; - return false; - } - - if( pass->size() < 5 ) - { - request.status = WINIX_ERR_PASSWORD_TOO_SHORT; - return false; - } - - if( data.users.IsUser(*login) ) - { - request.status = WINIX_ERR_USER_EXISTS; - return false; - } - -return true; -} - - - - - - -void Content::PostFunAddUser() -{ -User user; - - std::string * login = request.PostVar("login"); - std::string * pass = request.PostVar("password"); - std::string * conf_pass = request.PostVar("confirmpassword"); - std::string * email = request.PostVar("email"); - - if( !CheckAddUserVars(login, pass, conf_pass) ) - return; - - user.name = *login; - - if( email ) - user.email = *email; - - request.status = db.AddUser(user, *pass); - - if( request.status == WINIX_ERR_OK ) - { - if( data.users.AddUser(user) ) - { - if( !request.session->puser ) - LoginUser(user.id, false); - - log << log2 << "Content: added a new user: " << user.name << logend; - } - else - { - log << log1 << "Content: I can't add to data.users: " << user.name - << " but the user was added to the db correctly" << logend; - } - - if( request.is_item ) - RedirectTo(request.item); - else - RedirectToLastDir(); - } -} - - - - -void Content::FunAddUser() -{ - -} - - - diff --git a/content/cat.cpp b/content/cat.cpp deleted file mode 100755 index e89dbda..0000000 --- a/content/cat.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/data.h" - - - - -void Content::FunCat() -{ - if( !request.is_item ) - { - log << log1 << "Content: cat function requires an item" << logend; - request.status = WINIX_ERR_NO_ITEM; - return; - } - - - if( !request.HasReadAccess(request.item) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - request.send_as_attachment = request.IsParam("attachment"); -} - - diff --git a/content/content.cpp b/content/content.cpp deleted file mode 100755 index 4e2cbd8..0000000 --- a/content/content.cpp +++ /dev/null @@ -1,580 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/data.h" -#include "../core/misc.h" -#include "../core/plugin.h" - - - -bool Content::Init() -{ - templates.ReadIndexFileNames(); - templates.ReadTemplates(); - templates.CreateFunctions(); - -return true; -} - - - - - -bool Content::DirsHaveReadExecPerm() -{ - std::vector::iterator i; - - for(i = request.dir_table.begin() ; i!=request.dir_table.end() ; ++i) - { - if( !request.HasReadExecAccess(**i) ) - return false; - } - -return true; -} - - - -void Content::SetDefaultFunctionForFile() -{ - if( request.item.auth != Item::auth_none ) - request.pfunction = data.functions.GetFunction(FUN_DOWNLOAD); - else - if( request.HasReadExecAccess(request.item) ) - request.pfunction = data.functions.GetFunction(FUN_RUN); - else - request.pfunction = data.functions.GetFunction(FUN_CAT); - - if( request.pfunction ) - log << log3 << "Content: default function: " << request.pfunction->item.url << logend; -} - - - - -void Content::SetDefaultFunctionForDir() -{ - long default_item = request.dir_table.back()->default_item; - - if( default_item != -1 ) - { - log << log3 << "Content: Default item: id: " << default_item << logend; - RedirectTo(default_item); - return; - } - - - if( data.mounts.pmount->type == Mount::thread ) - { - request.pfunction = data.functions.GetFunction(FUN_THREAD); - - if( request.pfunction ) - log << log3 << "Content: default function: " << request.pfunction->item.url << logend; - } - else - if( data.mounts.pmount->type == Mount::ticket ) - { - request.pfunction = data.functions.GetFunction(FUN_TICKET); - - if( request.pfunction ) - log << log3 << "Content: default function: " << request.pfunction->item.url << logend; - } - else - { - // cms - request.pfunction = data.functions.GetFunction(FUN_LS); - - if( request.pfunction ) - log << log3 << "Content: default function: " << request.pfunction->item.url << logend; - } -} - - -void Content::SetDefaultFunction() -{ - if( request.is_item ) - { - SetDefaultFunctionForFile(); - } - else - { - SetDefaultFunctionForDir(); - } -} - - -void Content::FunNothing() -{ - /* do nothing */ -} - - -void Content::CallFunction() -{ - static FunItem tab[] = { - {FUN_LOGOUT, &Content::FunLogout}, - {FUN_CAT, &Content::FunCat}, - {FUN_LS, &Content::FunLs}, - {FUN_EMACS, &Content::FunEmacs}, - {FUN_MKDIR, &Content::FunMkdir}, - {FUN_DEFAULT, &Content::FunDefault}, - {FUN_PRIV, &Content::FunPriv}, - {FUN_RM, &Content::FunRm}, - {FUN_RUN, &Content::FunRun}, - {FUN_NODE, &Content::FunNode}, - {FUN_WHO, &Content::FunWho}, - {FUN_LAST, &Content::FunLast}, - {FUN_THREAD, &Content::FunThread}, - {FUN_RELOAD, &Content::FunReload}, - {FUN_UPLOAD, &Content::FunUpload}, - {FUN_TICKET, &Content::FunTicket}, - {FUN_CKEDITOR, &Content::FunEmacs}, - {FUN_TINYMCE, &Content::FunEmacs}, - {FUN_LOGIN, &Content::FunLogin}, - {FUN_MV, &Content::FunMv}, - {FUN_UNAME, &Content::FunUname}, - {FUN_CHMOD, &Content::FunPriv}, - {FUN_CHOWN, &Content::FunPriv}, - {FUN_DOWNLOAD, &Content::FunDownload}, - {FUN_ADDUSER, &Content::FunAddUser}, - {FUN_SUBJECT, &Content::FunSubject}, - {FUN_CP, &Content::FunCp}, - {FUN_UPTIME, &Content::FunNothing}, - {FUN_EDITTICKET,&Content::FunEditTicket}, - {FUN_CREATETHREAD, &Content::FunCreateThread}, - {FUN_CREATETICKET, &Content::FunCreateTicket} - }; - - size_t len = sizeof(tab) / sizeof(FunItem); - size_t i; - - for(i=0 ; icode ) - { - (this->*tab[i].fun)(); - return; - } - } - - request.status = WINIX_ERR_PERMISSION_DENIED; -} - - -void Content::MakeStandardFunction() -{ - if( request.role == Request::authorizer ) - { - // in authorizer mode only cat function is available - // (and must be default) - - if( request.pfunction ) - { - request.status = WINIX_ERR_NO_ITEM; - log << log1 << "Content: in authorizer mode only 'cat' funtion is available and must " - "be default (not in the url)" << logend; - return; - } - - request.pfunction = data.functions.GetFunction(FUN_CAT); - } - - if( !request.pfunction ) - SetDefaultFunction(); - - if( !request.redirect_to.empty() ) - return; - - if( !request.pfunction ) - { - request.status = WINIX_ERR_NO_FUNCTION; - log << log1 << "Content: no function (neither cat nor ls)" << logend; - return; - } - - CallFunction(); -} - - - - -void Content::CallPostFunction() -{ - static FunItem tab[] = { - {FUN_RUN, &Content::PostFunRun}, - {FUN_EMACS, &Content::PostFunEmacs}, - {FUN_MKDIR, &Content::PostFunMkdir}, - {FUN_DEFAULT, &Content::PostFunDefault}, - {FUN_PRIV, &Content::PostFunPriv}, - {FUN_CHMOD, &Content::PostFunPriv}, - {FUN_CHOWN, &Content::PostFunPriv}, - {FUN_LOGIN, &Content::PostFunLogin}, - {FUN_UPLOAD, &Content::PostFunUpload}, - {FUN_EDITTICKET,&Content::PostFunEditTicket}, - {FUN_CKEDITOR, &Content::PostFunEmacs}, - {FUN_TINYMCE, &Content::PostFunEmacs}, - {FUN_ADDUSER, &Content::PostFunAddUser}, - {FUN_MV, &Content::PostFunMv}, - {FUN_SUBJECT, &Content::PostFunSubject}, - {FUN_CP, &Content::PostFunCp}, - {FUN_CREATETHREAD, &Content::PostFunCreateThread}, - {FUN_CREATETICKET, &Content::PostFunCreateTicket} - }; - - size_t len = sizeof(tab) / sizeof(FunItem); - size_t i; - - for(i=0 ; icode ) - { - (this->*tab[i].fun)(); - return; - } - } - - log << log1 << "Content: unknown post function" << logend; - request.status = WINIX_ERR_PERMISSION_DENIED; -} - - -void Content::MakePost() -{ - if( request.role == Request::authorizer ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - if( !request.pfunction ) - SetDefaultFunction(); - - if( !request.pfunction ) - { - request.status = WINIX_ERR_NO_FUNCTION; - log << log1 << "Content: MakePost: no function" << logend; - return; - } - - CallPostFunction(); -} - - -void Content::MakePage() -{ -bool sent = false; - - if( !request.redirect_to.empty() || - !request.x_sendfile.empty() ) - return; - - - if( request.is_item && request.item.auth == Item::auth_none && - request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.pfunction ) - { - if( request.pfunction->code == FUN_CAT ) - { - request.page << request.item.content; - sent = true; - } - else - if( request.pfunction->code == FUN_RUN ) - { - templates.GenerateRunRaw(); - sent = true; - } - } - - if( !sent ) - { - templates.Generate(); - } -} - - - -void Content::Make() -{ - if( request.dir_table.empty() ) - { - log << log1 << "Content: there is no a root dir (dir_table is empty)" << logend; - return; - } - - // request.status can be changed by function_parser - if( request.status == WINIX_ERR_OK ) - { - if( DirsHaveReadExecPerm() ) - { - if( request.method == Request::post ) - MakePost(); - - if( request.redirect_to.empty() && request.status == WINIX_ERR_OK ) - MakeStandardFunction(); - } - else - request.status = WINIX_ERR_PERMISSION_DENIED; - } - - if( request.session->spam_score > 0 ) - log << log1 << "Content: spam score: " << request.session->spam_score << logend; - - if( request.IsParam("noredirect") ) - request.redirect_to.clear(); - - if( !request.redirect_to.empty() ) - return; - - if( request.dir_table.empty() ) - { - log << log1 << "Content: there is no a root dir (dir_table is empty -- after calling some standard functions)" << logend; - return; - } - - plugin.Call(WINIX_CONTENT_MAKE); - MakePage(); - - // !! dodac parametr do konfiga wlaczajacy te informacje - //request.PrintGetTable(); - //request.PrintEnv(); - //request.PrintIn(); -} - - - - -// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad -// !! moze zwracac jakas wartosc? -void Content::RedirectTo(const Item & item, const char * postfix) -{ -std::string path; - - request.redirect_to = data.base_url; - - - if( item.type == Item::dir ) - { - // item_id is pointing to a directory - data.dirs.MakePath(item.id, path); - request.redirect_to += path; - } - else - { - if( !data.dirs.MakePath(item.parent_id, path) ) - log << log1 << "Content: Can't redirect: no dirs for item id: " << item.id << logend; - - request.redirect_to += path; - request.redirect_to += item.url; - } - - if( postfix ) - request.redirect_to += postfix; -} - - - -void Content::RedirectTo(long item_id, const char * postfix) -{ -std::string path; -Item * pdir; - - request.redirect_to = data.base_url; - pdir = data.dirs.GetDir(item_id); - - - if( pdir ) - { - // item_id is pointing to a directory - data.dirs.MakePath(pdir->id, path); - request.redirect_to += path; - } - else - { - // !! zrobic nowy interfejs - // !! GetItem pozamieniac na GetFile - db.GetItem(request.item_table, item_id); - - if( !request.item_table.empty() ) - { - if( !data.dirs.MakePath(request.item_table[0].parent_id, path) ) - log << log1 << "Content: Can't redirect: no dirs for item id: " << request.item_table[0].id << ", requested directory id: " << request.item_table[0].parent_id << logend; - - request.redirect_to += path + request.item_table[0].url; - } - else - { - log << log1 << "Content: Can't redirect: no such item: id: " << item_id << logend; - } - } - - if( postfix ) - request.redirect_to += postfix; -} - - -void Content::RedirectToLastDir() -{ - RedirectTo( *request.dir_table.back() ); -} - - - -void Content::ReadAdditionalInfo() -{ - if( request.dir_table.empty() ) - return; - - if( data.mounts.pmount->type == Mount::thread ) - { - if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == WINIX_ERR_OK ) - request.is_thread = true; - } - else - if( data.mounts.pmount->type == Mount::ticket ) - { - if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == WINIX_ERR_OK ) - { - request.is_ticket = true; - - if( !request.is_item && (!request.pfunction || request.pfunction->code == FUN_TICKET) ) - { - db.GetItemById(request.ticket.item_id, request.item); - // don't set request.is_item here - } - } - } -} - - - -void Content::PrepareUrl(Item & item) -{ - TrimWhite(item.url); - - if( item.url.empty() ) - item.url = item.subject; // if the subject is empty then the url will be corrected by CorrectUrlOnlyAllowedChar() - - CorrectUrlOnlyAllowedChar(item.url); - - if( data.functions.GetFunction(item.url) ) - { - // the name provided by an user is the same as a name of a function - // we add one underscore character at the beginning - - // names of functions should not begin with an underscore '_' - // and we can simply add one '_' at the beginning - // and the name will be unique - item.url.insert(item.url.begin(), '_'); - } -} - - - -bool Content::CheckRebus() -{ - if( request.session->puser ) - // logged user don't have to use the rebus - return true; - - if( request.session->rebus_checked ) - return true; - - request.session->rebus_checked = true; - - if( !request.session->rebus_item ) - { - log << log1 << "Content: rebus not set" << logend; - return false; - } - - try - { - std::string * answer = request.PostVar("rebus"); - - if( answer && data.rebus.IsAnswerOk(request.session->rebus_item, *answer) ) - return true; - } - catch(const Error &) - { - } - - log << log1 << "Content: rebus has an incorrect answer" << logend; - // don't add request.session->spam_score when the rebus has incorrect answer - // a user could have made a mistake - -return false; -} - - -void Content::SetUser(Item & item) -{ - if( request.session->puser ) - { - item.user_id = request.session->puser->id; - item.guest_name.clear(); - } - else - { - item.user_id = -1; - request.PostVar("guestname", item.guest_name); - } - - item.group_id = request.dir_table.back()->group_id; -} - - - -void Content::CheckGetPostTimes(time_t difference) -{ - time_t now = std::time(0); - - if( request.session->puser ) - return; - - if( request.method != Request::post ) - return; - - if( now - request.session->last_time_get >= (time_t)difference ) - return; - - if( request.AllPostVarEmpty() ) - return; - - request.session->spam_score += 1; - log << log1 << "Content: spam +1: POST after GET sent too fast" << logend; -} - - -/* -bool Content::CreateFile(const std::string & path, const std::string & content) -{ - std::ofstream file(path.c_str(), std::ios_base::binary | std::ios_base::out); - - if( !file ) - { - log << log1 << "Content: can't create file: " << path << logend; - return false; - } - - file << content; - - file.close(); - - // !! dodac sprawdzenie prawidlowosci zapisania pliku - -return true; -} -*/ - - - diff --git a/content/content.h b/content/content.h deleted file mode 100755 index 1a92e22..0000000 --- a/content/content.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#ifndef headerfilecmslucontentcontent -#define headerfilecmslucontentcontent - -#include -#include -#include - -#include "../core/item.h" -#include "../templates/templates.h" -#include "../core/thread.h" -#include "../core/ticket.h" -#include "../core/db.h" - - - - -class Content -{ - Templates templates; - - std::string temp; - - void FunDownload(); - - void CheckSpecialFile(); - - void PrepareUrl(Item & item); - - - bool CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass); - void PostFunAddUser(); - void FunAddUser(); - - - /* - mv - */ - bool MoveIsTheSameFile(const Item & item); - void MoveAuth(Item & item); - void MoveFile(Item & item, bool redirect = true); - void MoveDir(Item & item, bool redirect = true); - void MoveAuthPrepareQuery(); - void MoveAuthContentOfDir(const Item & item); - bool MoveParseDir(long & dir_id, std::string & dir, std::string & file); - bool MoveCheckAccessFromToDir(); - bool MoveCheckAccessFrom(); - bool MoveCheckAccessTo(long dir_id); - bool MoveCheckMountPoints(long dir_id); - void MoveContentOfDir(); - void PostFunMv(); - void FunMv(); - std::string mv_dir; - std::string mv_file; - std::string mv_new_path; - long mv_dir_id; - std::vector mv_auth; - Db::ItemQuery mv_auth_iq; - - - /* - cp - */ - bool CpCheckAccessFrom(); - void CpAuth(Item & item); - void CpSetNewAttributes(Item & item); - void CpItem(Item & item, long dst_dir_id); - void CpFilesInDir(const Item & dir, long dst_dir_id); - void CpContentOfDir(const Item & item, long dst_dir_id); - long CpDir(const Item & item, long dst_dir_id); - void CpItemCheck(Item & item, bool redirect = true); - void CpContentOfDirCheck(const Item & item, bool redirect = true); - void CpDirCheck(const Item & item, bool redirect = true); - void PostFunCp(); - void FunCp(); - void CpPrepare(); - Item cp_temp; - Db::ItemQuery cp_iq; - bool cp_remove_defaults; - bool cp_preserve_attr; - long cp_new_user; - long cp_new_group; - - - - - - void SetDefaultFunctionForFile(); - void SetDefaultFunctionForDir(); - void SetDefaultFunction(); - bool DirsHaveReadExecPerm(); - - - /* - calling functions (standard, post) - */ - typedef void (Content::*Fun)(); - - struct FunItem - { - int code; - Fun fun; - }; - - void FunNothing(); - void CallFunction(); - void MakeStandardFunction(); - void CallPostFunction(); - void MakePost(); - - - - - - - void SetUser(Item & item); - bool CheckRebus(); - - - - void FunCat(); - void FunLogout(); - void FunLs(); - void FunEmacs(); - - - void AddPathToAuth(std::string & path); - - void FunCKEditor(); - - - void FunUname(); - - bool SubjectCheckAccess(); - void EditDirSubject(); - void EditFileSubject(); - void PostFunSubject(); - void FunSubject(); - - - /* - rm - */ - bool RemoveCheckAccess(); - void RemoveAllDirs(); - void RemoveAllDirs(long dir_id); - void RemoveDir(); - void RemoveAuthPrepareQuery(); - void RemoveAuth(Item & item); - void RemoveFile(); - void FunRm(); - Db::ItemQuery rm_auth_iq; - - - void FunNode(); - void FunMkdir(); - void FunDefault(); - void FunRun(); - void PostFunRun(); - void FunWho(); - void FunLast(); - - void FunReloadTemplates(); - void FunReload(); - - static bool FunThreadSort(const Thread & t1, const Thread & t2); - void FunThread(); - void FunCreateThread(); - - bool FunUploadCheckAccess(); - void FunUpload(); - - bool ReadItemUrlSubject(Item & item, Item::Type item_type); - bool ReadItem(Item & item, Item::Type item_type); - - void CheckAccessToItems(); - - void LoginUser(long user_id, bool remember_me); - void FunLogin(); - void PostFunLogin(); - - - void ReadItemContentWithType(Item & item); - bool FunEmacsCheckAccess(); - void PostFunEmacsAdd(Item & item); - void PostFunEmacsEdit(bool with_url); - bool PostEmacsCheckAbuse(bool adding); - void PostFunEmacsModifyMountPoint(bool adding); - void PostFunEmacs(); - - bool FunMkdirCheckAccess(); - void PostFunMkdir(bool add_to_dir_table, int privileges); - void PostFunMkdir(); - - void Mkdir(Item & item, bool add_to_dir_table); - long PostFunDefaultParsePath(); - void PostFunDefault(); - - - /* - function: priv, chmod, chown - */ - bool PrivCheckAccess(); - void PrivLogStart(const char * what, long user, long group, int priv); - void PrivLog(const char * what, long id, const std::string & url); - bool ChangeOwner(Item & item, long user_id, long group_id); - bool ChangePrivileges(Item & item, int privileges); - void ChangePriv(Item & item, long user_id, long group_id, int privileges); - void PostFunPriv(); - void PrivFilesInDir(long parent_id); - void PrivDir(long parent_id); - - - bool ReadPriv(const char * user_in, const char * group_in, const char * priv_in, long & user_id, long & group_id, int & priv); - void PrivDir(); - void PrivOneItem(); - void FunPriv(); - - long user_id_file, group_id_file, user_id_dir, group_id_dir; - int priv_file, priv_dir; - bool subdirectories; - bool change_owner, change_priv; - - - - bool FunCreateThreadCheckAccess(); - bool FunCreateThreadCheckAbuse(); - void ReadThread(Thread & thread); - void AddThread(); - void PostFunCreateThreadLogAndRedirect(); - void PostFunCreateThread(); - - bool UploadCreatePath(); - void UploadSaveFile(const std::string & tmp_filename, const std::string & destination); - void UploadMulti(); - void UploadSingle(); - bool FunUploadCheckAbuse(); - void PostFunUpload(); - - - bool FunCreateTicketCheckAccess(); - void FunCreateTicket(); - bool FunCreateTicketCheckAbuse(); - void PostFunCreateTicketLogAndRedirect(); - void PostFunCreateTicket(); - void FunTicket(); - void TicketDeleteFirst(); - - bool FunEditTicketCheckAccess(); - void PostFunEditTicketLogAndRedirect(); - void EditTicketCheckFirstItem(); - void EditTicketModTicket(); - void EditTicketModDir(); - void EditTicketModFirstItem(); - void PostFunEditTicket(); - void FunEditTicket(); - - void AddTicket(); - void ReadTicket(Ticket & ticket); - void ReadTicketType(Ticket & ticket); - void ReadTicketStatus(Ticket & ticket); - void ReadTicketPriority(Ticket & ticket); - void ReadTicketCategory(Ticket & ticket); - void ReadTicketExpected(Ticket & ticket); - void ReadTicketProgress(Ticket & ticket); - - void RedirectTo(const Item & item, const char * postfix = 0); - void RedirectTo(long item_id, const char * postfix = 0); - void RedirectToLastDir(); - - void CheckGetPostTimes(time_t difference = 10); -// bool CreateFile(const std::string & path, const std::string & content); - void MakePage(); - -public: - - bool Init(); - - void ReadAdditionalInfo(); - void Make(); - - - -}; - - -#endif diff --git a/content/cp.cpp b/content/cp.cpp deleted file mode 100755 index 6c5575b..0000000 --- a/content/cp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" -#include "../core/misc.h" - - -bool Content::CpCheckAccessFrom() -{ - if( request.is_item ) - { - if( !request.HasReadAccess(request.item) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - } - else - if( !request.IsParam("r") ) - { - // directories need 'r' parameter - request.status = WINIX_ERR_PERMISSION_DENIED; - } - - -return true; -} - - -void Content::CpAuth(Item & item) -{ - if( !request.MakePath(item, mv_new_path, true) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - if( CopyFile(item.auth_path, mv_new_path) ) - { - log << log1 << "Content: copied static file from: " << item.auth_path << ", to: " << mv_new_path << logend; - item.auth_path = mv_new_path; - request.status = db.EditAuthById(item, item.id); - } - else - { - log << log1 << "Content: can't copy a file from: " << item.auth_path << ", to: " << mv_new_path << logend; - request.status = WINIX_ERR_PERMISSION_DENIED; - } -} - - -void Content::CpSetNewAttributes(Item & item) -{ - item.user_id = cp_new_user; - item.group_id = cp_new_group; - item.SetDateModifyToNow(); -} - - -void Content::CpItem(Item & item, long dst_dir_id) -{ - if( !request.HasReadAccess(item) ) - return; // !! w przyszlosci bedziemy dodawac komunikaty do specjalnej tablicy (narazie nie zaimplementowane) - - item.parent_id = dst_dir_id; - - if( !cp_preserve_attr ) - CpSetNewAttributes(item); - - PostFunEmacsAdd(item); - - if( request.status == WINIX_ERR_OK ) - { - if( item.auth != Item::auth_none ) - CpAuth(item); - } -} - - - - -void Content::CpPrepare() -{ - cp_iq.SetAll(true, false); - cp_iq.WhereType(Item::file); - - cp_new_user = -1; - cp_new_group = -1; - - if( request.session->puser ) - cp_new_user = request.session->puser->id; - - Item * pdir = data.dirs.GetDir(mv_dir_id); - - if( pdir ) - cp_new_group = pdir->group_id; -} - - - -void Content::CpFilesInDir(const Item & dir, long dst_dir_id) -{ - cp_iq.WhereParentId(dir.id); - db.GetItems(request.item_table, cp_iq); - - for(size_t i=0 ; isecond), dst_dir_id); - - CpFilesInDir(item, dst_dir_id); -} - - - -// we shouldn't change 'item' because we have references to our data.dirs objects -long Content::CpDir(const Item & item, long dst_dir_id) -{ - cp_temp = item; - cp_temp.parent_id = dst_dir_id; - - if( !mv_file.empty() ) - { - cp_temp.url = mv_file; - mv_file.clear(); - PrepareUrl(cp_temp); - } - - if( !cp_preserve_attr ) - CpSetNewAttributes(cp_temp); - - if( cp_remove_defaults ) - cp_temp.default_item = -1; - - Mkdir(cp_temp, false); - long new_dir_id = cp_temp.id; // remember the new dir_id - - if( request.HasReadExecAccess(item) ) - CpContentOfDir(item, cp_temp.id); - -return new_dir_id; // and return it -} - - - - -// here 'item' can be changed in place -void Content::CpItemCheck(Item & item, bool redirect) -{ - if( MoveIsTheSameFile(item) ) - return; - - if( !mv_file.empty() ) - { - item.url = mv_file; - PrepareUrl(item); - } - - CpItem(item, mv_dir_id); - - if( request.status==WINIX_ERR_OK && redirect ) - RedirectTo(item); -} - - - -void Content::CpContentOfDirCheck(const Item & item, bool redirect) -{ - if( !mv_file.empty() ) - { - request.status = WINIX_ERR_INCORRECT_DIR; - return; - } - - if( mv_dir_id == item.id ) - return; // nothing to do - - if( data.dirs.HasParent(mv_dir_id, item.id) ) - { - log << log1 << "Content: cannot copy directory to inside it" << logend; - request.status = WINIX_ERR_INCORRECT_DIR; - return; - } - - CpContentOfDir(item, mv_dir_id); - - if( request.status==WINIX_ERR_OK && redirect ) - RedirectTo(mv_dir_id); -} - - - -void Content::CpDirCheck(const Item & item, bool redirect) -{ - if( mv_file.empty() && mv_dir_id == item.id ) - return; // nothing to do - - if( mv_dir_id == item.id || data.dirs.HasParent(mv_dir_id, item.id) ) - { - log << log1 << "Content: cannot copy directory to inside it" << logend; - request.status = WINIX_ERR_INCORRECT_DIR; - return; - } - - long new_dir_id = CpDir(item, mv_dir_id); - - if( request.status==WINIX_ERR_OK && redirect ) - RedirectTo(new_dir_id); -} - - - -void Content::PostFunCp() -{ - if( CpCheckAccessFrom() && - MoveParseDir(mv_dir_id, mv_dir, mv_file) && - MoveCheckAccessTo(mv_dir_id) ) - { - CpPrepare(); - cp_preserve_attr = request.IsPostVar("preserveattr"); - - if( request.is_item ) - { - CpItemCheck(request.item); - } - else - { - cp_remove_defaults = request.IsPostVar("removedefaults"); - - if( request.IsPostVar("onlycontent") ) - CpContentOfDirCheck(*request.dir_table.back()); - else - CpDirCheck(*request.dir_table.back()); - } - } -} - - - -void Content::FunCp() -{ - CpCheckAccessFrom(); -} diff --git a/content/createthread.cpp b/content/createthread.cpp deleted file mode 100755 index cd3d2d1..0000000 --- a/content/createthread.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/mount.h" -#include "../core/data.h" - - - - -bool Content::FunCreateThreadCheckAccess() -{ - if( !request.CanCreateThread() ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - - -return true; -} - - - -bool Content::FunCreateThreadCheckAbuse() -{ - if( !CheckRebus() ) - { - request.status = WINIX_ERR_INCORRECT_REBUS; - return false; - } - - 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 Content::ReadThread(Thread & thread) -{ - thread.parent_id = request.dir_table.back()->id; -} - - - -void Content::AddThread() -{ - request.thread.dir_id = request.dir_table.back()->id; - request.thread.closed = false; - request.thread.items = 1; - request.thread.last_item = request.item; // set by PostFunEmacsAdd() - - request.status = db.AddThread(request.thread); -} - - - -void Content::PostFunCreateThreadLogAndRedirect() -{ - if( request.status == WINIX_ERR_OK ) - { - log << log2 << "Content: added a new thread" << logend; - RedirectToLastDir(); - } - else - { - log << log1 << "Content: problem with adding a new thread, error code: " - << request.status << logend; - } -} - - - -void Content::PostFunCreateThread() -{ - if( !FunCreateThreadCheckAccess() ) - return; - - ReadItem(request.item, Item::dir); - SetUser(request.item); - ReadThread(request.thread); - request.item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty - - if( !FunCreateThreadCheckAbuse() ) - { - ReadItemContentWithType(request.item); // for correctly displaying the form - return; - } - - Mkdir(request.item, true); - - if( request.status == WINIX_ERR_OK ) - { - ReadItemContentWithType(request.item); - request.item.type = Item::file; - request.item.privileges = 0644; // !! tymczasowo - request.item.parent_id = request.dir_table.back()->id; - PostFunEmacsAdd(request.item); - - if( request.status == WINIX_ERR_OK ) - AddThread(); - } - - PostFunCreateThreadLogAndRedirect(); -} - - - - - - - -void Content::FunCreateThread() -{ - FunCreateThreadCheckAccess(); -} - - - - diff --git a/content/createticket.cpp b/content/createticket.cpp deleted file mode 100755 index 131bdd3..0000000 --- a/content/createticket.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/mount.h" -#include "../core/data.h" - - - - - -bool Content::FunCreateTicketCheckAccess() -{ - if( !request.CanCreateTicket() ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - - -return true; -} - - - -bool Content::FunCreateTicketCheckAbuse() -{ - if( !CheckRebus() ) - { - request.status = WINIX_ERR_INCORRECT_REBUS; - return false; - } - - 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 Content::ReadTicketType(Ticket & ticket) -{ -static std::string temp; - - request.PostVar("type", temp); - ticket.type = atoi(temp.c_str()); - - if( ticket.type >= data.mounts.pmount->param[Mount::par_ticket_type].arg.size() ) - ticket.type = data.mounts.pmount->param[Mount::par_ticket_type].arg.size(); -} - - - -void Content::ReadTicketStatus(Ticket & ticket) -{ -static std::string temp; - - request.PostVar("status", temp); - ticket.status = atoi(temp.c_str()); - - if( ticket.status >= data.mounts.pmount->param[Mount::par_ticket_status].arg.size() ) - ticket.status = data.mounts.pmount->param[Mount::par_ticket_status].arg.size(); -} - - - -void Content::ReadTicketPriority(Ticket & ticket) -{ -static std::string temp; - - request.PostVar("priority", temp); - ticket.priority = atoi(temp.c_str()); - - if( ticket.priority >= data.mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) - ticket.priority = data.mounts.pmount->param[Mount::par_ticket_priority].arg.size(); -} - - - -void Content::ReadTicketCategory(Ticket & ticket) -{ -static std::string temp; - - request.PostVar("category", temp); - ticket.category = atoi(temp.c_str()); - - if( ticket.category >= data.mounts.pmount->param[Mount::par_ticket_category].arg.size() ) - ticket.category = data.mounts.pmount->param[Mount::par_ticket_category].arg.size(); -} - - -void Content::ReadTicketExpected(Ticket & ticket) -{ -static std::string temp; - - request.PostVar("expected", temp); - ticket.expected = atoi(temp.c_str()); - - if( ticket.expected >= data.mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) - ticket.expected = data.mounts.pmount->param[Mount::par_ticket_expected].arg.size(); -} - - -void Content::ReadTicketProgress(Ticket & ticket) -{ -static std::string temp; - - request.PostVar("progress", temp); - int p = atoi(temp.c_str()); - - if( p < 0 ) - p = 0; - - if( p > 100 ) - p = 100; - - ticket.progress = p; -} - - - -void Content::ReadTicket(Ticket & ticket) -{ - ticket.parent_id = request.dir_table.back()->id; - - ReadTicketType(ticket); - ReadTicketStatus(ticket); - ReadTicketPriority(ticket); - ReadTicketCategory(ticket); - ReadTicketExpected(ticket); - ReadTicketProgress(ticket); -} - - - -void Content::AddTicket() -{ - static std::string temp; - - request.ticket.dir_id = request.dir_table.back()->id; // a new directory created by Mkdir() - request.ticket.item_id = request.item.id; // this id is set by PostFunEmacsAdd() - - request.status = db.AddTicket(request.ticket); -} - - -void Content::PostFunCreateTicketLogAndRedirect() -{ - if( request.status == WINIX_ERR_OK ) - { - log << log2 << "Content: added a new ticket" << logend; - RedirectToLastDir(); - } - else - { - log << log1 << "Content: problem with adding a new ticket, error code: " - << request.status << logend; - } -} - - - -void Content::PostFunCreateTicket() -{ - if( !FunCreateTicketCheckAccess() ) - return; - - ReadItem(request.item, Item::dir); - SetUser(request.item); - ReadTicket(request.ticket); - request.item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty - - if( !FunCreateTicketCheckAbuse() ) - { - ReadItemContentWithType(request.item); // for correctly displaying the form - return; - } - - Mkdir(request.item, true); - - if( request.status == WINIX_ERR_OK ) - { - ReadItemContentWithType(request.item); - request.item.type = Item::file; - request.item.privileges = 0644; // !! tymczasowo - request.item.parent_id = request.dir_table.back()->id; - PostFunEmacsAdd(request.item); - - if( request.status == WINIX_ERR_OK ) - AddTicket(); - } - - PostFunCreateTicketLogAndRedirect(); -} - - - - -void Content::FunCreateTicket() -{ - FunCreateTicketCheckAccess(); -} - - - - diff --git a/content/download.cpp b/content/download.cpp deleted file mode 100755 index d7f7317..0000000 --- a/content/download.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" - - - - - -void Content::FunDownload() -{ - // !! moze wywalic to no_item i wszedzie w takich miejscach dac poprostu permission_denied? - if( !request.is_item ) - { - log << log1 << "Content: download function requires an item" << logend; - request.status = WINIX_ERR_NO_ITEM; - return; - } - - - if( !request.HasReadAccess(request.item) || - request.item.auth == Item::auth_none || - request.item.auth_path.empty() ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - request.send_as_attachment = request.IsParam("attachment"); - request.x_sendfile = request.item.auth_path; -} - - - - diff --git a/content/editticket.cpp b/content/editticket.cpp deleted file mode 100755 index 22764ac..0000000 --- a/content/editticket.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/mount.h" -#include "../core/data.h" - - - -bool Content::FunEditTicketCheckAccess() -{ - if( !request.CanEditTicket() ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - -return true; -} - - - -void Content::EditTicketCheckFirstItem() -{ - if( request.status != WINIX_ERR_OK ) - return; - - - if( request.ticket.item_id == -1 ) - { - // creating a new item (the item was deleted by a user) - - Item item; - item.parent_id = request.dir_table.back()->id; - item.subject = request.dir_table.back()->subject; - item.type = Item::file; - item.privileges = 0644; // !! tymczasowo - SetUser(item); - PrepareUrl(item); - - request.status = db.AddItem(item); - - if( request.status == WINIX_ERR_OK ) - { - log << log2 << "Content: added the first item with content for the ticket, item.id: " << item.id << logend; - request.ticket.item_id = item.id; - } - } -} - - - -void Content::EditTicketModTicket() -{ - if( request.status != WINIX_ERR_OK ) - return; - - Ticket ticket; - ReadTicket(ticket); - - request.ticket.type = ticket.type; - request.ticket.status = ticket.status; - request.ticket.priority = ticket.priority; - request.ticket.category = ticket.category; - request.ticket.expected = ticket.expected; - request.ticket.progress = ticket.progress; - - request.status = db.EditTicketById(request.ticket); -} - - - -void Content::EditTicketModDir() -{ - if( request.status != WINIX_ERR_OK ) - return; - - // we don't modify the url - - Item & dir = *request.dir_table.back(); - bool edit_dir_subject = (dir.subject != request.item.subject); - - if( edit_dir_subject ) - { - dir.subject = request.item.subject; - request.status = db.EditItemById(dir, false); - } -} - - -void Content::EditTicketModFirstItem() -{ - if( request.status != WINIX_ERR_OK ) - return; - - // modyfing the first item (the one with content) - ReadItemContentWithType(request.item); - - Item item; - db.GetItemById(request.ticket.item_id, item); - item.subject = request.item.subject; - item.content = request.item.content; - item.content_type = request.item.content_type; - // the url doesn't matter - - db.EditItemById(item, false); -} - - - -void Content::PostFunEditTicketLogAndRedirect() -{ - if( request.status == WINIX_ERR_OK ) - { - log << log2 << "Content: edited a ticket" << logend; - RedirectToLastDir(); - } - else - { - log << log1 << "Content: problem with editing a ticket, error code: " - << request.status << logend; - } -} - - - -void Content::PostFunEditTicket() -{ - if( !FunEditTicketCheckAccess() ) - return; - - ReadItem(request.item, Item::dir); - // co z uzytkownikiem i grup¹? chyba nie wczytane? !!! (wczesniej bylo SetUser() w ReadItem() - teraz nie ma) - // dodac informacje o modyfikacji !!! - - if( !FunCreateTicketCheckAbuse() ) - { - ReadItemContentWithType(request.item); // for correctly displaying the form - return; - } - - if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) != WINIX_ERR_OK ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - EditTicketCheckFirstItem(); - EditTicketModTicket(); - EditTicketModDir(); - EditTicketModFirstItem(); - PostFunEditTicketLogAndRedirect(); -} - - - -void Content::FunEditTicket() -{ - FunEditTicketCheckAccess(); - - db.GetItemById(request.ticket.item_id, request.item); - - // the subject we get from the last directory - request.item.subject = request.dir_table.back()->subject; -} - diff --git a/content/emacs.cpp b/content/emacs.cpp deleted file mode 100755 index 3c687a6..0000000 --- a/content/emacs.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/data.h" -#include "../core/notify.h" -#include "../core/misc.h" - - - -bool Content::FunEmacsCheckAccess() -{ - if( !request.is_item ) - { - // adding a new item - if( !request.CanUseEmacs(*request.dir_table.back()) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - } - else // editing an existing item - if( !request.CanUseEmacs(request.item) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - -return true; -} - - -void Content::PostFunEmacsAdd(Item & item) -{ - request.status = db.AddItem(item); - - if( request.status == WINIX_ERR_OK ) - { - log << log2 << "Content: added a new item, url: " << item.url << ", id: " << item.id - << ", parent_id: " << item.parent_id << logend; - - request.notify_code |= WINIX_NOTIFY_ITEM_ADD; - } -} - - - -void Content::PostFunEmacsEdit(bool with_url) -{ - if( request.session->puser ) - request.item.modification_user_id = request.session->puser->id; - else - request.item.modification_user_id = -1; - - request.item.SetDateModifyToNow(); - request.status = db.EditItemById(request.item, with_url); - - - if( request.status == WINIX_ERR_OK ) - { - TemplatesFunctions::pattern_cacher.UpdatePattern(request.item); - log << log2 << "Content: modified an item" << logend; - - request.notify_code |= WINIX_NOTIFY_ITEM_EDIT; - } -} - - -bool Content::PostEmacsCheckAbuse(bool adding) -{ - if( !CheckRebus() ) - { - request.status = WINIX_ERR_INCORRECT_REBUS; - return false; - } - - // !! is tested in createthread once - 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 Content::PostFunEmacsModifyMountPoint(bool adding) -{ - if( data.mounts.pmount->type == Mount::thread ) - { - if( adding ) - db.EditThreadAddItem(request.dir_table.back()->id, request.item.id); - - RedirectToLastDir(); - } - else - if( data.mounts.pmount->type == Mount::ticket ) - { - RedirectToLastDir(); - } - else - { - // Mount::cms - RedirectTo(request.item); - } -} - - - -void Content::PostFunEmacs() -{ - if( !FunEmacsCheckAccess() ) - return; - - bool adding = !request.is_item; - bool edit_with_url = ReadItem(request.item, Item::file); - - if( adding ) - SetUser(request.item); // set user before checking the rebus - - if( !PostEmacsCheckAbuse(adding) ) - return; - - if( adding ) - { - request.is_item = true; - request.item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask - PostFunEmacsAdd(request.item); - } - else - { - PostFunEmacsEdit(edit_with_url); - } - - - if( request.status == WINIX_ERR_OK ) - { - PostFunEmacsModifyMountPoint(adding); - CheckSpecialFile(); - } - else - { - log << log1 << "Content: PostFunEmacs: Error: " - << request.status << logend; - } -} - - - - -void Content::FunEmacs() -{ - FunEmacsCheckAccess(); -} - - - - diff --git a/content/login.cpp b/content/login.cpp deleted file mode 100755 index cb68ef0..0000000 --- a/content/login.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/data.h" - - - - -void Content::LoginUser(long user_id, bool remember_me) -{ - request.session->puser = data.users.GetUser(user_id); - request.session->spam_score = 0; - - if( !request.session->puser ) - { - log << log1 << "Content: user id: " << user_id << " is not in data.users" << logend; - return; - } - - request.session->remember_me = remember_me; - - data.last.UserLogin(user_id, request.session->puser->name, inet_addr(request.env_remote_addr), request.session->id); - data.how_many_logged += 1; - - log << log2 << "User " << request.session->puser->name << " (id: " << user_id << ") logged" << logend; -} - - - -void Content::PostFunLogin() -{ - try - { - std::string * login = request.PostVar("login"); - std::string * pass = request.PostVar("password"); - std::string * remem = request.PostVar("rememberme"); - long user_id; - - if( login && pass && db.CheckUser(*login, *pass, user_id) ) - LoginUser(user_id, remem != 0); - - // !! moze zglosic komunikat o nie poprawnym logowaniu - } - catch(const Error &) - { - } - - - if( request.is_item ) - RedirectTo(request.item); - else - RedirectTo(*request.dir_table.back()); -} - - - -void Content::FunLogin() -{ -} diff --git a/content/logout.cpp b/content/logout.cpp deleted file mode 100755 index c5df11a..0000000 --- a/content/logout.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" - - - - - - - - - - - - -void Content::FunLogout() -{ - if( request.session->puser ) - { - log << log2 << "User: " << request.session->puser->name << ", id: " << request.session->puser->id << " logged out" << logend; - - data.last.UserLogout(request.session->puser->id, request.session->id); - - if( data.how_many_logged > 0 ) // for safety - data.how_many_logged -= 1; - - request.session->puser = 0; - request.session->remember_me = 0; - } - - std::string path; - data.dirs.MakePath(request.dir_table.back()->id, path); - request.redirect_to = data.base_url + path; - - if( request.is_item ) - request.redirect_to += request.item.url; - -} - - diff --git a/content/misc_item.cpp b/content/misc_item.cpp deleted file mode 100755 index 5f99bde..0000000 --- a/content/misc_item.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/misc.h" -#include "../core/db.h" - - - - - -// returning true if the 'url' has to be changed -bool Content::ReadItemUrlSubject(Item & item, Item::Type item_type) -{ - bool with_url = false; - - std::string * new_url = request.PostVar("url"); - std::string * new_subject = request.PostVar("subject"); - - if( item_type == Item::file ) - { - if( !request.is_item || (new_url && *new_url != item.url) ) - with_url = true; - } - else - { - with_url = true; - } - - - if( new_url ) - item.url = *new_url; - - if( new_subject ) - item.subject = *new_subject; - - - if( item.subject.empty() ) - { - item.subject = request.dir_table.back()->subject; - item.subject += "_msg_"; - item.subject += ToStr(db.Size(request.dir_table.back()->id, Item::file)); - } - - // if item.url is empty then it will be set from item.subject - PrepareUrl(item); - -return with_url; -} - - -void Content::ReadItemContentWithType(Item & item) -{ - item.content_type = Item::ct_formatted_text; // default is formatted text - request.PostVar("itemcontent", request.item.content); - request.PostVar("contenttype", temp); - - // ct_text and ct_formatted_text can use everyone - - if( temp == "0" ) - item.content_type = Item::ct_text; - else - if( temp == "1" ) - item.content_type = Item::ct_formatted_text; - - - // those below need special privileges - - if( !request.session->puser ) - return; - - long user_id = request.session->puser->id; - - - if( temp == "2" ) - { - if( request.CanUseHtml(user_id) ) - item.content_type = Item::ct_html; - } - else - if( temp == "3" ) - { - if( request.CanUseBBCode(user_id) ) - item.content_type = Item::ct_bbcode; - } - else - if( temp == "4" ) - { - if( request.CanUseRaw(user_id) ) - item.content_type = Item::ct_raw; - } -} - - - - -// item_type - the type of an item you are expecting to read -// returns true if the url has to be changed -// at the moment this is only checked for Item::file - for Item::dir it returns always true -bool Content::ReadItem(Item & item, Item::Type item_type) -{ - if( item_type == Item::none ) - return false; - - item.type = item_type; - item.parent_id = request.dir_table.back()->id; - - bool edit_with_url = ReadItemUrlSubject(item, item_type); - - if( item_type == Item::file ) - ReadItemContentWithType(item); - -return edit_with_url; -} - - - -// if we don't have access we only remove the item from the table -void Content::CheckAccessToItems() -{ -size_t i = 0; - - while( i < request.item_table.size() ) - { - if( !request.HasReadAccess(request.item_table[i]) ) - { - request.item_table.erase(request.item_table.begin() + i); - } - else - { - i += 1; - } - } -} diff --git a/content/misc_specialfile.cpp b/content/misc_specialfile.cpp deleted file mode 100755 index 3739b81..0000000 --- a/content/misc_specialfile.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" - - - -void Content::CheckSpecialFile() -{ - static std::string fstab = "fstab"; - - Item * etc = data.dirs.GetEtcDir(); - - if( !etc ) - return; - - if( request.item.parent_id != etc->id ) - return; - - if( request.item.url == fstab ) - { - log << log3 << "Content: reloading mount points" << logend; - - request.status = data.mounts.ReadMounts(request.item.content); - templates.ReadNewIndexTemplates(); - } -} - diff --git a/content/mkdir.cpp b/content/mkdir.cpp deleted file mode 100755 index a03cf46..0000000 --- a/content/mkdir.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/data.h" -#include "../core/notify.h" - - - - -bool Content::FunMkdirCheckAccess() -{ - if( request.is_item || !request.CanUseMkdir(*request.dir_table.back()) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - -return true; -} - - - -void Content::Mkdir(Item & item, bool add_to_dir_table) -{ - request.status = db.AddItem(item); - - if( request.status == WINIX_ERR_OK ) - { - Item * pdir = data.dirs.AddDir(item); - - if( add_to_dir_table ) - request.dir_table.push_back(pdir); - } -} - - - -void Content::PostFunMkdir(bool add_to_dir_table, int privileges) -{ - if( !FunMkdirCheckAccess() ) - return; - - ReadItem(request.item, Item::dir); - SetUser(request.item); - request.item.privileges = privileges; - - Mkdir(request.item, add_to_dir_table); - - if( request.status == WINIX_ERR_OK ) - { - request.notify_code |= WINIX_NOTIFY_DIR_ADD; - RedirectTo(request.item); - } - else - { - log << log1 << "Content: PostFunMkdir: Error: " << request.status << logend; - } -} - - -void Content::PostFunMkdir() -{ - PostFunMkdir(false, 0755); -} - - -void Content::FunMkdir() -{ - FunMkdirCheckAccess(); -} - - - - - diff --git a/content/mv.cpp b/content/mv.cpp deleted file mode 100755 index 04719c1..0000000 --- a/content/mv.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" - - - -bool Content::MoveCheckAccessFromToDir() -{ -Item * last; -Item * last_but_one = 0; - - last = request.dir_table[request.dir_table.size()-1]; - - if( request.dir_table.size() >= 2 ) - last_but_one = request.dir_table[request.dir_table.size()-2]; - - if( request.method != Request::post ) - { - // used in GET (HEAD in the future?) - - if( !request.HasWriteAccess(*last) && - (!last_but_one || !request.HasWriteAccess(*last_but_one)) ) - return false; - } - else - { - // used in POST when the moving is performed - - if( request.IsPostVar("onlycontent") ) - return request.HasWriteAccess(*last); - else - if( last_but_one ) - return request.HasWriteAccess(*last_but_one); - else - return false; // you cannot move the root directory - } - -return true; -} - - - -bool Content::MoveCheckAccessFrom() -{ - if( request.is_item ) - { - // moving a file - - if( !request.HasWriteAccess(*request.dir_table.back()) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - } - else - { - if( !MoveCheckAccessFromToDir() ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - } - -return true; -} - - -bool Content::MoveCheckAccessTo(long dir_id) -{ - Item * pdir = data.dirs.GetDir(dir_id); - - if( !pdir ) - { - request.status = WINIX_ERR_INCORRECT_DIR; - return false; - } - - if( !request.HasReadExecAccessToPath(dir_id) || !request.HasWriteAccess(*pdir) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - -return true; -} - - - -bool Content::MoveCheckMountPoints(long dir_id) -{ - /* - Mount * new_mount = data.mounts.CalcMount(dir_id); - - if( !new_mount ) - { - if( data.mounts.pmount->type != Mount::cms ) - { - request.status = WINIX_DIFFERENT_MOUNT_POINTS; - return false; - } - - return true; - } - - if( new_mount->type != data.mounts.pmount->type ) - { - request.status = WINIX_DIFFERENT_MOUNT_POINTS; - return false; - } - */ - -return true; -} - - - -bool Content::MoveParseDir(long & dir_id, std::string & dir, std::string & file) -{ - std::string * move_to = request.PostVar("to"); - - if( !move_to ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - - int res = data.dirs.AnalyzePath(*move_to, dir_id, dir, file); - - if( res == 1 ) - request.status = WINIX_ERR_NO_ROOT_DIR; - else - if( res != 0 ) - request.status = WINIX_ERR_INCORRECT_DIR; - -return res == 0; -} - - - -void Content::MoveAuth(Item & item) -{ - if( !request.MakePath(item, mv_new_path, true) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - if( rename(item.auth_path.c_str(), mv_new_path.c_str()) == 0 ) - { - log << log1 << "Content: moved static file from: " << item.auth_path << ", to: " << mv_new_path << logend; - item.auth_path = mv_new_path; - request.status = db.EditAuthById(item, item.id); - } - else - { - int err = errno; - - log << log1 << "Content: can't move a file from: " << item.auth_path << ", to: " << mv_new_path << ", "; - log.SystemErr(err); - log << logend; - - request.status = WINIX_ERR_PERMISSION_DENIED; - } -} - - - -bool Content::MoveIsTheSameFile(const Item & item) -{ - if( mv_file.empty() ) - { - if( item.parent_id == mv_dir_id ) - return true; // nothing to do - } - else - { - if( item.parent_id == mv_dir_id && item.url == mv_file ) - return true; // nothing to do - } - -return false; -} - - - -void Content::MoveFile(Item & item, bool redirect) -{ - if( MoveIsTheSameFile(item) ) - return; - - if( !mv_file.empty() ) - { - item.url = mv_file; - PrepareUrl(item); - } - - item.parent_id = mv_dir_id; - request.status = db.EditParentUrlById(item, item.id); - - if( request.status == WINIX_ERR_OK ) - { - log << log2 << "Content: the file was moved to: " << mv_dir << item.url << logend; - - if( item.auth != Item::auth_none ) - MoveAuth(item); - - if( redirect ) - RedirectTo(item); - } -} - - - -void Content::MoveContentOfDir() -{ -Db::ItemQuery iq; - - iq.sel_parent_id = true; - iq.sel_type = true; - iq.sel_url = true; - iq.sel_auth = true; - iq.WhereParentId(request.dir_table.back()->id); - - db.GetItems(request.item_table, iq); - - for(size_t i=0 ; isecond)); - - mv_auth_iq.WhereParentId(item.id); - - // don't use request.item here (is used in MoveContentOfDir()) - db.GetItems(mv_auth, mv_auth_iq); - - for(size_t i=0 ; ipuser || !request.session->puser->super_user ) - { - log << log1 << "Content: Only an admin has access to reload function" << logend; - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - if( request.IsParam("templates") ) - FunReloadTemplates(); -} - - - - diff --git a/content/rm.cpp b/content/rm.cpp deleted file mode 100755 index 46a57e9..0000000 --- a/content/rm.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include -#include -#include "content.h" -#include "core/request.h" -#include "core/error.h" -#include "core/data.h" -#include "core/plugin.h" - - -bool Content::RemoveCheckAccess() -{ - if( !request.is_item ) - { - if( !request.CanRemove(*request.dir_table.back()) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - } - else - if( !request.CanRemove(request.item) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - - -return true; -} - - - -void Content::RemoveAuthPrepareQuery() -{ - rm_auth_iq.SetAll(true, false); - - rm_auth_iq.sel_parent_id = true; - rm_auth_iq.sel_type = true; - rm_auth_iq.sel_auth = true; - - rm_auth_iq.WhereType(Item::file); - rm_auth_iq.WhereAuth(Item::auth_none, false); -} - - - -void Content::RemoveAllDirs(long dir_id) -{ - DirContainer::ParentIterator pnext, p = data.dirs.FindFirstParent(dir_id); - - for( ; p != data.dirs.ParentEnd() ; p = pnext ) - { - // this iterator p will be deleted by the next DeleteDir(p->second->id) - // (the next iterator we must calculate beforehand) - pnext = data.dirs.NextParent(p); - RemoveAllDirs(p->second->id); - } - - plugin.Call(WINIX_DIR_PREPARE_TO_REMOVE, dir_id); - - rm_auth_iq.WhereParentId(dir_id); - db.GetItems(request.item_table, rm_auth_iq); - - for(size_t i=0 ; iid); - request.dir_table.erase(--request.dir_table.end()); - - if( request.dir_table.empty() ) - { - // we have deleted the root directory - data.dirs.CheckRootDir(); // adding a new root dir - Item * proot = data.dirs.GetRootDir(); - - if( proot ) - request.dir_table.push_back(proot); - else - // there is no a root dir - // CheckRootDir() didn't add the root dir (probably problem with the database) - // make sure that Content::Make() will check that the dir_table is empty and returns - return; - } - - RedirectToLastDir(); -} - - -void Content::RemoveDir() -{ - if( request.param_table.empty() ) - request.status = WINIX_ERR_PERMISSION_DENIED; // use parameter "r" for removing a directory - else - if( request.IsParam("r") ) - RemoveAllDirs(); - else - request.status = WINIX_ERR_UNKNOWN_PARAM; -} - - - -void Content::RemoveAuth(Item & item) -{ - if( item.auth_path.empty() ) - { - log << log1 << "Content: can't remove a static file: auth_path is empty" << logend; - return; - } - - if( remove(item.auth_path.c_str()) == 0 ) - { - log << log1 << "Content: removed static file: " << item.auth_path << logend; - item.auth_path.clear(); - item.auth = Item::auth_none; - // we don't store it to db (will be removed or is removed already) - } - else - { - int err = errno; - - log << log1 << "Content: can't remove a file: " << item.auth_path; - log.SystemErr(err); - log << logend; - - request.status = WINIX_ERR_PERMISSION_DENIED; - } -} - - - -void Content::RemoveFile() -{ - // for safety we check if param_table is empty - // a user can use "confirm" but can make a mistake when typing - if( !request.param_table.empty() ) - { - request.status = WINIX_ERR_UNKNOWN_PARAM; - return; - } - - - if( db.DelItem( request.item ) ) - { - log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend; - TemplatesFunctions::pattern_cacher.DeletePattern(request.item); - - plugin.Call(WINIX_FILE_REMOVED, request.item.id); - - if( data.mounts.pmount->type == Mount::thread ) - db.EditThreadRemoveItem(request.item.parent_id); - else - if( data.mounts.pmount->type == Mount::ticket ) - db.EditTicketRemoveItem(request.item.id); - - if( request.item.auth != Item::auth_none ) - RemoveAuth(request.item); - } - else - { - request.status = WINIX_ERR_NO_ITEM; - } - - RedirectToLastDir(); -} - - - -void Content::FunRm() -{ - if( !RemoveCheckAccess() ) - return; - - if( request.IsParam("confirm") ) - return; // show confirmation dialog - - if( request.is_item ) - RemoveFile(); - else - RemoveDir(); -} - - - diff --git a/content/run.cpp b/content/run.cpp deleted file mode 100755 index 1ba9a0a..0000000 --- a/content/run.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" - - - - -void Content::FunRun() -{ - if( !request.is_item ) - { - log << log1 << "Content: Run function requires an item" << logend; - request.status = WINIX_ERR_NO_ITEM; - return; - } - - if( !request.HasReadExecAccess(request.item) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } -} - - -void Content::PostFunRun() -{ - FunRun(); -} - diff --git a/content/subject.cpp b/content/subject.cpp deleted file mode 100755 index e6c118f..0000000 --- a/content/subject.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/db.h" -#include "../core/log.h" - - - -bool Content::SubjectCheckAccess() -{ - // super user can always - if( request.session->puser && request.session->puser->super_user ) - return true; - - bool access; - - if( request.is_item ) - access = request.HasWriteAccess(request.item); - else - access = request.HasWriteAccess(*request.dir_table.back()); - - if( !access ) - request.status = WINIX_ERR_PERMISSION_DENIED; - -return access; -} - - - -void Content::EditDirSubject() -{ - Item & dir = *request.dir_table.back(); - - request.PostVar("subject", dir.subject); - db.EditSubjectById(dir, dir.id); - - RedirectToLastDir(); -} - - - -void Content::EditFileSubject() -{ - request.PostVar("subject", request.item.subject); - db.EditSubjectById(request.item, request.item.id); - - RedirectTo(request.item); -} - - - - -void Content::PostFunSubject() -{ - if( !SubjectCheckAccess() ) - return; - - if( request.is_item ) - EditFileSubject(); - else - EditDirSubject(); -} - - - -void Content::FunSubject() -{ - SubjectCheckAccess(); -} - - - - diff --git a/content/thread.cpp b/content/thread.cpp deleted file mode 100755 index 7392806..0000000 --- a/content/thread.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/db.h" -#include "../core/data.h" -#include "../core/mount.h" - -#include - - -bool Content::FunThreadSort(const Thread & t1, const Thread & t2) -{ - Item * pdir1 = data.dirs.GetDir(t1.dir_id); - Item * pdir2 = data.dirs.GetDir(t2.dir_id); - - if( !pdir1 || !pdir2 ) - return false; - - time_t time1 = mktime(&pdir1->date_creation); - time_t time2 = mktime(&pdir2->date_creation); - - return time1 > time2; -} - - -void Content::FunThread() -{ - if( request.is_item ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - Db::ItemQuery iq; - - if( data.mounts.pmount->IsArg(Mount::par_thread, "sort_desc") ) - iq.sort_asc = false; - - iq.WhereParentId(request.dir_table.back()->id); - iq.WhereType(Item::file); - iq.WhereAuth(Item::auth_none); - - db.GetItems(request.item_table, iq); - db.GetThreads(request.dir_table.back()->id, request.thread_tab); - - CheckAccessToItems(); - - std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort); -} - - - - diff --git a/content/ticket.cpp b/content/ticket.cpp deleted file mode 100755 index 1ed7e15..0000000 --- a/content/ticket.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "content.h" -#include "../core/request.h" -#include "../core/db.h" -#include "../core/data.h" -#include "../core/mount.h" - - - - -void Content::TicketDeleteFirst() -{ - if( !request.is_ticket ) - return; - - for(size_t i=0 ; itype != Mount::ticket ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - Db::ItemQuery iq; - - iq.WhereParentId(request.dir_table.back()->id); - iq.WhereType(Item::file); - iq.WhereAuth(Item::auth_none); - - db.GetItems(request.item_table, iq); - db.GetTickets(request.dir_table.back()->id, request.ticket_tab); - - TicketDeleteFirst(); - CheckAccessToItems(); -} - - - - diff --git a/content/upload.cpp b/content/upload.cpp deleted file mode 100755 index 970b4be..0000000 --- a/content/upload.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include -#include -#include -#include -#include "content.h" -#include "../core/request.h" -#include "../core/data.h" -#include "../core/misc.h" - - - - -bool Content::FunUploadCheckAccess() -{ - if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - - -return true; -} - - - -bool Content::UploadCreatePath() -{ - if( !request.MakePath(request.item, true) ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return false; - } - -return true; -} - - - - -void Content::UploadSaveFile(const std::string & tmp_filename, const std::string & destination) -{ - if( rename(tmp_filename.c_str(), destination.c_str()) == 0 ) - { - log << log1 << "Content: uploaded a new file: " << destination << logend; - } - else - { - int err = errno; - - // !! skasowac takze plik z bazy danych? - log << log1 << "Content: can't move the tmp file from: " << tmp_filename << ", to: " << destination << ", "; - log.SystemErr(err); - log << logend; - - request.status = WINIX_ERR_PERMISSION_DENIED; - } -} - - - -bool Content::FunUploadCheckAbuse() -{ - if( !CheckRebus() ) - { - request.status = WINIX_ERR_INCORRECT_REBUS; - return false; - } - - CheckGetPostTimes(4); - - 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 Content::UploadMulti() -{ - request.item.Clear(); // clearing and setting date - request.item.parent_id = request.dir_table.back()->id; - request.item.type = Item::file; - request.item.privileges = 0644; // !! tymczasowo - SetUser(request.item); - - PostFileTable::iterator i = request.post_file_table.begin(); - - for( ; i != request.post_file_table.end() ; ++i) - { - const char * file_name = i->second.filename.c_str(); - - request.item.subject = file_name; - request.item.url = file_name; - request.item.auth = SelectFileType(file_name); - - PrepareUrl(request.item); - PostFunEmacsAdd(request.item); // always adding a new item - - if( !UploadCreatePath() ) - return; - - if( request.status == WINIX_ERR_OK ) - { - UploadSaveFile(i->second.tmp_filename, request.item.auth_path); - request.status = db.EditAuthById(request.item, request.item.id); - } - } - - RedirectToLastDir(); -} - - -void Content::UploadSingle() -{ - std::string * new_subject = request.PostVar("subject"); - std::string * new_url = request.PostVar("url"); - bool has_subject = (new_subject && (*new_subject)[0] != 0 ); - bool has_url = (new_url && (*new_url)[0] != 0 ); - - ReadItem(request.item, Item::file); // ReadItem() changes the url if it is empty - SetUser(request.item); - request.item.privileges = 0644; // !! tymczasowo - - const char * file_name = request.post_file_table.begin()->second.filename.c_str(); - request.item.auth = SelectFileType(file_name); - - if( !has_subject ) - request.item.subject = file_name; - - if( !has_url ) - { - request.item.url = file_name; - PrepareUrl(request.item); - } - - PostFunEmacsAdd(request.item); // always adding a new item - - // url can be changed by PostFunEmacsAdd() - if( !UploadCreatePath() ) - return; - - if( request.status == WINIX_ERR_OK ) - { - const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename; - UploadSaveFile(tmp_filename, request.item.auth_path); - request.status = db.EditAuthById(request.item, request.item.id); - } - - if( request.status == WINIX_ERR_OK ) - RedirectTo(request.item, "/cat"); -} - - - -// !! dodac usuwanie plikow statycznych przez rm -void Content::PostFunUpload() -{ - if( !FunUploadCheckAccess() ) - return; - - if( request.post_file_table.empty() ) - { - request.status = WINIX_ERR_PERMISSION_DENIED; - return; - } - - if( !FunUploadCheckAbuse() ) - return; - - if( request.post_file_table.size() > 1 ) - UploadMulti(); - else - UploadSingle(); -} - - - -void Content::FunUpload() -{ - FunUploadCheckAccess(); -} - diff --git a/core/Makefile.dep b/core/Makefile.dep index 8a59923..382f0a6 100755 --- a/core/Makefile.dep +++ b/core/Makefile.dep @@ -1,128 +1,261 @@ # DO NOT DELETE +Kopia config.o: ../core/log.h ../core/request.h requesttypes.h session.h +Kopia config.o: item.h error.h log.h user.h plugindata.h rebus.h thread.h +Kopia config.o: compress.h acceptencodingparser.h acceptbaseparser.h +Kopia config.o: htmlfilter.h postmultiparser.h config.h confparser.h ticket.h +Kopia config.o: ../core/config.h ../core/db.h group.h dircontainer.h +Kopia config.o: ugcontainer.h acceptbaseparser.o: acceptbaseparser.h +app.o: app.h config.h confparser.h system.h dirs.h item.h dircontainer.h db.h +app.o: user.h group.h thread.h error.h log.h ugcontainer.h ticket.h request.h +app.o: requesttypes.h session.h plugindata.h rebus.h compress.h +app.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h +app.o: postmultiparser.h mounts.h mount.h users.h lastcontainer.h groups.h +app.o: loadavg.h sessionmanager.h sessioncontainer.h notify.h +app.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +app.o: ../core/mount.h ../core/locale.h ../core/config.h ../templates/misc.h +app.o: ../templates/localefilter.h ../core/locale.h ../functions/functions.h +app.o: ../functions/functionbase.h ../core/item.h ../core/db.h +app.o: ../core/request.h ../core/system.h ../core/notify.h +app.o: ../functions/functionparser.h ../functions/adduser.h +app.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h +app.o: ../functions/chown.h ../functions/cp.h ../functions/createthread.h +app.o: ../functions/createticket.h ../functions/default.h +app.o: ../functions/download.h ../functions/editticket.h ../functions/emacs.h +app.o: ../functions/last.h ../functions/login.h ../functions/logout.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/run.h ../functions/subject.h +app.o: ../functions/funthread.h ../core/thread.h ../functions/funticket.h +app.o: ../functions/uname.h ../functions/upload.h ../functions/who.h +app.o: ../templates/templates.h ../templates/patterncacher.h ../core/item.h +app.o: misc.h ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +app.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h +app.o: plugin.h pluginmsg.h bbcodeparser.o: bbcodeparser.h htmlfilter.h compress.o: compress.h log.h -config.o: config.h ../confparser/confparser.h log.h data.h dirs.h item.h -config.o: dircontainer.h users.h user.h ugcontainer.h groups.h group.h -config.o: functions.h function.h lastcontainer.h mounts.h mount.h error.h -config.o: rebus.h loadavg.h plugin.h request.h requesttypes.h session.h -config.o: plugindata.h thread.h compress.h acceptencodingparser.h -config.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h -config.o: pluginmsg.h misc.h -data.o: data.h dirs.h item.h dircontainer.h users.h user.h ugcontainer.h -data.o: log.h groups.h group.h functions.h function.h lastcontainer.h -data.o: mounts.h mount.h error.h rebus.h loadavg.h +config.o: config.h confparser.h log.h plugin.h pluginmsg.h plugindata.h +config.o: request.h requesttypes.h session.h item.h error.h user.h rebus.h +config.o: thread.h compress.h acceptencodingparser.h acceptbaseparser.h +config.o: htmlfilter.h postmultiparser.h ticket.h system.h dirs.h +config.o: dircontainer.h db.h group.h ugcontainer.h mounts.h mount.h users.h +config.o: lastcontainer.h groups.h loadavg.h sessionmanager.h +config.o: sessioncontainer.h ../functions/functions.h +config.o: ../functions/functionbase.h ../core/item.h ../core/db.h +config.o: ../core/request.h ../core/config.h ../core/system.h +config.o: ../core/notify.h ../../ezc/src/ezc.h ../functions/functionparser.h +config.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +config.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +config.o: ../functions/createthread.h ../functions/createticket.h +config.o: ../functions/default.h ../functions/download.h +config.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +config.o: ../functions/login.h ../functions/logout.h ../functions/ls.h +config.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h +config.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h +config.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h +config.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +config.o: ../functions/upload.h ../functions/who.h ../templates/templates.h +config.o: ../templates/patterncacher.h ../core/item.h misc.h +config.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +config.o: ../core/log.h ../templates/indexpatterns.h +config.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h +config.o: ../core/sessionmanager.h +confparser.o: confparser.h misc.h item.h db.o: db.h item.h user.h group.h thread.h error.h log.h dircontainer.h db.o: ugcontainer.h ticket.h misc.h db_itemcolumns.o: db.h item.h user.h group.h thread.h error.h log.h db_itemcolumns.o: dircontainer.h ugcontainer.h ticket.h dircontainer.o: dircontainer.h item.h log.h -dirs.o: dirs.h item.h dircontainer.h error.h log.h db.h user.h group.h -dirs.o: thread.h ugcontainer.h ticket.h data.h users.h groups.h functions.h -dirs.o: function.h lastcontainer.h mounts.h mount.h rebus.h loadavg.h -dirs.o: request.h requesttypes.h session.h plugindata.h compress.h -dirs.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -dirs.o: postmultiparser.h -function.o: function.h item.h -functioncodeparser.o: functioncodeparser.h item.h function.h log.h -functionparser.o: functionparser.h requesttypes.h log.h item.h error.h data.h -functionparser.o: dirs.h dircontainer.h users.h user.h ugcontainer.h groups.h -functionparser.o: group.h functions.h function.h lastcontainer.h mounts.h -functionparser.o: mount.h rebus.h loadavg.h db.h thread.h ticket.h request.h -functionparser.o: session.h plugindata.h compress.h acceptencodingparser.h -functionparser.o: acceptbaseparser.h htmlfilter.h postmultiparser.h -functions.o: functions.h function.h item.h +dirs.o: dirs.h item.h dircontainer.h db.h user.h group.h thread.h error.h +dirs.o: log.h ugcontainer.h ticket.h request.h requesttypes.h session.h +dirs.o: plugindata.h rebus.h compress.h acceptencodingparser.h +dirs.o: acceptbaseparser.h htmlfilter.h postmultiparser.h config.h +dirs.o: confparser.h groups.o: groups.h group.h ugcontainer.h log.h db.h item.h user.h thread.h groups.o: error.h dircontainer.h ticket.h htmlfilter.o: htmlfilter.h httpsimpleparser.o: httpsimpleparser.h lastcontainer.o: lastcontainer.h log.h loadavg.o: loadavg.h log.h -locale.o: locale.h ../confparser/confparser.h log.h +locale.o: locale.h confparser.h log.h log.o: log.h -misc.o: misc.h item.h log.h data.h dirs.h dircontainer.h users.h user.h -misc.o: ugcontainer.h groups.h group.h functions.h function.h lastcontainer.h -misc.o: mounts.h mount.h error.h rebus.h loadavg.h +misc.o: misc.h item.h log.h mount.o: mount.h -mountparser.o: mountparser.h mount.h item.h error.h log.h data.h dirs.h -mountparser.o: dircontainer.h users.h user.h ugcontainer.h groups.h group.h -mountparser.o: functions.h function.h lastcontainer.h mounts.h rebus.h -mountparser.o: loadavg.h misc.h -mounts.o: mounts.h mount.h error.h log.h data.h dirs.h item.h dircontainer.h -mounts.o: users.h user.h ugcontainer.h groups.h group.h functions.h -mounts.o: function.h lastcontainer.h rebus.h loadavg.h request.h -mounts.o: requesttypes.h session.h plugindata.h thread.h compress.h +mountparser.o: mountparser.h mount.h item.h error.h log.h dirs.h +mountparser.o: dircontainer.h db.h user.h group.h thread.h ugcontainer.h +mountparser.o: ticket.h request.h requesttypes.h session.h plugindata.h +mountparser.o: rebus.h compress.h acceptencodingparser.h acceptbaseparser.h +mountparser.o: htmlfilter.h postmultiparser.h config.h confparser.h misc.h +mounts.o: mounts.h mount.h error.h log.h dirs.h item.h dircontainer.h db.h +mounts.o: user.h group.h thread.h ugcontainer.h ticket.h request.h +mounts.o: requesttypes.h session.h plugindata.h rebus.h compress.h mounts.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -mounts.o: postmultiparser.h ticket.h mountparser.h db.h -notify.o: log.h notify.h ../templatesnotify/templatesnotify.h ../core/mount.h -notify.o: ../core/locale.h ../confparser/confparser.h ../templates/misc.h -notify.o: ../templates/localefilter.h ../../ezc/src/ezc.h data.h dirs.h -notify.o: item.h dircontainer.h users.h user.h ugcontainer.h groups.h group.h -notify.o: functions.h function.h lastcontainer.h mounts.h mount.h error.h -notify.o: rebus.h loadavg.h misc.h request.h requesttypes.h session.h -notify.o: plugindata.h thread.h compress.h acceptencodingparser.h -notify.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h -plugin.o: plugin.h request.h requesttypes.h session.h item.h error.h log.h -plugin.o: user.h rebus.h plugindata.h function.h thread.h compress.h -plugin.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -plugin.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h users.h -plugin.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h mounts.h -plugin.o: mount.h loadavg.h pluginmsg.h -plugindata.o: plugindata.h plugin.h request.h requesttypes.h session.h item.h -plugindata.o: error.h log.h user.h rebus.h function.h thread.h compress.h -plugindata.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -plugindata.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h users.h -plugindata.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h -plugindata.o: mounts.h mount.h loadavg.h pluginmsg.h -postmultiparser.o: postmultiparser.h error.h log.h requesttypes.h data.h -postmultiparser.o: dirs.h item.h dircontainer.h users.h user.h ugcontainer.h -postmultiparser.o: groups.h group.h functions.h function.h lastcontainer.h -postmultiparser.o: mounts.h mount.h rebus.h loadavg.h -rebus.o: log.h rebus.h misc.h item.h +mounts.o: postmultiparser.h config.h confparser.h mountparser.h +notify.o: log.h notify.h ../templatesnotify/templatesnotify.h +notify.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h confparser.h +notify.o: ../core/config.h ../templates/misc.h ../templates/localefilter.h +notify.o: ../core/locale.h request.h requesttypes.h session.h item.h error.h +notify.o: user.h plugindata.h rebus.h thread.h compress.h +notify.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h +notify.o: postmultiparser.h config.h ticket.h system.h dirs.h dircontainer.h +notify.o: db.h group.h ugcontainer.h mounts.h mount.h users.h lastcontainer.h +notify.o: groups.h loadavg.h misc.h +plugin.o: plugin.h pluginmsg.h log.h plugindata.h config.h confparser.h +plugin.o: request.h requesttypes.h session.h item.h error.h user.h rebus.h +plugin.o: thread.h compress.h acceptencodingparser.h acceptbaseparser.h +plugin.o: htmlfilter.h postmultiparser.h ticket.h system.h dirs.h +plugin.o: dircontainer.h db.h group.h ugcontainer.h mounts.h mount.h users.h +plugin.o: lastcontainer.h groups.h loadavg.h sessionmanager.h +plugin.o: sessioncontainer.h ../functions/functions.h +plugin.o: ../functions/functionbase.h ../core/item.h ../core/db.h +plugin.o: ../core/request.h ../core/config.h ../core/system.h +plugin.o: ../core/notify.h ../../ezc/src/ezc.h ../functions/functionparser.h +plugin.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +plugin.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +plugin.o: ../functions/createthread.h ../functions/createticket.h +plugin.o: ../functions/default.h ../functions/download.h +plugin.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +plugin.o: ../functions/login.h ../functions/logout.h ../functions/ls.h +plugin.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h +plugin.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h +plugin.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h +plugin.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +plugin.o: ../functions/upload.h ../functions/who.h ../templates/templates.h +plugin.o: ../templates/patterncacher.h ../core/item.h misc.h +plugin.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +plugin.o: ../core/log.h ../templates/indexpatterns.h +plugin.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h +plugin.o: ../core/sessionmanager.h +plugindata.o: plugindata.h plugin.h pluginmsg.h log.h config.h confparser.h +plugindata.o: request.h requesttypes.h session.h item.h error.h user.h +plugindata.o: rebus.h thread.h compress.h acceptencodingparser.h +plugindata.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h +plugindata.o: system.h dirs.h dircontainer.h db.h group.h ugcontainer.h +plugindata.o: mounts.h mount.h users.h lastcontainer.h groups.h loadavg.h +plugindata.o: sessionmanager.h sessioncontainer.h ../functions/functions.h +plugindata.o: ../functions/functionbase.h ../core/item.h ../core/db.h +plugindata.o: ../core/request.h ../core/config.h ../core/system.h +plugindata.o: ../core/notify.h ../../ezc/src/ezc.h +plugindata.o: ../functions/functionparser.h ../functions/adduser.h +plugindata.o: ../functions/cat.h ../functions/chmod.h +plugindata.o: ../functions/privchanger.h ../functions/chown.h +plugindata.o: ../functions/cp.h ../functions/createthread.h +plugindata.o: ../functions/createticket.h ../functions/default.h +plugindata.o: ../functions/download.h ../functions/editticket.h +plugindata.o: ../functions/emacs.h ../functions/last.h ../functions/login.h +plugindata.o: ../functions/logout.h ../functions/ls.h ../functions/mkdir.h +plugindata.o: ../functions/mv.h ../functions/node.h ../functions/priv.h +plugindata.o: ../functions/reload.h ../functions/rm.h ../functions/run.h +plugindata.o: ../functions/subject.h ../functions/funthread.h +plugindata.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +plugindata.o: ../functions/upload.h ../functions/who.h +plugindata.o: ../templates/templates.h ../templates/patterncacher.h +plugindata.o: ../core/item.h misc.h ../templates/ckeditorgetparser.h +plugindata.o: ../core/httpsimpleparser.h ../core/log.h +plugindata.o: ../templates/indexpatterns.h ../templates/localefilter.h +plugindata.o: ../core/locale.h ../core/locale.h ../core/sessionmanager.h +postmultiparser.o: postmultiparser.h error.h log.h requesttypes.h config.h +postmultiparser.o: confparser.h +rebus.o: log.h rebus.h misc.h item.h request.h requesttypes.h session.h +rebus.o: error.h user.h plugindata.h thread.h compress.h +rebus.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h +rebus.o: postmultiparser.h config.h confparser.h ticket.h request.o: request.h requesttypes.h session.h item.h error.h log.h user.h -request.o: rebus.h plugindata.h function.h thread.h compress.h -request.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -request.o: postmultiparser.h ticket.h getparser.h httpsimpleparser.h -request.o: postparser.h cookieparser.h data.h dirs.h dircontainer.h users.h -request.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h -request.o: mounts.h mount.h loadavg.h plugin.h pluginmsg.h misc.h db.h -requestcontroller.o: requestcontroller.h ../content/content.h ../core/item.h -requestcontroller.o: ../templates/templates.h ../../ezc/src/ezc.h -requestcontroller.o: ../templates/patterncacher.h misc.h item.h -requestcontroller.o: ../templates/ckeditorgetparser.h -requestcontroller.o: ../core/httpsimpleparser.h ../core/log.h -requestcontroller.o: ../core/locale.h ../confparser/confparser.h -requestcontroller.o: ../templates/indexpatterns.h ../templates/localefilter.h -requestcontroller.o: ../core/thread.h ../core/ticket.h ../core/db.h user.h -requestcontroller.o: group.h thread.h error.h log.h dircontainer.h -requestcontroller.o: ugcontainer.h ticket.h sessionmanager.h -requestcontroller.o: sessioncontainer.h session.h rebus.h plugindata.h -requestcontroller.o: functionparser.h requesttypes.h data.h dirs.h users.h -requestcontroller.o: groups.h functions.h function.h lastcontainer.h mounts.h -requestcontroller.o: mount.h loadavg.h request.h compress.h -requestcontroller.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -requestcontroller.o: postmultiparser.h postparser.h httpsimpleparser.h -requestcontroller.o: cookieparser.h notify.h -requestcontroller.o: ../templatesnotify/templatesnotify.h ../core/mount.h -requestcontroller.o: ../templates/misc.h -session.o: session.h item.h error.h log.h user.h rebus.h plugindata.h +request.o: plugindata.h rebus.h thread.h compress.h acceptencodingparser.h +request.o: acceptbaseparser.h htmlfilter.h postmultiparser.h config.h +request.o: confparser.h ticket.h getparser.h httpsimpleparser.h postparser.h +request.o: cookieparser.h plugin.h pluginmsg.h system.h dirs.h dircontainer.h +request.o: db.h group.h ugcontainer.h mounts.h mount.h users.h +request.o: lastcontainer.h groups.h loadavg.h sessionmanager.h +request.o: sessioncontainer.h ../functions/functions.h +request.o: ../functions/functionbase.h ../core/item.h ../core/db.h +request.o: ../core/request.h ../core/config.h ../core/system.h +request.o: ../core/notify.h ../../ezc/src/ezc.h ../functions/functionparser.h +request.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +request.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +request.o: ../functions/createthread.h ../functions/createticket.h +request.o: ../functions/default.h ../functions/download.h +request.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +request.o: ../functions/login.h ../functions/logout.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/subject.h ../functions/funthread.h +request.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +request.o: ../functions/upload.h ../functions/who.h ../templates/templates.h +request.o: ../templates/patterncacher.h ../core/item.h misc.h +request.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +request.o: ../core/log.h ../templates/indexpatterns.h +request.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h +request.o: ../core/sessionmanager.h ../functions/functionbase.h +session.o: session.h item.h error.h log.h user.h plugindata.h rebus.h sessioncontainer.o: sessioncontainer.h session.h item.h error.h log.h user.h -sessioncontainer.o: rebus.h plugindata.h data.h dirs.h dircontainer.h users.h -sessioncontainer.o: ugcontainer.h groups.h group.h functions.h function.h -sessioncontainer.o: lastcontainer.h mounts.h mount.h loadavg.h +sessioncontainer.o: plugindata.h rebus.h lastcontainer.h sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h -sessionmanager.o: error.h log.h user.h rebus.h plugindata.h request.h -sessionmanager.o: requesttypes.h function.h thread.h compress.h -sessionmanager.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h -sessionmanager.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h -sessionmanager.o: users.h ugcontainer.h groups.h group.h functions.h -sessionmanager.o: lastcontainer.h mounts.h mount.h loadavg.h sessionparser.h -sessionmanager.o: plugin.h pluginmsg.h +sessionmanager.o: error.h log.h user.h plugindata.h rebus.h lastcontainer.h +sessionmanager.o: config.h confparser.h request.h requesttypes.h thread.h +sessionmanager.o: compress.h acceptencodingparser.h acceptbaseparser.h +sessionmanager.o: htmlfilter.h postmultiparser.h ticket.h system.h dirs.h +sessionmanager.o: dircontainer.h db.h group.h ugcontainer.h mounts.h mount.h +sessionmanager.o: users.h groups.h loadavg.h sessionparser.h plugin.h +sessionmanager.o: pluginmsg.h ../functions/functions.h +sessionmanager.o: ../functions/functionbase.h ../core/item.h ../core/db.h +sessionmanager.o: ../core/request.h ../core/config.h ../core/system.h +sessionmanager.o: ../core/notify.h ../../ezc/src/ezc.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/cp.h ../functions/createthread.h +sessionmanager.o: ../functions/createticket.h ../functions/default.h +sessionmanager.o: ../functions/download.h ../functions/editticket.h +sessionmanager.o: ../functions/emacs.h ../functions/last.h +sessionmanager.o: ../functions/login.h ../functions/logout.h +sessionmanager.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h +sessionmanager.o: ../functions/node.h ../functions/priv.h +sessionmanager.o: ../functions/reload.h ../functions/rm.h ../functions/run.h +sessionmanager.o: ../functions/subject.h ../functions/funthread.h +sessionmanager.o: ../core/thread.h ../functions/funticket.h +sessionmanager.o: ../functions/uname.h ../functions/upload.h +sessionmanager.o: ../functions/who.h ../templates/templates.h +sessionmanager.o: ../templates/patterncacher.h ../core/item.h misc.h +sessionmanager.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +sessionmanager.o: ../core/log.h ../templates/indexpatterns.h +sessionmanager.o: ../templates/localefilter.h ../core/locale.h +sessionmanager.o: ../core/locale.h ../core/sessionmanager.h sessionparser.o: sessionparser.h session.h item.h error.h log.h user.h -sessionparser.o: rebus.h plugindata.h sessioncontainer.h data.h dirs.h -sessionparser.o: dircontainer.h users.h ugcontainer.h groups.h group.h -sessionparser.o: functions.h function.h lastcontainer.h mounts.h mount.h -sessionparser.o: loadavg.h -users.o: users.h user.h ugcontainer.h log.h db.h item.h group.h thread.h -users.o: error.h dircontainer.h ticket.h +sessionparser.o: plugindata.h rebus.h sessioncontainer.h lastcontainer.h +sessionparser.o: users.h ugcontainer.h request.h requesttypes.h thread.h +sessionparser.o: compress.h acceptencodingparser.h acceptbaseparser.h +sessionparser.o: htmlfilter.h postmultiparser.h config.h confparser.h +sessionparser.o: ticket.h db.h group.h dircontainer.h +system.o: system.h dirs.h item.h dircontainer.h db.h user.h group.h thread.h +system.o: error.h log.h ugcontainer.h ticket.h request.h requesttypes.h +system.o: session.h plugindata.h rebus.h compress.h acceptencodingparser.h +system.o: acceptbaseparser.h htmlfilter.h postmultiparser.h config.h +system.o: confparser.h mounts.h mount.h users.h lastcontainer.h groups.h +system.o: loadavg.h misc.h notify.h ../templatesnotify/templatesnotify.h +system.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +system.o: ../core/config.h ../templates/misc.h ../templates/localefilter.h +system.o: ../core/locale.h ../functions/functions.h +system.o: ../functions/functionbase.h ../core/item.h ../core/db.h +system.o: ../core/request.h ../core/system.h ../core/notify.h +system.o: ../functions/functionparser.h ../functions/adduser.h +system.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h +system.o: ../functions/chown.h ../functions/cp.h ../functions/createthread.h +system.o: ../functions/createticket.h ../functions/default.h +system.o: ../functions/download.h ../functions/editticket.h +system.o: ../functions/emacs.h ../functions/last.h ../functions/login.h +system.o: ../functions/logout.h ../functions/ls.h ../functions/mkdir.h +system.o: ../functions/mv.h ../functions/node.h ../functions/priv.h +system.o: ../functions/reload.h ../functions/rm.h ../functions/run.h +system.o: ../functions/subject.h ../functions/funthread.h ../core/thread.h +system.o: ../functions/funticket.h ../functions/uname.h ../functions/upload.h +system.o: ../functions/who.h ../templates/templates.h +system.o: ../templates/patterncacher.h ../core/item.h +system.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +system.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h +users.o: users.h user.h ugcontainer.h log.h lastcontainer.h request.h +users.o: requesttypes.h session.h item.h error.h plugindata.h rebus.h +users.o: thread.h compress.h acceptencodingparser.h acceptbaseparser.h +users.o: htmlfilter.h postmultiparser.h config.h confparser.h ticket.h db.h +users.o: group.h dircontainer.h diff --git a/core/Makefile.o.dep b/core/Makefile.o.dep index 776f1b9..860474a 100755 --- a/core/Makefile.o.dep +++ b/core/Makefile.o.dep @@ -1 +1 @@ -o = acceptbaseparser.o bbcodeparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o plugindata.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o +o = Kopia config.o acceptbaseparser.o app.o bbcodeparser.o compress.o config.o confparser.o db.o db_itemcolumns.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o plugindata.o postmultiparser.o rebus.o request.o session.o sessioncontainer.o sessionmanager.o sessionparser.o system.o users.o diff --git a/core/app.cpp b/core/app.cpp new file mode 100755 index 0000000..c8c6790 --- /dev/null +++ b/core/app.cpp @@ -0,0 +1,398 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "app.h" +#include "plugin.h" + + + +App::App() +{ + stdout_is_closed = false; + last_sessions_save = time(0); + + plugin.SetDb(&db); + plugin.SetConfig(&config); + plugin.SetRequest(&request); + plugin.SetSystem(&system); + plugin.SetFunctions(&functions); + plugin.SetTemplates(&templates); + plugin.SetSessionManager(&session_manager); + + request.SetConfig(&config); + + functions.SetConfig(&config); + functions.SetRequest(&request); + functions.SetDb(&db); + functions.SetSystem(&system); + functions.SetTemplates(&templates); + functions.SetNotify(¬ify); + + system.SetConfig(&config); + system.SetRequest(&request); + system.SetDb(&db); + system.SetFunctions(&functions); // !! czy model musi cos wiedziec o funkcjach? + system.SetTemplates(&templates); + + templates_notify.SetConfig(&config); + + notify.SetRequest(&request); + notify.SetConfig(&config); + notify.SetSystem(&system); + notify.SetTemplatesNotify(&templates_notify); + + templates.SetConfig(&config); + templates.SetRequest(&request); + templates.SetDb(&db); + templates.SetSystem(&system); + templates.SetFunctions(&functions); + templates.SetSessionManager(&session_manager); + + session_manager.SetLastContainer(&system.users.last); + session_manager.SetConfig(&config); + session_manager.SetRequest(&request); + session_manager.SetSystem(&system); + +} + + + +bool App::CreateFCGISocket() +{ + const char * sock = config.fcgi_socket.c_str(); + + unlink(sock); + + + + int s = FCGX_OpenSocket(sock, 10); + + if( s < 0 ) + { + log << log1 << "An error during creating a socket" << logend; + return false; + } + + + chmod(sock, config.fcgi_socket_chmod); + + passwd * pw = getpwnam(config.fcgi_socket_user.c_str()); + + if( !pw ) + { + log << log1 << "There is no user: " << config.fcgi_socket_user << logend; + return false; + } + + group * gr = getgrnam(config.fcgi_socket_group.c_str()); + + if( !gr ) + { + log << log1 << "There is no group: " << config.fcgi_socket_group << logend; + return false; + } + + chown(sock, pw->pw_uid, gr->gr_gid); + + + if( setuid(pw->pw_uid) < 0 ) + { + log << log1 << "I can't change the user into: " << config.fcgi_socket_user << logend; + return false; + } + + + /* + if( setgid(gr->gr_gid) < 0 ) + { + int e = errno; + + log << log1 << "I can't change the group into: " << config.fcgi_socket_group << " " << gr->gr_gid << logend; + log << log1 << "errno: " << e << logend; + return false; + } + */ + + dup2(s, 0); + +return true; +} + + + +bool App::Init() +{ + request.Init(); + + if( !CreateFCGISocket() ) + return false; + + system.Init(); + + functions.Create(); + + // !! teraz mamy dwa katalogi z templetami + // !! o co chodzilo? + if( !notify.Init() ) + return false; + + + templates.ReadIndexFileNames(); + templates.ReadTemplates(); + templates.CreateFunctions(); + + + session_manager.LoadSessions(); + +return true; +} + + + +void App::Close() +{ + session_manager.SaveSessions(); + session_manager.DeleteAllPluginsData(); +} + + + +bool App::BaseUrlRedirect() +{ + if( request.role == Request::responder ) + { + if( config.base_url_http_host.empty() ) + return false; + + if( config.base_url_http_host == request.env_http_host ) + return false; + + request.redirect_to = config.base_url + request.env_request_uri; + } + else + { + // authorizer + + if( config.base_url_auth_http_host.empty() ) + return false; + + if( config.base_url_auth_http_host == request.env_http_host ) + return false; + + request.redirect_to = config.base_url_auth + request.env_request_uri; + } + + log << log3 << "RC: BaseUrlRedirect from: " << request.env_http_host << logend; + +return true; +} + + +void App::ProcessRequest() +{ + request.Clear(); + request.Read(); + + // 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 + // and then BaseUrlRedirect() will be called (for performance) + if( !BaseUrlRedirect() ) + { + session_manager.DeleteOldSessions(); + session_manager.SetSession(); // set request.session as well + + // !! tutaj dodac to ustawianie request.session + + functions.Parse(); + + system.mounts.CalcCurMount(); + + ReadAdditionalInfo(); + Make(); + } + + request.SendAll(); // !! czemu request sam sie chce wyslac? wrzucic to tutaj do app + notify.ItemChanged(request.notify_code); +} + + + + +void App::Start() +{ + while( FCGX_Accept(&request.in, &request.out, &request.err, &request.env) == 0 ) + { + system.load_avg.StartRequest(); + log << log2 << "---------------------------------------------------------------------------------" << logend; + + try + { + ProcessRequest(); + } + catch(const std::logic_error & e) + { + log << log1 << "std logic exception: " << e.what() << logend; + } + catch(const std::exception & e) + { + log << log1 << "std exception: " << e.what() << logend; + } + catch(const Error & e) + { + log << log1 << "exception: Error: " << e << logend; + } + catch(...) + { + log << log1 << "uncaught unknown exception" << logend; + } + + SaveSessionsIfNeeded(); + + // !! this should be immediately after FCGX_Accept() but signals don't want to break FCGX_Accept + //if( signal_hup ) + if( false ) + { + log << logsave; + FCGX_Finish(); + return; + } + + request.ClearPostFileTmp(); + system.load_avg.StopRequest(); + log << logsave; + } +} + + +void App::SaveSessionsIfNeeded() +{ + time_t t = time(0); + + if( last_sessions_save + 86400 > t ) + return; + + // saving once a day for safety + last_sessions_save = t; + session_manager.SaveSessions(); +} + + + + +// !! zmienic na lepsza nazwe +void App::MakePage() +{ +bool sent = false; + + if( !request.redirect_to.empty() || !request.x_sendfile.empty() ) + return; + + + if( request.is_item && request.item.auth == Item::auth_none && + request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.pfunction ) + { + if( request.pfunction->fun.url == "cat" ) + { + request.page << request.item.content; + sent = true; + } + else + if( request.pfunction->fun.url == "run" ) + { + templates.GenerateRunRaw(); + sent = true; + } + } + + if( !sent ) + { + templates.Generate(); + } +} + + + +void App::Make() +{ + if( request.dir_table.empty() ) + { + log << log1 << "Content: there is no a root dir (dir_table is empty)" << logend; + return; + } + + // request->status can be changed by function_parser + if( request.status == WINIX_ERR_OK ) + { + if( system.DirsHaveReadExecPerm() ) + { + if( request.method == Request::post ) + functions.MakePost(); + + if( request.redirect_to.empty() && request.status == WINIX_ERR_OK ) + functions.MakeGet(); + } + else + request.status = WINIX_ERR_PERMISSION_DENIED; + } + + if( request.session->spam_score > 0 ) + log << log1 << "App: spam score: " << request.session->spam_score << logend; + + if( request.IsParam("noredirect") ) + request.redirect_to.clear(); + + if( !request.redirect_to.empty() ) + return; + + if( request.dir_table.empty() ) + { + log << log1 << "App: there is no a root dir (dir_table is empty -- after calling a function)" << logend; + return; + } + + plugin.Call(WINIX_CONTENT_MAKE); + MakePage(); + + // !! dodac parametr do konfiga wlaczajacy te informacje + //request->PrintGetTable(); + //request->PrintEnv(); + //request->PrintIn(); +} + + + + +// !! dac lepsza nazwe i czy napewno w app to ma byc? +void App::ReadAdditionalInfo() +{ + if( request.dir_table.empty() ) + return; + + if( system.mounts.pmount->type == Mount::thread ) + { + if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == WINIX_ERR_OK ) + request.is_thread = true; + } + else + if( system.mounts.pmount->type == Mount::ticket ) + { + if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == WINIX_ERR_OK ) + { + request.is_ticket = true; + + if( !request.is_item && (!request.pfunction || request.pfunction->fun.url == "ticket") ) + { + db.GetItemById(request.ticket.item_id, request.item); + // don't set request->is_item here + } + } + } +} + + diff --git a/core/app.h b/core/app.h new file mode 100755 index 0000000..64afc33 --- /dev/null +++ b/core/app.h @@ -0,0 +1,111 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucoreapp +#define headerfilecmslucoreapp + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "system.h" +#include "mounts.h" +#include "request.h" +#include "sessionmanager.h" +#include "notify.h" +#include "db.h" +#include "functions/functions.h" +#include "templates/templates.h" +#include "templatesnotify/templatesnotify.h" + + + + +class App +{ +public: + + App(); + + bool Init(); + void Start(); + void Close(); + + + + // configuration read from a config file + Config config; + + // current request + Request request; + + // users sessions + SessionManager session_manager; + + // notifications (by emails) + Notify notify; + + // database + Db db; + + + + + /* + model + */ + + // file system + System system; + + // false at the beginning + bool stdout_is_closed; + + + + + /* + controller + */ + + // functions (ls, cat, emacs, ...) + Functions functions; + + + /* + view + */ + + Templates templates; + TemplatesNotify templates_notify; + + +private: + bool CreateFCGISocket(); + void ProcessRequest(); + bool BaseUrlRedirect(); + void DeleteAllPluginsData(); + void MakePage(); + void Make(); + void ReadAdditionalInfo(); + void SaveSessionsIfNeeded(); // !! wywalic do managara sesji?? + + // !! dodac do session managera? + time_t last_sessions_save; +}; + +#endif + + diff --git a/core/config.cpp b/core/config.cpp index ad3a2e4..fec0988 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -9,7 +9,6 @@ #include "config.h" #include "log.h" -#include "data.h" #include "plugin.h" #include "misc.h" @@ -17,10 +16,6 @@ Config::Config() { - default_str.clear(); - default_int = 0; - default_bool = false; - errors_to_stdout = true; } @@ -33,7 +28,7 @@ Config::Config() void Config::ShowError() { - switch( conf_parser.status ) + switch( parser.status ) { case ConfParser::ok: log << log2 << "Config: syntax ok" << logend; @@ -41,16 +36,16 @@ void Config::ShowError() case ConfParser::cant_open_file: if( errors_to_stdout ) - std::cout << "Config: cant open a config file: " << data.config_file << std::endl; + std::cout << "Config: cant open a config file: " << config_file << std::endl; - log << log1 << "Config: cant open a config file: " << data.config_file << logend; + log << log1 << "Config: cant open a config file: " << config_file << logend; break; case ConfParser::syntax_error: if( errors_to_stdout ) - std::cout << "Config: syntax error, line: " << conf_parser.line << std::endl; + std::cout << "Config: syntax error, line: " << parser.line << std::endl; - log << log1 << "Config: syntax error, line: " << conf_parser.line << logend; + log << log1 << "Config: syntax error, line: " << parser.line << logend; break; } } @@ -60,11 +55,11 @@ void Config::ShowError() -bool Config::ReadConfig(bool errors_to_stdout_) +bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed) { errors_to_stdout = errors_to_stdout_; - if( data.config_file.empty() ) + if( config_file.empty() ) { log << log2 << "Config: name of the config file is empty" << logend; return false; @@ -72,14 +67,14 @@ bool Config::ReadConfig(bool errors_to_stdout_) log << log2 << "Config: reading a config file" << logend; - conf_parser.SplitSingle(true); - ConfParser::Status status = conf_parser.Parse( data.config_file ); + parser.SplitSingle(true); + ConfParser::Status status = parser.Parse( config_file ); if( status == ConfParser::ok ) { - AssignValues(); - data.SetAdditionalVariables(); + AssignValues(stdout_is_closed); + SetAdditionalVariables(); return true; } else @@ -92,177 +87,148 @@ bool Config::ReadConfig(bool errors_to_stdout_) -void Config::AssignValues() +void Config::AssignValues(bool stdout_is_closed) { - data.log_file = Text("log_file"); - data.log_notify_file = Text("log_notify_file"); - data.fcgi_socket = Text("fcgi_socket"); - data.fcgi_socket_chmod = Int("fcgi_socket_chmod", 0770); - data.fcgi_socket_user = Text("fcgi_socket_user"); - data.fcgi_socket_group = Text("fcgi_socket_group"); - data.log_level = Int("log_level", 1); - data.log_request = Int("log_request", 1); + log_file = Text("log_file"); + log_notify_file = Text("log_notify_file"); + fcgi_socket = Text("fcgi_socket"); + fcgi_socket_chmod = Int("fcgi_socket_chmod", 0770); + fcgi_socket_user = Text("fcgi_socket_user"); + fcgi_socket_group = Text("fcgi_socket_group"); + log_level = Int("log_level", 1); + log_request = Int("log_request", 1); + log_stdout = Bool("log_stdout", false); - if( !data.stdout_is_closed ) - data.log_stdout = Bool("log_stdout", false); - else - data.log_stdout = false; + post_file_max = Int("post_file_max", 8388608); // 8 MB + auth_simplefs_dir = Text("auth_simplefs_dir"); + auth_hashfs_dir = Text("auth_hashfs_dir"); + auth_tmp_dir = Text("auth_tmp_dir"); + + templates_dir = Text("templates_dir"); + templates_dir_default = Text("templates_dir_default"); + http_session_id_name = Text("http_session_id_name"); + db_database = Text("db_database"); + db_user = Text("db_user"); + db_pass = Text("db_pass"); + item_url_empty = Text("item_url_empty"); + + base_server = Text("base_server"); + base_url = Text("base_url"); + base_url_auth = Text("base_url_auth"); + base_url_static = Text("base_url_static"); + base_url_common = Text("base_url_common"); + + NoLastSlash(base_server); + NoLastSlash(base_url); + NoLastSlash(base_url_auth); + NoLastSlash(base_url_static); + NoLastSlash(base_url_common); + + priv_no_user = Text("priv_no_user", "-- no user --"); + priv_no_group = Text("priv_no_group", "-- no group --"); - data.post_file_max = Int("post_file_max", 8388608); // 8 MB - data.auth_simplefs_dir = Text("auth_simplefs_dir"); - data.auth_hashfs_dir = Text("auth_hashfs_dir"); - data.auth_tmp_dir = Text("auth_tmp_dir"); + session_max_idle = Int("session_max_idle", 10800); // 3h + session_remember_max_idle = Int("session_remember_max_idle", 16070400); // 3 months + session_file = Text("session_file"); - data.templates_dir = Text("templates_dir"); - data.templates_dir_default = Text("templates_dir_default"); - data.http_session_id_name = Text("http_session_id_name"); - data.db_database = Text("db_database"); - data.db_user = Text("db_user"); - data.db_pass = Text("db_pass"); - data.item_url_empty = Text("item_url_empty"); + compression = Bool("compression", true); + html_filter = Bool("html_filter", true); - data.base_server = Text("base_server"); - data.base_url = Text("base_url"); - data.base_url_auth = Text("base_url_auth"); - data.base_url_static = Text("base_url_static"); - data.base_url_common = Text("base_url_common"); + locale_str = Text("locale", "en"); + locale_dir = Text("locale_dir"); + locale_dir_default = Text("locale_dir_default"); - NoLastSlash(data.base_server); - NoLastSlash(data.base_url); - NoLastSlash(data.base_url_auth); - NoLastSlash(data.base_url_static); - NoLastSlash(data.base_url_common); + title_separator = Text("title_separator", " / "); - data.priv_no_user = Text("priv_no_user", "-- no user --"); - data.priv_no_group = Text("priv_no_group", "-- no group --"); - - data.session_max_idle = Int("session_max_idle", 10800); // 3h - data.session_remember_max_idle = Int("session_remember_max_idle", 16070400); // 3 months - data.session_file = Text("session_file"); - - data.compression = Bool("compression", true); - data.html_filter = Bool("html_filter", true); - - data.locale_str = Text("locale", "en"); - data.locale_dir = Text("locale_dir"); - data.locale_dir_default = Text("locale_dir_default"); - - data.title_separator = Text("title_separator", " / "); - - - ListText(data.plugin_file, "plugins"); + parser.ListText("plugins", plugin_file); } +void Config::SetAdditionalVariables() +{ + SetHttpHost(base_url, base_url_http_host); + SetHttpHost(base_url_auth, base_url_auth_http_host); +} + + + + +void Config::SetHttpHost(const std::string & in, std::string & out) +{ + if( strncmp(in.c_str(), "http://", 7) == 0 ) + out = in.substr(7); + else + if( strncmp(in.c_str(), "https://", 8) == 0 ) + out = in.substr(8); + else + out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done +} std::string Config::Text(const char * name) { - return Text(std::string(name), default_str); + return parser.Text(name); } - std::string Config::Text(const char * name, const char * def) { - return Text(std::string(name), std::string(def)); + return parser.Text(name, def); } std::string Config::Text(const std::string & name, const std::string & def) { - ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name); - - if( i == conf_parser.table_single.end() ) - return def; - -return i->second; + return parser.Text(name, def); } - int Config::Int(const char * name) { - return Int(std::string(name), default_int); + return parser.Int(name); } int Config::Int(const char * name, int def) { - return Int(std::string(name), def); + return parser.Int(name, def); } int Config::Int(const std::string & name, int def) { - ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name); - - if( i == conf_parser.table_single.end() || i->second.empty() ) - return def; - - long res = (i->second[0] == '0')? strtol(i->second.c_str() + 1, 0, 8) : strtol(i->second.c_str(), 0, 10); - -return res; + return parser.Int(name, def); } bool Config::Bool(const char * name) { - return Bool(std::string(name), default_bool); + return parser.Bool(name); } bool Config::Bool(const char * name, bool def) { - return Bool(std::string(name), def); + return parser.Bool(name, def); } bool Config::Bool(const std::string & name, bool def) { - ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name); - - if( i == conf_parser.table_single.end() || i->second.empty() ) - return def; - - bool res = false; - - if( EqualNoCase(i->second.c_str(), "true") || - EqualNoCase(i->second.c_str(), "yes") || - EqualNoCase(i->second.c_str(), "1") - ) - res = true; - -return res; + return parser.Bool(name, def); } -// in lists we don't use default values -void Config::ListText(std::vector & list, const char * name) + +void Config::ListText(const char * name, std::vector & list) { - ListText(list, std::string(name)); + parser.ListText(name, list); } -void Config::ListText(std::vector & list, const std::string & name) +void Config::ListText(const std::string & name, std::vector & list) { - list.clear(); - - ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name); - - if( i != conf_parser.table_single.end() ) - { - list.push_back(i->second); - return; - } - - ConfParser::Table::iterator z = conf_parser.table.find(name); - - if( z != conf_parser.table.end() ) - { - list = z->second; - return; - } + parser.ListText(name, list); } diff --git a/core/config.h b/core/config.h index 4641dff..c20d157 100755 --- a/core/config.h +++ b/core/config.h @@ -11,43 +11,157 @@ #define headerfilecmslucoreconfig #include -#include "../confparser/confparser.h" +#include "confparser.h" class Config { - public: - Config(); - bool ReadConfig(bool errors_to_stdout_); + // name of the config file (full path can be) + std::string config_file; + + // log file name, log file name for notifications (sending emails, etc) + std::string log_file, log_notify_file; + + // 1 - minimum + // 2 - (default) + // 3 - maximum - all logs + int log_level; + + // logging to stdout too + bool log_stdout; + + // how many requests should be logged in the same time + // default: 1 + int log_request; + + // fast cgi: socket (unix domain) + std::string fcgi_socket; + + // fast cgi: socket permissions + int fcgi_socket_chmod; + + // fast cgi: owner of the socket + std::string fcgi_socket_user; + + // fast cgi: group of the socket + std::string fcgi_socket_group; + + std::string templates_dir; + std::string templates_dir_default; // templates from winix + + std::string db_database; + std::string db_user; + std::string db_pass; + + std::string http_session_id_name; + + // when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed) + // the server will redirect into 'base_url' + 'REQUEST_URI' + // it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc. + bool base_url_redirect; + + // string used in a place where is a user (or group) selected + std::string priv_no_user; + std::string priv_no_group; + + // time in seconds when the user will be automatically logged out (iddle time) + int session_max_idle; + + // time in seconds when the user will be automatically logged out (when he selected 'remember me' option) + // this time is usually greater than session_max_idle + int session_remember_max_idle; + + // this file is used when the program is starting and ending + std::string session_file; + + // allow the html ouput to be compressed + bool compression; + + // plugins + std::vector plugin_file; + + // the html code is cleaned by our filter + bool html_filter; + + // the url of a new empty item (if there is not the subject too) + std::string item_url_empty; + + // maximum length of a file send by post multipart form + // 0 - not used + int post_file_max; + + // directories for static files + std::string auth_simplefs_dir; + std::string auth_hashfs_dir; + + // temporary directory for static content used by the upload function + // should be on the same partition as auth_simplefs_dir and auth_hashfs_dir + std::string auth_tmp_dir; + + // default locale: en pl + std::string locale_str; + + // directory with locale files + std::string locale_dir; + + // directory with default locale files (those from winix) + std::string locale_dir_default; + + // the main address of the server (e.g. someserver.com) (without the 'www' part etc) + std::string base_server; + + // the main address of the site (e.g. http://www.someserver.com) + std::string base_url; + + // static content authorized by winix + std::string base_url_auth; + + // static content not authorized by winix + std::string base_url_static; + + // additional static server for common content (not authorized) + std::string base_url_common; + + // separator used in html tag + std::string title_separator; + + + // based on base_url + // set by SetAdditionalVariables() + // without the first part http:// (or https://) or the whole string is empty + std::string base_url_http_host; + std::string base_url_auth_http_host; + + + Config(); + bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true); std::string Text(const char * name); std::string Text(const char * name, const char * def); std::string Text(const std::string & name, const std::string & def); - int Int(const char *); int Int(const char * name, int def); int Int(const std::string & name, int def); - bool Bool(const char *); bool Bool(const char * name, bool def); bool Bool(const std::string & name, bool def); - - void ListText(std::vector<std::string> & list, const char * name); - void ListText(std::vector<std::string> & list, const std::string & name); + void ListText(const char * name, std::vector<std::string> & list); + void ListText(const std::string & name, std::vector<std::string> & list); void NoLastSlash(std::string & s); void NoFirstHttp(std::string & s); - - private: - ConfParser conf_parser; void ShowError(); - void AssignValues(); + void AssignValues(bool stdout_is_closed); + void SetHttpHost(const std::string & in, std::string & out); + void SetAdditionalVariables(); + + ConfParser parser; std::string default_str; int default_int; @@ -58,7 +172,7 @@ private: }; -extern Config config; + diff --git a/confparser/confparser.cpp b/core/confparser.cpp similarity index 67% rename from confparser/confparser.cpp rename to core/confparser.cpp index 37bd555..f4599e7 100755 --- a/confparser/confparser.cpp +++ b/core/confparser.cpp @@ -8,7 +8,7 @@ */ #include "confparser.h" - +#include "misc.h" @@ -24,6 +24,10 @@ ConfParser::ConfParser() list_delimiter = ','; split_single = false; skip_empty = false; + + default_str = ""; + default_int = 0; + default_bool = false; } @@ -377,3 +381,161 @@ std::string::size_type i; + + + +std::string ConfParser::Text(const char * name) +{ + return Text(std::string(name), default_str); +} + + + +std::string ConfParser::Text(const char * name, const char * def) +{ + return Text(std::string(name), std::string(def)); +} + + +std::string ConfParser::Text(const std::string & name, const std::string & def) +{ + TableSingle::iterator i = table_single.find(name); + + if( i == table_single.end() ) + { + Table::iterator t = table.find(name); + + if( t == table.end() || t->second.empty() ) + return def; + + return t->second[0]; + } + +return i->second; +} + + + +int ConfParser::Int(const char * name) +{ + return Int(std::string(name), default_int); +} + + +int ConfParser::Int(const char * name, int def) +{ + return Int(std::string(name), def); +} + + +int ConfParser::ToInt(const std::string & value) +{ + long res = (value[0] == '0')? strtol(value.c_str() + 1, 0, 8) : strtol(value.c_str(), 0, 10); + +return res; +} + + +int ConfParser::Int(const std::string & name, int def) +{ + TableSingle::iterator i = table_single.find(name); + + if( i == table_single.end() ) + { + Table::iterator t = table.find(name); + + if( t == table.end() || t->second.empty() ) + return def; + + return ToInt(t->second[0]); + } + +return ToInt(i->second); +} + + +bool ConfParser::Bool(const char * name) +{ + return Bool(std::string(name), default_bool); +} + + +bool ConfParser::Bool(const char * name, bool def) +{ + return Bool(std::string(name), def); +} + + +bool ConfParser::ToBool(const std::string & value) +{ + return ( EqualNoCase(value.c_str(), "true") || + EqualNoCase(value.c_str(), "yes") || + EqualNoCase(value.c_str(), "1") + ); +} + + +bool ConfParser::Bool(const std::string & name, bool def) +{ + TableSingle::iterator i = table_single.find(name); + + if( i == table_single.end() ) + { + Table::iterator t = table.find(name); + + if( t == table.end() || t->second.empty() ) + return def; + + return ToBool(t->second[0]); + } + +return ToBool(i->second); +} + + +void ConfParser::SetDefaultText(const std::string & def) +{ + default_str = def; +} + +void ConfParser::SetDefaultInt(int def) +{ + default_int = def; +} + +void ConfParser::SetDefaultBool(bool def) +{ + default_bool = def; +} + + + + +// in lists we don't use default values +void ConfParser::ListText(const char * name, std::vector<std::string> & list) +{ + ListText(std::string(name), list); +} + + +void ConfParser::ListText(const std::string & name, std::vector<std::string> & list) +{ + list.clear(); + + ConfParser::TableSingle::iterator i = table_single.find(name); + + if( i != table_single.end() ) + { + list.push_back(i->second); + return; + } + + ConfParser::Table::iterator z = table.find(name); + + if( z != table.end() ) + { + list = z->second; + return; + } +} + diff --git a/confparser/confparser.h b/core/confparser.h similarity index 81% rename from confparser/confparser.h rename to core/confparser.h index 8bfaf6b..572a47f 100755 --- a/confparser/confparser.h +++ b/core/confparser.h @@ -202,8 +202,45 @@ public: void SkipEmpty(bool skip); + /* + those methods are used to extract information from table or table_single + as a parameter they take the name of an option + and a default value (if there is no such a parameter), + they return appropriate value (either text, int or boolean) + (in lists they return the first item if exists) + */ + std::string Text(const char * name); + std::string Text(const char * name, const char * def); + std::string Text(const std::string & name, const std::string & def); + int Int(const char *); + int Int(const char * name, int def); + int Int(const std::string & name, int def); + bool Bool(const char *); + bool Bool(const char * name, bool def); + bool Bool(const std::string & name, bool def); + /* + some default values + used in Text() Int() or Bool() when you don't explicitly set the default value + + if you don't set it directly then: + default text is: "" (empty) + default int is: 0 + default bool is: false + */ + void SetDefaultText(const std::string & def); + void SetDefaultInt(int def); + void SetDefaultBool(bool def); + + + /* + those methods are used to extract lists + note: if there is one option in table_single they will return it + */ + void ListText(const char * name, std::vector<std::string> & list); + void ListText(const std::string & name, std::vector<std::string> & list); + private: @@ -284,6 +321,14 @@ private: bool skip_empty; + + std::string default_str; + int default_int; + bool default_bool; + + int ToInt(const std::string & value); + bool ToBool(const std::string & value); + Status ParseFile(); void AddOption(); diff --git a/core/data.cpp b/core/data.cpp deleted file mode 100755 index 9306972..0000000 --- a/core/data.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "data.h" - - - - - -Data::Data() -{ - signal_hup = false; - stdout_is_closed = false; - how_many_logged = 0; - - // the rest will be read from a config file -} - - - -void Data::SetAdditionalVariables() -{ - SetHttpHost(base_url, base_url_http_host); - SetHttpHost(base_url_auth, base_url_auth_http_host); -} - - - -void Data::SetHttpHost(const std::string & in, std::string & out) -{ - if( strncmp(in.c_str(), "http://", 7) == 0 ) - out = in.substr(7); - else - if( strncmp(in.c_str(), "https://", 8) == 0 ) - out = in.substr(8); - else - out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done -} diff --git a/core/data.h b/core/data.h deleted file mode 100755 index 0d3dee3..0000000 --- a/core/data.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#ifndef headerfilecmslucoredata -#define headerfilecmslucoredata - -#include <string> -#include <vector> -#include <map> -#include <string.h> - -#include "dirs.h" -#include "users.h" -#include "groups.h" -#include "functions.h" -#include "lastcontainer.h" -#include "mounts.h" -#include "rebus.h" -#include "loadavg.h" - - -class Data -{ -public: - - // ----------------------------------------------------------------- - // members read from a config file - - // name of the config file (full path can be) - std::string config_file; - - // log file name, log file name for notifications (sending emails, etc) - std::string log_file, log_notify_file; - - // 1 - minimum - // 2 - (default) - // 3 - maximum - all logs - int log_level; - - // logging to stdout too - bool log_stdout; - - // how many requests should be logged in the same time - // default: 1 - int log_request; - - // fast cgi: socket (unix domain) - std::string fcgi_socket; - - // fast cgi: socket permissions - int fcgi_socket_chmod; - - // fast cgi: owner of the socket - std::string fcgi_socket_user; - - // fast cgi: group of the socket - std::string fcgi_socket_group; - - std::string templates_dir; - std::string templates_dir_default; // templates from winix - - std::string db_database; - std::string db_user; - std::string db_pass; - - std::string http_session_id_name; - - // when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed) - // the server will redirect into 'base_url' + 'REQUEST_URI' - // it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc. - bool base_url_redirect; - - // string used in a place where is a user (or group) selected - std::string priv_no_user; - std::string priv_no_group; - - // time in seconds when the user will be automatically logged out (iddle time) - int session_max_idle; - - // time in seconds when the user will be automatically logged out (when he selected 'remember me' option) - // this time is usually greater than session_max_idle - int session_remember_max_idle; - - // this file is used when the program is starting and ending - std::string session_file; - - // allow the html ouput to be compressed - bool compression; - - // plugins - std::vector<std::string> plugin_file; - - // the html code is cleaned by our filter - bool html_filter; - - // the url of a new empty item (if there is not the subject too) - std::string item_url_empty; - - // maximum length of a file send by post multipart form - // 0 - not used - int post_file_max; - - // directories for static files - std::string auth_simplefs_dir; - std::string auth_hashfs_dir; - - // temporary directory for static content used by the upload function - // should be on the same partition as auth_simplefs_dir and auth_hashfs_dir - std::string auth_tmp_dir; - - // default locale: en pl - std::string locale_str; - - // directory with locale files - std::string locale_dir; - - // directory with default locale files (those from winix) - std::string locale_dir_default; - - // the main address of the server (e.g. someserver.com) (without the 'www' part etc) - std::string base_server; - - // the main address of the site (e.g. http://www.someserver.com) - std::string base_url; - - // static content authorized by winix - std::string base_url_auth; - - // static content not authorized by winix - std::string base_url_static; - - // additional static server for common content (not authorized) - std::string base_url_common; - - // separator used in <title> html tag - std::string title_separator; - - - - // end config members - // ----------------------------------------------------------------- - - - - // false at the beginning - bool stdout_is_closed; - - // true if there was SIGHUP signal - volatile bool signal_hup; - - // contains current directories tree - Dirs dirs; - - // based on base_url - // set by SetAdditionalVariables() - // without the first part http:// (or https://) or the whole string is empty - std::string base_url_http_host; - std::string base_url_auth_http_host; - - - - // call this method after the config file is read - void SetAdditionalVariables(); - - - - // users - Users users; - - // groups - Groups groups; - - // functions (ls, cat, etc) - Functions functions; - - // for 'last' function - LastContainer last; - - // mount points - Mounts mounts; - - // rebus (captcha) - Rebus rebus; - - // the time when the winix starts - time_t system_start; - - // how many logged users - long how_many_logged; - - // load averages - LoadAvg load_avg; - - Data(); - - -private: - void SetHttpHost(const std::string & in, std::string & out); -}; - - - - -extern Data data; - - -#endif diff --git a/core/db.h b/core/db.h index 9755eb4..174d24c 100755 --- a/core/db.h +++ b/core/db.h @@ -249,7 +249,7 @@ protected: }; // class Db -extern Db db; + #endif diff --git a/core/dirs.cpp b/core/dirs.cpp index 6ab883c..72f88a5 100755 --- a/core/dirs.cpp +++ b/core/dirs.cpp @@ -10,9 +10,19 @@ #include "dirs.h" #include "error.h" #include "log.h" -#include "db.h" -#include "data.h" -#include "request.h" + + + +void Dirs::SetDb(Db * pdb) +{ + db = pdb; +} + + +void Dirs::SetRequest(Request * prequest) +{ + request = prequest; +} void Dirs::Clear() @@ -21,6 +31,12 @@ void Dirs::Clear() } +bool Dirs::HasReadExecAccessForRoot(const Item & item) +{ + // there must be at least one 'x' (for the root) + return (item.privileges & 01111) != 0; // !! in the future there'll be another 'x' +} + void Dirs::CheckRootDir() { @@ -28,11 +44,11 @@ void Dirs::CheckRootDir() if( i != dir_table.End() ) { - if( !request.HasReadExecAccessForRoot(*i) ) + if( !HasReadExecAccessForRoot(*i) ) { i->privileges = 0755; log << log1 << "Dirs: there is no access for root (admin) to the root dir, setting 0755 for root dir" << logend; - db.EditPrivById(*i, i->id); + db->EditPrivById(*i, i->id); } return; @@ -52,7 +68,7 @@ void Dirs::CheckRootDir() // !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url) // !! zrobic jakis wyjatek do wprowadzania roota? - if( db.AddItem(root) == WINIX_ERR_OK ) + if( db->AddItem(root) == WINIX_ERR_OK ) { dir_table.PushBack(root); } @@ -65,7 +81,7 @@ void Dirs::ReadDirs() { Clear(); - db.GetDirs(dir_table); + db->GetDirs(dir_table); CheckRootDir(); dir_table.FindSpecialFolders(); } @@ -301,7 +317,7 @@ size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, st for( ; i<path.size() && path[i] != '/' ; ++i) analyze_temp += path[i]; - pdir = data.dirs.GetDir(analyze_temp, pdir->id); + pdir = GetDir(analyze_temp, pdir->id); if( !pdir ) return old_i; // analyze_temp is not a directory @@ -327,7 +343,7 @@ size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, st */ int Dirs::AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file) { - Item * pdir = data.dirs.GetRootDir(); + Item * pdir = GetRootDir(); dir = '/'; file.clear(); @@ -386,13 +402,30 @@ void Dirs::SplitPath(const std::string & path, std::string & dir, std::string & } - +// !! dodac kasowanie z bazy bool Dirs::DelDir(long dir_id) { return dir_table.DelById(dir_id); } +Error Dirs::AddDirectory(Item & item, bool add_to_dir_table) +{ + if( item.type != Item::dir ) + return WINIX_ERR_DIR_EXPECTED; + + Error status = db->AddItem(item); + + if( status == WINIX_ERR_OK ) + { + Item * pdir = AddDir(item); + + if( add_to_dir_table && request->dir_table.back()->id == item.parent_id ) + request->dir_table.push_back(pdir); + } + +return status; +} diff --git a/core/dirs.h b/core/dirs.h index 05e8e2c..90cc811 100755 --- a/core/dirs.h +++ b/core/dirs.h @@ -17,6 +17,8 @@ #include "item.h" #include "dircontainer.h" +#include "db.h" +#include "request.h" // we do not support '..' in a path (for simplicity and security reasons) @@ -28,7 +30,9 @@ public: void Clear(); void ReadDirs(); - + + void SetRequest(Request * prequest); + void SetDb(Db * pdb); // these methods return false if there is no such a dir bool IsDir(long dir_id); @@ -47,6 +51,7 @@ public: // these methods return null if there is no such a dir + // !! zmienic nazwy wskazujace ze operujemy tylko na lokalnej tablicy Item * GetRootDir(); Item * GetEtcDir(); Item * GetDir(const std::string & name, long parent); @@ -56,16 +61,22 @@ public: void CheckRootDir(); + + // !! jak juz wczesniejsze nazwy beda zmienione to tutaj damy AddDir() + Error AddDirectory(Item & item, bool add_to_dir_table = false); private: + Request * request; + Db * db; + DirContainer dir_table; size_t AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir); std::string analyze_temp; bool ExtractName(const char * & s, std::string & name); - + bool HasReadExecAccessForRoot(const Item & item); }; diff --git a/core/error.h b/core/error.h index 479938f..eff50df 100755 --- a/core/error.h +++ b/core/error.h @@ -64,9 +64,11 @@ #define WINIX_ERR_DB_MORE_THAN_ONE_LOGIN 105 #define WINIX_ERR_DB_ERR_CURRVAL 106 +#define WINIX_ERR_FILE_EXPECTED 107 +#define WINIX_ERR_DIR_EXPECTED 108 //#define WINIX_ERR_UNKNOWN 1000 - +#define WINIX_NOTHING_TO_DO 109 typedef int Error; diff --git a/core/function.cpp b/core/function.cpp deleted file mode 100755 index c3107ea..0000000 --- a/core/function.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "function.h" - - - -Function::Function() -{ - code = FUN_NONE; -} - -void Function::Clear() -{ - code = FUN_NONE; - item.Clear(); -} - - -Function::Function(const Function & f) -{ - code = f.code; - item = f.item; -} - - - -Function & Function::operator=(const Function & f) -{ - code = f.code; - item = f.item; - -return *this; -} - - - - - - - - - - - - - - - - - - - diff --git a/core/function.h b/core/function.h deleted file mode 100755 index a37392c..0000000 --- a/core/function.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#ifndef headerfilecmslucorefunction -#define headerfilecmslucorefunction - -#include <iostream> -#include "item.h" - - -#define FUN_NONE 0 -#define FUN_LS 1 -#define FUN_CAT 2 -#define FUN_NODE 3 -#define FUN_EMACS 4 -#define FUN_MKDIR 5 -#define FUN_DEFAULT 6 -#define FUN_PRIV 7 -#define FUN_RM 8 -#define FUN_LOGIN 9 -#define FUN_LOGOUT 10 -#define FUN_RUN 11 -#define FUN_WHO 12 -#define FUN_LAST 13 -#define FUN_CREATETHREAD 14 -#define FUN_THREAD 15 -#define FUN_RELOAD 16 -#define FUN_UPLOAD 17 -#define FUN_CREATETICKET 18 -#define FUN_EDITTICKET 19 -#define FUN_TICKET 20 -#define FUN_UPTIME 21 -#define FUN_MV 23 -#define FUN_UNAME 24 -#define FUN_CHMOD 25 -#define FUN_CHOWN 26 -#define FUN_CKEDITOR 27 -#define FUN_DOWNLOAD 28 -#define FUN_ADDUSER 29 -#define FUN_SUBJECT 30 -#define FUN_CP 31 -#define FUN_TINYMCE 32 - - - -class Function -{ - -public: - - int code; - Item item; - - void Clear(); - - Function(); - Function(const Function & f); - Function & operator=(const Function & f); - -}; - - - - -#endif diff --git a/core/functioncodeparser.cpp b/core/functioncodeparser.cpp deleted file mode 100755 index eeabf1e..0000000 --- a/core/functioncodeparser.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "functioncodeparser.h" -#include "function.h" -#include "log.h" - - - -bool FunctionCodeParser::ContentHasOneRow(const Item & item) -{ - for(size_t i=0 ; i<item.content.size() ; ++i) - if( item.content[i] == '\n' ) - return false; - -return true; -} - - -int FunctionCodeParser::ParseValue(const char * s) -{ - if( strncmp(s, "[fun:", 5) != 0 ) - return FUN_NONE; - - const char * send; - int result = strtol(s+5, (char**)&send, 10); - - if( send==s+5 || strcmp(send, "]") != 0 ) - return FUN_NONE; - - log << log2 << "FCP: function code: " << result << logend; - -return result; -} - - - - - - -int FunctionCodeParser::Parse(const Item & item) -{ - // format: [fun:1] - // minimum size: 7 characters - if( item.content.size() < 7 ) - return FUN_NONE; - - if( !ContentHasOneRow(item) ) - return FUN_NONE; - - return ParseValue(item.content.c_str()); -} diff --git a/core/functioncodeparser.h b/core/functioncodeparser.h deleted file mode 100755 index a335b3f..0000000 --- a/core/functioncodeparser.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#ifndef headerfilecmslucorefunctioncodeparser -#define headerfilecmslucorefunctioncodeparser - -#include <cstring> -#include <cstdlib> - -#include "item.h" - - -class FunctionCodeParser -{ - bool ContentHasOneRow(const Item & item); - int ParseValue(const char * s); - - -public: - - int Parse(const Item & item); - -}; - - - - -#endif diff --git a/core/functions.cpp b/core/functions.cpp deleted file mode 100755 index 2e13008..0000000 --- a/core/functions.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "functions.h" - - - - - - - -void Functions::Clear() -{ - table.clear(); -} - - - -void Functions::AddFun(int code, const char * url) -{ - fun.code = code; - fun.item.url = url; - table.insert( std::make_pair(fun.item.url, fun) ); -} - - - -// in the future we will read these functions from the database -void Functions::ReadFunctions() -{ - Clear(); - - fun.item.user_id = -1; - fun.item.group_id = -1; - fun.item.privileges = 0755; - fun.item.parent_id = -1; // !! temporarily doesn't matter - fun.item.id = -1; - fun.item.type = Item::file; - - - AddFun(FUN_LS, "ls"); - AddFun(FUN_CAT, "cat"); - AddFun(FUN_NODE, "node"); - AddFun(FUN_EMACS, "emacs"); - AddFun(FUN_MKDIR, "mkdir"); - AddFun(FUN_DEFAULT, "default"); - AddFun(FUN_PRIV, "priv"); - AddFun(FUN_RM, "rm"); - AddFun(FUN_LOGOUT, "logout"); - AddFun(FUN_LOGIN, "login"); - AddFun(FUN_RUN, "run"); - AddFun(FUN_WHO, "who"); - AddFun(FUN_LAST, "last"); - AddFun(FUN_CREATETHREAD, "createthread"); - AddFun(FUN_THREAD, "thread"); - AddFun(FUN_UPLOAD, "upload"); - AddFun(FUN_CREATETICKET, "createticket"); - AddFun(FUN_EDITTICKET, "editticket"); - AddFun(FUN_TICKET, "ticket"); - AddFun(FUN_UPTIME, "uptime"); - AddFun(FUN_MV, "mv"); - AddFun(FUN_UNAME, "uname"); - AddFun(FUN_CHMOD, "chmod"); - AddFun(FUN_CHOWN, "chown"); - AddFun(FUN_CKEDITOR, "ckeditor"); - AddFun(FUN_DOWNLOAD, "download"); - AddFun(FUN_ADDUSER, "adduser"); - AddFun(FUN_SUBJECT, "subject"); - AddFun(FUN_CP, "cp"); - AddFun(FUN_TINYMCE, "tinymce"); - - - // functions which need more privileges - fun.item.privileges = 0700; - - AddFun(FUN_RELOAD, "reload"); -} - - - - - -Function * Functions::GetFunction(const std::string & name) -{ -Table::iterator i = table.find(name); - - if( i == table.end() ) - return 0; - -return &(i->second); -} - - -// !! in the future there will be a special container where we can search through the Code object -Function * Functions::GetFunction(int code) -{ -Table::iterator i = table.begin(); - - for( ; i != table.end() ; ++i ) - { - if( i->second.code == code ) - return &(i->second); - } - - -return 0; -} - - - - - - - - - - - - - - diff --git a/core/functions.h b/core/functions.h deleted file mode 100755 index de2ee2c..0000000 --- a/core/functions.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#ifndef headerfilecmslucorefunctions -#define headerfilecmslucorefunctions - -#include <map> -#include <string> - -#include "function.h" - - - -class Functions -{ - -typedef std::map<std::string, Function> Table; -Table table; - -Function fun; - - void AddFun(int code, const char * url); - -public: - - - void Clear(); - void ReadFunctions(); - - Function * GetFunction(const std::string & name); - Function * GetFunction(int code); - -}; - - - -#endif diff --git a/core/groups.cpp b/core/groups.cpp index d084ada..ed28302 100755 --- a/core/groups.cpp +++ b/core/groups.cpp @@ -8,7 +8,6 @@ */ #include "groups.h" -#include "db.h" @@ -25,11 +24,11 @@ void Groups::Clear() } -void Groups::ReadGroups() +void Groups::ReadGroups(Db * db) { Clear(); - db.GetGroups(table); + db->GetGroups(table); } diff --git a/core/groups.h b/core/groups.h index b2badfe..a269a67 100755 --- a/core/groups.h +++ b/core/groups.h @@ -14,6 +14,8 @@ #include "group.h" #include "ugcontainer.h" +#include "db.h" + class Groups @@ -29,7 +31,7 @@ public: Groups(); void Clear(); - void ReadGroups(); + void ReadGroups(Db * db); Group * GetGroup(long group_id); Group * GetGroup(const std::string & name); long GetGroupId(const std::string & name); diff --git a/core/locale.h b/core/locale.h index 7010027..4a1fc73 100755 --- a/core/locale.h +++ b/core/locale.h @@ -10,12 +10,12 @@ #ifndef headerfilecmslucorelocale #define headerfilecmslucorelocale -#include "../confparser/confparser.h" +#include "confparser.h" #include <vector> #include <string> - +// !! locale nie powinny byc w templates? class Locale { public: diff --git a/core/misc.cpp b/core/misc.cpp index c69d250..f071291 100755 --- a/core/misc.cpp +++ b/core/misc.cpp @@ -11,7 +11,7 @@ #include <sys/stat.h> #include "misc.h" #include "log.h" -#include "data.h" + @@ -100,17 +100,18 @@ void CorrectUrlOnlyAllowedChar(std::string & url) if( url.empty() || url == "." ) { - if( data.item_url_empty.empty() ) + // !! brakuje config-> + //if( config->item_url_empty.empty() ) url = "unnamed"; - else - { - url = data.item_url_empty; + //else + //{ + // url = config->item_url_empty; - CorrectUrlDots(url); - CorrectUrlChars(url); - ToSmall(url); + // CorrectUrlDots(url); + // CorrectUrlChars(url); + // ToSmall(url); // we don't trim here and the string will not be empty - } + //} } if( url[0] >= '0' && url[0] <= '9' ) diff --git a/core/mountparser.cpp b/core/mountparser.cpp index 65b9037..bd81ad6 100755 --- a/core/mountparser.cpp +++ b/core/mountparser.cpp @@ -8,11 +8,16 @@ */ #include "mountparser.h" -#include "data.h" #include "log.h" #include "misc.h" +void MountParser::SetDirs(Dirs * pdirs) +{ + dirs = pdirs; +} + + bool MountParser::IsWhite(int c) { if( c==' ' || c=='\t' || c==13 || c==160 ) @@ -229,7 +234,7 @@ void MountParser::ReadMountPoint() { ReadWord(temp); - pdir = data.dirs.GetDir(temp); + pdir = dirs->GetDir(temp); if( pdir ) { diff --git a/core/mountparser.h b/core/mountparser.h index 0f8106a..780c96c 100755 --- a/core/mountparser.h +++ b/core/mountparser.h @@ -19,6 +19,7 @@ #include "mount.h" #include "item.h" #include "error.h" +#include "dirs.h" @@ -27,10 +28,12 @@ class MountParser public: Error Parse(const std::string & input, std::map<long, Mount> & output); - + void SetDirs(Dirs * pdirs); private: + Dirs * dirs; + bool IsWhite(int c); void SkipWhite(); void SkipLine(); diff --git a/core/mounts.cpp b/core/mounts.cpp index e3788bd..58b61d0 100755 --- a/core/mounts.cpp +++ b/core/mounts.cpp @@ -8,7 +8,6 @@ */ #include "mounts.h" -#include "data.h" #include "request.h" #include "log.h" #include "mountparser.h" @@ -23,12 +22,29 @@ Mounts::Mounts() } +void Mounts::SetDirs(Dirs * pdirs) +{ + dirs = pdirs; +} + + +void Mounts::SetDb(Db * pdb) +{ + db = pdb; +} + +void Mounts::SetRequest(Request * prequest) +{ + request = prequest; +} + // reading from 'mounts' Error Mounts::ReadMounts(const std::string & mounts) { MountParser mp; + mp.SetDirs(dirs); Error err = mp.Parse(mounts, mount_tab); if( err != WINIX_ERR_OK ) @@ -49,7 +65,7 @@ Error Mounts::ReadMounts() { static std::string file = "fstab"; - Item * etc = data.dirs.GetEtcDir(); + Item * etc = dirs->GetEtcDir(); if( !etc ) { @@ -58,7 +74,7 @@ Error Mounts::ReadMounts() } Item fstab; - Error err = db.GetItem(etc->id, file, fstab); + Error err = db->GetItem(etc->id, file, fstab); if( err == WINIX_ERR_NO_ITEM ) { @@ -82,7 +98,7 @@ void Mounts::MountCmsForRoot() mount.type = Mount::cms; mount.fs = Mount::simplefs; - Item * proot = data.dirs.GetRootDir(); + Item * proot = dirs->GetRootDir(); if( proot ) mount.dir_id = proot->id; @@ -105,10 +121,10 @@ std::vector<Item*>::reverse_iterator i; // when the program starts (when the dir_table is empty() // we don't want to call MountCmsForRoot() - if( request.dir_table.empty() ) + if( request->dir_table.empty() ) return; - for(i = request.dir_table.rbegin() ; i!=request.dir_table.rend() ; ++i) + for(i = request->dir_table.rbegin() ; i!=request->dir_table.rend() ; ++i) { std::map<long, Mount>::iterator m = mount_tab.find( (*i)->id ); @@ -135,7 +151,7 @@ Mount * Mounts::CalcMount(long dir_id) { while( true ) { - Item * pdir = data.dirs.GetDir(dir_id); + Item * pdir = dirs->GetDir(dir_id); if( !pdir ) return 0; diff --git a/core/mounts.h b/core/mounts.h index c6664ba..c13788f 100755 --- a/core/mounts.h +++ b/core/mounts.h @@ -16,12 +16,20 @@ #include <string> #include "mount.h" #include "error.h" +#include "dirs.h" +#include "db.h" +#include "request.h" + class Mounts { public: + void SetDirs(Dirs * pdirs); + void SetDb(Db * pdb); + void SetRequest(Request * prequest); + // dir_id, mount_point typedef std::map<long, Mount> MountTab; @@ -41,6 +49,10 @@ public: private: + Dirs * dirs; + Db * db; + Request * request; + MountTab mount_tab; void MountCmsForRoot(); diff --git a/core/notify.cpp b/core/notify.cpp index 2fe07b7..7a03fc5 100755 --- a/core/notify.cpp +++ b/core/notify.cpp @@ -14,7 +14,6 @@ #include "log.h" #include "notify.h" -#include "data.h" #include "misc.h" #include "request.h" @@ -26,6 +25,30 @@ Notify * Notify::obj; +void Notify::SetRequest(Request * prequest) +{ + request = prequest; +} + + +void Notify::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + +void Notify::SetSystem(System * psystem) +{ + system = psystem; +} + +void Notify::SetTemplatesNotify(TemplatesNotify * ptemplates_notify) +{ + templates_notify = ptemplates_notify; +} + + + /* methods for the second thread @@ -71,10 +94,10 @@ void Notify::SendEmail(NotifyMsg & n) TemplatesNotifyFunctions::notify_msg = &n; obj->Lock(); // templates can be reloaded from the first thread - obj->templates_notify.Generate(n.lang); + obj->templates_notify->Generate(n.lang); obj->Unlock(); - SendEmail(n.email, obj->templates_notify.notify_str.str()); + SendEmail(n.email, obj->templates_notify->notify_str.str()); } @@ -142,7 +165,7 @@ void Notify::ReadTemplates() // the second thread can use our templates and we must Lock() // (the second thread is using Lock() too) Lock(); - templates_notify.Read(); + templates_notify->Read(); Unlock(); } @@ -150,7 +173,7 @@ void Notify::ReadTemplates() bool Notify::Init() { - templates_notify.CreateFunctions(); + templates_notify->CreateFunctions(); int t = pthread_create(&thread, 0, ThreadRoutine, (void*)this); @@ -188,9 +211,9 @@ void Notify::CreateItemDir(std::string & dir, bool clear) if( clear ) dir.clear(); - for(size_t a=0 ; a<request.dir_table.size() ; ++a) + for(size_t a=0 ; a<request->dir_table.size() ; ++a) { - dir += request.dir_table[a]->url; + dir += request->dir_table[a]->url; dir += '/'; } } @@ -198,9 +221,9 @@ void Notify::CreateItemDir(std::string & dir, bool clear) void Notify::CreateItemLink(std::string & link) { - link = data.base_url; + link = config->base_url; CreateItemDir(link, false); - link += request.item.url; + link += request->item.url; } @@ -213,8 +236,8 @@ Users::Iterator i; return; n.notify_code = notify_code; - n.current_mount_type = data.mounts.pmount->type; - n.doc_base_url = data.base_url; + n.current_mount_type = system->mounts.pmount->type; + n.doc_base_url = config->base_url; CreateItemDir(n.item_dir); CreateItemLink(n.item_link); @@ -225,17 +248,17 @@ Users::Iterator i; { // don't clear notify_pool here -- it is used (and will be cleared) by the second thread - for(i=data.users.Begin() ; i != data.users.End() ; ++i) + for(i=system->users.Begin() ; i != system->users.End() ; ++i) { sending = false; - if( data.mounts.pmount->type == Mount::thread ) + if( system->mounts.pmount->type == Mount::thread ) { if( (i->thread_notify & notify_code) != 0 ) sending = true; } else - if( data.mounts.pmount->type == Mount::cms ) + if( system->mounts.pmount->type == Mount::cms ) { if( (i->cms_notify & notify_code) != 0 ) sending = true; @@ -244,7 +267,7 @@ Users::Iterator i; if( sending ) { n.email = i->email; - n.lang = Locale::StrToLang(data.locale_str);// !! bedzie osobno dla kazdego uzytkownika + n.lang = Locale::StrToLang(config->locale_str);// !! bedzie osobno dla kazdego uzytkownika if( n.lang == Locale::lang_unknown ) n.lang = Locale::lang_en; diff --git a/core/notify.h b/core/notify.h index f23d12a..94f21b7 100755 --- a/core/notify.h +++ b/core/notify.h @@ -13,7 +13,12 @@ #include <list> #include <string> #include <cstdio> -#include "../templatesnotify/templatesnotify.h" +#include "templatesnotify/templatesnotify.h" + +#include "request.h" +#include "config.h" +#include "system.h" +#include "users.h" #define WINIX_NOTIFY_ITEM_ADD 1 @@ -30,6 +35,11 @@ public: Notify(); ~Notify(); + void SetRequest(Request * prequest); + void SetConfig(Config * pconfig); + void SetSystem(System * psystem); + void SetTemplatesNotify(TemplatesNotify * ptemplates_notify); + void ReadTemplates(); bool Init(); @@ -43,6 +53,10 @@ public: private: + Request * request; + Config * config; + System * system; + TemplatesNotify * templates_notify; static void * ThreadRoutine(void * arg); bool Lock(); @@ -66,12 +80,12 @@ private: std::list<NotifyMsg> notify_pool; static Notify * obj; std::string command; - TemplatesNotify templates_notify; + }; -extern Notify notify; + #endif diff --git a/core/plugin.cpp b/core/plugin.cpp index 7821a6d..1ce5cc8 100755 --- a/core/plugin.cpp +++ b/core/plugin.cpp @@ -30,6 +30,15 @@ size_t i; Plugin::Plugin() { current_plugin = -1; + request = 0; + + db = 0; + config = 0; + request = 0; + system = 0; + functions = 0; + templates = 0; + session_manager = 0; } @@ -39,6 +48,67 @@ Plugin::~Plugin() } +void Plugin::SetDb(Db * pdb) +{ + db = pdb; +} + +void Plugin::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + +void Plugin::SetRequest(Request * prequest) +{ + request = prequest; +} + + +void Plugin::SetSystem(System * psystem) +{ + system = psystem; +} + + +void Plugin::SetFunctions(Functions * pfunctions) +{ + functions = pfunctions; +} + + +void Plugin::SetTemplates(Templates * ptemplates) +{ + templates = ptemplates; +} + + +void Plugin::SetSessionManager(SessionManager * psession_manager) +{ + session_manager = 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 && 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.system = system; + info.functions = functions; + info.templates = templates; + info.session_manager = session_manager; + +return res; +} + + void Plugin::LoadPlugins(const std::vector<std::string> & plugins) { size_t i; @@ -60,7 +130,8 @@ void * Plugin::LoadInitFun(const char * filename, Fun1 & fun_init) if( !p ) { - log << log1 << "Plugin: cannot load a plugin: " << filename << logend; + log << log1 << "Plugin: cannot load a plugin: \"" << filename << "\"" << logend; + log << log1 << "Plugin: dlerror: " << dlerror() << logend; return 0; } @@ -90,6 +161,9 @@ Fun1 fun_init; void * plugin_handle; int old_current_plugin; + if( !SetPointers(info) ) + return; + if( !(plugin_handle = LoadInitFun(filename, fun_init)) ) return; @@ -102,7 +176,7 @@ int old_current_plugin; PluginsItem item; item.handle = plugin_handle; - item.plugin_name = (const char *)info.p1; + item.plugin_name = reinterpret_cast<const char *>(info.p1); plugins.push_back(item); @@ -113,11 +187,14 @@ int old_current_plugin; void Plugin::Call(int message, Slots::iterator & slot) { + if( !SetPointers(info) ) + return; + current_plugin = slot->second.index; info.plugin_id = current_plugin; - if( request.session && current_plugin != -1 ) - info.plugin_data_base = request.session->plugin_data.Get(current_plugin); + if( request && request->session && current_plugin != -1 ) + info.plugin_data_base = request->session->plugin_data.Get(current_plugin); else info.plugin_data_base = 0; @@ -168,36 +245,43 @@ void Plugin::Call(int message) Call(message, 0, 0, 0, 0); } + void Plugin::Call(int message, void * p1_) { Call(message, p1_, 0, 0, 0); } + void Plugin::Call(int message, void * p1_, void * p2_) { Call(message, p1_, p2_, 0, 0); } + void Plugin::Call(int message, long l1_) { Call(message, 0, 0, l1_, 0); } + void Plugin::Call(int message, long l1_, long l2_) { Call(message, 0, 0, l1_, l2_); } + void Plugin::Call(int message, void * p1_, long l1_) { Call(message, p1_, 0, l1_, 0); } + void Plugin::Call(int message, void * p1_, long l1_, long l2_) { Call(message, p1_, 0, l1_, l2_); } + void Plugin::Call(int message, void * p1_, void * p2_, long l1_) { Call(message, p1_, p2_, l1_, 0); diff --git a/core/plugin.h b/core/plugin.h index e76c8cb..2805947 100755 --- a/core/plugin.h +++ b/core/plugin.h @@ -14,11 +14,15 @@ #include <vector> #include <string> #include <map> -#include "request.h" -#include "data.h" #include "pluginmsg.h" #include "log.h" #include "plugindata.h" +#include "config.h" +#include "request.h" +#include "system.h" +#include "sessionmanager.h" +#include "functions/functions.h" +#include "templates/templates.h" /* @@ -33,6 +37,8 @@ and you can set the name of the plugin by setting info.p1 pointer to a string buffer (const char *) (this buffer will not be copied so it should not be destroyed after Init finishes) + also in Init you can only use logger (log) info.config and info.db objects + (the rest winix objects are not initialized yet) */ @@ -50,10 +56,19 @@ struct PluginInfo // unique plugin identifier int plugin_id; + // objects from winix which are accessible from a plugin + Db * db; + Config * config; + Request * request; + System * system; + Functions * functions; + Templates * templates; + SessionManager * session_manager; + // pointer to the plugin session (can be null if not set by the plugin) // you should use WINIX_SESSION_CREATED and WINIX_SESSION_REMOVE // to create your plugin's session data - PluginDataBase * plugin_data_base; + PluginDataBase * plugin_data_base; // !! zmienic nazwe na plugin_session_base ? a moze session_base; a moze plugin_session? // function return status // default: false (if not set by the plugin) @@ -62,6 +77,8 @@ struct PluginInfo void Clear() { + // pointers to winix objects are not cleared here + p1 = 0; p2 = 0; l1 = 0; @@ -109,6 +126,14 @@ public: Plugin(); ~Plugin(); + void SetDb(Db * pdb); + void SetConfig(Config * pconfig); + void SetRequest(Request * prequest); + void SetSystem(System * psystem); + void SetFunctions(Functions * pfunctions); + void SetTemplates(Templates * ptemplates); + void SetSessionManager(SessionManager * psession_manager); + void LoadPlugin(const char * filename); void LoadPlugin(const std::string & filename); void LoadPlugins(const std::vector<std::string> & plugins); @@ -134,6 +159,14 @@ public: private: + Db * db; + Config * config; + Request * request; + System * system; + Functions * functions; + Templates * templates; + SessionManager * session_manager; + struct PluginsItem { @@ -151,6 +184,8 @@ private: void * LoadInitFun(const char * filename, Fun1 & fun_init); void Call(int message, Slots::iterator & slot); + + bool SetPointers(PluginInfo & info); }; diff --git a/core/pluginmsg.h b/core/pluginmsg.h index 4412b19..c5864d8 100755 --- a/core/pluginmsg.h +++ b/core/pluginmsg.h @@ -30,9 +30,6 @@ // when a session is changed (you can save a pointer to your data here) #define WINIX_SESSION_CHANGED 3002 -// all plugins have been started, now you can init -#define WINIX_PLUGIN_INIT 3003 - // the winix is closing #define WINIX_CLOSE 3004 diff --git a/core/postmultiparser.cpp b/core/postmultiparser.cpp index 8adb14c..a74e0cd 100755 --- a/core/postmultiparser.cpp +++ b/core/postmultiparser.cpp @@ -9,7 +9,7 @@ #include "postmultiparser.h" #include "log.h" -#include "data.h" + PostMultiParser::PostMultiParser() @@ -18,16 +18,17 @@ PostMultiParser::PostMultiParser() } -PostMultiParser::PostMultiParser(const PostMultiParser &) +PostMultiParser::PostMultiParser(const PostMultiParser & p) { in_buffer = new unsigned char[WINIX_POSTMULTI_INPUT_BUFFER]; + config = p.config; } - -PostMultiParser & PostMultiParser::operator=(const PostMultiParser &) +PostMultiParser & PostMultiParser::operator=(const PostMultiParser & p) { in_buffer = new unsigned char[WINIX_POSTMULTI_INPUT_BUFFER]; + config = p.config; return *this; } @@ -39,6 +40,11 @@ PostMultiParser::~PostMultiParser() } +void PostMultiParser::SetConfig(Config * pconfig) +{ + config = pconfig; +} + void PostMultiParser::ReadBoundary() { @@ -263,10 +269,10 @@ bool has_boundary = false; content.erase(0, WINIX_POSTMULTI_OUTPUT_BUFFER); } - if( data.post_file_max != 0 && content_len > (size_t)data.post_file_max ) + if( config->post_file_max != 0 && content_len > (size_t)config->post_file_max ) { err = WINIX_ERR_INPUT_TOO_LARGE; - log << log1 << "PMP: content greater than " << data.post_file_max << " (skipping)" << logend; + log << log1 << "PMP: content greater than " << config->post_file_max << " (skipping)" << logend; return; } } @@ -317,10 +323,10 @@ bool has_boundary = false; content_len += 1; ReadChar(); - if( data.post_file_max != 0 && content_len > (size_t)data.post_file_max ) + if( config->post_file_max != 0 && content_len > (size_t)config->post_file_max ) { err = WINIX_ERR_INPUT_TOO_LARGE; - log << log1 << "PMP: content greater than " << data.post_file_max << " (skipping)" << logend; + log << log1 << "PMP: content greater than " << config->post_file_max << " (skipping)" << logend; return; } } @@ -433,14 +439,14 @@ void PostMultiParser::CreateTmpFile() { char buf[100]; - if( data.auth_tmp_dir.empty() ) + if( config->auth_tmp_dir.empty() ) { log << log1 << "PMP: auth_tmp_dir is not set in the config" << logend; err = WINIX_ERR_CANT_CREATE_FILE; return; } - sprintf(buf, "%s/winix_%u_%d_%u", data.auth_tmp_dir.c_str(), (unsigned)getpid(), tmp_filename_postfix, rand()); + sprintf(buf, "%s/winix_%u_%d_%u", config->auth_tmp_dir.c_str(), (unsigned)getpid(), tmp_filename_postfix, rand()); tmp_filename_postfix += 1; tmp_file.open(buf, std::ios_base::binary | std::ios_base::out); @@ -457,6 +463,8 @@ char buf[100]; } + + void PostMultiParser::ReadPart() { name.clear(); diff --git a/core/postmultiparser.h b/core/postmultiparser.h index 3eec242..96770b6 100755 --- a/core/postmultiparser.h +++ b/core/postmultiparser.h @@ -15,6 +15,8 @@ #include <fstream> #include "error.h" #include "requesttypes.h" +#include "config.h" + // 2 MB #define WINIX_POSTMULTI_INPUT_BUFFER 2097152 @@ -31,10 +33,13 @@ public: PostMultiParser & operator=(const PostMultiParser &); ~PostMultiParser(); + void SetConfig(Config * pconfig); Error Parse(FCGX_Stream * in_, PostTable & post_table_, PostFileTable & post_file_table_); private: + Config * config; + FCGX_Stream * in; unsigned char * in_buffer; std::ofstream tmp_file; diff --git a/core/rebus.cpp b/core/rebus.cpp index b5e8101..fa12b36 100755 --- a/core/rebus.cpp +++ b/core/rebus.cpp @@ -12,9 +12,16 @@ #include "log.h" #include "rebus.h" #include "misc.h" +#include "request.h" +void Rebus::SetRequest(Request * prequest) +{ + request = prequest; +} + + bool Rebus::InitPair(int a, int b, Item & item) { char buffer[100]; @@ -118,6 +125,37 @@ return result; +bool Rebus::CheckRebus() +{ + if( !request->session ) + return false; + + if( request->session->puser ) + // logged users don't have to use the rebus + return true; + + if( request->session->rebus_checked ) + return true; + + request->session->rebus_checked = true; + + if( !request->session->rebus_item ) + { + log << log1 << "Rebus: rebus not set" << logend; + return false; + } + + std::string * answer = request->PostVar("rebus"); + + if( answer && IsAnswerOk(request->session->rebus_item, *answer) ) + return true; + + log << log1 << "Rebus: rebus has an incorrect answer" << logend; + // don't add request->session->spam_score when the rebus has incorrect answer + // a user could have made a mistake + +return false; +} diff --git a/core/rebus.h b/core/rebus.h index 4910a35..38593eb 100755 --- a/core/rebus.h +++ b/core/rebus.h @@ -15,6 +15,9 @@ #include <vector> +class Request; + + class Rebus { public: @@ -27,12 +30,17 @@ public: }; + + void SetRequest(Request * prequest); void Init(); Item * Rand(); bool IsAnswerOk(Item * item, const std::string & answer); + bool CheckRebus(); private: + Request * request; + bool InitPair(int a, int b, Item & item); std::vector<Item> table; diff --git a/core/request.cpp b/core/request.cpp index 9d275cf..f982146 100755 --- a/core/request.cpp +++ b/core/request.cpp @@ -15,10 +15,13 @@ #include "postparser.h" #include "cookieparser.h" #include "log.h" -#include "data.h" #include "plugin.h" #include "misc.h" #include "db.h" +#include "functions/functionbase.h" + + + Request::Request() : char_empty(0) @@ -27,6 +30,13 @@ Request::Request() : char_empty(0) Clear(); } + +void Request::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + void Request::Init() { compress.Init(); @@ -125,7 +135,7 @@ void Request::SetCookie(const char * name, const char * value, tm * expires) if( expires ) headers << "; expires=" << DateToStrCookie(expires) << " GMT"; - headers << "; path=/; domain=." << data.base_server << "\r\n"; + headers << "; path=/; domain=." << config->base_server << "\r\n"; } @@ -137,7 +147,7 @@ void Request::SetCookie(const char * name, long value, tm * expires) if( expires ) headers << "; expires=" << DateToStrCookie(expires) << " GMT"; - headers << "; path=/; domain=." << data.base_server << "\r\n"; + headers << "; path=/; domain=." << config->base_server << "\r\n"; } @@ -327,6 +337,8 @@ return true; } + +// !! czy te parsery powinny byc skladowymi Request? void Request::ReadParameters() { // !! wrzucic jako skladowa klasy @@ -339,6 +351,7 @@ void Request::ReadParameters() { log << log3 << "Request: post content type: multipart/form-data" << logend; + post_multi_parser.SetConfig(config); post_multi_parser.Parse(in, post_table, post_file_table); } else @@ -390,21 +403,21 @@ void Request::SendSessionCookie() if( !session->puser || !session->remember_me ) { - SetCookie(data.http_session_id_name.c_str(), session->id); + SetCookie(config->http_session_id_name.c_str(), session->id); return; } - time_t t = time(0) + data.session_remember_max_idle; + time_t t = time(0) + config->session_remember_max_idle; tm * expires = localtime(&t); if( !expires ) { // oops, something wrong - SetCookie(data.http_session_id_name.c_str(), session->id); + SetCookie(config->http_session_id_name.c_str(), session->id); return; } - SetCookie(data.http_session_id_name.c_str(), session->id, expires); + SetCookie(config->http_session_id_name.c_str(), session->id, expires); } @@ -472,15 +485,15 @@ void Request::AddDebugInfo() } } - +// !! to powinno isc do kontrolera app void Request::SendPage(bool compressing, const std::string & source_ref) { const std::string * source = &source_ref; - bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && - request.pfunction && (request.pfunction->code == FUN_CAT || request.pfunction->code == FUN_RUN); + bool raw = is_item && item.content_type == Item::ct_raw && status == WINIX_ERR_OK && + pfunction && (pfunction->fun.url == "cat" || pfunction->fun.url == "run"); - if( data.html_filter && !raw ) + if( config->html_filter && !raw ) { html_filter.TrimWhite(true); html_filter.BreakLines(60); @@ -502,7 +515,7 @@ void Request::SendAll() { const std::string & source = page.str(); Header header = h_200; -bool compressing = data.compression && role == responder && redirect_to.empty() && x_sendfile.empty() && +bool compressing = config->compression && role == responder && redirect_to.empty() && x_sendfile.empty() && !browser_msie && !browser_konqueror && accept_encoding_parser.AcceptDeflate() && source.size() >= 512; @@ -567,514 +580,7 @@ return str_empty; } -bool Request::CanChangeUser(const Item & item, long new_user_id) -{ - if( !session ) - // session must be set - return false; - - if( session->puser && session->puser->super_user ) - // super user is allowed everything - return true; - - if( item.user_id != new_user_id ) - // only super user can change the owner of an item - return false; -return true; -} -bool Request::CanChangeGroup(const Item & item, long new_group_id) -{ - if( !session ) - // session must be set - return false; - if( session->puser && session->puser->super_user ) - // super user is allowed everything - return true; - - if( item.group_id != 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( !session->puser ) - return false; - - if( session->puser->id != item.user_id ) - return false; - - if( new_group_id == -1 ) - return true; - - if( !session->puser->IsMemberOf(new_group_id) ) - return false; - - // is logged, is the owner of the item, is the member of the new group - } - -return true; -} - - -bool Request::CanChangePrivileges(const Item & item, int new_priv) -{ - if( !session ) - // session must be set - return false; - - if( session->puser && session->puser->super_user ) - // super user is allowed everything - return true; - - if( item.privileges != new_priv ) - { - // the owner of an item is allowed to change the privileges - - if( !session->puser ) - return false; - - if( session->puser->id != item.user_id ) - return false; - } - -return true; -} - - - -bool Request::HasAccess(const Item & item, int mask) -{ - if( !session ) - // session must be set - return false; - - if( session->puser && session->puser->super_user ) - // super user is allowed everything - return true; - - if( session->puser && session->puser->id == item.user_id ) - { - // the owner - return ((item.privileges >> 6) & mask) == mask; - } - - if( session->puser && session->puser->IsMemberOf(item.group_id) ) - { - // group - return ((item.privileges >> 3) & mask) == mask; - } - - // others - -return (item.privileges & mask) == mask; -} - - -bool Request::HasReadAccess(const Item & item) -{ - return HasAccess(item, 4); -} - - -bool Request::HasWriteAccess(const Item & item) -{ - return HasAccess(item, 2); -} - - -bool Request::HasReadWriteAccess(const Item & item) -{ - return HasAccess(item, 6); // r+w -} - - -bool Request::HasReadExecAccess(const Item & item) -{ - if( session && session->puser && session->puser->super_user ) - { - // there must be at least one 'x' (for the root) - - return (item.privileges & 0111) != 0; - } - - return HasAccess(item, 5); // r+x -} - - -bool Request::HasReadExecAccessForRoot(const Item & item) -{ - // there must be at least one 'x' (for the root) - - return (item.privileges & 0111) != 0; -} - - - -bool Request::HasReadExecAccessToPath(long dir_id) -{ - while( true ) - { - Item * pdir = data.dirs.GetDir(dir_id); - - if( !pdir ) - return false; - - if( !HasReadExecAccess(*pdir) ) - return false; - - dir_id = pdir->parent_id; - - if( dir_id == -1 ) - return true; - } -} - - - -// returning true if we can create a thread in the current directory -bool Request::CanCreateThread(bool check_root) -{ - if( request.dir_table.empty() ) - return false; - - if( request.is_item ) - return false; - - if( !HasWriteAccess(*request.dir_table.back()) ) - return false; - - if( !data.mounts.pmount || data.mounts.pmount->type != Mount::thread ) - return false; - - if( !check_root && session && session->puser && session->puser->super_user ) - // super can create thread regardless of the restrictcreatethread option - return true; - - if( !data.mounts.pmount->IsPar(Mount::par_createthread_on) ) - return true; - - if( data.mounts.pmount->IsArg(Mount::par_createthread_on, request.dir_table.size()) ) - return true; - -return false; -} - - - -// returning true if we can create a ticket in the current directory -bool Request::CanCreateTicket(bool check_root) -{ - if( request.dir_table.empty() ) - return false; - - if( request.is_item ) - return false; - - if( !HasWriteAccess(*request.dir_table.back()) ) - return false; - - if( !data.mounts.pmount || data.mounts.pmount->type != Mount::ticket ) - return false; - - - // checking for par_createticket_on mount option - - if( !check_root && session && session->puser && session->puser->super_user ) - // super can create tickets regardless of the createticket_on option - return true; - - if( !data.mounts.pmount->IsPar(Mount::par_createticket_on) ) - return true; - - if( data.mounts.pmount->IsArg(Mount::par_createticket_on, request.dir_table.size()) ) - return true; - -return false; -} - - - -bool Request::CanEditTicket() -{ - // not logged users cannot edit tickets - if( !request.session->puser ) - return false; - - if( request.dir_table.empty() ) - return false; - - if( request.is_item || !request.is_ticket ) - return false; - - if( !HasWriteAccess(*request.dir_table.back()) ) - return false; - - if( !data.mounts.pmount || data.mounts.pmount->type != Mount::ticket ) - return false; - -return true; -} - - - -bool Request::CanRemove(const Item & item) -{ - // !! temporarily (we're waiting for the sticky bit to be implemented) - // not logged users cannot remove anything - if( !request.session->puser ) - return false; - - if( item.parent_id == -1 ) - { - // rm for the root dir - // only the superuser can do it - if( !request.session->puser || !request.session->puser->super_user ) - return false; - } - else - { - Item * last_but_one_dir = data.dirs.GetDir(item.parent_id); - - if( !last_but_one_dir ) - // ops, there is no a parent dir - return false; - - if( !request.HasWriteAccess(*last_but_one_dir) ) - return false; - } - - if( data.mounts.pmount->IsPar(Mount::par_only_root_remove) ) - if( !request.session->puser || !request.session->puser->super_user ) - return false; - -return true; -} - - -bool Request::CanUseEmacs(const Item & item, bool check_root) -{ - if( !check_root && request.session->puser && request.session->puser->super_user ) - // super user can use emacs everywhere - return true; - - if( !request.HasWriteAccess(item) ) - return false; - - if( !data.mounts.pmount->IsPar(Mount::par_emacs_on) ) - return true; - - if( data.mounts.pmount->IsArg(Mount::par_emacs_on, request.dir_table.size()) ) - return true; - -return false; -} - - -bool Request::CanUseMkdir(const Item & item, bool check_root) -{ - // you can create a directory only in a directory - if( item.type != Item::dir ) - return false; - - if( !check_root && request.session->puser && request.session->puser->super_user ) - // super user can use mkdir everywhere - return true; - - if( !request.HasWriteAccess(item) ) - return false; - - if( !data.mounts.pmount->IsPar(Mount::par_mkdir_on) ) - return true; - - if( data.mounts.pmount->IsArg(Mount::par_mkdir_on, request.dir_table.size()) ) - return true; - -return false; -} - - -bool Request::CanUseUpload(const Item & item, bool check_root) -{ - // you can use 'upload' only in a directory - if( item.type != Item::dir ) - return false; - - // we must know where to store the file - if( !data.mounts.pmount ) - return false; - - if( data.mounts.pmount->fs == Mount::simplefs && data.auth_simplefs_dir.empty() ) - { - log << log1 << "Request: can't use upload function, auth_simplefs_dir must be set in the config file" << logend; - return false; - } - - if( data.mounts.pmount->fs == Mount::hashfs && data.auth_hashfs_dir.empty() ) - { - log << log1 << "Request: can't use upload function, auth_hashfs_dir must be set in the config file" << logend; - return false; - } - - if( data.auth_tmp_dir.empty() ) - { - log << log1 << "Request: can't use upload function, auth_tmp_dir must be set in the config file" << logend; - return false; - } - - if( !check_root && request.session->puser && request.session->puser->super_user ) - // super user can use upload everywhere - return true; - - if( !request.HasWriteAccess(item) ) - return false; - -return true; -} - - -bool Request::CanUseHtml(long user_id) -{ - return CanUse(user_id, "allow_html"); -} - - -bool Request::CanUseBBCode(long user_id) -{ - // logged users can use bbcode - return (user_id != -1); -} - - -bool Request::CanUseRaw(long user_id) -{ - return CanUse(user_id, "allow_raw"); -} - - -bool Request::CanUse(long user_id, const char * group_name) -{ - User * puser = data.users.GetUser(user_id); - - if( !puser ) - return false; - - if( puser->super_user ) - return true; - - long group = data.groups.GetGroupId(group_name); - - if( group == -1 ) - // there is no such a group - return false; - - if( puser->IsMemberOf(group) ) - return true; - -return false; -} - - - - -bool Request::MakePathSimpleFs(std::string & path, long dir_id, bool create_dir) -{ - if( data.auth_simplefs_dir.empty() ) - { - log << log1 << "Request: auth_simplefs_dir is not set in the config file" << logend; - return false; - } - - if( !data.dirs.MakePath(dir_id, path) ) - return false; - - if( create_dir && !CreateDirs(data.auth_simplefs_dir, path, 0755) ) - return false; - - path.insert(0, data.auth_simplefs_dir); - -return true; -} - - - - -// the path depends on id -bool Request::MakePathHashFs(std::string & path, long id, bool create_dir) -{ -char buffer[50]; -char * hash = buffer; - - // get 'id' as hexadecimal - buffer[0] = '0'; - sprintf(buffer+1, "%lx", (unsigned long)id); - - path = data.auth_hashfs_dir; - if( path.empty() ) - { - log << log1 << "Request: auth_hashfs_dir is not set in the config file" << logend; - return false; - } - - path += '/'; - - // make sure that the length is even - if( (strlen(hash) & 1) != 0 ) - hash = buffer + 1; // the first character was zero - - // creating dirs without the last part - // the last part is a part of a file - for(size_t i=0 ; hash[i] != 0 ; i+=2) - { - path += hash[i]; - path += hash[i+1]; - - if( hash[i+2] != 0 ) - { - if( create_dir && !CreateDir(path, 0755) ) - return false; - - path += '/'; - } - } - - // one character more to make sure the path is unique - // (we can have a directory without the character) - path += "_"; - -return true; -} - - -// making a complete path to a static file -bool Request::MakePath(const Item & item, std::string & path, bool create_dir) -{ -bool res; - - Mount * pmount = data.mounts.CalcMount(item.parent_id); - - if( !pmount || pmount->fs == Mount::simplefs ) - { - res = MakePathSimpleFs(path, item.parent_id, create_dir); - } - else - { - res = MakePathHashFs(path, item.id, create_dir); - } - - if( res ) - path += item.url; - else - path.clear(); - -return res; -} - - - -bool Request::MakePath(Item & item, bool create_dir) -{ - return MakePath(item, item.auth_path, create_dir); -} diff --git a/core/request.h b/core/request.h index 3de035f..9f17673 100755 --- a/core/request.h +++ b/core/request.h @@ -19,16 +19,19 @@ #include "session.h" #include "item.h" #include "error.h" -#include "function.h" #include "thread.h" #include "compress.h" #include "acceptencodingparser.h" #include "htmlfilter.h" #include "postmultiparser.h" #include "ticket.h" +#include "config.h" +class FunctionBase; + + struct Request { // request id @@ -87,7 +90,7 @@ struct Request Item item; // null if there is no a function - Function * pfunction; + FunctionBase * pfunction; // parameters (name:value) ParamTable param_table; @@ -149,37 +152,12 @@ struct Request void SendAll(); void SendNotify(); - bool CanChangeUser(const Item & item, long new_user_id); - bool CanChangeGroup(const Item & item, long new_group_id); - bool CanChangePrivileges(const Item & item, int new_priv); - - bool HasAccess(const Item & item, int mask); - bool HasReadAccess(const Item & item); - bool HasWriteAccess(const Item & item); - bool HasReadWriteAccess(const Item & item); - bool HasReadExecAccess(const Item & item); - bool HasReadExecAccessForRoot(const Item & item); - bool HasReadExecAccessToPath(long dir_id); - - bool CanCreateThread(bool check_root = false); - bool CanCreateTicket(bool check_root = false); - bool CanEditTicket(); - bool CanRemove(const Item & item); - bool CanUseEmacs(const Item & item, bool check_root = false); - bool CanUseMkdir(const Item & item, bool check_root = false); - bool CanUseUpload(const Item & item, bool check_root = false); - - bool CanUseHtml(long user_id); - bool CanUseBBCode(long user_id); - bool CanUseRaw(long user_id); - - bool MakePathSimpleFs(std::string & path, long dir_id, bool create_dir = false); - bool MakePathHashFs(std::string & path, long id, bool create_dir = false); - bool MakePath(const Item & item, std::string & path, bool create_dir = false); - bool MakePath(Item & item, bool create_dir = false); + void SetConfig(Config * pconfig); private: + Config * config; + enum Header { h_200, @@ -204,6 +182,7 @@ private: // used in ParamValue(const char * param_name) when there is no such a param const std::string str_empty; + PostMultiParser post_multi_parser; const char * SetEnvVar(const char * var); @@ -221,7 +200,7 @@ private: -extern Request request; + diff --git a/core/requestcontroller.cpp b/core/requestcontroller.cpp deleted file mode 100755 index 79241e6..0000000 --- a/core/requestcontroller.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#include "requestcontroller.h" -#include "data.h" -#include "log.h" -#include "request.h" -#include "postparser.h" -#include "cookieparser.h" -#include "notify.h" - - - -RequestController::RequestController() -{ - last_sessions_save = time(0); -} - - -RequestController::~RequestController() -{ - Close(); -} - - -void RequestController::Close() -{ - // don't call close(0) - // it will be closed next time during dup(s,0) - - // if you closed the descriptor here - // then the database would have that descriptor (during connecting) - // and there'll be a problem in the next loop (after SIGHUP) -} - - - - -bool RequestController::Init() -{ - const char * sock = data.fcgi_socket.c_str(); - - unlink(sock); - - - - int s = FCGX_OpenSocket(sock, 10); - - if( s < 0 ) - { - log << log1 << "An error during creating a socket" << logend; - return false; - } - - - chmod(sock, data.fcgi_socket_chmod); - - passwd * pw = getpwnam(data.fcgi_socket_user.c_str()); - - if( !pw ) - { - log << log1 << "There is no user: " << data.fcgi_socket_user << logend; - return false; - } - - group * gr = getgrnam(data.fcgi_socket_group.c_str()); - - if( !gr ) - { - log << log1 << "There is no group: " << data.fcgi_socket_group << logend; - return false; - } - - chown(sock, pw->pw_uid, gr->gr_gid); - - - - if( setuid(pw->pw_uid) < 0 ) - { - log << log1 << "I can't change the user into: " << data.fcgi_socket_user << logend; - return false; - } - - - /* - if( setgid(gr->gr_gid) < 0 ) - { - int e = errno; - - log << log1 << "I can't change the group into: " << data.fcgi_socket_group << " " << gr->gr_gid << logend; - log << log1 << "errno: " << e << logend; - return false; - } - */ - - - dup2(s, 0); - -// - data.dirs.ReadDirs(); - data.users.ReadUsers(); - data.groups.ReadGroups(); - data.functions.ReadFunctions(); - data.mounts.ReadMounts(); - data.rebus.Init(); -// - - - - if( !content.Init() ) - return false; - - -return true; -} - - -void RequestController::LoadSessions() -{ - session_manager.LoadSessions(); -} - -void RequestController::SaveSessions() -{ - session_manager.SaveSessions(); -} - - -void RequestController::DeleteAllPluginsData() -{ - session_manager.DeleteAllPluginsData(); -} - - -void RequestController::SaveSessionsIfNeeded() -{ - time_t t = time(0); - - if( last_sessions_save + 86400 > t ) - return; - - // saving once a day for safety - last_sessions_save = t; - SaveSessions(); -} - - -bool RequestController::BaseUrlRedirect() -{ - if( request.role == Request::responder ) - { - if( data.base_url_http_host.empty() ) - return false; - - if( data.base_url_http_host == request.env_http_host ) - return false; - - request.redirect_to = data.base_url + request.env_request_uri; - } - else - { - // authorizer - - if( data.base_url_auth_http_host.empty() ) - return false; - - if( data.base_url_auth_http_host == request.env_http_host ) - return false; - - request.redirect_to = data.base_url_auth + request.env_request_uri; - } - - log << log3 << "RC: BaseUrlRedirect from: " << request.env_http_host << logend; - -return true; -} - - - -void RequestController::Loop() -{ - while( FCGX_Accept(&request.in, &request.out, &request.err, &request.env) == 0 ) - { - data.load_avg.StartRequest(); - log << log2 << "---------------------------------------------------------------------------------" << logend; - - try - { - request.Clear(); - request.Read(); - - // 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 - // and then BaseUrlRedirect() will be called (for performance) - if( !BaseUrlRedirect() ) - { - session_manager.DeleteOldSessions(); - session_manager.SetSession(); // set request.session as well - - function_parser.Parse(); - data.mounts.CalcCurMount(); - - content.ReadAdditionalInfo(); - content.Make(); - } - - request.SendAll(); - notify.ItemChanged(request.notify_code); - } - catch(const std::logic_error & e) - { - log << log1 << "std logic exception: " << e.what() << logend; - } - catch(const std::exception & e) - { - log << log1 << "std exception: " << e.what() << logend; - } - catch(const Error & e) - { - log << log1 << "exception: Error: " << e << logend; - } - catch(...) - { - log << log1 << "uncaught unknown exception" << logend; - } - - SaveSessionsIfNeeded(); - - // !! this should be immediately after FCGX_Accept() but signals don't want to break FCGX_Accept - if( data.signal_hup ) - { - log << logsave; - FCGX_Finish(); - return; - } - - request.ClearPostFileTmp(); - data.load_avg.StopRequest(); - log << logsave; - } -} - - - -SessionContainer::Iterator RequestController::SessionBegin() -{ - return session_manager.SessionBegin(); -} - - -SessionContainer::Iterator RequestController::SessionEnd() -{ - return session_manager.SessionEnd(); -} diff --git a/core/requestcontroller.h b/core/requestcontroller.h deleted file mode 100755 index a69694b..0000000 --- a/core/requestcontroller.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is a part of Winix - * and is not publicly distributed - * - * Copyright (c) 2008-2010, Tomasz Sowa - * All rights reserved. - * - */ - -#ifndef headerfilecmslucorerequestcontroller -#define headerfilecmslucorerequestcontroller - -#include <unistd.h> -#include <sys/stat.h> -#include <iostream> -#include <sys/types.h> -#include <pwd.h> -#include <grp.h> -#include <errno.h> -#include <ctime> - -#include "../content/content.h" -#include "sessionmanager.h" -#include "functionparser.h" -#include "sessioncontainer.h" - - -class RequestController -{ - Content content; - - - SessionManager session_manager; - - bool BaseUrlRedirect(); - - FunctionParser function_parser; - -public: - - RequestController(); - ~RequestController(); - - bool Init(); - void Close(); - void Loop(); - - void LoadSessions(); - void SaveSessions(); - void SaveSessionsIfNeeded(); // saving only once a day - void DeleteAllPluginsData(); - - SessionContainer::Iterator SessionBegin(); - SessionContainer::Iterator SessionEnd(); - - time_t last_sessions_save; -}; - - -extern RequestController req_controller; - -#endif diff --git a/core/session.h b/core/session.h index f71e6c1..9633d33 100755 --- a/core/session.h +++ b/core/session.h @@ -14,11 +14,8 @@ #include "item.h" #include "error.h" #include "user.h" -#include "rebus.h" #include "plugindata.h" - - - +#include "rebus.h" struct Session diff --git a/core/sessioncontainer.cpp b/core/sessioncontainer.cpp index 11261fd..20994e5 100755 --- a/core/sessioncontainer.cpp +++ b/core/sessioncontainer.cpp @@ -8,7 +8,6 @@ */ #include "sessioncontainer.h" -#include "data.h" #include "log.h" @@ -22,6 +21,12 @@ void SessionContainer::Clear() } +void SessionContainer::SetLastContainer(LastContainer * plast_container) +{ + last_container = plast_container; +} + + SessionContainer::TableSize SessionContainer::Size() { return table.size(); @@ -96,7 +101,7 @@ time_t limit = std::time(0) - interval; continue; if( iold->second->puser ) - data.last.UserLogout(iold->second->puser->id, iold->second->id); + last_container->UserLogout(iold->second->puser->id, iold->second->id); // we're logging session.id (call this before table.erase()) DelFromIdIndex(iold->second); diff --git a/core/sessioncontainer.h b/core/sessioncontainer.h index aaeb308..634773f 100755 --- a/core/sessioncontainer.h +++ b/core/sessioncontainer.h @@ -16,7 +16,7 @@ #include <ctime> #include "session.h" - +#include "lastcontainer.h" @@ -30,8 +30,12 @@ public: typedef std::map<long, Iterator> IndexId; typedef std::multimap<time_t, Iterator> IndexTime; + void SetLastContainer(LastContainer * plast_container); + private: + LastContainer * last_container; + Table table; IndexId index_id; IndexTime index_time; diff --git a/core/sessionmanager.cpp b/core/sessionmanager.cpp index 99d743d..8e6010c 100755 --- a/core/sessionmanager.cpp +++ b/core/sessionmanager.cpp @@ -11,7 +11,6 @@ #include "sessionmanager.h" #include "request.h" #include "log.h" -#include "data.h" #include "session.h" #include "sessionparser.h" #include "plugin.h" @@ -27,6 +26,28 @@ SessionManager::SessionManager() } +void SessionManager::SetRequest(Request * prequest) +{ + request = prequest; +} + + +void SessionManager::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + +void SessionManager::SetSystem(System * psystem) +{ + system = psystem; +} + +void SessionManager::SetLastContainer(LastContainer * plast_container) +{ + session_table.SetLastContainer(plast_container); +} + bool SessionManager::IsSession(long id) { @@ -79,11 +100,11 @@ void SessionManager::CreateTemporarySession() s.id = 0; session_table.PushBack(s); - request.session = &session_table.Back(); + request->session = &session_table.Back(); } else { - request.session = &(*i); + request->session = &(*i); } } @@ -102,10 +123,10 @@ int attempts = 100; if( added ) { - request.session = &session_table.Back(); - request.session->new_session = true; + request->session = &session_table.Back(); + request->session->new_session = true; - log << log2 << "SM: created a new session: " << request.session->id << logend; + log << log2 << "SM: created a new session: " << request->session->id << logend; return; } @@ -129,17 +150,17 @@ 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 = &(*s); + request->session->new_session = false; session_table.UpdateLastTime(s, std::time(0)); - if( request.method == Request::get ) - request.session->last_time_get = request.session->last_time; + if( request->method == Request::get ) + request->session->last_time_get = request->session->last_time; log << log2 << "SM: session: " << s->id; - if( request.session->puser ) - log << log2 << ", user: " << request.session->puser->name << ", id: " << request.session->puser->id; + if( request->session->puser ) + log << log2 << ", user: " << request->session->puser->name << ", id: " << request->session->puser->id; log << log2 << logend; @@ -150,9 +171,9 @@ return true; void SessionManager::SetSession() { - CookieTable::iterator i = request.cookie_table.find(data.http_session_id_name); + CookieTable::iterator i = request->cookie_table.find(config->http_session_id_name); - if( i == request.cookie_table.end() ) + if( i == request->cookie_table.end() ) { CreateSession(); } @@ -162,18 +183,18 @@ void SessionManager::SetSession() { // there is no such a session // deleting the old cookie - request.cookie_table.erase(i); + request->cookie_table.erase(i); // and creating a new one CreateSession(); } } - // request.session is set now + // request->session is set now - if( request.session->new_session ) + if( request->session->new_session ) { - request.session->plugin_data.Resize(plugin.Size()); + request->session->plugin_data.Resize(plugin.Size()); plugin.Call(WINIX_SESSION_CREATED); } @@ -199,7 +220,7 @@ SessionContainer::Iterator SessionManager::SessionEnd() void SessionManager::DeleteOldSessions() { - session_table.DelFirstByTimeInterval(data.session_max_idle); + session_table.DelFirstByTimeInterval(config->session_max_idle); if( ++session_checker > 1000 ) { @@ -207,7 +228,7 @@ void SessionManager::DeleteOldSessions() log << log3 << "SM: checking sessions which have 'remember me' flag set" << logend; session_checker = 0; - session_table.DelFirstByTimeInterval(data.session_remember_max_idle, false); + session_table.DelFirstByTimeInterval(config->session_remember_max_idle, false); } } @@ -217,15 +238,15 @@ void SessionManager::DeleteAllPluginsData() { SessionContainer::Iterator i = session_table.Begin(); - Session * old_session = request.session; + Session * old_session = request->session; for( ; i!=session_table.End() ; ++i ) { - request.session = &(*i); + request->session = &(*i); i->plugin_data.DeleteAll(); } - request.session = old_session; + request->session = old_session; } @@ -237,19 +258,20 @@ void SessionManager::LoadSessions() SessionParser sp; SessionContainer::Iterator i; - Session * old_session = request.session; + sp.SetUsers(&system->users); + Session * old_session = request->session; - sp.Parse(data.session_file, session_table); + sp.Parse(config->session_file, session_table); i = session_table.Begin(); for( ; i!=session_table.End() ; ++i ) { i->plugin_data.Resize(plugin.Size()); - request.session = &(*i); + request->session = &(*i); plugin.Call(WINIX_SESSION_CREATED); } - request.session = old_session; + request->session = old_session; } @@ -258,10 +280,10 @@ SessionContainer::Iterator i; void SessionManager::SaveSessions() { - if( data.session_file.empty() ) + if( config->session_file.empty() ) return; - std::ofstream file(data.session_file.c_str()); + std::ofstream file(config->session_file.c_str()); if( !file ) { @@ -286,7 +308,7 @@ void SessionManager::SaveSessions() } file.close(); - chmod(data.session_file.c_str(), 0600); + chmod(config->session_file.c_str(), 0600); log << log2 << "SM: saved " << len << " session(s)" << logend; } diff --git a/core/sessionmanager.h b/core/sessionmanager.h index a4cd162..0126d31 100755 --- a/core/sessionmanager.h +++ b/core/sessionmanager.h @@ -14,15 +14,21 @@ #include <ctime> #include "sessioncontainer.h" +#include "config.h" +#include "request.h" +#include "lastcontainer.h" +#include "system.h" class SessionManager { + Config * config; + Request * request; + System * system; + SessionContainer session_table; - - bool IsSession(long s); long CreateSessionId(); @@ -34,6 +40,12 @@ class SessionManager public: SessionManager(); + + void SetRequest(Request * prequest); + void SetConfig(Config * pconfig); + void SetSystem(System * psystem); + void SetLastContainer(LastContainer * plast_container); + void SetSession(); void DeleteAllPluginsData(); void DeleteOldSessions(); diff --git a/core/sessionparser.cpp b/core/sessionparser.cpp index d9f863f..ee81986 100755 --- a/core/sessionparser.cpp +++ b/core/sessionparser.cpp @@ -9,7 +9,7 @@ #include "sessionparser.h" #include "log.h" -#include "data.h" + bool SessionParser::Parse(const std::string & path, SessionContainer & container) @@ -18,6 +18,12 @@ bool SessionParser::Parse(const std::string & path, SessionContainer & container } +void SessionParser::SetUsers(Users * pusers) +{ + users = pusers; +} + + bool SessionParser::Parse(const char * path, SessionContainer & container) { container.Clear(); @@ -66,7 +72,7 @@ bool SessionParser::Parse(SessionContainer & container) if( MakeSession(user_id) ) { - data.how_many_logged += 1; + users->IncrementLoggedUsers(); container.PushBack(session); log << log2 << "SP: read session id: " << session.id << " for user: " << session.puser->name << logend; } @@ -82,7 +88,7 @@ return true; bool SessionParser::MakeSession(long user_id) { - User * puser = data.users.GetUser(user_id); + User * puser = users->GetUser(user_id); if( !puser ) { diff --git a/core/sessionparser.h b/core/sessionparser.h index 6c0a95e..a99afd8 100755 --- a/core/sessionparser.h +++ b/core/sessionparser.h @@ -14,6 +14,9 @@ #include <string> #include "session.h" #include "sessioncontainer.h" +#include "users.h" + + class SessionParser { @@ -21,9 +24,11 @@ public: bool Parse(const char * path, SessionContainer & container); bool Parse(const std::string & path, SessionContainer & container); - + void SetUsers(Users * pusers); private: + + Users * users; bool Parse(SessionContainer & container); bool MakeSession(long user_id); diff --git a/core/system.cpp b/core/system.cpp new file mode 100755 index 0000000..1fe45a9 --- /dev/null +++ b/core/system.cpp @@ -0,0 +1,589 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "system.h" +#include "misc.h" +#include "error.h" +#include "notify.h" +#include "functions/functions.h" +#include "templates/templates.h" + + + +void System::SetRequest(Request * prequest) +{ + request = prequest; +} + + +void System::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + +void System::SetDb(Db * pdb) +{ + db = pdb; +} + + +void System::SetFunctions(Functions * pfunctions) +{ + functions = pfunctions; +} + + +void System::SetTemplates(Templates * ptemplates) +{ + templates = ptemplates; +} + + + +void System::Init() +{ + dirs.SetDb(db); + dirs.SetRequest(request); + + dirs.ReadDirs(); + + mounts.SetDirs(&dirs); + mounts.SetDb(db); + mounts.SetRequest(request); + mounts.ReadMounts(); + + users.SetRequest(request); + users.ReadUsers(db); + groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione + + rebus.SetRequest(request); + rebus.Init(); +} + + +// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad +// !! moze zwracac jakas wartosc? +void System::RedirectTo(const Item & item, const char * postfix) +{ + request->redirect_to = config->base_url; + + if( item.type == Item::dir ) + { + // item_id is pointing to a directory + dirs.MakePath(item.id, path); + request->redirect_to += path; + } + else + { + if( !dirs.MakePath(item.parent_id, path) ) + log << log1 << "Content: Can't redirect: no dirs for item id: " << item.id << logend; + + request->redirect_to += path; + request->redirect_to += item.url; + } + + if( postfix ) + request->redirect_to += postfix; +} + + + +void System::RedirectTo(long item_id, const char * postfix) +{ +std::string path; +Item * pdir; + + request->redirect_to = config->base_url; + pdir = dirs.GetDir(item_id); + + + if( pdir ) + { + // item_id is pointing to a directory + dirs.MakePath(pdir->id, path); + request->redirect_to += path; + } + else + { + // !! zrobic nowy interfejs + // !! GetItem pozamieniac na GetFile + // !! i nie uzywac request->item_table (zrobic sobie lokalny tutaj) + db->GetItem(request->item_table, item_id); + + if( !request->item_table.empty() ) + { + if( !dirs.MakePath(request->item_table[0].parent_id, path) ) + log << log1 << "Content: Can't redirect: no dirs for item id: " << request->item_table[0].id << ", requested directory id: " << request->item_table[0].parent_id << logend; + + request->redirect_to += path + request->item_table[0].url; + } + else + { + log << log1 << "Content: Can't redirect: no such item: id: " << item_id << logend; + } + } + + if( postfix ) + request->redirect_to += postfix; +} + + +void System::RedirectToLastDir() +{ + // !! dac sprawdzenie czy istnieje + RedirectTo( *request->dir_table.back() ); +} + + +void System::RedirectToLastItem() +{ + if( request->is_item ) + RedirectTo(request->item); + else + RedirectTo( *request->dir_table.back() );// !! dac sprawdzenie czy istnieje +} + + +void System::PrepareUrl(Item & item) +{ + TrimWhite(item.url); + + if( item.url.empty() ) + item.url = item.subject; // if the subject is empty then the url will be corrected by CorrectUrlOnlyAllowedChar() + + CorrectUrlOnlyAllowedChar(item.url); + + if( functions->Find(item.url) ) + { + // the name provided by an user is the same as a name of a function + // we add one underscore character at the beginning + + // names of functions should not begin with an underscore '_' + // and we can simply add one '_' at the beginning + // and the name will be unique + item.url.insert(item.url.begin(), '_'); + } +} + + +bool System::CanChangeUser(const Item & item, long new_user_id) +{ + if( !request->session ) + // session must be set + return false; + + if( request->session->puser && request->session->puser->super_user ) + // super user is allowed everything + return true; + + if( item.user_id != new_user_id ) + // only super user can change the owner of an item + return false; + +return true; +} + + +bool System::CanChangeGroup(const Item & item, long new_group_id) +{ + if( !request->session ) + // session must be set + return false; + + if( request->session->puser && request->session->puser->super_user ) + // super user is allowed everything + return true; + + if( item.group_id != 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 ) + return false; + + if( request->session->puser->id != item.user_id ) + return false; + + if( new_group_id == -1 ) + return true; + + if( !request->session->puser->IsMemberOf(new_group_id) ) + return false; + + // is logged, is the owner of the item, is the member of the new group + } + +return true; +} + + +bool System::CanChangePrivileges(const Item & item, int new_priv) +{ + if( !request->session ) + // session must be set + return false; + + if( request->session->puser && request->session->puser->super_user ) + // super user is allowed everything + return true; + + if( item.privileges != new_priv ) + { + // the owner of an item is allowed to change the privileges + + if( !request->session->puser ) + return false; + + if( request->session->puser->id != item.user_id ) + return false; + } + +return true; +} + + + +bool System::HasAccess(const Item & item, int mask) +{ + if( !request->session ) + // session must be set + return false; + + if( request->session->puser && request->session->puser->super_user ) + // super user is allowed everything + return true; + + if( request->session->puser && request->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) ) + { + // group + return ((item.privileges >> 3) & mask) == mask; + } + + // others + +return (item.privileges & mask) == mask; +} + + +bool System::HasReadAccess(const Item & item) +{ + return HasAccess(item, 4); +} + + +bool System::HasWriteAccess(const Item & item) +{ + return HasAccess(item, 2); +} + + +bool System::HasReadWriteAccess(const Item & item) +{ + return HasAccess(item, 6); // r+w +} + + +bool System::HasReadExecAccess(const Item & item) +{ + if( request->session && request->session->puser && request->session->puser->super_user ) + { + // there must be at least one 'x' (for the root) + + return (item.privileges & 0111) != 0; + } + + return HasAccess(item, 5); // r+x +} + + + + + +bool System::HasReadExecAccessToPath(long dir_id) +{ + while( true ) + { + Item * pdir = dirs.GetDir(dir_id); + + if( !pdir ) + return false; + + if( !HasReadExecAccess(*pdir) ) + return false; + + dir_id = pdir->parent_id; + + if( dir_id == -1 ) + return true; + } +} + + +bool System::DirsHaveReadExecPerm() +{ + std::vector<Item*>::iterator i; + + for(i = request->dir_table.begin() ; i!=request->dir_table.end() ; ++i) + { + if( !HasReadExecAccess(**i) ) + return false; + } + +return true; +} + + +// if we don't have access we only remove the item from the table +void System::CheckAccessToItems(std::vector<Item> & item_table) +{ +size_t i = 0; + + while( i < item_table.size() ) + { + if( !HasReadAccess(item_table[i]) ) + { + item_table.erase(item_table.begin() + i); + } + else + { + i += 1; + } + } +} + + + +bool System::CanUseHtml(long user_id) +{ + return IsMemberOfGroup(user_id, "allow_html"); +} + + +bool System::CanUseBBCode(long user_id) +{ + // logged users can use bbcode + return (user_id != -1); +} + + +bool System::CanUseRaw(long user_id) +{ + return IsMemberOfGroup(user_id, "allow_raw"); +} + + + +bool System::IsMemberOfGroup(long user_id, const char * group_name) +{ + User * puser = users.GetUser(user_id); + + if( !puser ) + return false; + + if( puser->super_user ) + return true; + + long group = groups.GetGroupId(group_name); + + if( group == -1 ) + // there is no such a group + return false; + + if( puser->IsMemberOf(group) ) + return true; + +return false; +} + + + + + + +bool System::MakePathSimpleFs(std::string & path, long dir_id, bool create_dir) +{ + if( config->auth_simplefs_dir.empty() ) + { + log << log1 << "System: auth_simplefs_dir is not set in the config file" << logend; + return false; + } + + if( !dirs.MakePath(dir_id, path) ) + return false; + + if( create_dir && !CreateDirs(config->auth_simplefs_dir, path, 0755) ) + return false; + + path.insert(0, config->auth_simplefs_dir); + +return true; +} + + + + +// the path depends on id +bool System::MakePathHashFs(std::string & path, long id, bool create_dir) +{ +char buffer[50]; +char * hash = buffer; + + // get 'id' as hexadecimal + buffer[0] = '0'; + sprintf(buffer+1, "%lx", (unsigned long)id); + + path = config->auth_hashfs_dir; + if( path.empty() ) + { + log << log1 << "System: auth_hashfs_dir is not set in the config file" << logend; + return false; + } + + path += '/'; + + // make sure that the length is even + if( (strlen(hash) & 1) != 0 ) + hash = buffer + 1; // the first character was zero + + // creating dirs without the last part + // the last part is a part of a file + for(size_t i=0 ; hash[i] != 0 ; i+=2) + { + path += hash[i]; + path += hash[i+1]; + + if( hash[i+2] != 0 ) + { + if( create_dir && !CreateDir(path, 0755) ) + return false; + + path += '/'; + } + } + + // one character more to make sure the path is unique + // (we can have a directory without the character) + path += "_"; + +return true; +} + + +// making a complete path to a static file +bool System::MakePath(const Item & item, std::string & path, bool create_dir) +{ +bool res; + + Mount * pmount = mounts.CalcMount(item.parent_id); + + if( !pmount || pmount->fs == Mount::simplefs ) + { + res = MakePathSimpleFs(path, item.parent_id, create_dir); + } + else + { + res = MakePathHashFs(path, item.id, create_dir); + } + + if( res ) + path += item.url; + else + path.clear(); + +return res; +} + + + +bool System::MakePath(Item & item, bool create_dir) +{ + return MakePath(item, item.auth_path, create_dir); +} + + + +Error System::AddFile(Item & item) +{ + if( item.type == Item::dir ) + return WINIX_ERR_FILE_EXPECTED; + + Error status = db->AddItem(item); + + if( status == WINIX_ERR_OK ) + { + log << log2 << "System: added a new file, url: " << item.url << ", id: " << item.id + << ", parent_id: " << item.parent_id << logend; + + request->notify_code |= WINIX_NOTIFY_ITEM_ADD; + } + +return status; +} + + + +Error System::EditFile(Item & item, bool with_url) +{ + if( item.type == Item::dir ) + return WINIX_ERR_FILE_EXPECTED; + + if( request->session && request->session->puser ) + request->item.modification_user_id = request->session->puser->id; + else + request->item.modification_user_id = -1; + + item.SetDateModifyToNow(); + Error status = db->EditItemById(item, with_url); + + if( status == WINIX_ERR_OK ) + { + TemplatesFunctions::pattern_cacher.UpdatePattern(item); + log << log2 << "System: modified an item" << logend; + + request->notify_code |= WINIX_NOTIFY_ITEM_EDIT; + } + +return status; +} + + + + +Error System::CheckSpecialFile(const Item & item) +{ + static std::string fstab = "fstab"; + + Item * etc = dirs.GetEtcDir(); + + if( !etc ) + return WINIX_NOTHING_TO_DO; + + if( item.parent_id != etc->id ) + return WINIX_NOTHING_TO_DO; + + if( item.url == fstab ) + { + log << log3 << "System: reloading mount points" << logend; + + Error status = mounts.ReadMounts(item.content); + templates->ReadNewIndexTemplates(); + + return status; + } + +return WINIX_NOTHING_TO_DO; +} diff --git a/core/system.h b/core/system.h new file mode 100755 index 0000000..354c052 --- /dev/null +++ b/core/system.h @@ -0,0 +1,111 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucorefs +#define headerfilecmslucorefs + + +#include "dirs.h" +#include "mounts.h" +#include "db.h" +#include "request.h" +#include "config.h" +#include "users.h" +#include "groups.h" +#include "rebus.h" +#include "loadavg.h" + + +class Functions; +class Templates; + + +// file system +class System +{ +public: + + // contains current directories tree + Dirs dirs; + + // mount points + Mounts mounts; + + // users + Users users; + + // groups + Groups groups; + + // rebus (captcha) + Rebus rebus; + + // load averages + LoadAvg load_avg; + + // the time when the winix starts + time_t system_start; + + + void SetRequest(Request * prequest); + void SetConfig(Config * pconfig); + void SetDb(Db * pdb); + void SetFunctions(Functions * pfunctions); + void SetTemplates(Templates * ptemplates); + void Init(); + + void RedirectTo(const Item & item, const char * postfix = 0); + void RedirectTo(long item_id, const char * postfix = 0); + void RedirectToLastDir(); + void RedirectToLastItem(); // redirect to an item if exists or to the last directory + + void PrepareUrl(Item & item); + + bool CanChangeUser(const Item & item, long new_user_id); + bool CanChangeGroup(const Item & item, long new_group_id); + bool CanChangePrivileges(const Item & item, int new_priv); + bool HasAccess(const Item & item, int mask); + bool HasReadAccess(const Item & item); + bool HasWriteAccess(const Item & item); + bool HasReadWriteAccess(const Item & item); + bool HasReadExecAccess(const Item & item); + bool HasReadExecAccessToPath(long dir_id); + bool DirsHaveReadExecPerm(); + void CheckAccessToItems(std::vector<Item> & item_table); + + bool CanUseHtml(long user_id); + bool CanUseBBCode(long user_id); + bool CanUseRaw(long user_id); + + bool IsMemberOfGroup(long user_id, const char * group_name); + + bool MakePath(const Item & item, std::string & path, bool create_dir); + bool MakePath(Item & item, bool create_dir); // output path is: item.auth_path + + Error AddFile(Item & item); + Error EditFile(Item & item, bool with_url = true); + + Error CheckSpecialFile(const Item & item); + +private: + Request * request; + Config * config; + Db * db; + Functions * functions; + Templates * templates; + + std::string path; + bool MakePathSimpleFs(std::string & path, long dir_id, bool create_dir); + bool MakePathHashFs(std::string & path, long id, bool create_dir); + +}; + + +#endif + diff --git a/core/thread.h b/core/thread.h index 948c30e..809b34e 100755 --- a/core/thread.h +++ b/core/thread.h @@ -31,12 +31,16 @@ public: // at the moment only used: id, date_modification, user_id Item last_item; + // used when sorting + long sort; + void Clear() { id = parent_id = dir_id = -1; last_item.Clear(); closed = false; items = 0; + sort = 0; } Thread() diff --git a/core/users.cpp b/core/users.cpp index a2bf339..94321ba 100755 --- a/core/users.cpp +++ b/core/users.cpp @@ -7,17 +7,23 @@ * */ +#include <arpa/inet.h> #include "users.h" -#include "db.h" Users::Users() { + how_many_logged = 0; Clear(); } +void Users::SetRequest(Request * prequest) +{ + request = prequest; +} + void Users::Clear() { @@ -26,11 +32,10 @@ void Users::Clear() -void Users::ReadUsers() +void Users::ReadUsers(Db * db) { Clear(); - - db.GetUsers(table); + db->GetUsers(table); } @@ -110,13 +115,59 @@ User & Users::operator[](Users::SizeType pos) } +void Users::LoginUser(long user_id, bool remember_me) +{ + if( !request->session ) + return; + + request->session->puser = GetUser(user_id); + request->session->spam_score = 0; + + if( !request->session->puser ) + { + log << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend; + return; + } + + request->session->remember_me = remember_me; + + last.UserLogin(user_id, request->session->puser->name, inet_addr(request->env_remote_addr), request->session->id); + how_many_logged += 1; + + log << log2 << "User " << request->session->puser->name << " (id: " << user_id << ") logged" << logend; +} - - - +void Users::LogoutCurrentUser() +{ + if( !request->session || !request->session->puser ) + return; + + log << log2 << "Users: user " << request->session->puser->name << ", id: " + << request->session->puser->id << " logged out" << logend; + + last.UserLogout(request->session->puser->id, request->session->id); + + if( how_many_logged > 0 ) // for safety + how_many_logged -= 1; + + request->session->puser = 0; + request->session->remember_me = 0; +} + + +void Users::IncrementLoggedUsers() +{ + how_many_logged += 1; +} + + +long Users::HowManyLogged() +{ + return how_many_logged; +} diff --git a/core/users.h b/core/users.h index fadace6..3a82fad 100755 --- a/core/users.h +++ b/core/users.h @@ -13,26 +13,32 @@ #include <map> #include "user.h" #include "ugcontainer.h" - - +#include "lastcontainer.h" +#include "request.h" +#include "db.h" class Users { - typedef UGContainer<User> Table; Table table; + Request * request; + long how_many_logged; public: typedef Table::Iterator Iterator; typedef Table::SizeType SizeType; + LastContainer last; Users(); + + void SetRequest(Request * request); + void Clear(); - void ReadUsers(); + void ReadUsers(Db * db); bool AddUser(const User & user); bool IsUser(const std::string & name); User * GetUser(long user_id); @@ -42,6 +48,12 @@ public: Iterator End(); SizeType Size(); User & operator[](SizeType pos); + + void LoginUser(long user_id, bool remember_me); + void LogoutCurrentUser(); + + void IncrementLoggedUsers(); + long HowManyLogged(); }; diff --git a/core/version.h b/core/version.h index bf96f6c..c812aed 100755 --- a/core/version.h +++ b/core/version.h @@ -12,8 +12,8 @@ #define WINIX_VER_MAJOR 0 -#define WINIX_VER_MINOR 3 -#define WINIX_VER_REVISION 3 +#define WINIX_VER_MINOR 4 +#define WINIX_VER_REVISION 0 #endif diff --git a/content/Makefile b/functions/Makefile similarity index 100% rename from content/Makefile rename to functions/Makefile diff --git a/functions/Makefile.dep b/functions/Makefile.dep new file mode 100755 index 0000000..cc9b6a7 --- /dev/null +++ b/functions/Makefile.dep @@ -0,0 +1,568 @@ +# DO NOT DELETE + +adduser.o: adduser.h functionbase.h ../core/item.h ../core/db.h +adduser.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +adduser.o: ../core/error.h ../core/log.h ../core/dircontainer.h +adduser.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +adduser.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +adduser.o: ../core/rebus.h ../core/compress.h ../core/acceptencodingparser.h +adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +adduser.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +adduser.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +adduser.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +adduser.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +adduser.o: ../core/notify.h ../templatesnotify/templatesnotify.h +adduser.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +adduser.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +adduser.o: ../core/system.h +cat.o: cat.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +cat.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +cat.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +cat.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +cat.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +cat.o: ../core/compress.h ../core/acceptencodingparser.h +cat.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +cat.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +cat.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +cat.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +cat.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +cat.o: ../core/notify.h ../templatesnotify/templatesnotify.h +cat.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +cat.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +cat.o: ../core/system.h +chmod.o: chmod.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +chmod.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +chmod.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +chmod.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +chmod.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +chmod.o: ../core/compress.h ../core/acceptencodingparser.h +chmod.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +chmod.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +chmod.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +chmod.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +chmod.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +chmod.o: ../core/notify.h ../templatesnotify/templatesnotify.h +chmod.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +chmod.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +chmod.o: ../core/system.h privchanger.h +chown.o: chown.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +chown.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +chown.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +chown.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +chown.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +chown.o: ../core/compress.h ../core/acceptencodingparser.h +chown.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +chown.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +chown.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +chown.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +chown.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +chown.o: ../core/notify.h ../templatesnotify/templatesnotify.h +chown.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +chown.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +chown.o: ../core/system.h privchanger.h +cp.o: cp.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +cp.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +cp.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +cp.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +cp.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +cp.o: ../core/compress.h ../core/acceptencodingparser.h +cp.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +cp.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +cp.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +cp.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +cp.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +cp.o: ../core/notify.h ../templatesnotify/templatesnotify.h +cp.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +cp.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +cp.o: ../core/system.h ../core/misc.h +createthread.o: createthread.h functionbase.h ../core/item.h ../core/db.h +createthread.o: ../core/item.h ../core/user.h ../core/group.h +createthread.o: ../core/thread.h ../core/error.h ../core/log.h +createthread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h +createthread.o: ../core/request.h ../core/requesttypes.h ../core/session.h +createthread.o: ../core/plugindata.h ../core/rebus.h ../core/compress.h +createthread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +createthread.o: ../core/htmlfilter.h ../core/postmultiparser.h +createthread.o: ../core/config.h ../core/confparser.h ../core/config.h +createthread.o: ../core/system.h ../core/dirs.h ../core/db.h +createthread.o: ../core/request.h ../core/mounts.h ../core/mount.h +createthread.o: ../core/users.h ../core/lastcontainer.h ../core/groups.h +createthread.o: ../core/loadavg.h ../core/notify.h +createthread.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +createthread.o: ../core/mount.h ../core/locale.h ../templates/misc.h +createthread.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +createthread.o: functions.h functionparser.h adduser.h cat.h chmod.h +createthread.o: privchanger.h chown.h cp.h createticket.h default.h +createthread.o: download.h editticket.h emacs.h last.h login.h logout.h ls.h +createthread.o: mkdir.h mv.h node.h priv.h reload.h rm.h run.h subject.h +createthread.o: funthread.h ../core/thread.h funticket.h uname.h upload.h +createthread.o: who.h +createticket.o: createticket.h functionbase.h ../core/item.h ../core/db.h +createticket.o: ../core/item.h ../core/user.h ../core/group.h +createticket.o: ../core/thread.h ../core/error.h ../core/log.h +createticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h +createticket.o: ../core/request.h ../core/requesttypes.h ../core/session.h +createticket.o: ../core/plugindata.h ../core/rebus.h ../core/compress.h +createticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +createticket.o: ../core/htmlfilter.h ../core/postmultiparser.h +createticket.o: ../core/config.h ../core/confparser.h ../core/config.h +createticket.o: ../core/system.h ../core/dirs.h ../core/db.h +createticket.o: ../core/request.h ../core/mounts.h ../core/mount.h +createticket.o: ../core/users.h ../core/lastcontainer.h ../core/groups.h +createticket.o: ../core/loadavg.h ../core/notify.h +createticket.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +createticket.o: ../core/mount.h ../core/locale.h ../templates/misc.h +createticket.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +createticket.o: readticket.h ../core/ticket.h functions.h functionparser.h +createticket.o: adduser.h cat.h chmod.h privchanger.h chown.h cp.h +createticket.o: createthread.h default.h download.h editticket.h emacs.h +createticket.o: last.h login.h logout.h ls.h mkdir.h mv.h node.h priv.h +createticket.o: reload.h rm.h run.h subject.h funthread.h ../core/thread.h +createticket.o: funticket.h uname.h upload.h who.h +default.o: default.h functionbase.h ../core/item.h ../core/db.h +default.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +default.o: ../core/error.h ../core/log.h ../core/dircontainer.h +default.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +default.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +default.o: ../core/rebus.h ../core/compress.h ../core/acceptencodingparser.h +default.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +default.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +default.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +default.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +default.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +default.o: ../core/notify.h ../templatesnotify/templatesnotify.h +default.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +default.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +default.o: ../core/system.h +download.o: download.h functionbase.h ../core/item.h ../core/db.h +download.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +download.o: ../core/error.h ../core/log.h ../core/dircontainer.h +download.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +download.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +download.o: ../core/rebus.h ../core/compress.h ../core/acceptencodingparser.h +download.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +download.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +download.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +download.o: ../core/request.h ../core/mounts.h ../core/mount.h +download.o: ../core/users.h ../core/lastcontainer.h ../core/groups.h +download.o: ../core/loadavg.h ../core/notify.h +download.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +download.o: ../core/mount.h ../core/locale.h ../templates/misc.h +download.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +editticket.o: editticket.h functionbase.h ../core/item.h ../core/db.h +editticket.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +editticket.o: ../core/error.h ../core/log.h ../core/dircontainer.h +editticket.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +editticket.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +editticket.o: ../core/rebus.h ../core/compress.h +editticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +editticket.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +editticket.o: ../core/confparser.h ../core/config.h ../core/system.h +editticket.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +editticket.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +editticket.o: ../core/groups.h ../core/loadavg.h ../core/notify.h +editticket.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +editticket.o: ../core/mount.h ../core/locale.h ../templates/misc.h +editticket.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +editticket.o: functions.h functionparser.h adduser.h cat.h chmod.h +editticket.o: privchanger.h chown.h cp.h createthread.h createticket.h +editticket.o: default.h download.h emacs.h last.h login.h logout.h ls.h +editticket.o: mkdir.h mv.h node.h priv.h reload.h rm.h run.h subject.h +editticket.o: funthread.h ../core/thread.h funticket.h uname.h upload.h who.h +editticket.o: readticket.h ../core/ticket.h +emacs.o: emacs.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +emacs.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +emacs.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +emacs.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +emacs.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +emacs.o: ../core/compress.h ../core/acceptencodingparser.h +emacs.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +emacs.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +emacs.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +emacs.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +emacs.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +emacs.o: ../core/notify.h ../templatesnotify/templatesnotify.h +emacs.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +emacs.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +emacs.o: ../core/system.h ../templates/templates.h +emacs.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h +emacs.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +emacs.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h +emacs.o: ../core/sessioncontainer.h functions.h functionparser.h adduser.h +emacs.o: cat.h chmod.h privchanger.h chown.h cp.h createthread.h +emacs.o: createticket.h default.h download.h editticket.h last.h login.h +emacs.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h +emacs.o: subject.h funthread.h ../core/thread.h funticket.h uname.h upload.h +emacs.o: who.h +functionbase.o: functionbase.h ../core/item.h ../core/db.h ../core/item.h +functionbase.o: ../core/user.h ../core/group.h ../core/thread.h +functionbase.o: ../core/error.h ../core/log.h ../core/dircontainer.h +functionbase.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +functionbase.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +functionbase.o: ../core/rebus.h ../core/compress.h +functionbase.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +functionbase.o: ../core/htmlfilter.h ../core/postmultiparser.h +functionbase.o: ../core/config.h ../core/confparser.h ../core/config.h +functionbase.o: ../core/system.h ../core/dirs.h ../core/db.h +functionbase.o: ../core/request.h ../core/mounts.h ../core/mount.h +functionbase.o: ../core/users.h ../core/lastcontainer.h ../core/groups.h +functionbase.o: ../core/loadavg.h ../core/notify.h +functionbase.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +functionbase.o: ../core/mount.h ../core/locale.h ../templates/misc.h +functionbase.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +functionbase.o: functions.h functionparser.h adduser.h cat.h chmod.h +functionbase.o: privchanger.h chown.h cp.h createthread.h createticket.h +functionbase.o: default.h download.h editticket.h emacs.h last.h login.h +functionbase.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h +functionbase.o: subject.h funthread.h ../core/thread.h funticket.h uname.h +functionbase.o: upload.h who.h +functionparser.o: functionparser.h ../core/request.h ../core/requesttypes.h +functionparser.o: ../core/session.h ../core/item.h ../core/error.h +functionparser.o: ../core/log.h ../core/user.h ../core/plugindata.h +functionparser.o: ../core/rebus.h ../core/thread.h ../core/compress.h +functionparser.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +functionparser.o: ../core/htmlfilter.h ../core/postmultiparser.h +functionparser.o: ../core/config.h ../core/confparser.h ../core/ticket.h +functionparser.o: ../core/db.h ../core/group.h ../core/dircontainer.h +functionparser.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h +functionparser.o: ../core/db.h ../core/request.h ../core/mounts.h +functionparser.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +functionparser.o: ../core/groups.h ../core/loadavg.h ../core/log.h +functionparser.o: ../core/item.h ../core/error.h functions.h functionbase.h +functionparser.o: ../core/config.h ../core/notify.h +functionparser.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +functionparser.o: ../core/mount.h ../core/locale.h ../templates/misc.h +functionparser.o: ../templates/localefilter.h ../core/locale.h +functionparser.o: ../core/system.h adduser.h cat.h chmod.h privchanger.h +functionparser.o: chown.h cp.h createthread.h createticket.h default.h +functionparser.o: download.h editticket.h emacs.h last.h login.h logout.h +functionparser.o: ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h +functionparser.o: subject.h funthread.h ../core/thread.h funticket.h uname.h +functionparser.o: upload.h who.h +functions.o: functions.h functionbase.h ../core/item.h ../core/db.h +functions.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +functions.o: ../core/error.h ../core/log.h ../core/dircontainer.h +functions.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +functions.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +functions.o: ../core/rebus.h ../core/compress.h +functions.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +functions.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +functions.o: ../core/confparser.h ../core/config.h ../core/system.h +functions.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +functions.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +functions.o: ../core/groups.h ../core/loadavg.h ../core/notify.h +functions.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +functions.o: ../core/mount.h ../core/locale.h ../templates/misc.h +functions.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +functions.o: functionparser.h adduser.h cat.h chmod.h privchanger.h chown.h +functions.o: cp.h createthread.h createticket.h default.h download.h +functions.o: editticket.h emacs.h last.h login.h logout.h ls.h mkdir.h mv.h +functions.o: node.h priv.h reload.h rm.h run.h subject.h funthread.h +functions.o: ../core/thread.h funticket.h uname.h upload.h who.h +functions.o: ../core/log.h ../core/misc.h ../templates/templates.h +functions.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h +functions.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +functions.o: ../core/log.h ../templates/indexpatterns.h +functions.o: ../core/sessionmanager.h ../core/sessioncontainer.h +funthread.o: funthread.h functionbase.h ../core/item.h ../core/db.h +funthread.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +funthread.o: ../core/error.h ../core/log.h ../core/dircontainer.h +funthread.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +funthread.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +funthread.o: ../core/rebus.h ../core/compress.h +funthread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +funthread.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +funthread.o: ../core/confparser.h ../core/config.h ../core/system.h +funthread.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +funthread.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +funthread.o: ../core/groups.h ../core/loadavg.h ../core/notify.h +funthread.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +funthread.o: ../core/mount.h ../core/locale.h ../templates/misc.h +funthread.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +funthread.o: ../core/thread.h +funticket.o: funticket.h functionbase.h ../core/item.h ../core/db.h +funticket.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +funticket.o: ../core/error.h ../core/log.h ../core/dircontainer.h +funticket.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +funticket.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +funticket.o: ../core/rebus.h ../core/compress.h +funticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +funticket.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +funticket.o: ../core/confparser.h ../core/config.h ../core/system.h +funticket.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +funticket.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +funticket.o: ../core/groups.h ../core/loadavg.h ../core/notify.h +funticket.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +funticket.o: ../core/mount.h ../core/locale.h ../templates/misc.h +funticket.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +last.o: last.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +last.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +last.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +last.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +last.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +last.o: ../core/compress.h ../core/acceptencodingparser.h +last.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +last.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +last.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +last.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +last.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +last.o: ../core/notify.h ../templatesnotify/templatesnotify.h +last.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +last.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +last.o: ../core/system.h +login.o: login.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +login.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +login.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +login.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +login.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +login.o: ../core/compress.h ../core/acceptencodingparser.h +login.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +login.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +login.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +login.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +login.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +login.o: ../core/notify.h ../templatesnotify/templatesnotify.h +login.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +login.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +login.o: ../core/system.h +logout.o: logout.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +logout.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +logout.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +logout.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +logout.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +logout.o: ../core/compress.h ../core/acceptencodingparser.h +logout.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +logout.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +logout.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +logout.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +logout.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +logout.o: ../core/notify.h ../templatesnotify/templatesnotify.h +logout.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +logout.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +logout.o: ../core/system.h +ls.o: ls.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +ls.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +ls.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +ls.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +ls.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +ls.o: ../core/compress.h ../core/acceptencodingparser.h +ls.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +ls.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +ls.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +ls.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +ls.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +ls.o: ../core/notify.h ../templatesnotify/templatesnotify.h +ls.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +ls.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +ls.o: ../core/system.h +mkdir.o: mkdir.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +mkdir.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +mkdir.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +mkdir.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +mkdir.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +mkdir.o: ../core/compress.h ../core/acceptencodingparser.h +mkdir.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +mkdir.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +mkdir.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +mkdir.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +mkdir.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +mkdir.o: ../core/notify.h ../templatesnotify/templatesnotify.h +mkdir.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +mkdir.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +mkdir.o: ../core/system.h functions.h functionparser.h adduser.h cat.h +mkdir.o: chmod.h privchanger.h chown.h cp.h createthread.h createticket.h +mkdir.o: default.h download.h editticket.h emacs.h last.h login.h logout.h +mkdir.o: ls.h mv.h node.h priv.h reload.h rm.h run.h subject.h funthread.h +mkdir.o: ../core/thread.h funticket.h uname.h upload.h who.h +mv.o: mv.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +mv.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +mv.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +mv.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +mv.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +mv.o: ../core/compress.h ../core/acceptencodingparser.h +mv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +mv.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +mv.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +mv.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +mv.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +mv.o: ../core/notify.h ../templatesnotify/templatesnotify.h +mv.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +mv.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +mv.o: ../core/system.h +node.o: node.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +node.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +node.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +node.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +node.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +node.o: ../core/compress.h ../core/acceptencodingparser.h +node.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +node.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +node.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +node.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +node.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +node.o: ../core/notify.h ../templatesnotify/templatesnotify.h +node.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +node.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +node.o: ../core/system.h +priv.o: priv.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +priv.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +priv.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +priv.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +priv.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +priv.o: ../core/compress.h ../core/acceptencodingparser.h +priv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +priv.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +priv.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +priv.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +priv.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +priv.o: ../core/notify.h ../templatesnotify/templatesnotify.h +priv.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +priv.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +priv.o: ../core/system.h privchanger.h +privchanger.o: privchanger.h ../core/request.h ../core/requesttypes.h +privchanger.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h +privchanger.o: ../core/user.h ../core/plugindata.h ../core/rebus.h +privchanger.o: ../core/thread.h ../core/compress.h +privchanger.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +privchanger.o: ../core/htmlfilter.h ../core/postmultiparser.h +privchanger.o: ../core/config.h ../core/confparser.h ../core/ticket.h +privchanger.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h +privchanger.o: ../core/db.h ../core/request.h ../core/mounts.h +privchanger.o: ../core/mount.h ../core/users.h ../core/ugcontainer.h +privchanger.o: ../core/lastcontainer.h ../core/groups.h ../core/group.h +privchanger.o: ../core/loadavg.h ../core/db.h +readticket.o: readticket.h ../core/request.h ../core/requesttypes.h +readticket.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h +readticket.o: ../core/user.h ../core/plugindata.h ../core/rebus.h +readticket.o: ../core/thread.h ../core/compress.h +readticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +readticket.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +readticket.o: ../core/confparser.h ../core/ticket.h ../core/ticket.h +readticket.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h +readticket.o: ../core/db.h ../core/request.h ../core/mounts.h ../core/mount.h +readticket.o: ../core/users.h ../core/ugcontainer.h ../core/lastcontainer.h +readticket.o: ../core/groups.h ../core/group.h ../core/loadavg.h +reload.o: reload.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +reload.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +reload.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +reload.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +reload.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +reload.o: ../core/compress.h ../core/acceptencodingparser.h +reload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +reload.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +reload.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +reload.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +reload.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +reload.o: ../core/notify.h ../templatesnotify/templatesnotify.h +reload.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +reload.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +reload.o: ../core/system.h ../templates/templates.h +reload.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h +reload.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +reload.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h +reload.o: ../core/sessioncontainer.h +rm.o: rm.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +rm.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +rm.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +rm.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +rm.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +rm.o: ../core/compress.h ../core/acceptencodingparser.h +rm.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +rm.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +rm.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +rm.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +rm.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +rm.o: ../core/notify.h ../templatesnotify/templatesnotify.h +rm.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +rm.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +rm.o: ../core/system.h ../core/plugin.h ../core/pluginmsg.h +rm.o: ../core/sessionmanager.h ../core/sessioncontainer.h +rm.o: ../functions/functions.h functionparser.h adduser.h cat.h chmod.h +rm.o: privchanger.h chown.h cp.h createthread.h createticket.h default.h +rm.o: download.h editticket.h emacs.h last.h login.h logout.h ls.h mkdir.h +rm.o: mv.h node.h priv.h reload.h run.h subject.h funthread.h +rm.o: ../core/thread.h funticket.h uname.h upload.h who.h +rm.o: ../templates/templates.h ../templates/patterncacher.h ../core/item.h +rm.o: ../templates/misc.h ../templates/ckeditorgetparser.h +rm.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h +rm.o: ../core/sessionmanager.h +run.o: run.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +run.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +run.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +run.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +run.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +run.o: ../core/compress.h ../core/acceptencodingparser.h +run.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +run.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +run.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +run.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +run.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +run.o: ../core/notify.h ../templatesnotify/templatesnotify.h +run.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +run.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +run.o: ../core/system.h +subject.o: subject.h functionbase.h ../core/item.h ../core/db.h +subject.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +subject.o: ../core/error.h ../core/log.h ../core/dircontainer.h +subject.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +subject.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +subject.o: ../core/rebus.h ../core/compress.h ../core/acceptencodingparser.h +subject.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +subject.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +subject.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +subject.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +subject.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +subject.o: ../core/notify.h ../templatesnotify/templatesnotify.h +subject.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +subject.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +subject.o: ../core/system.h +uname.o: uname.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +uname.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +uname.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +uname.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +uname.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +uname.o: ../core/compress.h ../core/acceptencodingparser.h +uname.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +uname.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +uname.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +uname.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +uname.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +uname.o: ../core/notify.h ../templatesnotify/templatesnotify.h +uname.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +uname.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +uname.o: ../core/system.h +upload.o: upload.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +upload.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +upload.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +upload.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +upload.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +upload.o: ../core/compress.h ../core/acceptencodingparser.h +upload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +upload.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +upload.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +upload.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +upload.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +upload.o: ../core/notify.h ../templatesnotify/templatesnotify.h +upload.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +upload.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +upload.o: ../core/system.h ../core/misc.h ../functions/functions.h +upload.o: functionparser.h adduser.h cat.h chmod.h privchanger.h chown.h cp.h +upload.o: createthread.h createticket.h default.h download.h editticket.h +upload.o: emacs.h last.h login.h logout.h ls.h mkdir.h mv.h node.h priv.h +upload.o: reload.h rm.h run.h subject.h funthread.h ../core/thread.h +upload.o: funticket.h uname.h who.h +who.o: who.h functionbase.h ../core/item.h ../core/db.h ../core/item.h +who.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h +who.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h +who.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h +who.o: ../core/session.h ../core/plugindata.h ../core/rebus.h +who.o: ../core/compress.h ../core/acceptencodingparser.h +who.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +who.o: ../core/postmultiparser.h ../core/config.h ../core/confparser.h +who.o: ../core/config.h ../core/system.h ../core/dirs.h ../core/db.h +who.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +who.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +who.o: ../core/notify.h ../templatesnotify/templatesnotify.h +who.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h +who.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +who.o: ../core/system.h diff --git a/functions/Makefile.o.dep b/functions/Makefile.o.dep new file mode 100755 index 0000000..8710e95 --- /dev/null +++ b/functions/Makefile.o.dep @@ -0,0 +1 @@ +o = adduser.o cat.o chmod.o chown.o cp.o createthread.o createticket.o default.o download.o editticket.o emacs.o functionbase.o functionparser.o functions.o funthread.o funticket.o last.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o readticket.o reload.o rm.o run.o subject.o uname.o upload.o who.o diff --git a/functions/adduser.cpp b/functions/adduser.cpp new file mode 100755 index 0000000..daa4e5f --- /dev/null +++ b/functions/adduser.cpp @@ -0,0 +1,105 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "adduser.h" + + + +namespace Fun +{ + + +AddUser::AddUser() +{ + fun.url = "adduser"; +} + + +bool AddUser::CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass) +{ + if( !login || !pass || !conf_pass ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + + if( login->empty() ) + { + request->status = WINIX_ERR_LOGIN_EMPTY; + return false; + } + + if( *pass != *conf_pass ) + { + request->status = WINIX_ERR_PASSWORDS_DIFFERENT; + return false; + } + + if( pass->size() < 5 ) + { + request->status = WINIX_ERR_PASSWORD_TOO_SHORT; + return false; + } + + if( system->users.IsUser(*login) ) + { + request->status = WINIX_ERR_USER_EXISTS; + return false; + } + +return true; +} + + + + + + +void AddUser::MakePost() +{ +User user; + + std::string * login = request->PostVar("login"); + std::string * pass = request->PostVar("password"); + std::string * conf_pass = request->PostVar("confirmpassword"); + std::string * email = request->PostVar("email"); + + if( !CheckAddUserVars(login, pass, conf_pass) ) + return; + + user.name = *login; + + if( email ) + user.email = *email; + + request->status = db->AddUser(user, *pass); + + if( request->status == WINIX_ERR_OK ) + { + if( system->users.AddUser(user) ) + { + if( !request->session->puser ) + system->users.LoginUser(user.id, false); + + log << log2 << "Content: added a new user: " << user.name << logend; + } + else + { + log << log1 << "Content: I can't add to system->users: " << user.name + << " but the user was added to the db correctly" << logend; + } + + system->RedirectToLastItem(); + } +} + + + + +} // namespace diff --git a/functions/adduser.h b/functions/adduser.h new file mode 100755 index 0000000..c1bd36f --- /dev/null +++ b/functions/adduser.h @@ -0,0 +1,37 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentadduser +#define headerfilecmslucontentadduser + +#include "functionbase.h" + + + +namespace Fun +{ + + +class AddUser : public FunctionBase +{ +public: + + AddUser(); + void MakePost(); + +private: + + bool CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass); + +}; + + +} // namespace + +#endif diff --git a/functions/cat.cpp b/functions/cat.cpp new file mode 100755 index 0000000..2988a70 --- /dev/null +++ b/functions/cat.cpp @@ -0,0 +1,43 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "cat.h" + + + +namespace Fun +{ + +Cat::Cat() +{ + fun.url = "cat"; +} + + +void Cat::MakeGet() +{ + if( !request->is_item ) + { + log << log1 << "Content: cat function requires an item" << logend; + request->status = WINIX_ERR_NO_ITEM; + return; + } + + + if( !system->HasReadAccess(request->item) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + request->send_as_attachment = request->IsParam("attachment"); +} + + +} // namespace diff --git a/functions/cat.h b/functions/cat.h new file mode 100755 index 0000000..16f9b02 --- /dev/null +++ b/functions/cat.h @@ -0,0 +1,33 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentfuncatcat +#define headerfilecmslucontentfuncatcat + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Cat : public FunctionBase +{ +public: + + Cat(); + void MakeGet(); + +}; + + +} // namespace Fun + +#endif diff --git a/functions/chmod.cpp b/functions/chmod.cpp new file mode 100755 index 0000000..5bca6ba --- /dev/null +++ b/functions/chmod.cpp @@ -0,0 +1,45 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "chmod.h" + + + +namespace Fun +{ + + +Chmod::Chmod() +{ + fun.url = "chmod"; +} + + +void Chmod::MakePost() +{ + priv_changer.SetRequest(request); + priv_changer.SetSystem(system); + priv_changer.SetDb(db); + + priv_changer.Change(false, true); +} + + +void Chmod::MakeGet() +{ + priv_changer.SetRequest(request); + priv_changer.SetSystem(system); + priv_changer.SetDb(db); + + priv_changer.CheckAccess(); +} + + + +} // namespace diff --git a/functions/chmod.h b/functions/chmod.h new file mode 100755 index 0000000..b152d97 --- /dev/null +++ b/functions/chmod.h @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentchmod +#define headerfilecmslucontentchmod + +#include "functionbase.h" +#include "privchanger.h" + + + +namespace Fun +{ + + +class Chmod : public FunctionBase +{ +public: + + Chmod(); + void MakePost(); + void MakeGet(); + +private: + + PrivChanger priv_changer; +}; + + +} // namespace + +#endif diff --git a/functions/chown.cpp b/functions/chown.cpp new file mode 100755 index 0000000..e219fc3 --- /dev/null +++ b/functions/chown.cpp @@ -0,0 +1,45 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "chown.h" + + + +namespace Fun +{ + + +Chown::Chown() +{ + fun.url = "chown"; +} + + +void Chown::MakePost() +{ + priv_changer.SetRequest(request); + priv_changer.SetSystem(system); + priv_changer.SetDb(db); + + priv_changer.Change(true, false); +} + + +void Chown::MakeGet() +{ + priv_changer.SetRequest(request); + priv_changer.SetSystem(system); + priv_changer.SetDb(db); + + priv_changer.CheckAccess(); +} + + + +} // namespace diff --git a/functions/chown.h b/functions/chown.h new file mode 100755 index 0000000..48b93fd --- /dev/null +++ b/functions/chown.h @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentchown +#define headerfilecmslucontentchown + +#include "functionbase.h" +#include "privchanger.h" + + + +namespace Fun +{ + + +class Chown : public FunctionBase +{ +public: + + Chown(); + void MakePost(); + void MakeGet(); + +private: + + PrivChanger priv_changer; +}; + + +} // namespace + +#endif diff --git a/functions/cp.cpp b/functions/cp.cpp new file mode 100755 index 0000000..8fd3b6c --- /dev/null +++ b/functions/cp.cpp @@ -0,0 +1,334 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include <errno.h> +#include "cp.h" +#include "core/misc.h" + + + +namespace Fun +{ + +Cp::Cp() +{ + fun.url = "cp"; +} + + +bool Cp::CpCheckAccessFrom() +{ + if( request->is_item ) + { + if( !system->HasReadAccess(request->item) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + } + else + if( !request->IsParam("r") ) + { + // directories need 'r' parameter + request->status = WINIX_ERR_PERMISSION_DENIED; + } + + +return true; +} + + +bool Cp::CheckAccessTo(long dir_id) +{ + Item * pdir = system->dirs.GetDir(dir_id); + + if( !pdir ) + { + request->status = WINIX_ERR_INCORRECT_DIR; + return false; + } + + if( !system->HasReadExecAccessToPath(dir_id) || !system->HasWriteAccess(*pdir) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + +return true; +} + + + +bool Cp::ParseDir(long & dir_id, std::string & dir, std::string & file) +{ + std::string * move_to = request->PostVar("to"); + + if( !move_to ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + + int res = system->dirs.AnalyzePath(*move_to, dir_id, dir, file); + + if( res == 1 ) + request->status = WINIX_ERR_NO_ROOT_DIR; + else + if( res != 0 ) + request->status = WINIX_ERR_INCORRECT_DIR; + +return res == 0; +} + + + +void Cp::CpAuth(Item & item) +{ + if( !system->MakePath(item, mv_new_path, true) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + if( CopyFile(item.auth_path, mv_new_path) ) + { + log << log1 << "Content: copied static file from: " << item.auth_path << ", to: " << mv_new_path << logend; + item.auth_path = mv_new_path; + request->status = db->EditAuthById(item, item.id); + } + else + { + log << log1 << "Content: can't copy a file from: " << item.auth_path << ", to: " << mv_new_path << logend; + request->status = WINIX_ERR_PERMISSION_DENIED; + } +} + + +void Cp::CpSetNewAttributes(Item & item) +{ + item.user_id = cp_new_user; + item.group_id = cp_new_group; + item.SetDateModifyToNow(); +} + + +void Cp::CpItem(Item & item, long dst_dir_id) +{ + if( !system->HasReadAccess(item) ) + return; // !! w przyszlosci bedziemy dodawac komunikaty do specjalnej tablicy (narazie nie zaimplementowane) + + item.parent_id = dst_dir_id; + + if( !cp_preserve_attr ) + CpSetNewAttributes(item); + + request->status = system->AddFile(item); + + if( request->status == WINIX_ERR_OK ) + { + if( item.auth != Item::auth_none ) + CpAuth(item); + } +} + + + + +void Cp::CpPrepare() +{ + cp_iq.SetAll(true, false); + cp_iq.WhereType(Item::file); + + cp_new_user = -1; + cp_new_group = -1; + + if( request->session->puser ) + cp_new_user = request->session->puser->id; + + Item * pdir = system->dirs.GetDir(mv_dir_id); + + if( pdir ) + cp_new_group = pdir->group_id; +} + + + +void Cp::CpFilesInDir(const Item & dir, long dst_dir_id) +{ + cp_iq.WhereParentId(dir.id); + db->GetItems(request->item_table, cp_iq); + + for(size_t i=0 ; i<request->item_table.size() ; ++i) + CpItem(request->item_table[i], dst_dir_id); +} + + + +void Cp::CpContentOfDir(const Item & item, long dst_dir_id) +{ + DirContainer::ParentIterator i = system->dirs.FindFirstParent(item.id); + + // go through all directories + for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextParent(i) ) + CpDir(*(i->second), dst_dir_id); + + CpFilesInDir(item, dst_dir_id); +} + + + +// we shouldn't change 'item' because we have references to our app.dirs objects +long Cp::CpDir(const Item & item, long dst_dir_id) +{ + cp_temp = item; + cp_temp.parent_id = dst_dir_id; + + if( !mv_file.empty() ) + { + cp_temp.url = mv_file; + mv_file.clear(); + system->PrepareUrl(cp_temp); + } + + if( !cp_preserve_attr ) + CpSetNewAttributes(cp_temp); + + if( cp_remove_defaults ) + cp_temp.default_item = -1; + + request->status = system->dirs.AddDirectory(cp_temp); + long new_dir_id = cp_temp.id; // remember the new dir_id + + if( system->HasReadExecAccess(item) ) + CpContentOfDir(item, cp_temp.id); + +return new_dir_id; // and return it +} + + +bool Cp::IsTheSameFile(const Item & item) +{ + if( mv_file.empty() ) + { + if( item.parent_id == mv_dir_id ) + return true; // nothing to do + } + else + { + if( item.parent_id == mv_dir_id && item.url == mv_file ) + return true; // nothing to do + } + +return false; +} + + + + +// here 'item' can be changed in place +void Cp::CpItemCheck(Item & item, bool redirect) +{ + if( IsTheSameFile(item) ) + return; + + if( !mv_file.empty() ) + { + item.url = mv_file; + system->PrepareUrl(item); + } + + CpItem(item, mv_dir_id); + + if( request->status==WINIX_ERR_OK && redirect ) + system->RedirectTo(item); +} + + + +void Cp::CpContentOfDirCheck(const Item & item, bool redirect) +{ + if( !mv_file.empty() ) + { + request->status = WINIX_ERR_INCORRECT_DIR; + return; + } + + if( mv_dir_id == item.id ) + return; // nothing to do + + if( system->dirs.HasParent(mv_dir_id, item.id) ) + { + log << log1 << "Content: cannot copy directory to inside it" << logend; + request->status = WINIX_ERR_INCORRECT_DIR; + return; + } + + CpContentOfDir(item, mv_dir_id); + + if( request->status==WINIX_ERR_OK && redirect ) + system->RedirectTo(mv_dir_id); +} + + + +void Cp::CpDirCheck(const Item & item, bool redirect) +{ + if( mv_file.empty() && mv_dir_id == item.id ) + return; // nothing to do + + if( mv_dir_id == item.id || system->dirs.HasParent(mv_dir_id, item.id) ) + { + log << log1 << "Content: cannot copy directory to inside it" << logend; + request->status = WINIX_ERR_INCORRECT_DIR; + return; + } + + long new_dir_id = CpDir(item, mv_dir_id); + + if( request->status==WINIX_ERR_OK && redirect ) + system->RedirectTo(new_dir_id); +} + + + +void Cp::MakePost() +{ + if( CpCheckAccessFrom() && + ParseDir(mv_dir_id, mv_dir, mv_file) && + CheckAccessTo(mv_dir_id) ) + { + CpPrepare(); + cp_preserve_attr = request->IsPostVar("preserveattr"); + + if( request->is_item ) + { + CpItemCheck(request->item); + } + else + { + cp_remove_defaults = request->IsPostVar("removedefaults"); + + if( request->IsPostVar("onlycontent") ) + CpContentOfDirCheck(*request->dir_table.back()); + else + CpDirCheck(*request->dir_table.back()); + } + } +} + + + +void Cp::MakeGet() +{ + CpCheckAccessFrom(); +} + + + +} // namespace diff --git a/functions/cp.h b/functions/cp.h new file mode 100755 index 0000000..e5a5665 --- /dev/null +++ b/functions/cp.h @@ -0,0 +1,65 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentcp +#define headerfilecmslucontentcp + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Cp : public FunctionBase +{ +public: + + Cp(); + +private: + + // !! wywalic przedrostki cp_ Cp + + Item cp_temp; + Db::ItemQuery cp_iq; + bool cp_remove_defaults; + bool cp_preserve_attr; + long cp_new_user; + long cp_new_group; + + std::string mv_dir; + std::string mv_file; + std::string mv_new_path; + long mv_dir_id; + + bool CpCheckAccessFrom(); + bool CheckAccessTo(long dir_id); + bool ParseDir(long & dir_id, std::string & dir, std::string & file); + void CpAuth(Item & item); + void CpSetNewAttributes(Item & item); + void CpItem(Item & item, long dst_dir_id); + void CpPrepare(); + void CpFilesInDir(const Item & dir, long dst_dir_id); + void CpContentOfDir(const Item & item, long dst_dir_id); + long CpDir(const Item & item, long dst_dir_id); + bool IsTheSameFile(const Item & item); + void CpItemCheck(Item & item, bool redirect = true); + void CpContentOfDirCheck(const Item & item, bool redirect = true); + void CpDirCheck(const Item & item, bool redirect = true); + void MakePost(); + void MakeGet(); + +}; + + +} // namespace + +#endif diff --git a/functions/createthread.cpp b/functions/createthread.cpp new file mode 100755 index 0000000..90117e4 --- /dev/null +++ b/functions/createthread.cpp @@ -0,0 +1,148 @@ +/* + * 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 Fun +{ + +CreateThread::CreateThread() +{ + fun.url = "createthread"; +} + + + +// returning true if we can create a thread in the current directory +bool CreateThread::HasAccess() +{ + if( request->dir_table.empty() ) + return false; + + if( request->is_item ) + return false; + + if( !system->HasWriteAccess(*request->dir_table.back()) ) + return false; + + if( !system->mounts.pmount || system->mounts.pmount->type != Mount::thread ) + return false; + + if( 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(Mount::par_createthread_on) ) + return true; + + if( system->mounts.pmount->IsArg(Mount::par_createthread_on, request->dir_table.size()) ) + return true; + +return 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 & thread) +{ + thread.parent_id = request->dir_table.back()->id; +} + + + +void CreateThread::AddThread() +{ + request->thread.dir_id = request->dir_table.back()->id; + request->thread.closed = false; + request->thread.items = 1; + request->thread.last_item = request->item; // set by PostFunEmacsAdd() + + request->status = db->AddThread(request->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->thread); + 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); + + 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_table.back()->id; + request->status = system->AddFile(request->item); + + if( request->status == WINIX_ERR_OK ) + AddThread(); + } + + PostFunCreateThreadLogAndRedirect(); +} + + + + + + + + +} // namespace diff --git a/functions/createthread.h b/functions/createthread.h new file mode 100755 index 0000000..0634349 --- /dev/null +++ b/functions/createthread.h @@ -0,0 +1,40 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentcreatethread +#define headerfilecmslucontentcreatethread + +#include "functionbase.h" + + + +namespace Fun +{ + + +class CreateThread : public FunctionBase +{ +public: + + CreateThread(); + bool HasAccess(); + void MakePost(); + +private: + + bool FunCreateThreadCheckAbuse(); + void ReadThread(Thread & thread); + void AddThread(); + void PostFunCreateThreadLogAndRedirect(); +}; + + +} // namespace + +#endif diff --git a/functions/createticket.cpp b/functions/createticket.cpp new file mode 100755 index 0000000..6a70f91 --- /dev/null +++ b/functions/createticket.cpp @@ -0,0 +1,147 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "createticket.h" +#include "readticket.h" +#include "functions.h" + + +namespace Fun +{ + +CreateTicket::CreateTicket() +{ + fun.url = "createticket"; +} + + +// returning true if we can create a ticket in the current directory +bool CreateTicket::HasAccess() +{ + if( request->dir_table.empty() ) + return false; + + if( request->is_item ) + return false; + + if( !system->HasWriteAccess(*request->dir_table.back()) ) + return false; + + if( !system->mounts.pmount || system->mounts.pmount->type != Mount::ticket ) + return false; + + + // checking for par_createticket_on mount option + + if( request->session && request->session->puser && request->session->puser->super_user ) + // super can create tickets regardless of the createticket_on option + return true; + + if( !system->mounts.pmount->IsPar(Mount::par_createticket_on) ) + return true; + + if( system->mounts.pmount->IsArg(Mount::par_createticket_on, request->dir_table.size()) ) + return true; + +return false; +} + + + + +bool CreateTicket::FunCreateTicketCheckAbuse() +{ + 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 CreateTicket::AddTicket() +{ + static std::string temp; + + request->ticket.dir_id = request->dir_table.back()->id; // a new directory created by Mkdir() + request->ticket.item_id = request->item.id; // this id is set by PostFunEmacsAdd() + + request->status = db->AddTicket(request->ticket); +} + + +void CreateTicket::PostFunCreateTicketLogAndRedirect() +{ + if( request->status == WINIX_ERR_OK ) + { + log << log2 << "Content: added a new ticket" << logend; + system->RedirectToLastDir(); + } + else + { + log << log1 << "Content: problem with adding a new ticket, error code: " + << request->status << logend; + } +} + + + +void CreateTicket::MakePost() +{ + functions->ReadItem(request->item, Item::dir); + functions->SetUser(request->item); + + ReadTicket read_ticket; + read_ticket.Read(system, request, &request->ticket); + + request->item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty + + if( !FunCreateTicketCheckAbuse() ) + { + functions->ReadItemContentWithType(request->item); // for correctly displaying the form + return; + } + + request->status = system->dirs.AddDirectory(request->item, true); + + 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_table.back()->id; + + request->status = system->AddFile(request->item); + + if( request->status == WINIX_ERR_OK ) + AddTicket(); + } + + PostFunCreateTicketLogAndRedirect(); +} + + + + + + + +} // namespace diff --git a/functions/createticket.h b/functions/createticket.h new file mode 100755 index 0000000..0e30eaf --- /dev/null +++ b/functions/createticket.h @@ -0,0 +1,40 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentcreateticket +#define headerfilecmslucontentcreateticket + +#include "functionbase.h" + + + +namespace Fun +{ + + +class CreateTicket : public FunctionBase +{ +public: + + CreateTicket(); + bool HasAccess(); + void MakePost(); + +private: + + bool FunCreateTicketCheckAbuse(); + void AddTicket(); + void PostFunCreateTicketLogAndRedirect(); + +}; + + +} // namespace + +#endif diff --git a/content/default.cpp b/functions/default.cpp similarity index 50% rename from content/default.cpp rename to functions/default.cpp index 7480898..91c4dfd 100755 --- a/content/default.cpp +++ b/functions/default.cpp @@ -7,22 +7,25 @@ * */ -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/data.h" +#include "default.h" +namespace Fun +{ + +Default::Default() +{ + fun.url = "default"; +} -long Content::PostFunDefaultParsePath() +long Default::PostFunDefaultParsePath() { Item * pdir, * pdir2; long defaultid = -1; - std::string * path = request.PostVar("defaultitem"); + std::string * path = request->PostVar("defaultitem"); if( path && !path->empty() ) @@ -30,7 +33,7 @@ long defaultid = -1; std::string dir, file; Dirs::SplitPath(*path, dir, file); - pdir = data.dirs.GetDir(dir); + pdir = system->dirs.GetDir(dir); if( !pdir ) throw Error(WINIX_ERR_INCORRECT_DIR); @@ -42,11 +45,11 @@ long defaultid = -1; else { // checking whether the file is a directory too (the method SplitPath does not check it) - pdir2 = data.dirs.GetDir(file, pdir->id); + pdir2 = system->dirs.GetDir(file, pdir->id); if( !pdir2 ) { - defaultid = db.GetFileId(pdir->id, file); + defaultid = db->GetFileId(pdir->id, file); if( defaultid == -1 ) throw Error(WINIX_ERR_NO_ITEM); @@ -65,11 +68,11 @@ return defaultid; -void Content::PostFunDefault() +void Default::MakePost() { - if( !request.HasWriteAccess(*request.dir_table.back()) ) + if( !system->HasWriteAccess(*request->dir_table.back()) ) { - request.status = WINIX_ERR_PERMISSION_DENIED; + request->status = WINIX_ERR_PERMISSION_DENIED; return; } @@ -77,34 +80,35 @@ void Content::PostFunDefault() try { long defaultid = PostFunDefaultParsePath(); - request.status = db.EditDefaultItem(request.dir_table.back()->id, defaultid); + request->status = db->EditDefaultItem(request->dir_table.back()->id, defaultid); - if( request.status == WINIX_ERR_OK ) - request.dir_table.back()->default_item = defaultid; + if( request->status == WINIX_ERR_OK ) + request->dir_table.back()->default_item = defaultid; } catch(const Error & e) { - request.status = e; + request->status = e; } - if( request.status == WINIX_ERR_OK ) - RedirectTo(*request.dir_table.back()); + if( request->status == WINIX_ERR_OK ) + system->RedirectTo(*request->dir_table.back()); else - log << log1 << "Content: PostFunDefaultItem: Error: " << request.status << logend; + log << log1 << "Content: PostFunDefaultItem: Error: " << request->status << logend; } -void Content::FunDefault() +void Default::MakeGet() { - if( !request.HasWriteAccess(*request.dir_table.back()) ) + if( !system->HasWriteAccess(*request->dir_table.back()) ) { - request.status = WINIX_ERR_PERMISSION_DENIED; + request->status = WINIX_ERR_PERMISSION_DENIED; return; } } +} // namespace diff --git a/functions/default.h b/functions/default.h new file mode 100755 index 0000000..fb361d7 --- /dev/null +++ b/functions/default.h @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentdefault +#define headerfilecmslucontentdefault + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Default : public FunctionBase +{ +public: + + Default(); + void MakePost(); + void MakeGet(); + +private: + + long PostFunDefaultParsePath(); + +}; + + +} // namespace + +#endif diff --git a/functions/download.cpp b/functions/download.cpp new file mode 100755 index 0000000..8a248e1 --- /dev/null +++ b/functions/download.cpp @@ -0,0 +1,50 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "download.h" + + + +namespace Fun +{ + + +Download::Download() +{ + fun.url = "download"; +} + + +void Download::MakeGet() +{ + // !! moze wywalic to no_item i wszedzie w takich miejscach dac poprostu permission_denied? + if( !request->is_item ) + { + log << log1 << "Content: download function requires an item" << logend; + request->status = WINIX_ERR_NO_ITEM; + return; + } + + + if( !system->HasReadAccess(request->item) || + request->item.auth == Item::auth_none || + request->item.auth_path.empty() ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + request->send_as_attachment = request->IsParam("attachment"); + request->x_sendfile = request->item.auth_path; +} + + + + +} // namespace diff --git a/functions/download.h b/functions/download.h new file mode 100755 index 0000000..b00c7f3 --- /dev/null +++ b/functions/download.h @@ -0,0 +1,35 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentdownload +#define headerfilecmslucontentdownload + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Download : public FunctionBase +{ +public: + + Download(); + void MakeGet(); + +private: + +}; + + +} // namespace + +#endif diff --git a/functions/editticket.cpp b/functions/editticket.cpp new file mode 100755 index 0000000..470ec99 --- /dev/null +++ b/functions/editticket.cpp @@ -0,0 +1,214 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "editticket.h" +#include "functions.h" +#include "readticket.h" + + + + +namespace Fun +{ + +EditTicket::EditTicket() +{ + fun.url = "editticket"; +} + + + +bool EditTicket::HasAccess() +{ + // not logged users cannot edit tickets + if( !request->session->puser ) + return false; + + if( request->dir_table.empty() ) + return false; + + if( request->is_item || !request->is_ticket ) + return false; + + if( !system->HasWriteAccess(*request->dir_table.back()) ) + return false; + + if( !system->mounts.pmount || system->mounts.pmount->type != Mount::ticket ) + return false; + +return true; +} + + + + + +void EditTicket::EditTicketCheckFirstItem() +{ + if( request->status != WINIX_ERR_OK ) + return; + + + if( request->ticket.item_id == -1 ) + { + // creating a new item (the item was deleted by a user) + + Item item; + item.parent_id = request->dir_table.back()->id; + item.subject = request->dir_table.back()->subject; + item.type = Item::file; + item.privileges = 0644; // !! tymczasowo + functions->SetUser(item); + system->PrepareUrl(item); + + request->status = db->AddItem(item); + + if( request->status == WINIX_ERR_OK ) + { + log << log2 << "Content: added the first item with content for the ticket, item.id: " << item.id << logend; + request->ticket.item_id = item.id; + } + } +} + + + +void EditTicket::EditTicketModTicket() +{ + if( request->status != WINIX_ERR_OK ) + return; + + Ticket ticket; + ReadTicket read_ticket; + read_ticket.Read(system, request, &ticket); + + request->ticket.type = ticket.type; + request->ticket.status = ticket.status; + request->ticket.priority = ticket.priority; + request->ticket.category = ticket.category; + request->ticket.expected = ticket.expected; + request->ticket.progress = ticket.progress; + + request->status = db->EditTicketById(request->ticket); +} + + + +void EditTicket::EditTicketModDir() +{ + if( request->status != WINIX_ERR_OK ) + return; + + // we don't modify the url + + Item & dir = *request->dir_table.back(); + bool edit_dir_subject = (dir.subject != request->item.subject); + + if( edit_dir_subject ) + { + dir.subject = request->item.subject; + request->status = db->EditItemById(dir, false); + } +} + + +void EditTicket::EditTicketModFirstItem() +{ + if( request->status != WINIX_ERR_OK ) + return; + + // modyfing the first item (the one with content) + functions->ReadItemContentWithType(request->item); + + Item item; + db->GetItemById(request->ticket.item_id, item); + item.subject = request->item.subject; + item.content = request->item.content; + item.content_type = request->item.content_type; + // the url doesn't matter + + db->EditItemById(item, false); +} + + + +void EditTicket::PostFunEditTicketLogAndRedirect() +{ + if( request->status == WINIX_ERR_OK ) + { + log << log2 << "Content: edited a ticket" << logend; + system->RedirectToLastDir(); + } + else + { + log << log1 << "Content: problem with editing a ticket, error code: " + << request->status << logend; + } +} + + +bool EditTicket::FunCreateTicketCheckAbuse() +{ + 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 EditTicket::MakePost() +{ + functions->ReadItem(request->item, Item::dir); + // co z uzytkownikiem i grup¹? chyba nie wczytane? !!! (wczesniej bylo SetUser() w ReadItem() - teraz nie ma) + // dodac informacje o modyfikacji !!! + + if( !FunCreateTicketCheckAbuse() ) + { + functions->ReadItemContentWithType(request->item); // for correctly displaying the form + return; + } + + if( db->GetTicketByDirId(request->dir_table.back()->id, request->ticket) != WINIX_ERR_OK ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + EditTicketCheckFirstItem(); + EditTicketModTicket(); + EditTicketModDir(); + EditTicketModFirstItem(); + PostFunEditTicketLogAndRedirect(); +} + + + +void EditTicket::MakeGet() +{ + db->GetItemById(request->ticket.item_id, request->item); + + // the subject we get from the last directory + request->item.subject = request->dir_table.back()->subject; +} + + + +} // namespace diff --git a/functions/editticket.h b/functions/editticket.h new file mode 100755 index 0000000..e3da110 --- /dev/null +++ b/functions/editticket.h @@ -0,0 +1,44 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontenteditticket +#define headerfilecmslucontenteditticket + +#include "functionbase.h" + + + +namespace Fun +{ + + +class EditTicket : public FunctionBase +{ +public: + + EditTicket(); + bool HasAccess(); + void MakePost(); + void MakeGet(); + +private: + + void EditTicketCheckFirstItem(); + void EditTicketModTicket(); + void EditTicketModDir(); + void EditTicketModFirstItem(); + void PostFunEditTicketLogAndRedirect(); + bool FunCreateTicketCheckAbuse(); + +}; + + +} // namespace + +#endif diff --git a/functions/emacs.cpp b/functions/emacs.cpp new file mode 100755 index 0000000..6d1c4c1 --- /dev/null +++ b/functions/emacs.cpp @@ -0,0 +1,149 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "emacs.h" +#include "templates/templates.h" +#include "core/notify.h" +#include "functions.h" + + + +namespace Fun +{ + +Emacs::Emacs() +{ + fun.url = "emacs"; +} + + + +bool Emacs::HasAccess(const Item & item) +{ + if( request->session->puser && request->session->puser->super_user ) + // super user can use emacs everywhere + return true; + + if( !system->HasWriteAccess(item) ) + return false; + + if( !system->mounts.pmount->IsPar(Mount::par_emacs_on) ) + return true; + + if( system->mounts.pmount->IsArg(Mount::par_emacs_on, request->dir_table.size()) ) + return true; + +return false; +} + + + +bool Emacs::HasAccess() +{ + if( !request->is_item ) + return HasAccess(*request->dir_table.back()); // adding a new item + else + return HasAccess(request->item); // editing an existing item + +return true; +} + + + + + +bool Emacs::PostEmacsCheckAbuse(bool adding) +{ + if( !system->rebus.CheckRebus() ) + { + request->status = WINIX_ERR_INCORRECT_REBUS; + return false; + } + + // !! is tested in createthread once + 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 Emacs::PostFunEmacsModifyMountPoint(bool adding) +{ + if( system->mounts.pmount->type == Mount::thread ) + { + if( adding ) + db->EditThreadAddItem(request->dir_table.back()->id, request->item.id); + + system->RedirectToLastDir(); + } + else + if( system->mounts.pmount->type == Mount::ticket ) + { + system->RedirectToLastDir(); + } + else + { + // Mount::cms + system->RedirectTo(request->item); + } +} + + + +void Emacs::MakePost() +{ + bool adding = !request->is_item; + bool edit_with_url = functions->ReadItem(request->item, Item::file); + + if( adding ) + functions->SetUser(request->item); // set user before checking the rebus + + if( !PostEmacsCheckAbuse(adding) ) + return; + + if( adding ) + { + request->is_item = true; + request->item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask + system->AddFile(request->item); + } + else + { + system->EditFile(request->item, edit_with_url); + } + + + if( request->status == WINIX_ERR_OK ) + { + PostFunEmacsModifyMountPoint(adding); + system->CheckSpecialFile(request->item); + } + else + { + log << log1 << "Content: PostFunEmacs: Error: " + << request->status << logend; + } +} + + + + + + + + +} // namespace diff --git a/functions/emacs.h b/functions/emacs.h new file mode 100755 index 0000000..056c125 --- /dev/null +++ b/functions/emacs.h @@ -0,0 +1,40 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentemacs +#define headerfilecmslucontentemacs + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Emacs : public FunctionBase +{ +public: + + Emacs(); + bool HasAccess(); + void MakePost(); + +private: + + bool HasAccess(const Item & item); // !! takie funkcje to nie powinny byc skladowe modelu? + bool PostEmacsCheckAbuse(bool adding); + void PostFunEmacsModifyMountPoint(bool adding); + +}; + + +} // namespace + +#endif diff --git a/functions/functionbase.cpp b/functions/functionbase.cpp new file mode 100755 index 0000000..2c4de5f --- /dev/null +++ b/functions/functionbase.cpp @@ -0,0 +1,88 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "functionbase.h" +#include "functions.h" + + + +FunctionBase::FunctionBase() +{ + fun.user_id = -1; + fun.group_id = -1; + fun.privileges = 0755; + fun.parent_id = -1; // !! temporarily doesn't matter + fun.id = -1; + fun.type = Item::file; +} + + + +void FunctionBase::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + +void FunctionBase::SetRequest(Request * prequest) +{ + request = prequest; +} + + +void FunctionBase::SetDb(Db * pdb) +{ + db = pdb; +} + + +void FunctionBase::SetSystem(System * psystem) +{ + system = psystem; +} + + +void FunctionBase::SetFunctions(Functions * pfunctions) +{ + functions = pfunctions; +} + + +void FunctionBase::SetTemplates(Templates * ptemplates) +{ + templates = ptemplates; +} + +void FunctionBase::SetNotify(Notify * pnotify) +{ + notify = pnotify; +} + + +bool FunctionBase::HasAccess() +{ + // true by default + return true; +} + + +void FunctionBase::MakePost() +{ + // do nothing by default +} + + +void FunctionBase::MakeGet() +{ + // do nothing by default +} + + + + diff --git a/functions/functionbase.h b/functions/functionbase.h new file mode 100755 index 0000000..2c89e83 --- /dev/null +++ b/functions/functionbase.h @@ -0,0 +1,64 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentfunctionbase +#define headerfilecmslucontentfunctionbase + +#include <string> +#include <vector> +#include "core/item.h" +#include "core/db.h" +#include "core/request.h" +#include "core/config.h" +#include "core/system.h" +#include "core/notify.h" +#include "ezc.h" + + +class Functions; +class Templates; + + + +class FunctionBase +{ +public: + + FunctionBase(); + + // user, group, permissions, url (function name) + Item fun; + + virtual bool HasAccess(); + virtual void MakePost(); + virtual void MakeGet(); + + void SetConfig(Config * pconfig); + void SetRequest(Request * prequest); + void SetDb(Db * pdb); + void SetSystem(System * psystem); + void SetFunctions(Functions * pfunctions); + void SetTemplates(Templates * ptemplates); + void SetNotify(Notify * pnotify); + +protected: + + Config * config; + Request * request; + Db * db; + System * system; + Functions * functions; + Templates * templates; + Notify * notify; + +// std::vector<Ezc::Pattern> pattern_tab; +}; + + +#endif diff --git a/core/functionparser.cpp b/functions/functionparser.cpp similarity index 54% rename from core/functionparser.cpp rename to functions/functionparser.cpp index f9fd058..030a239 100755 --- a/core/functionparser.cpp +++ b/functions/functionparser.cpp @@ -8,19 +8,16 @@ */ #include "functionparser.h" -#include "log.h" -#include "item.h" -#include "error.h" -#include "data.h" -#include "db.h" -#include "request.h" - +#include "core/log.h" +#include "core/item.h" +#include "core/error.h" +#include "functions.h" void FunctionParser::SkipEmptyString(const char * msg) { - for( ; get_index != get_table_len && request.get_table[get_index].empty() ; ++get_index ) + for( ; get_index != get_table_len && request->get_table[get_index].empty() ; ++get_index ) log << log3 << msg << logend; } @@ -29,19 +26,19 @@ void FunctionParser::SkipEmptyString(const char * msg) void FunctionParser::ParseDirectories() { - Item * pdir = data.dirs.GetRootDir(); + Item * pdir = system->dirs.GetRootDir(); if( !pdir ) { // there is no the root dir - request.status = WINIX_ERR_NO_ROOT_DIR; + request->status = WINIX_ERR_NO_ROOT_DIR; return; } while( true ) { - request.dir_table.push_back( pdir ); + request->dir_table.push_back( pdir ); log << log3 << "FP: Directory: "; if( pdir->parent_id == -1 ) @@ -54,7 +51,7 @@ void FunctionParser::ParseDirectories() if( get_index == get_table_len ) break; - pdir = data.dirs.GetDir(request.get_table[get_index], pdir->id); + pdir = system->dirs.GetDir(request->get_table[get_index], pdir->id); if( !pdir ) break; @@ -72,24 +69,24 @@ void FunctionParser::ParseItem() if( get_index == get_table_len ) return; - // request.dir_table has at least one element - long parent_id = request.dir_table.back()->id; - const std::string & url = request.get_table[get_index]; + // request->dir_table has at least one element + long parent_id = request->dir_table.back()->id; + const std::string & url = request->get_table[get_index]; - request.status = db.GetItem(parent_id, url, request.item); + request->status = db->GetItem(parent_id, url, request->item); - if( request.status == WINIX_ERR_OK ) + if( request->status == WINIX_ERR_OK ) { - if( request.role == Request::authorizer && request.item.auth == Item::auth_none ) + if( request->role == Request::authorizer && request->item.auth == Item::auth_none ) { log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend; - request.status = WINIX_ERR_NO_ITEM; + request->status = WINIX_ERR_NO_ITEM; return; } ++get_index; - request.is_item = true; - log << log3 << "FP: Item: id: " << request.item.id << ", url: " << request.item.url << logend; + request->is_item = true; + log << log3 << "FP: Item: id: " << request->item.id << ", url: " << request->item.url << logend; } else { @@ -106,13 +103,13 @@ void FunctionParser::ParseFunction() if( get_index == get_table_len ) return; - request.pfunction = data.functions.GetFunction(request.get_table[get_index]); + request->pfunction = functions->Find(request->get_table[get_index]); - if( request.pfunction ) + if( request->pfunction ) { ++get_index; - log << log3 << "FP: Function: " << request.pfunction->item.url << logend; + log << log3 << "FP: Function: " << request->pfunction->fun.url << logend; } } @@ -143,7 +140,7 @@ size_t i; param.value = par.substr(i+1); } - request.param_table.push_back(param); + request->param_table.push_back(param); log << log3 << "FP: Param: name=" << param.name; @@ -164,41 +161,46 @@ void FunctionParser::ParseParams() if( get_index == get_table_len ) break; - ParseParams(request.get_table[get_index]); + ParseParams(request->get_table[get_index]); } } -void FunctionParser::Parse() +void FunctionParser::Parse(Request * prequest, Db * pdb, Functions * pfunctions, System * psystem) { - request.status = WINIX_ERR_OK; - get_index = 0; - get_table_len = request.get_table.size(); - request.pfunction = 0; - request.is_item = false; + request = prequest; + db = pdb; + functions = pfunctions; + system = psystem; + + request->status = WINIX_ERR_OK; + get_index = 0; + get_table_len = request->get_table.size(); + request->pfunction = 0; + request->is_item = false; ParseDirectories(); - if( request.status != WINIX_ERR_OK ) + if( request->status != WINIX_ERR_OK ) return; ParseFunction(); - if( !request.pfunction ) + if( !request->pfunction ) { ParseItem(); - if( request.status != WINIX_ERR_OK ) + if( request->status != WINIX_ERR_OK ) return; ParseFunction(); - if( !request.pfunction && get_index != get_table_len ) + if( !request->pfunction && get_index != get_table_len ) { - request.status = WINIX_ERR_NO_FUNCTION; - log << log3 << "FP: Parse: unknown function: \"" << request.get_table[get_index] << "\"" << logend; + request->status = WINIX_ERR_NO_FUNCTION; + log << log3 << "FP: Parse: unknown function: \"" << request->get_table[get_index] << "\"" << logend; return; } } diff --git a/core/functionparser.h b/functions/functionparser.h similarity index 67% rename from core/functionparser.h rename to functions/functionparser.h index b1940c0..a7a4420 100755 --- a/core/functionparser.h +++ b/functions/functionparser.h @@ -10,11 +10,22 @@ #ifndef headerfilecmslucorefunctionparser #define headerfilecmslucorefunctionparser -#include "requesttypes.h" +#include "core/request.h" +#include "core/db.h" +#include "core/system.h" + + +class Functions; + class FunctionParser { + Request * request; + Db * db; + Functions * functions; + System * system; + GetTable::size_type get_index; GetTable::size_type get_table_len; @@ -29,9 +40,7 @@ class FunctionParser public: - - void Parse(); - + void Parse(Request * prequest, Db * pdb, Functions * pfunctions, System * psystem); }; diff --git a/functions/functions.cpp b/functions/functions.cpp new file mode 100755 index 0000000..75e8262 --- /dev/null +++ b/functions/functions.cpp @@ -0,0 +1,413 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "functions.h" +#include "core/log.h" +#include "core/misc.h" +#include "templates/templates.h" + + + +void Functions::SetConfig(Config * pconfig) +{ + config = pconfig; +} + + +void Functions::SetRequest(Request * prequest) +{ + request = prequest; +} + + +void Functions::SetDb(Db * pdb) +{ + db = pdb; +} + + +void Functions::SetSystem(System * psystem) +{ + system = psystem; +} + +void Functions::SetTemplates(Templates * ptemplates) +{ + templates = ptemplates; +} + +void Functions::SetNotify(Notify * pnotify) +{ + notify = pnotify; +} + +FunctionBase * Functions::Find(const std::string & function_name) +{ + Table::iterator i = table.find(function_name); + + if( i == table.end() ) + return 0; + +return i->second; +} + + +void Functions::SetObjects(FunctionBase * fun) +{ + fun->SetConfig(config); + fun->SetRequest(request); + fun->SetDb(db); + fun->SetSystem(system); + fun->SetFunctions(this); + fun->SetTemplates(templates); + fun->SetNotify(notify); +} + + +void Functions::Add(FunctionBase * fun) +{ + if( Find(fun->fun.url) ) + { + log << log1 << "Functions: function " << fun->fun.url + << " already exists (skipped)" << logend; + return; + } + + table[fun->fun.url] = fun; + SetObjects(fun); +} + + +void Functions::Add(FunctionBase & fun) +{ + Add(&fun); +} + + + + + +void Functions::Create() +{ + Add(fun_adduser); + Add(fun_cat); + Add(fun_chmod); + Add(fun_chown); + Add(fun_cp); + Add(fun_createthread); + Add(fun_createticket); + Add(fun_default); + Add(fun_download); + Add(fun_editticket); + Add(fun_emacs); + Add(fun_last); + Add(fun_login); + Add(fun_logout); + Add(fun_ls); + Add(fun_mkdir); + Add(fun_mv); + Add(fun_node); + Add(fun_priv); + Add(fun_reload); + Add(fun_rm); + Add(fun_run); + Add(fun_subject); + Add(fun_thread); + Add(fun_ticket); + Add(fun_uname); + Add(fun_upload); + Add(fun_who); +} + + +void Functions::Parse() +{ + function_parser.Parse(request, db, this, system); +} + + + +void Functions::SetDefaultFunctionForFile() +{ + if( request->item.auth != Item::auth_none ) + request->pfunction = &fun_download; + else + if( system->HasReadExecAccess(request->item) ) + request->pfunction = &fun_run; + else + request->pfunction = &fun_cat; + + log << log3 << "Content: default function: " << request->pfunction->fun.url << logend; +} + + + + +void Functions::SetDefaultFunctionForDir() +{ + long default_item = request->dir_table.back()->default_item; + + if( default_item != -1 ) + { + log << log3 << "Content: Default item: id: " << default_item << logend; + system->RedirectTo(default_item); + return; + } + + + if( system->mounts.pmount->type == Mount::thread ) + { + request->pfunction = &fun_thread; + log << log3 << "Content: default function: " << request->pfunction->fun.url << logend; + } + else + if( system->mounts.pmount->type == Mount::ticket ) + { + request->pfunction = &fun_ticket; + log << log3 << "Content: default function: " << request->pfunction->fun.url << logend; + } + else + { + // cms + request->pfunction = &fun_ls; + log << log3 << "Content: default function: " << request->pfunction->fun.url << logend; + } +} + + +void Functions::SetDefaultFunction() +{ + if( request->is_item ) + { + SetDefaultFunctionForFile(); + } + else + { + SetDefaultFunctionForDir(); + } +} + + + + +void Functions::MakeGet() +{ + if( request->role == Request::authorizer ) + { + // in authorizer mode only cat function is available + // (and must be default) + + if( request->pfunction ) + { + request->status = WINIX_ERR_NO_ITEM; + log << log1 << "Content: in authorizer mode only 'cat' funtion is available and must " + "be default (not in the url)" << logend; + return; + } + + request->pfunction = &fun_cat; + } + + + if( !request->pfunction ) + SetDefaultFunction(); + + if( !request->redirect_to.empty() ) + return; + + if( !request->pfunction ) + { + request->status = WINIX_ERR_NO_FUNCTION; + log << log1 << "Functions: no function (neither cat nor ls)" << logend; + return; + } + + if( !request->pfunction->HasAccess() ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + request->pfunction->MakeGet(); +} + + + +void Functions::MakePost() +{ + if( request->role == Request::authorizer ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + if( !request->pfunction ) + SetDefaultFunction(); + + if( !request->pfunction ) + { + request->status = WINIX_ERR_NO_FUNCTION; + log << log1 << "Functions: MakePost: no function" << logend; + return; + } + + if( !request->pfunction->HasAccess() ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + request->pfunction->MakePost(); +} + + +void Functions::CheckGetPostTimes(time_t difference) +{ + time_t now = std::time(0); + + if( request->session->puser ) + return; + + if( request->method != Request::post ) + return; + + if( now - request->session->last_time_get >= (time_t)difference ) + return; + + if( request->AllPostVarEmpty() ) + return; + + request->session->spam_score += 1; + log << log1 << "Functions: spam +1: POST after GET sent too fast" << logend; +} + + + + + +// returning true if the 'url' has to be changed +bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type) +{ + bool with_url = false; + + std::string * new_url = request->PostVar("url"); + std::string * new_subject = request->PostVar("subject"); + + if( item_type == Item::file ) + { + if( !request->is_item || (new_url && *new_url != item.url) ) + with_url = true; + } + else + { + with_url = true; + } + + + if( new_url ) + item.url = *new_url; + + if( new_subject ) + item.subject = *new_subject; + + + if( item.subject.empty() ) + { + item.subject = request->dir_table.back()->subject; + item.subject += "_msg_"; + item.subject += ToStr(db->Size(request->dir_table.back()->id, Item::file)); + } + + // if item.url is empty then it will be set from item.subject + system->PrepareUrl(item); + +return with_url; +} + + +void Functions::ReadItemContentWithType(Item & item) +{ + item.content_type = Item::ct_formatted_text; // default is formatted text + request->PostVar("itemcontent", request->item.content); + request->PostVar("contenttype", temp); + + // ct_text and ct_formatted_text can use everyone + + if( temp == "0" ) + item.content_type = Item::ct_text; + else + if( temp == "1" ) + item.content_type = Item::ct_formatted_text; + + + // those below need special privileges + + if( !request->session->puser ) + return; + + long user_id = request->session->puser->id; + + + if( temp == "2" ) + { + if( system->CanUseHtml(user_id) ) + item.content_type = Item::ct_html; + } + else + if( temp == "3" ) + { + if( system->CanUseBBCode(user_id) ) + item.content_type = Item::ct_bbcode; + } + else + if( temp == "4" ) + { + if( system->CanUseRaw(user_id) ) + item.content_type = Item::ct_raw; + } +} + + + + +// item_type - the type of an item you are expecting to read +// returns true if the url has to be changed +// at the moment this is only checked for Item::file - for Item::dir it returns always true +bool Functions::ReadItem(Item & item, Item::Type item_type) +{ + if( item_type == Item::none ) + return false; + + item.type = item_type; + item.parent_id = request->dir_table.back()->id; // !! moze to dac jako parametr? + + bool edit_with_url = ReadItemUrlSubject(item, item_type); + + if( item_type == Item::file ) + ReadItemContentWithType(item); + +return edit_with_url; +} + + +void Functions::SetUser(Item & item) +{ + if( request->session && request->session->puser ) + { + item.user_id = request->session->puser->id; + item.guest_name.clear(); + } + else + { + item.user_id = -1; + request->PostVar("guestname", item.guest_name); + } + + item.group_id = request->dir_table.back()->group_id; +} diff --git a/functions/functions.h b/functions/functions.h new file mode 100755 index 0000000..ddbdd73 --- /dev/null +++ b/functions/functions.h @@ -0,0 +1,135 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentfunctions +#define headerfilecmslucontentfunctions + +#include <string> +#include "functionbase.h" +#include "functionparser.h" +#include "adduser.h" +#include "cat.h" +#include "chmod.h" +#include "chown.h" +#include "cp.h" +#include "createthread.h" +#include "createticket.h" +#include "default.h" +#include "download.h" +#include "editticket.h" +#include "emacs.h" +#include "last.h" +#include "login.h" +#include "logout.h" +#include "ls.h" +#include "mkdir.h" +#include "mv.h" +#include "node.h" +#include "priv.h" +#include "reload.h" +#include "rm.h" +#include "run.h" +#include "subject.h" +#include "funthread.h" +#include "funticket.h" +#include "uname.h" +#include "upload.h" +#include "who.h" + + + +class Templates; + + + +class Functions +{ +public: + + Fun::AddUser fun_adduser; + Fun::Cat fun_cat; + Fun::Chmod fun_chmod; + Fun::Chown fun_chown; + Fun::Cp fun_cp; + Fun::CreateThread fun_createthread; + Fun::CreateTicket fun_createticket; + Fun::Default fun_default; + Fun::Download fun_download; + Fun::EditTicket fun_editticket; + Fun::Emacs fun_emacs; + Fun::Last fun_last; + Fun::Login fun_login; + Fun::Logout fun_logout; + Fun::Ls fun_ls; + Fun::Mkdir fun_mkdir; + Fun::Mv fun_mv; + Fun::Node fun_node; + Fun::Priv fun_priv; + Fun::Reload fun_reload; + Fun::Rm fun_rm; + Fun::Run fun_run; + Fun::Subject fun_subject; + Fun::FunThread fun_thread; + Fun::FunTicket fun_ticket; + Fun::Uname fun_uname; + Fun::Upload fun_upload; + Fun::Who fun_who; + + + + void Create(); + void Parse(); + + void MakeGet(); + void MakePost(); + + void SetConfig(Config * pconfig); + void SetRequest(Request * prequest); + void SetDb(Db * pdb); + void SetSystem(System * psystem); + void SetTemplates(Templates * ptemplates); + void SetNotify(Notify * pnotify); + + FunctionBase * Find(const std::string & function_name); + void SetDefaultFunction(); + + void CheckGetPostTimes(time_t difference = 10); + + // !! dac lepsze nazwy + void ReadItemContentWithType(Item & item); + bool ReadItem(Item & item, Item::Type item_type); + + void SetUser(Item & item); + +private: + + Config * config; + Request * request; + Db * db; + System * system; + Templates * templates; + Notify * notify; + + std::string temp; + + void Add(FunctionBase * fun); + void Add(FunctionBase & fun); + void SetObjects(FunctionBase * fun); + void SetDefaultFunctionForFile(); + void SetDefaultFunctionForDir(); + + bool ReadItemUrlSubject(Item & item, Item::Type item_type); + + typedef std::map<std::string, FunctionBase*> Table; + Table table; + + FunctionParser function_parser; +}; + +#endif diff --git a/functions/funthread.cpp b/functions/funthread.cpp new file mode 100755 index 0000000..cdf55f5 --- /dev/null +++ b/functions/funthread.cpp @@ -0,0 +1,75 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include <algorithm> +#include "funthread.h" + + + +namespace Fun +{ + +FunThread::FunThread() +{ + fun.url = "thread"; +} + + +void FunThread::CreateSortIndexByDate() +{ +size_t i; + + for(i = 0; i < request->thread_tab.size() ; ++i) + { + Item * pdir = system->dirs.GetDir(request->thread_tab[i].dir_id); + + if( pdir ) + request->thread_tab[i].sort = (long)mktime(&pdir->date_creation); + } +} + + + +bool FunThread::FunThreadSort(const Thread & t1, const Thread & t2) +{ + return t1.sort > t2.sort; +} + + +void FunThread::MakeGet() +{ + // !! dac do hasaccess() + if( request->is_item ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + Db::ItemQuery iq; + + if( system->mounts.pmount->IsArg(Mount::par_thread, "sort_desc") ) + iq.sort_asc = false; + + iq.WhereParentId(request->dir_table.back()->id); + iq.WhereType(Item::file); + iq.WhereAuth(Item::auth_none); + + db->GetItems(request->item_table, iq); + db->GetThreads(request->dir_table.back()->id, request->thread_tab); + + system->CheckAccessToItems(request->item_table); + + CreateSortIndexByDate(); + std::sort(request->thread_tab.begin(), request->thread_tab.end(), FunThreadSort); +} + + + + +} // namespace diff --git a/functions/funthread.h b/functions/funthread.h new file mode 100755 index 0000000..daf1e75 --- /dev/null +++ b/functions/funthread.h @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentthread +#define headerfilecmslucontentthread + +#include "functionbase.h" +#include "core/thread.h" + + +namespace Fun +{ + + +class FunThread : public FunctionBase +{ +public: + + FunThread(); + void MakeGet(); + +private: + + static bool FunThreadSort(const Thread & t1, const Thread & t2); + void CreateSortIndexByDate(); + +}; + + +} // namespace + +#endif diff --git a/functions/funticket.cpp b/functions/funticket.cpp new file mode 100755 index 0000000..41c1a74 --- /dev/null +++ b/functions/funticket.cpp @@ -0,0 +1,70 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "funticket.h" + + +namespace Fun +{ + +FunTicket::FunTicket() +{ + fun.url = "ticket"; +} + + +void FunTicket::TicketDeleteFirst() +{ + if( !request->is_ticket ) + return; + + for(size_t i=0 ; i<request->item_table.size() ; ++i) + { + if( request->item_table[i].id == request->ticket.item_id ) + { + // this is the first item with the content for the ticket + + if( !system->HasReadAccess(request->item_table[i]) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + } + + request->item_table.erase(request->item_table.begin() + i); + break; + } + } +} + + + +void FunTicket::MakeGet() +{ + if( request->is_item || system->mounts.pmount->type != Mount::ticket ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + Db::ItemQuery iq; + + iq.WhereParentId(request->dir_table.back()->id); + iq.WhereType(Item::file); + iq.WhereAuth(Item::auth_none); + + db->GetItems(request->item_table, iq); + db->GetTickets(request->dir_table.back()->id, request->ticket_tab); + + TicketDeleteFirst(); + system->CheckAccessToItems(request->item_table); +} + + + + +} // namespace diff --git a/functions/funticket.h b/functions/funticket.h new file mode 100755 index 0000000..2d1eadd --- /dev/null +++ b/functions/funticket.h @@ -0,0 +1,36 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentticket +#define headerfilecmslucontentticket + +#include "functionbase.h" + + + +namespace Fun +{ + + +class FunTicket : public FunctionBase +{ +public: + + FunTicket(); + void MakeGet(); + +private: + + void TicketDeleteFirst(); +}; + + +} // namespace + +#endif diff --git a/content/last.cpp b/functions/last.cpp similarity index 66% rename from content/last.cpp rename to functions/last.cpp index c25dd9f..2b4f4d2 100755 --- a/content/last.cpp +++ b/functions/last.cpp @@ -7,18 +7,17 @@ * */ -#include "content.h" +#include "last.h" - - - -void Content::FunLast() +namespace Fun { - +Last::Last() +{ + fun.url = "last"; } - +} // namespace diff --git a/functions/last.h b/functions/last.h new file mode 100755 index 0000000..5028a89 --- /dev/null +++ b/functions/last.h @@ -0,0 +1,35 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentlast +#define headerfilecmslucontentlast + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Last : public FunctionBase +{ +public: + + Last(); + +private: + + +}; + + +} // namespace + +#endif diff --git a/functions/login.cpp b/functions/login.cpp new file mode 100755 index 0000000..33ed33e --- /dev/null +++ b/functions/login.cpp @@ -0,0 +1,43 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "login.h" + + +namespace Fun +{ + +Login::Login() +{ + fun.url = "login"; +} + + + +void Login::MakePost() +{ + std::string * login = request->PostVar("login"); + std::string * pass = request->PostVar("password"); + std::string * remem = request->PostVar("rememberme"); + long user_id; + + if( login && pass && db->CheckUser(*login, *pass, user_id) ) + system->users.LoginUser(user_id, remem != 0); + + // !! moze zglosic komunikat o nie poprawnym logowaniu + + system->RedirectToLastItem(); +} + + + + + + +} // namespace diff --git a/functions/login.h b/functions/login.h new file mode 100755 index 0000000..adc41d3 --- /dev/null +++ b/functions/login.h @@ -0,0 +1,36 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentlogin +#define headerfilecmslucontentlogin + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Login : public FunctionBase +{ +public: + + Login(); + void MakePost(); + +private: + void LoginUser(long user_id, bool remember_me); + +}; + + +} // namespace + +#endif diff --git a/functions/logout.cpp b/functions/logout.cpp new file mode 100755 index 0000000..caa427e --- /dev/null +++ b/functions/logout.cpp @@ -0,0 +1,33 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "logout.h" + + + + +namespace Fun +{ + + +Logout::Logout() +{ + fun.url = "logout"; +} + + + +void Logout::MakeGet() +{ + system->users.LogoutCurrentUser(); + system->RedirectToLastItem(); +} + + +} // namespace diff --git a/functions/logout.h b/functions/logout.h new file mode 100755 index 0000000..fbf5835 --- /dev/null +++ b/functions/logout.h @@ -0,0 +1,35 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentlogout +#define headerfilecmslucontentlogout + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Logout : public FunctionBase +{ +public: + + Logout(); + void MakeGet(); + +private: + +}; + + +} // namespace + +#endif diff --git a/content/ls.cpp b/functions/ls.cpp similarity index 50% rename from content/ls.cpp rename to functions/ls.cpp index 92a02cd..b7078e5 100755 --- a/content/ls.cpp +++ b/functions/ls.cpp @@ -7,31 +7,39 @@ * */ -#include "content.h" -#include "../core/request.h" -#include "../core/db.h" +#include "ls.h" -void Content::FunLs() + +namespace Fun { - if( !request.is_item ) + +Ls::Ls() +{ + fun.url = "ls"; +} + + +void Ls::MakeGet() +{ + if( !request->is_item ) { Db::ItemQuery iq; iq.sel_content = false; - iq.WhereParentId(request.dir_table.back()->id); + iq.WhereParentId(request->dir_table.back()->id); iq.WhereType(Item::file); - if( request.IsParam("ckeditor_browse") ) + if( request->IsParam("ckeditor_browse") ) { iq.WhereAuth(Item::auth_image); - db.GetItems(request.item_table, iq); + db->GetItems(request->item_table, iq); } else { - db.GetItems(request.item_table, iq); + db->GetItems(request->item_table, iq); } } } @@ -43,3 +51,4 @@ void Content::FunLs() +} // namespace diff --git a/functions/ls.h b/functions/ls.h new file mode 100755 index 0000000..7edab83 --- /dev/null +++ b/functions/ls.h @@ -0,0 +1,37 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentls +#define headerfilecmslucontentls + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Ls : public FunctionBase +{ +public: + + Ls(); + void MakeGet(); + + +private: + + +}; + + +} // namespace + +#endif diff --git a/functions/mkdir.cpp b/functions/mkdir.cpp new file mode 100755 index 0000000..89deb71 --- /dev/null +++ b/functions/mkdir.cpp @@ -0,0 +1,93 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "mkdir.h" +#include "functions.h" +#include "core/notify.h" + + + +namespace Fun +{ + +Mkdir::Mkdir() +{ + fun.url = "mkdir"; +} + + + + + +bool Mkdir::HasAccess(const Item & item) +{ + // you can create a directory only in a directory + if( item.type != Item::dir ) + return false; + + if( request->session->puser && request->session->puser->super_user ) + // super user can use mkdir everywhere + return true; + + if( !system->HasWriteAccess(item) ) + return false; + + if( !system->mounts.pmount->IsPar(Mount::par_mkdir_on) ) + return true; + + if( system->mounts.pmount->IsArg(Mount::par_mkdir_on, request->dir_table.size()) ) + return true; + +return false; +} + + +bool Mkdir::HasAccess() +{ + if( request->is_item || !HasAccess(*request->dir_table.back()) ) + return false; + +return true; +} + + + + +void Mkdir::PostFunMkdir(bool add_to_dir_table, int privileges) +{ + functions->ReadItem(request->item, Item::dir); + functions->SetUser(request->item); + request->item.privileges = privileges; + + request->status = system->dirs.AddDirectory(request->item, add_to_dir_table); + + if( request->status == WINIX_ERR_OK ) + { + request->notify_code |= WINIX_NOTIFY_DIR_ADD; + system->RedirectTo(request->item); + } + else + { + log << log1 << "Content: PostFunMkdir: Error: " << request->status << logend; + } +} + + +void Mkdir::MakePost() +{ + PostFunMkdir(false, 0755); +} + + + + + + + +} // namespace diff --git a/functions/mkdir.h b/functions/mkdir.h new file mode 100755 index 0000000..d5f2f4b --- /dev/null +++ b/functions/mkdir.h @@ -0,0 +1,39 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentmkdir +#define headerfilecmslucontentmkdir + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Mkdir : public FunctionBase +{ +public: + + Mkdir(); + bool HasAccess(); + void MakePost(); + +private: + + bool HasAccess(const Item & item); // !! moze to powinien byc skladnik modelu? + bool FunMkdirCheckAccess(); + void PostFunMkdir(bool add_to_dir_table, int privileges); +}; + + +} // namespace + +#endif diff --git a/functions/mv.cpp b/functions/mv.cpp new file mode 100755 index 0000000..86dcaa4 --- /dev/null +++ b/functions/mv.cpp @@ -0,0 +1,373 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +// !! potrzebne errno? +#include <errno.h> +#include "mv.h" + + + +namespace Fun +{ + +Mv::Mv() +{ + fun.url = "mv"; +} + + +bool Mv::MoveCheckAccessFromToDir() +{ +Item * last; +Item * last_but_one = 0; + + last = request->dir_table[request->dir_table.size()-1]; + + if( request->dir_table.size() >= 2 ) + last_but_one = request->dir_table[request->dir_table.size()-2]; + + if( request->method != Request::post ) + { + // used in GET (HEAD in the future?) + + if( !system->HasWriteAccess(*last) && + (!last_but_one || !system->HasWriteAccess(*last_but_one)) ) + return false; + } + else + { + // used in POST when the moving is performed + + if( request->IsPostVar("onlycontent") ) + return system->HasWriteAccess(*last); + else + if( last_but_one ) + return system->HasWriteAccess(*last_but_one); + else + return false; // you cannot move the root directory + } + +return true; +} + + + +bool Mv::MoveCheckAccessFrom() +{ + if( request->is_item ) + { + // moving a file + + if( !system->HasWriteAccess(*request->dir_table.back()) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + } + else + { + if( !MoveCheckAccessFromToDir() ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + } + +return true; +} + + +bool Mv::MoveCheckAccessTo(long dir_id) +{ + Item * pdir = system->dirs.GetDir(dir_id); + + if( !pdir ) + { + request->status = WINIX_ERR_INCORRECT_DIR; + return false; + } + + if( !system->HasReadExecAccessToPath(dir_id) || !system->HasWriteAccess(*pdir) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + +return true; +} + + + +bool Mv::MoveCheckMountPoints(long dir_id) +{ + /* + Mount * new_mount = system->mounts.CalcMount(dir_id); + + if( !new_mount ) + { + if( system->mounts.pmount->type != Mount::cms ) + { + request->status = WINIX_DIFFERENT_MOUNT_POINTS; + return false; + } + + return true; + } + + if( new_mount->type != system->mounts.pmount->type ) + { + request->status = WINIX_DIFFERENT_MOUNT_POINTS; + return false; + } + */ + +return true; +} + + + +bool Mv::MoveParseDir(long & dir_id, std::string & dir, std::string & file) +{ + std::string * move_to = request->PostVar("to"); + + if( !move_to ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + + int res = system->dirs.AnalyzePath(*move_to, dir_id, dir, file); + + if( res == 1 ) + request->status = WINIX_ERR_NO_ROOT_DIR; + else + if( res != 0 ) + request->status = WINIX_ERR_INCORRECT_DIR; + +return res == 0; +} + + + +void Mv::MoveAuth(Item & item) +{ + if( !system->MakePath(item, mv_new_path, true) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + if( rename(item.auth_path.c_str(), mv_new_path.c_str()) == 0 ) + { + log << log1 << "Content: moved static file from: " << item.auth_path << ", to: " << mv_new_path << logend; + item.auth_path = mv_new_path; + request->status = db->EditAuthById(item, item.id); + } + else + { + int err = errno; + + log << log1 << "Content: can't move a file from: " << item.auth_path << ", to: " << mv_new_path << ", "; + log.SystemErr(err); + log << logend; + + request->status = WINIX_ERR_PERMISSION_DENIED; + } +} + + + +bool Mv::MoveIsTheSameFile(const Item & item) +{ + if( mv_file.empty() ) + { + if( item.parent_id == mv_dir_id ) + return true; // nothing to do + } + else + { + if( item.parent_id == mv_dir_id && item.url == mv_file ) + return true; // nothing to do + } + +return false; +} + + + +void Mv::MoveFile(Item & item, bool redirect) +{ + if( MoveIsTheSameFile(item) ) + return; + + if( !mv_file.empty() ) + { + item.url = mv_file; + system->PrepareUrl(item); + } + + item.parent_id = mv_dir_id; + request->status = db->EditParentUrlById(item, item.id); + + if( request->status == WINIX_ERR_OK ) + { + log << log2 << "Content: the file was moved to: " << mv_dir << item.url << logend; + + if( item.auth != Item::auth_none ) + MoveAuth(item); + + if( redirect ) + system->RedirectTo(item); + } +} + + + +void Mv::MoveContentOfDir() +{ +Db::ItemQuery iq; + + iq.sel_parent_id = true; + iq.sel_type = true; + iq.sel_url = true; + iq.sel_auth = true; + iq.WhereParentId(request->dir_table.back()->id); + + db->GetItems(request->item_table, iq); + + for(size_t i=0 ; i<request->item_table.size() ; ++i) + { + if( request->item_table[i].type == Item::dir ) + MoveDir(request->item_table[i], false); + else + MoveFile(request->item_table[i], false); + } + + system->RedirectToLastDir(); +} + + + +void Mv::MoveAuthPrepareQuery() +{ + mv_auth_iq.SetAll(false, false); + + mv_auth_iq.sel_parent_id = true; + mv_auth_iq.sel_type = true; + mv_auth_iq.sel_url = true; + mv_auth_iq.sel_auth = true; + + mv_auth_iq.WhereType(Item::file); + mv_auth_iq.WhereAuth(Item::auth_none, false); +} + + + +void Mv::MoveAuthContentOfDir(const Item & item) +{ + DirContainer::ParentIterator i = system->dirs.FindFirstParent(item.id); + + // go through all directories + for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextParent(i) ) + MoveAuthContentOfDir(*(i->second)); + + mv_auth_iq.WhereParentId(item.id); + + // don't use request->item here (is used in MoveContentOfDir()) + db->GetItems(mv_auth, mv_auth_iq); + + for(size_t i=0 ; i<mv_auth.size() ; ++i) + MoveAuth(mv_auth[i]); + + mv_auth.clear(); +} + + + +void Mv::MoveDir(Item & item, bool redirect) +{ + if( mv_file.empty() && mv_dir_id == item.id ) + return; // nothing to do + + if( mv_dir_id == item.id || system->dirs.HasParent(mv_dir_id, item.id) ) + { + log << log1 << "Content: cannot move directory to inside it" << logend; + request->status = WINIX_ERR_INCORRECT_DIR; + return; + } + + if( !system->dirs.ChangeParent(item.id, mv_dir_id) ) + { + request->status = WINIX_ERR_INCORRECT_DIR; + return; + } + + item.parent_id = mv_dir_id; + + if( !mv_file.empty() ) + { + item.url = mv_file; + system->PrepareUrl(item); + } + + request->status = db->EditParentUrlById(item, item.id); + + if( request->status == WINIX_ERR_OK ) + { + log << log2 << "Content: the directory was moved to: " << mv_dir << item.url << logend; + MoveAuthContentOfDir(item); + + if( redirect ) + system->RedirectToLastDir(); + } +} + + + + +void Mv::MakePost() +{ + if( MoveCheckAccessFrom() && + MoveParseDir(mv_dir_id, mv_dir, mv_file) && + MoveCheckAccessTo(mv_dir_id) && + MoveCheckMountPoints(mv_dir_id) ) + { + if( request->is_item ) + { + MoveFile(request->item); + } + else + { + MoveAuthPrepareQuery(); + + if( request->IsPostVar("onlycontent") ) + { + if( mv_file.empty() ) + MoveContentOfDir(); + else + request->status = WINIX_ERR_INCORRECT_DIR; + } + else + { + MoveDir(*request->dir_table.back()); + } + } + } +} + + + +void Mv::MakeGet() +{ + MoveCheckAccessFrom(); +} + + + +} // namespace diff --git a/functions/mv.h b/functions/mv.h new file mode 100755 index 0000000..6f59387 --- /dev/null +++ b/functions/mv.h @@ -0,0 +1,56 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentmv +#define headerfilecmslucontentmv + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Mv : public FunctionBase +{ +public: + + Mv(); + void MakePost(); + void MakeGet(); + +private: + + std::string mv_dir; + std::string mv_file; + std::string mv_new_path; + long mv_dir_id; + std::vector<Item> mv_auth; + Db::ItemQuery mv_auth_iq; + + bool MoveCheckAccessFromToDir(); + bool MoveCheckAccessFrom(); + bool MoveCheckAccessTo(long dir_id); + bool MoveCheckMountPoints(long dir_id); + bool MoveParseDir(long & dir_id, std::string & dir, std::string & file); + void MoveAuth(Item & item); + bool MoveIsTheSameFile(const Item & item); + void MoveFile(Item & item, bool redirect = true); + void MoveContentOfDir(); + void MoveAuthPrepareQuery(); + void MoveAuthContentOfDir(const Item & item); + void MoveDir(Item & item, bool redirect = true); + +}; + + +} // namespace + +#endif diff --git a/functions/node.cpp b/functions/node.cpp new file mode 100755 index 0000000..99d7174 --- /dev/null +++ b/functions/node.cpp @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "node.h" + + +namespace Fun +{ + +Node::Node() +{ + fun.url = "node"; +} + + +void Node::MakeGet() +{ + if( request->param_table.empty() ) + { + //request->status = Error + //!!zglosic 404 + return; + } + + long id = atol( request->param_table[0].name.c_str() ); + + system->RedirectTo(id); +} + + + +} // namespace diff --git a/functions/node.h b/functions/node.h new file mode 100755 index 0000000..fdaf4c9 --- /dev/null +++ b/functions/node.h @@ -0,0 +1,36 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentnode +#define headerfilecmslucontentnode + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Node : public FunctionBase +{ +public: + + Node(); + void MakeGet(); + +private: + + +}; + + +} // namespace + +#endif diff --git a/functions/priv.cpp b/functions/priv.cpp new file mode 100755 index 0000000..1a6c9cb --- /dev/null +++ b/functions/priv.cpp @@ -0,0 +1,45 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "priv.h" + + + +namespace Fun +{ + + +Priv::Priv() +{ + fun.url = "priv"; +} + + +void Priv::MakePost() +{ + priv_changer.SetRequest(request); + priv_changer.SetSystem(system); + priv_changer.SetDb(db); + + priv_changer.Change(true, true); +} + + +void Priv::MakeGet() +{ + priv_changer.SetRequest(request); + priv_changer.SetSystem(system); + priv_changer.SetDb(db); + + priv_changer.CheckAccess(); +} + + + +} // namespace diff --git a/functions/priv.h b/functions/priv.h new file mode 100755 index 0000000..61e4471 --- /dev/null +++ b/functions/priv.h @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentpriv +#define headerfilecmslucontentpriv + +#include "functionbase.h" +#include "privchanger.h" + + + +namespace Fun +{ + + +class Priv : public FunctionBase +{ +public: + + Priv(); + void MakePost(); + void MakeGet(); + +private: + + PrivChanger priv_changer; +}; + + +} // namespace + +#endif diff --git a/content/priv.cpp b/functions/privchanger.cpp similarity index 56% rename from content/priv.cpp rename to functions/privchanger.cpp index 1fc2e2c..e93a0e0 100755 --- a/content/priv.cpp +++ b/functions/privchanger.cpp @@ -2,32 +2,41 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2010, Tomasz Sowa + * Copyright (c) 2010, Tomasz Sowa * All rights reserved. * */ - -#include "content.h" -#include "../core/request.h" -#include "../core/error.h" -#include "../core/db.h" -#include "../core/data.h" + +#include "privchanger.h" +void PrivChanger::SetRequest(Request * prequest) +{ + request = prequest; +} +void PrivChanger::SetSystem(System * psystem) +{ + system = psystem; +} + +void PrivChanger::SetDb(Db * pdb) +{ + db = pdb; +} -bool Content::PrivCheckAccess() +bool PrivChanger::CheckAccess() { // we do not check permissions here // permissions depends on the user, group, and privileges // but we cannot use parameter 'r' on files // and only logged users can change permissions - if( !request.session->puser || (request.is_item && request.IsParam("r")) ) + if( !request->session->puser || (request->is_item && request->IsParam("r")) ) { - request.status = WINIX_ERR_PERMISSION_DENIED; + request->status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -36,17 +45,17 @@ return true; -bool Content::ChangeOwner(Item & item, long user_id, long group_id) +bool PrivChanger::ChangeOwner(Item & item, long user_id, long group_id) { if( user_id!=item.user_id || group_id!=item.group_id ) { - if( !request.CanChangeUser(item, user_id) ) + if( !system->CanChangeUser(item, user_id) ) { log << log3 << "Content: can't change the user" << logend; return false; } - if( !request.CanChangeGroup(item, group_id) ) + if( !system->CanChangeGroup(item, group_id) ) { log << log3 << "Content: can't change the group" << logend; return false; @@ -61,11 +70,11 @@ return true; -bool Content::ChangePrivileges(Item & item, int privileges) +bool PrivChanger::ChangePrivileges(Item & item, int privileges) { if( privileges != item.privileges ) { - if( !request.CanChangePrivileges(item, privileges) ) + if( !system->CanChangePrivileges(item, privileges) ) { log << log3 << "Content: can't change privileges" << logend; return false; @@ -79,7 +88,7 @@ return true; -void Content::ChangePriv(Item & item, long user_id, long group_id, int privileges) +void PrivChanger::ChangePriv(Item & item, long user_id, long group_id, int privileges) { if( change_owner ) { @@ -93,19 +102,19 @@ void Content::ChangePriv(Item & item, long user_id, long group_id, int privilege return; } - request.status = db.EditPrivById(item, item.id); + request->status = db->EditPrivById(item, item.id); } -void Content::PrivLogStart(const char * what, long user, long group, int priv) +void PrivChanger::PrivLogStart(const char * what, long user, long group, int priv) { log << log2 << what; if( change_owner ) { - User * puser = data.users.GetUser(user); - Group * pgroup = data.groups.GetGroup(group); + User * puser = system->users.GetUser(user); + Group * pgroup = system->groups.GetGroup(group); log << "new user: "; @@ -137,12 +146,12 @@ void Content::PrivLogStart(const char * what, long user, long group, int priv) -void Content::PrivLog(const char * what, long id, const std::string & url) +void PrivChanger::PrivLog(const char * what, long id, const std::string & url) { Item * root = 0; if( id != -1 ) - root = data.dirs.GetRootDir(); + root = system->dirs.GetRootDir(); log << log3 << "Content: " << what; @@ -155,7 +164,7 @@ Item * root = 0; } -void Content::PrivFilesInDir(long parent_id) +void PrivChanger::PrivFilesInDir(long parent_id) { Db::ItemQuery iq; @@ -165,12 +174,12 @@ void Content::PrivFilesInDir(long parent_id) iq.WhereParentId(parent_id); iq.WhereType(Item::file); - db.GetItems(request.item_table, iq); + db->GetItems(request->item_table, iq); - std::vector<Item>::iterator i = request.item_table.begin(); + std::vector<Item>::iterator i = request->item_table.begin(); - for( ; i != request.item_table.end() ; ++i) + for( ; i != request->item_table.end() ; ++i) { PrivLog("changed file: ", -1, i->url); ChangePriv(*i, user_id_file, group_id_file, priv_file); @@ -178,15 +187,16 @@ void Content::PrivFilesInDir(long parent_id) } + // recurrence -void Content::PrivDir(long parent_id) +void PrivChanger::PrivDir(long parent_id) { PrivFilesInDir(parent_id); - DirContainer::ParentIterator i = data.dirs.FindFirstParent(parent_id); + DirContainer::ParentIterator i = system->dirs.FindFirstParent(parent_id); - for( ; i != data.dirs.ParentEnd() ; i = data.dirs.NextParent(i) ) + for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextParent(i) ) { PrivLog("changed dir: ", -1, i->second->url); ChangePriv(*(i->second), user_id_dir, group_id_dir, priv_dir); @@ -197,12 +207,12 @@ void Content::PrivDir(long parent_id) } -bool Content::ReadPriv(const char * user_in, const char * group_in, const char * priv_in, +bool PrivChanger::ReadPriv(const char * user_in, const char * group_in, const char * priv_in, long & user_id, long & group_id, int & priv) { - std::string * user_str = request.PostVar(user_in); - std::string * group_str = request.PostVar(group_in); - std::string * priv_str = request.PostVar(priv_in); + std::string * user_str = request->PostVar(user_in); + std::string * group_str = request->PostVar(group_in); + std::string * priv_str = request->PostVar(priv_in); if( change_owner && (!user_str || !group_str) ) { @@ -218,8 +228,8 @@ bool Content::ReadPriv(const char * user_in, const char * group_in, const char * if( change_owner ) { - user_id = data.users.GetUserId( *user_str ); - group_id = data.groups.GetGroupId( *group_str ); + user_id = system->users.GetUserId( *user_str ); + group_id = system->groups.GetGroupId( *group_str ); } if( change_priv ) @@ -229,7 +239,7 @@ return true; } -void Content::PrivDir() +void PrivChanger::PrivDir() { if( !ReadPriv("userfile", "groupfile", "privilegesfile", user_id_file, group_id_file, priv_file) ) return; @@ -241,55 +251,55 @@ void Content::PrivDir() PrivLogStart("Content: changes for dirs: ", user_id_dir, group_id_dir, priv_dir); - if( request.IsPostVar("changecurrentdir") ) + if( request->IsPostVar("changecurrentdir") ) { - Item & last_dir = *request.dir_table.back(); + Item & last_dir = *request->dir_table.back(); PrivLog("changed dir: ", last_dir.id, last_dir.url); - ChangePriv(*request.dir_table.back(), user_id_dir, group_id_dir, priv_dir); + ChangePriv(*request->dir_table.back(), user_id_dir, group_id_dir, priv_dir); } - subdirectories = request.IsPostVar("changesubdirs"); + subdirectories = request->IsPostVar("changesubdirs"); // go through all directories - PrivDir(request.dir_table.back()->id); + PrivDir(request->dir_table.back()->id); - RedirectToLastDir(); + system->RedirectToLastDir(); } // changing only one item (either a dir or file) -void Content::PrivOneItem() +void PrivChanger::PrivOneItem() { if( !ReadPriv("user", "group", "privileges", user_id_file, group_id_file, priv_file) ) return; PrivLogStart("Content: changes: ", user_id_file, group_id_file, priv_file); - if( request.is_item ) + if( request->is_item ) { - ChangePriv(request.item, user_id_file, group_id_file, priv_file); - RedirectTo(request.item); + ChangePriv(request->item, user_id_file, group_id_file, priv_file); + system->RedirectTo(request->item); } else { - ChangePriv(*request.dir_table.back(), user_id_file, group_id_file, priv_file); - RedirectToLastDir(); + ChangePriv(*request->dir_table.back(), user_id_file, group_id_file, priv_file); + system->RedirectToLastDir(); } } -void Content::PostFunPriv() +void PrivChanger::Change(bool change_owner_, bool change_priv_) { - if( !PrivCheckAccess() ) + if( !CheckAccess() ) return; - change_owner = (request.pfunction->code == FUN_PRIV || request.pfunction->code == FUN_CHOWN); - change_priv = (request.pfunction->code == FUN_PRIV || request.pfunction->code == FUN_CHMOD); + change_owner = change_owner_; + change_priv = change_priv_; - if( request.IsParam("r") ) + if( request->IsParam("r") ) { PrivDir(); } @@ -298,14 +308,9 @@ void Content::PostFunPriv() PrivOneItem(); } - data.dirs.CheckRootDir(); + system->dirs.CheckRootDir(); } -void Content::FunPriv() -{ - PrivCheckAccess(); -} - diff --git a/functions/privchanger.h b/functions/privchanger.h new file mode 100755 index 0000000..f4bd853 --- /dev/null +++ b/functions/privchanger.h @@ -0,0 +1,57 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentprivchanger +#define headerfilecmslucontentprivchanger + + +#include "core/request.h" +#include "core/system.h" +#include "core/db.h" + + + +class PrivChanger +{ +public: + + bool CheckAccess(); + void Change(bool change_owner_, bool change_priv_); + + void SetRequest(Request * prequest); + void SetSystem(System * psystem); + void SetDb(Db * pdb); + +private: + + Request * request; + System * system; + Db * db; + + long user_id_file, group_id_file, user_id_dir, group_id_dir; + int priv_file, priv_dir; + bool subdirectories; + bool change_owner, change_priv; + + bool ChangeOwner(Item & item, long user_id, long group_id); + bool ChangePrivileges(Item & item, int privileges); + void ChangePriv(Item & item, long user_id, long group_id, int privileges); + void PrivLogStart(const char * what, long user, long group, int priv); + void PrivLog(const char * what, long id, const std::string & url); + void PrivFilesInDir(long parent_id); + void PrivDir(long parent_id); + bool ReadPriv(const char * user_in, const char * group_in, const char * priv_in, + long & user_id, long & group_id, int & priv); + void PrivDir(); + void PrivOneItem(); +}; + + + +#endif diff --git a/functions/readticket.cpp b/functions/readticket.cpp new file mode 100755 index 0000000..e4bc2ce --- /dev/null +++ b/functions/readticket.cpp @@ -0,0 +1,127 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "readticket.h" + + +namespace Fun +{ + +ReadTicket::ReadTicket() +{ +} + + + + + +void ReadTicket::ReadTicketType() +{ +static std::string temp; + + request->PostVar("type", temp); + ticket->type = atoi(temp.c_str()); + + if( ticket->type >= system->mounts.pmount->param[Mount::par_ticket_type].arg.size() ) + ticket->type = system->mounts.pmount->param[Mount::par_ticket_type].arg.size(); +} + + + +void ReadTicket::ReadTicketStatus() +{ +static std::string temp; + + request->PostVar("status", temp); + ticket->status = atoi(temp.c_str()); + + if( ticket->status >= system->mounts.pmount->param[Mount::par_ticket_status].arg.size() ) + ticket->status = system->mounts.pmount->param[Mount::par_ticket_status].arg.size(); +} + + + +void ReadTicket::ReadTicketPriority() +{ +static std::string temp; + + request->PostVar("priority", temp); + ticket->priority = atoi(temp.c_str()); + + if( ticket->priority >= system->mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) + ticket->priority = system->mounts.pmount->param[Mount::par_ticket_priority].arg.size(); +} + + + +void ReadTicket::ReadTicketCategory() +{ +static std::string temp; + + request->PostVar("category", temp); + ticket->category = atoi(temp.c_str()); + + if( ticket->category >= system->mounts.pmount->param[Mount::par_ticket_category].arg.size() ) + ticket->category = system->mounts.pmount->param[Mount::par_ticket_category].arg.size(); +} + + +void ReadTicket::ReadTicketExpected() +{ +static std::string temp; + + request->PostVar("expected", temp); + ticket->expected = atoi(temp.c_str()); + + if( ticket->expected >= system->mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) + ticket->expected = system->mounts.pmount->param[Mount::par_ticket_expected].arg.size(); +} + + +void ReadTicket::ReadTicketProgress() +{ +static std::string temp; + + request->PostVar("progress", temp); + int p = atoi(temp.c_str()); + + if( p < 0 ) + p = 0; + + if( p > 100 ) + p = 100; + + ticket->progress = p; +} + + + +void ReadTicket::Read(System * psystem, Request * prequest, Ticket * pticket) +{ + system = psystem; + request = prequest; + ticket = pticket; + + ticket->parent_id = request->dir_table.back()->id; + + ReadTicketType(); + ReadTicketStatus(); + ReadTicketPriority(); + ReadTicketCategory(); + ReadTicketExpected(); + ReadTicketProgress(); +} + + + + + + + +} // namespace diff --git a/functions/readticket.h b/functions/readticket.h new file mode 100755 index 0000000..f621d3a --- /dev/null +++ b/functions/readticket.h @@ -0,0 +1,46 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentreadticket +#define headerfilecmslucontentreadticket + +#include "core/request.h" +#include "core/ticket.h" +#include "core/system.h" + + + +namespace Fun +{ + + +class ReadTicket +{ +public: + ReadTicket(); + void Read(System * psystem, Request * prequest, Ticket * pticket); + +private: + Request * request; + Ticket * ticket; + System * system; + + void ReadTicketType(); + void ReadTicketStatus(); + void ReadTicketPriority(); + void ReadTicketCategory(); + void ReadTicketExpected(); + void ReadTicketProgress(); +}; + + +} // namespace + + +#endif diff --git a/functions/reload.cpp b/functions/reload.cpp new file mode 100755 index 0000000..4a7a82b --- /dev/null +++ b/functions/reload.cpp @@ -0,0 +1,54 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "reload.h" +#include "templates/templates.h" + + +namespace Fun +{ + + +Reload::Reload() +{ + fun.url = "reload"; + fun.privileges = 0700; +} + + +void Reload::FunReloadTemplates() +{ + log << log1 << "Content: reloading html templates" << logend; + + templates->ReadTemplates(); + notify->ReadTemplates(); // make sure that ReadTemplates() is using some kind of locking +} + + + + +void Reload::MakeGet() +{ + // !! temporarily only an admin has access + + if( !request->session->puser || !request->session->puser->super_user ) + { + log << log1 << "Content: Only an admin has access to reload function" << logend; + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + if( request->IsParam("templates") ) + FunReloadTemplates(); +} + + + + +} // namespace diff --git a/functions/reload.h b/functions/reload.h new file mode 100755 index 0000000..2c89961 --- /dev/null +++ b/functions/reload.h @@ -0,0 +1,37 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentreload +#define headerfilecmslucontentreload + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Reload : public FunctionBase +{ +public: + + Reload(); + void MakeGet(); + +private: + + void FunReloadTemplates(); + +}; + + +} // namespace + +#endif diff --git a/functions/rm.cpp b/functions/rm.cpp new file mode 100755 index 0000000..278d044 --- /dev/null +++ b/functions/rm.cpp @@ -0,0 +1,240 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include <cstdio> +#include <errno.h> +#include "rm.h" +#include "core/plugin.h" +#include "templates/templates.h" + + + +namespace Fun +{ + +Rm::Rm() +{ + fun.url = "rm"; +} + + + +bool Rm::HasAccess(const Item & item) +{ + // !! temporarily (we're waiting for the sticky bit to be implemented) + // not logged users cannot remove anything + if( !request->session->puser ) + return false; + + if( item.parent_id == -1 ) + { + // rm for the root dir + // only the superuser can do it + if( !request->session->puser || !request->session->puser->super_user ) + return false; + } + else + { + Item * last_but_one_dir = system->dirs.GetDir(item.parent_id); + + if( !last_but_one_dir ) + // ops, there is no a parent dir + return false; + + if( !system->HasWriteAccess(*last_but_one_dir) ) + return false; + } + + if( system->mounts.pmount->IsPar(Mount::par_only_root_remove) ) + if( !request->session->puser || !request->session->puser->super_user ) + return false; + +return true; +} + + +bool Rm::HasAccess() +{ + if( !request->is_item ) + return HasAccess(*request->dir_table.back()); + else + return HasAccess(request->item); + +return true; +} + + + +void Rm::RemoveAuthPrepareQuery() +{ + rm_auth_iq.SetAll(true, false); + + rm_auth_iq.sel_parent_id = true; + rm_auth_iq.sel_type = true; + rm_auth_iq.sel_auth = true; + + rm_auth_iq.WhereType(Item::file); + rm_auth_iq.WhereAuth(Item::auth_none, false); +} + + + +void Rm::RemoveAllDirs(long dir_id) +{ + DirContainer::ParentIterator pnext, p = system->dirs.FindFirstParent(dir_id); + + for( ; p != system->dirs.ParentEnd() ; p = pnext ) + { + // this iterator p will be deleted by the next DeleteDir(p->second->id) + // (the next iterator we must calculate beforehand) + pnext = system->dirs.NextParent(p); + RemoveAllDirs(p->second->id); + } + + plugin.Call(WINIX_DIR_PREPARE_TO_REMOVE, dir_id); + + rm_auth_iq.WhereParentId(dir_id); + db->GetItems(request->item_table, rm_auth_iq); + + for(size_t i=0 ; i<request->item_table.size() ; ++i) + RemoveAuth(request->item_table[i]); + + if( db->DelDirById(dir_id) == WINIX_ERR_OK ) + { + system->dirs.DelDir(dir_id); + + db->RemoveThread(dir_id); + db->RemoveTicket(dir_id); + + plugin.Call(WINIX_DIR_REMOVED, dir_id); + } +} + + + +void Rm::RemoveAllDirs() +{ + RemoveAuthPrepareQuery(); + + // this method deletes recursively all directories + RemoveAllDirs(request->dir_table.back()->id); + request->dir_table.erase(--request->dir_table.end()); + + if( request->dir_table.empty() ) + { + // we have deleted the root directory + system->dirs.CheckRootDir(); // adding a new root dir + Item * proot = system->dirs.GetRootDir(); + + if( proot ) + request->dir_table.push_back(proot); + else + // there is no a root dir + // CheckRootDir() didn't add the root dir (probably problem with the database) + // make sure that ::Make() will check that the dir_table is empty and returns + return; + } + + system->RedirectToLastDir(); +} + + +void Rm::RemoveDir() +{ + if( request->param_table.empty() ) + request->status = WINIX_ERR_PERMISSION_DENIED; // use parameter "r" for removing a directory + else + if( request->IsParam("r") ) + RemoveAllDirs(); + else + request->status = WINIX_ERR_UNKNOWN_PARAM; +} + + + +void Rm::RemoveAuth(Item & item) +{ + if( item.auth_path.empty() ) + { + log << log1 << "Content: can't remove a static file: auth_path is empty" << logend; + return; + } + + if( remove(item.auth_path.c_str()) == 0 ) + { + log << log1 << "Content: removed static file: " << item.auth_path << logend; + item.auth_path.clear(); + item.auth = Item::auth_none; + // we don't store it to db (will be removed or is removed already) + } + else + { + int err = errno; + + log << log1 << "Content: can't remove a file: " << item.auth_path; + log.SystemErr(err); + log << logend; + + request->status = WINIX_ERR_PERMISSION_DENIED; + } +} + + + +void Rm::RemoveFile() +{ + // for safety we check if param_table is empty + // a user can use "confirm" but can make a mistake when typing + if( !request->param_table.empty() ) + { + request->status = WINIX_ERR_UNKNOWN_PARAM; + return; + } + + + if( db->DelItem( request->item ) ) + { + log << log2 << "Content: deleted item: subject: " << request->item.subject << ", id: " << request->item.id << logend; + TemplatesFunctions::pattern_cacher.DeletePattern(request->item); + + plugin.Call(WINIX_FILE_REMOVED, request->item.id); + + if( system->mounts.pmount->type == Mount::thread ) + db->EditThreadRemoveItem(request->item.parent_id); + else + if( system->mounts.pmount->type == Mount::ticket ) + db->EditTicketRemoveItem(request->item.id); + + if( request->item.auth != Item::auth_none ) + RemoveAuth(request->item); + } + else + { + request->status = WINIX_ERR_NO_ITEM; + } + + system->RedirectToLastDir(); +} + + + +void Rm::MakeGet() +{ + if( request->IsParam("confirm") ) + return; // show confirmation dialog + + if( request->is_item ) + RemoveFile(); + else + RemoveDir(); +} + + + +} // namespace diff --git a/functions/rm.h b/functions/rm.h new file mode 100755 index 0000000..28b70e6 --- /dev/null +++ b/functions/rm.h @@ -0,0 +1,46 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentrm +#define headerfilecmslucontentrm + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Rm : public FunctionBase +{ +public: + + Rm(); + bool HasAccess(); + void MakeGet(); + +private: + + Db::ItemQuery rm_auth_iq; + + bool HasAccess(const Item & item); + void RemoveAuthPrepareQuery(); + void RemoveAllDirs(long dir_id); + void RemoveAllDirs(); + void RemoveDir(); + void RemoveAuth(Item & item); + void RemoveFile(); + +}; + + +} // namespace + +#endif diff --git a/functions/run.cpp b/functions/run.cpp new file mode 100755 index 0000000..f12461f --- /dev/null +++ b/functions/run.cpp @@ -0,0 +1,47 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "run.h" + + + +namespace Fun +{ + +Run::Run() +{ + fun.url = "run"; +} + + + +void Run::MakePost() +{ + MakeGet(); +} + + +void Run::MakeGet() +{ + if( !request->is_item ) + { + log << log1 << "Content: Run function requires an item" << logend; + request->status = WINIX_ERR_NO_ITEM; + return; + } + + if( !system->HasReadExecAccess(request->item) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } +} + + +} // namespace diff --git a/functions/run.h b/functions/run.h new file mode 100755 index 0000000..62a5a4c --- /dev/null +++ b/functions/run.h @@ -0,0 +1,37 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentrun +#define headerfilecmslucontentrun + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Run : public FunctionBase +{ +public: + + Run(); + +private: + + void MakePost(); + void MakeGet(); + +}; + + +} // namespace + +#endif diff --git a/functions/subject.cpp b/functions/subject.cpp new file mode 100755 index 0000000..fa95c30 --- /dev/null +++ b/functions/subject.cpp @@ -0,0 +1,88 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "subject.h" + + +namespace Fun +{ + +Subject::Subject() +{ + fun.url = "subject"; +} + + + +bool Subject::SubjectCheckAccess() +{ + // super user can always + if( request->session->puser && request->session->puser->super_user ) + return true; + + bool access; + + if( request->is_item ) + access = system->HasWriteAccess(request->item); + else + access = system->HasWriteAccess(*request->dir_table.back()); + + if( !access ) + request->status = WINIX_ERR_PERMISSION_DENIED; + +return access; +} + + + +void Subject::EditDirSubject() +{ + Item & dir = *request->dir_table.back(); + + request->PostVar("subject", dir.subject); + db->EditSubjectById(dir, dir.id); + + system->RedirectToLastDir(); +} + + + +void Subject::EditFileSubject() +{ + request->PostVar("subject", request->item.subject); + db->EditSubjectById(request->item, request->item.id); + + system->RedirectTo(request->item); +} + + + + +void Subject::MakePost() +{ + if( !SubjectCheckAccess() ) + return; + + if( request->is_item ) + EditFileSubject(); + else + EditDirSubject(); +} + + + +void Subject::MakeGet() +{ + SubjectCheckAccess(); +} + + + + +} // namespace diff --git a/functions/subject.h b/functions/subject.h new file mode 100755 index 0000000..c3ba187 --- /dev/null +++ b/functions/subject.h @@ -0,0 +1,40 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentsubject +#define headerfilecmslucontentsubject + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Subject : public FunctionBase +{ +public: + + Subject(); + void MakePost(); + void MakeGet(); + +private: + + bool SubjectCheckAccess(); + void EditDirSubject(); + void EditFileSubject(); + +}; + + +} // namespace + +#endif diff --git a/content/uname.cpp b/functions/uname.cpp similarity index 64% rename from content/uname.cpp rename to functions/uname.cpp index 884b8ec..05fa136 100755 --- a/content/uname.cpp +++ b/functions/uname.cpp @@ -7,12 +7,19 @@ * */ -#include "content.h" +#include "uname.h" - -void Content::FunUname() +namespace Fun { + +Uname::Uname() +{ + fun.url = "uname"; } + + +} // namespace + diff --git a/functions/uname.h b/functions/uname.h new file mode 100755 index 0000000..b556691 --- /dev/null +++ b/functions/uname.h @@ -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 headerfilecmslucontentuname +#define headerfilecmslucontentuname + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Uname : public FunctionBase +{ +public: + + Uname(); + +private: + +}; + + +} // namespace + +#endif diff --git a/functions/upload.cpp b/functions/upload.cpp new file mode 100755 index 0000000..409cdbb --- /dev/null +++ b/functions/upload.cpp @@ -0,0 +1,239 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <cstdio> +#include <errno.h> +#include "upload.h" +#include "core/misc.h" +#include "functions/functions.h" + + + +namespace Fun +{ + +Upload::Upload() +{ + fun.url = "upload"; +} + + + + +bool Upload::HasAccess(const Item & item) +{ + // you can use 'upload' only in a directory + if( item.type != Item::dir ) + return false; + + // we must know where to store the file + if( !system->mounts.pmount ) + return false; + + if( system->mounts.pmount->fs == Mount::simplefs && config->auth_simplefs_dir.empty() ) + { + log << log1 << "Request: can't use upload function, auth_simplefs_dir must be set in the config file" << logend; + return false; + } + + if( system->mounts.pmount->fs == Mount::hashfs && config->auth_hashfs_dir.empty() ) + { + log << log1 << "Request: can't use upload function, auth_hashfs_dir must be set in the config file" << logend; + return false; + } + + if( config->auth_tmp_dir.empty() ) + { + log << log1 << "Request: can't use upload function, auth_tmp_dir must be set in the config file" << logend; + return false; + } + + if( request->session->puser && request->session->puser->super_user ) + // super user can use upload everywhere + return true; + + if( !system->HasWriteAccess(item) ) + return false; + +return true; +} + + +bool Upload::HasAccess() +{ + if( request->is_item || !HasAccess(*request->dir_table.back()) ) + return false; + +return true; +} + + + +bool Upload::UploadCreatePath() +{ + if( !system->MakePath(request->item, true) ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + +return true; +} + + + + +void Upload::UploadSaveFile(const std::string & tmp_filename, const std::string & destination) +{ + if( rename(tmp_filename.c_str(), destination.c_str()) == 0 ) + { + log << log1 << "Content: uploaded a new file: " << destination << logend; + } + else + { + int err = errno; + + // !! skasowac takze plik z bazy danych? + log << log1 << "Content: can't move the tmp file from: " << tmp_filename << ", to: " << destination << ", "; + log.SystemErr(err); + log << logend; + + request->status = WINIX_ERR_PERMISSION_DENIED; + } +} + + + +bool Upload::FunUploadCheckAbuse() +{ + if( !system->rebus.CheckRebus() ) + { + request->status = WINIX_ERR_INCORRECT_REBUS; + return false; + } + + functions->CheckGetPostTimes(4); + + 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 Upload::UploadMulti() +{ + request->item.Clear(); // clearing and setting date + request->item.parent_id = request->dir_table.back()->id; + request->item.type = Item::file; + request->item.privileges = 0644; // !! tymczasowo + functions->SetUser(request->item); + + PostFileTable::iterator i = request->post_file_table.begin(); + + for( ; i != request->post_file_table.end() ; ++i) + { + const char * file_name = i->second.filename.c_str(); + + request->item.subject = file_name; + request->item.url = file_name; + request->item.auth = SelectFileType(file_name); + + system->PrepareUrl(request->item); + request->status = system->AddFile(request->item); + + if( !UploadCreatePath() ) + return; + + if( request->status == WINIX_ERR_OK ) + { + UploadSaveFile(i->second.tmp_filename, request->item.auth_path); + request->status = db->EditAuthById(request->item, request->item.id); + } + } + + system->RedirectToLastDir(); +} + + +void Upload::UploadSingle() +{ + std::string * new_subject = request->PostVar("subject"); + std::string * new_url = request->PostVar("url"); + bool has_subject = (new_subject && (*new_subject)[0] != 0 ); + bool has_url = (new_url && (*new_url)[0] != 0 ); + + functions->ReadItem(request->item, Item::file); // ReadItem() changes the url if it is empty + functions->SetUser(request->item); + request->item.privileges = 0644; // !! tymczasowo + + const char * file_name = request->post_file_table.begin()->second.filename.c_str(); + request->item.auth = SelectFileType(file_name); + + if( !has_subject ) + request->item.subject = file_name; + + if( !has_url ) + { + request->item.url = file_name; + system->PrepareUrl(request->item); + } + + request->status = system->AddFile(request->item); + + // url can be changed by PostFunEmacsAdd() + if( !UploadCreatePath() ) + return; + + if( request->status == WINIX_ERR_OK ) + { + const std::string & tmp_filename = request->post_file_table.begin()->second.tmp_filename; + UploadSaveFile(tmp_filename, request->item.auth_path); + request->status = db->EditAuthById(request->item, request->item.id); + } + + if( request->status == WINIX_ERR_OK ) + system->RedirectTo(request->item, "/cat"); +} + + + +// !! dodac usuwanie plikow statycznych przez rm +void Upload::MakePost() +{ + if( request->post_file_table.empty() ) + { + request->status = WINIX_ERR_PERMISSION_DENIED; + return; + } + + if( !FunUploadCheckAbuse() ) + return; + + if( request->post_file_table.size() > 1 ) + UploadMulti(); + else + UploadSingle(); +} + + + + + +} // namespace diff --git a/functions/upload.h b/functions/upload.h new file mode 100755 index 0000000..3730ad1 --- /dev/null +++ b/functions/upload.h @@ -0,0 +1,42 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontentupload +#define headerfilecmslucontentupload + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Upload : public FunctionBase +{ +public: + + Upload(); + bool HasAccess(); + void MakePost(); + +private: + + bool HasAccess(const Item & item); + bool UploadCreatePath(); + void UploadSaveFile(const std::string & tmp_filename, const std::string & destination); + bool FunUploadCheckAbuse(); + void UploadMulti(); + void UploadSingle(); +}; + + +} // namespace + +#endif diff --git a/content/who.cpp b/functions/who.cpp similarity index 67% rename from content/who.cpp rename to functions/who.cpp index c884b60..e6266bf 100755 --- a/content/who.cpp +++ b/functions/who.cpp @@ -7,18 +7,18 @@ * */ -#include "content.h" +#include "who.h" - - - -void Content::FunWho() +namespace Fun { - +Who::Who() +{ + fun.url = "who"; } +} // namespace diff --git a/functions/who.h b/functions/who.h new file mode 100755 index 0000000..b98c97b --- /dev/null +++ b/functions/who.h @@ -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 headerfilecmslucontentwho +#define headerfilecmslucontentwho + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Who : public FunctionBase +{ +public: + + Who(); + +private: + +}; + + +} // namespace + +#endif diff --git a/main/Makefile.dep b/main/Makefile.dep index f573802..969b8a6 100755 --- a/main/Makefile.dep +++ b/main/Makefile.dep @@ -1,23 +1,34 @@ # DO NOT DELETE -main.o: ../core/requestcontroller.h ../content/content.h ../core/item.h -main.o: ../templates/templates.h ../../ezc/src/ezc.h -main.o: ../templates/patterncacher.h ../templates/misc.h -main.o: ../templates/localefilter.h ../core/locale.h -main.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h -main.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h -main.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h -main.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h -main.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h -main.o: ../core/ticket.h ../core/sessionmanager.h ../core/sessioncontainer.h -main.o: ../core/session.h ../core/rebus.h ../core/plugindata.h -main.o: ../core/functionparser.h ../core/requesttypes.h ../core/data.h -main.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -main.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -main.o: ../core/mount.h ../core/loadavg.h ../core/request.h -main.o: ../core/compress.h ../core/acceptencodingparser.h -main.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -main.o: ../core/postmultiparser.h ../core/config.h ../core/notify.h -main.o: ../templatesnotify/templatesnotify.h ../core/mount.h -main.o: ../templates/misc.h ../core/plugin.h ../core/request.h ../core/data.h -main.o: ../core/pluginmsg.h +main.o: ../core/log.h ../core/app.h ../core/config.h ../core/confparser.h +main.o: ../core/system.h ../core/dirs.h ../core/item.h ../core/dircontainer.h +main.o: ../core/db.h ../core/user.h ../core/group.h ../core/thread.h +main.o: ../core/error.h ../core/log.h ../core/ugcontainer.h ../core/ticket.h +main.o: ../core/request.h ../core/requesttypes.h ../core/session.h +main.o: ../core/plugindata.h ../core/rebus.h ../core/compress.h +main.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +main.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/mounts.h +main.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +main.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h +main.o: ../core/sessioncontainer.h ../core/notify.h +main.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +main.o: ../core/mount.h ../core/locale.h ../core/config.h ../templates/misc.h +main.o: ../templates/localefilter.h ../core/locale.h ../functions/functions.h +main.o: ../functions/functionbase.h ../core/item.h ../core/db.h +main.o: ../core/request.h ../core/system.h ../core/notify.h +main.o: ../functions/functionparser.h ../functions/adduser.h +main.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h +main.o: ../functions/chown.h ../functions/cp.h ../functions/createthread.h +main.o: ../functions/createticket.h ../functions/default.h +main.o: ../functions/download.h ../functions/editticket.h +main.o: ../functions/emacs.h ../functions/last.h ../functions/login.h +main.o: ../functions/logout.h ../functions/ls.h ../functions/mkdir.h +main.o: ../functions/mv.h ../functions/node.h ../functions/priv.h +main.o: ../functions/reload.h ../functions/rm.h ../functions/run.h +main.o: ../functions/subject.h ../functions/funthread.h ../core/thread.h +main.o: ../functions/funticket.h ../functions/uname.h ../functions/upload.h +main.o: ../functions/who.h ../templates/templates.h +main.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h +main.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +main.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h +main.o: ../core/plugin.h ../core/pluginmsg.h diff --git a/main/main.cpp b/main/main.cpp index e0d2c86..1faae4b 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -12,52 +12,39 @@ #include <signal.h> #include <iostream> -#include "../core/requestcontroller.h" -#include "../core/data.h" -#include "../core/log.h" -#include "../core/request.h" -#include "../core/db.h" -#include "../core/config.h" -#include "../core/notify.h" -#include "../core/plugin.h" +#include "core/log.h" +#include "core/app.h" +#include "core/plugin.h" + +// !! chwilowo +#include "core/db.h" -// singletons -// first 'data' then 'log' then 'request' -Data data; Log log; Log nlog; // notify log (used by another thread) -Request request; -Db db; -Config config; -RequestController req_controller; -Notify notify; Plugin plugin; +/* + application object +*/ +App app; + + void signal_term(int) { plugin.Call(WINIX_CLOSE); + app.Close(); + log << log1 << "winix stopped" << logend << logsave; - req_controller.SaveSessions(); - req_controller.DeleteAllPluginsData(); - log << log1 << "cmslu stopped" << logend << logsave; - + // !! sprawdzic czemu ta flaga zatrzymania nie dzialala + // i sprobowac pozbyc sie tego exita tutaj exit(0); } -void signal_hup(int) -{ - log << log1 << "SIGHUP received" << logend; - data.signal_hup = true; - //config.ReadConfig(false); /* errors not to stdout */ - // plugins are not ready for reloading -} - - void print_syntax() { @@ -77,65 +64,61 @@ int main(int argv, char ** argc) return 1; } - data.system_start = time(0); - data.config_file = argc[1]; + app.system.system_start = time(0); + app.config.config_file = argc[1]; - if( !config.ReadConfig(true) ) /* errors to stdout */ + if( !app.config.ReadConfig(true, false) ) /* errors to stdout, stdout in not closed */ return 2; + if( app.stdout_is_closed ) + app.config.log_stdout = false; + // closing descriptors only at the beginning // !! temporary we do not close standard output for errors // client postgresql uses it for reporting warnings (I don't know why) //close(2); - if( !data.log_stdout ) + if( !app.config.log_stdout ) { close(1); - data.stdout_is_closed = true; + app.stdout_is_closed = true; } - log.Init(data.log_level, data.log_file, data.log_stdout, data.log_request); - nlog.Init(data.log_level, data.log_notify_file, false, 1); - db.Init(data.db_database, data.db_user, data.db_pass); + log.Init(app.config.log_level, app.config.log_file, app.config.log_stdout, app.config.log_request); + nlog.Init(app.config.log_level, app.config.log_notify_file, false, 1); + app.db.Init(app.config.db_database, app.config.db_user, app.config.db_pass); - // data.base_server can be changed (stripped from 'http://' or a last slash) + // app.config.base_server can be changed (stripped from 'http://' or a last slash) // it is done when the config is read - log << log3 << "base_server: " << data.base_server << logend; + log << log3 << "base_server: " << app.config.base_server << logend; - // load plugins before loading sessions - req_controller.LoadSessions() - plugin.LoadPlugins(data.plugin_file); - plugin.Call(WINIX_PLUGIN_INIT); + // load plugins before loading sessions - session_manager.LoadSessions() + // because some of the plugins can init your own session dates + plugin.LoadPlugins(app.config.plugin_file); + //plugin.Call(WINIX_PLUGIN_INIT); - request.Init(); - - if( !req_controller.Init() ) + if( !app.Init() ) return 1; - // !! teraz mamy dwa katalogi z templetami - if( !notify.Init() ) - return 2; - notify.ReadTemplates(); + app.notify.ReadTemplates(); // wrzucic do notify.Init() ? signal(SIGTERM, signal_term); signal(SIGINT, signal_term); - signal(SIGHUP, signal_hup); - req_controller.LoadSessions(); - log << log1 << "cmslu started" << logend << logsavenow; + log << log1 << "winix started" << logend << logsavenow; - while( true ) - { - //log << log2 << "checking for table consistency:" << logend; - // !! zrobic wyjatek dla root - //db.CheckAllUrlSubject(); + // !! wywalic to sprawdzanie + //log << log2 << "checking for table consistency:" << logend; + // !! zrobic wyjatek dla root + //app.db.CheckAllUrlSubject(); - req_controller.Loop(); - - if( data.signal_hup ) - data.signal_hup = false; - } + app.Start(); + + plugin.Call(WINIX_CLOSE); + app.Close(); + log << log1 << "winix stopped" << logend << logsave; return 0; } diff --git a/plugins/stats/Makefile.dep b/plugins/stats/Makefile.dep index 4acea33..43a54ff 100755 --- a/plugins/stats/Makefile.dep +++ b/plugins/stats/Makefile.dep @@ -1,18 +1,84 @@ # DO NOT DELETE +bot.o: bot.h init.o: ../../core/log.h ../../core/request.h ../../core/requesttypes.h init.o: ../../core/session.h ../../core/item.h ../../core/error.h -init.o: ../../core/log.h ../../core/user.h ../../core/rebus.h -init.o: ../../core/plugindata.h ../../core/function.h ../../core/thread.h -init.o: ../../core/compress.h ../../core/acceptencodingparser.h -init.o: ../../core/acceptbaseparser.h ../../core/htmlfilter.h -init.o: ../../core/postmultiparser.h ../../core/ticket.h ../../core/config.h -init.o: ../../confparser/confparser.h ../../core/db.h ../../core/group.h -init.o: ../../core/dircontainer.h ../../core/ugcontainer.h stats.h -init.o: templates.h ../../core/plugin.h ../../core/request.h data.h -init.o: ../../core/plugindata.h ../../core/pluginmsg.h -stats.o: stats.h data.h ../../core/plugindata.h ../../core/log.h -templates.o: templates.h ../../core/plugin.h ../../core/request.h data.h -templates.o: stats.h ../../core/plugindata.h ../../core/pluginmsg.h -templates.o: ../../core/log.h ../../core/plugindata.h ../../../ezc/src/ezc.h -templates.o: ../../core/misc.h ../../core/item.h +init.o: ../../core/log.h ../../core/user.h ../../core/plugindata.h +init.o: ../../core/rebus.h ../../core/thread.h ../../core/compress.h +init.o: ../../core/acceptencodingparser.h ../../core/acceptbaseparser.h +init.o: ../../core/htmlfilter.h ../../core/postmultiparser.h +init.o: ../../core/config.h ../../core/confparser.h ../../core/ticket.h +init.o: ../../core/config.h ../../core/db.h ../../core/group.h +init.o: ../../core/dircontainer.h ../../core/ugcontainer.h bot.h stats.h +init.o: templates.h ../../core/plugin.h ../../core/pluginmsg.h +init.o: ../../core/request.h ../../core/system.h ../../core/dirs.h +init.o: ../../core/db.h ../../core/mounts.h ../../core/mount.h +init.o: ../../core/users.h ../../core/lastcontainer.h ../../core/groups.h +init.o: ../../core/loadavg.h ../../core/sessionmanager.h +init.o: ../../core/sessioncontainer.h ../../functions/functions.h +init.o: ../../functions/functionbase.h ../../core/item.h ../../core/system.h +init.o: ../../core/notify.h ../../templatesnotify/templatesnotify.h +init.o: ../../../ezc/src/ezc.h ../../core/mount.h ../../core/locale.h +init.o: ../../templates/misc.h ../../templates/localefilter.h +init.o: ../../core/locale.h ../../functions/functionparser.h +init.o: ../../functions/adduser.h ../../functions/cat.h +init.o: ../../functions/chmod.h ../../functions/privchanger.h +init.o: ../../functions/chown.h ../../functions/cp.h +init.o: ../../functions/createthread.h ../../functions/createticket.h +init.o: ../../functions/default.h ../../functions/download.h +init.o: ../../functions/editticket.h ../../functions/emacs.h +init.o: ../../functions/last.h ../../functions/login.h +init.o: ../../functions/logout.h ../../functions/ls.h ../../functions/mkdir.h +init.o: ../../functions/mv.h ../../functions/node.h ../../functions/priv.h +init.o: ../../functions/reload.h ../../functions/rm.h ../../functions/run.h +init.o: ../../functions/subject.h ../../functions/funthread.h +init.o: ../../core/thread.h ../../functions/funticket.h +init.o: ../../functions/uname.h ../../functions/upload.h +init.o: ../../functions/who.h ../../templates/templates.h +init.o: ../../templates/patterncacher.h ../../core/item.h +init.o: ../../templates/misc.h ../../templates/ckeditorgetparser.h +init.o: ../../core/httpsimpleparser.h ../../core/log.h +init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h +init.o: statssession.h ../../core/plugindata.h +stats.o: stats.h ../../core/log.h +templates.o: templates.h ../../core/plugin.h ../../core/pluginmsg.h +templates.o: ../../core/log.h ../../core/plugindata.h ../../core/config.h +templates.o: ../../core/confparser.h ../../core/request.h ../../core/system.h +templates.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h +templates.o: ../../core/db.h ../../core/mounts.h ../../core/mount.h +templates.o: ../../core/error.h ../../core/users.h ../../core/user.h +templates.o: ../../core/ugcontainer.h ../../core/lastcontainer.h +templates.o: ../../core/groups.h ../../core/group.h ../../core/rebus.h +templates.o: ../../core/loadavg.h ../../core/sessionmanager.h +templates.o: ../../core/sessioncontainer.h ../../core/session.h +templates.o: ../../functions/functions.h ../../functions/functionbase.h +templates.o: ../../core/item.h ../../core/db.h ../../core/thread.h +templates.o: ../../core/ticket.h ../../core/request.h +templates.o: ../../core/requesttypes.h ../../core/compress.h +templates.o: ../../core/acceptencodingparser.h ../../core/acceptbaseparser.h +templates.o: ../../core/htmlfilter.h ../../core/postmultiparser.h +templates.o: ../../core/config.h ../../core/system.h ../../core/notify.h +templates.o: ../../templatesnotify/templatesnotify.h ../../../ezc/src/ezc.h +templates.o: ../../core/mount.h ../../core/locale.h ../../templates/misc.h +templates.o: ../../templates/localefilter.h ../../core/locale.h +templates.o: ../../functions/functionparser.h ../../functions/adduser.h +templates.o: ../../functions/cat.h ../../functions/chmod.h +templates.o: ../../functions/privchanger.h ../../functions/chown.h +templates.o: ../../functions/cp.h ../../functions/createthread.h +templates.o: ../../functions/createticket.h ../../functions/default.h +templates.o: ../../functions/download.h ../../functions/editticket.h +templates.o: ../../functions/emacs.h ../../functions/last.h +templates.o: ../../functions/login.h ../../functions/logout.h +templates.o: ../../functions/ls.h ../../functions/mkdir.h +templates.o: ../../functions/mv.h ../../functions/node.h +templates.o: ../../functions/priv.h ../../functions/reload.h +templates.o: ../../functions/rm.h ../../functions/run.h +templates.o: ../../functions/subject.h ../../functions/funthread.h +templates.o: ../../core/thread.h ../../functions/funticket.h +templates.o: ../../functions/uname.h ../../functions/upload.h +templates.o: ../../functions/who.h ../../templates/templates.h +templates.o: ../../templates/patterncacher.h ../../core/item.h +templates.o: ../../templates/misc.h ../../templates/ckeditorgetparser.h +templates.o: ../../core/httpsimpleparser.h ../../core/log.h +templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h +templates.o: ../../core/misc.h stats.h diff --git a/plugins/stats/Makefile.o.dep b/plugins/stats/Makefile.o.dep index 0360402..4291481 100755 --- a/plugins/stats/Makefile.o.dep +++ b/plugins/stats/Makefile.o.dep @@ -1 +1 @@ -o = init.o stats.o templates.o +o = bot.o init.o stats.o templates.o diff --git a/plugins/stats/bot.cpp b/plugins/stats/bot.cpp new file mode 100755 index 0000000..1bacdcb --- /dev/null +++ b/plugins/stats/bot.cpp @@ -0,0 +1,45 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include <string.h> +#include "bot.h" + +namespace Stats +{ + + + +void Bot::SetBrowserName(const char * name) +{ + browser_name = name; +} + + + +bool Bot::BrowserNameHas(const char * name) +{ + return strstr(browser_name, name) != 0; +} + + + +bool Bot::IsGoogle() +{ + return BrowserNameHas("Googlebot") && BrowserNameHas("www.google.com"); +} + + + +bool Bot::IsYahoo() +{ + return BrowserNameHas("Yahoo!") && BrowserNameHas("yahoo.com"); +} + + +} // namespace diff --git a/plugins/stats/bot.h b/plugins/stats/bot.h new file mode 100755 index 0000000..d2f30dd --- /dev/null +++ b/plugins/stats/bot.h @@ -0,0 +1,40 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmsluplugin_stats_bot +#define headerfilecmsluplugin_stats_bot + + +namespace Stats +{ + + + +struct Bot +{ + void SetBrowserName(const char * name); + + bool IsGoogle(); + bool IsYahoo(); + + + +private: + + const char * browser_name; + + bool BrowserNameHas(const char * name); +}; + + + + +} // namespace + +#endif diff --git a/plugins/stats/init.cpp b/plugins/stats/init.cpp index f243202..0640b75 100755 --- a/plugins/stats/init.cpp +++ b/plugins/stats/init.cpp @@ -8,15 +8,16 @@ */ -#include <map> #include "core/log.h" #include "core/request.h" #include "core/config.h" #include "core/db.h" +#include "bot.h" #include "stats.h" #include "templates.h" -#include "data.h" +#include "statssession.h" + extern "C" void Init(PluginInfo &); const char plugin_name[] = "stats"; @@ -25,126 +26,86 @@ const char plugin_name[] = "stats"; namespace Stats { -// when the statistics start -time_t stats_start; - - -// statistics for all pages -StatsGlobal stat_global; - -// statistics for one item -// <item_id, Stats> -std::map<long, Stats> stats_tab; - - -// when to save the config (how many requests should have gone) -// (for safety: power failure etc) -// default: 1000 -// you can set: stats_req_save_freq in the config file to overwrite it -// 0 - turn it off -int req_save_freq = 1000; -int req_current = 0; // helper +Stats stats; +Bot bot; +long current_item_id; -long ItemId() + +void CalcItemId(Request * request) { -long item_id; - - if( request.is_item ) - item_id = request.item.id; + if( request->is_item ) + current_item_id = request->item.id; else - item_id = request.dir_table.back()->id; - -return item_id; + if( !request->dir_table.empty() ) + current_item_id = request->dir_table.back()->id; + else + current_item_id = -1; } -void CheckSaving() -{ - req_current += 1; - if( req_save_freq != 0 && req_current >= req_save_freq ) + + +void UpdateStats(PluginInfo & info, Stats::ItemStats & item_stats) +{ + bot.SetBrowserName(info.request->env_http_user_agent); + + stats.global_all += 1; + item_stats.all += 1; + + if( bot.IsGoogle() ) { - SaveStats(); - req_current = 0; + stats.global_google += 1; + item_stats.google += 1; + } + + if( bot.IsYahoo() ) + { + stats.global_yahoo += 1; + item_stats.yahoo += 1; } } -bool BrowserHas(const char * name) -{ - const char * is = strstr(request.env_http_user_agent, name); - return is != 0; -} - - -bool IsGoogle() -{ - return BrowserHas("Googlebot") && BrowserHas("www.google.com"); -} - - -bool IsYahoo() -{ - return BrowserHas("Yahoo!") && BrowserHas("yahoo.com"); -} - - -void UpdateStats(Stats & item_stats) -{ - stat_global.all += 1; - item_stats.all += 1; - - if( IsGoogle() ) - { - stat_global.google += 1; - item_stats.google += 1; - } - - if( IsYahoo() ) - { - stat_global.yahoo += 1; - item_stats.yahoo += 1; - } -} - - void ContentMake(PluginInfo & info) { -StatsData * d = 0; +StatsSession * stats_session = 0; - long id = ItemId(); + CalcItemId(info.request); - if( info.plugin_data_base ) - d = reinterpret_cast<StatsData*>(info.plugin_data_base); - - // this simply prevents F5 (refresh) from a webbrowser - if( d && d->last_visited != -1 && d->last_visited == id ) + if( current_item_id == - 1 || !info.plugin_data_base ) return; - if( d ) - d->last_visited = id; + stats_session = reinterpret_cast<StatsSession*>(info.plugin_data_base); - UpdateStats(stats_tab[id]); + // this simply prevents F5 (refresh) from a webbrowser + if( stats_session->last_visited != -1 && + stats_session->last_visited == current_item_id ) + return; - if( d && !d->calculated ) + stats_session->last_visited = current_item_id; + + UpdateStats(info, stats.stats_tab[current_item_id]); + + if( !stats_session->calculated ) { - stat_global.unique += 1; - d->calculated = true; + stats.global_unique += 1; + stats_session->calculated = true; } - CheckSaving(); + stats.PeriodicSave(); } void SessionCreated(PluginInfo & info) { - StatsData * d = new StatsData(); - request.session->plugin_data.Assign(d); + StatsSession * d = new StatsSession(); + info.request->session->plugin_data.Assign(d); log << log3 << "created stats plugin data" << ", plugin id: " << info.plugin_id @@ -164,43 +125,18 @@ void RemoveSession(PluginInfo & info) -void ReadConfig() + +void Close(PluginInfo & info) { - stats_file = config.Text("stats_file"); - req_save_freq = config.Int("stats_req_save_freq", req_save_freq); - - if( stats_file.empty() ) - log << log1 << "you should set stats_file in your config to keep statistics between restarting winix" << logend; - else - log << log2 << "stats_file: " << stats_file << logend; - - stats_start = time(0); // it will be overwritten if the config file exists - ReadStats(); + stats.SaveStats(); } -void Close() -{ - SaveStats(); -} - - -void RemoveItem(long id) -{ - std::map<long, Stats>::iterator i = stats_tab.find(id); - - if( i == stats_tab.end() ) - return; - - stats_tab.erase(i); - log << log3 << "Stats: removed stats for item.id: " << id << logend; -} - void RemoveFile(PluginInfo & info) { - RemoveItem(info.l1); + stats.RemoveItem(info.l1); } @@ -210,16 +146,17 @@ Db::ItemQuery query; std::vector<long> items; size_t i; + // !! may only files can be retrieved here? query.SetAll(false, false); query.WhereParentId(info.l1); - db.GetItems(items, query); + info.db->GetItems(items, query); // removing childs for(i=0 ; i<items.size() ; ++i) - RemoveItem(items[i]); + stats.RemoveItem(items[i]); // removing the directory - RemoveItem(info.l1); + stats.RemoveItem(info.l1); } @@ -227,6 +164,7 @@ size_t i; + void Init(PluginInfo & info) { using namespace Stats; @@ -235,11 +173,13 @@ using namespace Stats; plugin.Assign(WINIX_CONTENT_MAKE, ContentMake); plugin.Assign(WINIX_SESSION_CREATED, SessionCreated); plugin.Assign(WINIX_SESSION_REMOVE, RemoveSession); - plugin.Assign(WINIX_PLUGIN_INIT, ReadConfig); plugin.Assign(WINIX_CLOSE, Close); plugin.Assign(WINIX_FILE_REMOVED, RemoveFile); plugin.Assign(WINIX_DIR_PREPARE_TO_REMOVE, RemoveDir); + stats.ReadConfig(info.config); + stats.ReadStats(); + info.p1 = (void*)plugin_name; } diff --git a/plugins/stats/stats.cpp b/plugins/stats/stats.cpp index 9953f8d..03ef512 100755 --- a/plugins/stats/stats.cpp +++ b/plugins/stats/stats.cpp @@ -8,30 +8,42 @@ */ #include "stats.h" -#include <fstream> -#include "data.h" #include "core/log.h" +#include <ctime> + namespace Stats { -std::string stats_file; + +Stats::Stats() +{ + global_all = 0; + global_unique = 0; + global_google = 0; + global_yahoo = 0; + + req_save_freq = 1000; + req_current = 0; + + stats_start = time(0); +} -void ReadStats(std::ifstream & file) +void Stats::ReadStats(std::ifstream & file) { file >> stats_start; - file >> stat_global.all; - file >> stat_global.unique; - file >> stat_global.google; - file >> stat_global.yahoo; + file >> global_all; + file >> global_unique; + file >> global_google; + file >> global_yahoo; size_t len; file >> len; - Stats s; + ItemStats s; long item_id; for(size_t i = 0 ; i<len && !file.eof() ; ++i) @@ -48,7 +60,7 @@ void ReadStats(std::ifstream & file) -void ReadStats() +void Stats::ReadStats() { if( stats_file.empty() ) return; @@ -57,7 +69,7 @@ void ReadStats() if( !file ) { - log << log1 << "Stats: I cannot open the stats file: " << stats_file << logend; + log << log1 << "Stats: I cannot open a file: " << stats_file << logend; return; } @@ -71,19 +83,19 @@ void ReadStats() -void SaveStats(std::ofstream & file) +void Stats::SaveStats(std::ofstream & file) { file << stats_start << std::endl; - file << stat_global.all << ' '; - file << stat_global.unique << ' '; - file << stat_global.google << ' '; - file << stat_global.yahoo << ' '; + file << global_all << ' '; + file << global_unique << ' '; + file << global_google << ' '; + file << global_yahoo << ' '; file << std::endl; file << stats_tab.size() << std::endl; - std::map<long, Stats>::iterator i = stats_tab.begin(); + StatsTab::iterator i = stats_tab.begin(); for( ; i != stats_tab.end() ; ++i) { @@ -96,7 +108,7 @@ void SaveStats(std::ofstream & file) } -void SaveStats() +void Stats::SaveStats() { if( stats_file.empty() ) return; @@ -105,7 +117,7 @@ void SaveStats() if( !file ) { - log << log1 << "Stats: I cannot open the stats file: " << stats_file << logend; + log << log1 << "Stats: I cannot open a file: " << stats_file << logend; return; } @@ -115,6 +127,49 @@ void SaveStats() log << log3 << "Stats: statistics saved to: " << stats_file << logend; } + + +void Stats::PeriodicSave() +{ + req_current += 1; + + if( req_save_freq != 0 && req_current >= req_save_freq ) + { + SaveStats(); + req_current = 0; + } +} + + +void Stats::ReadConfig(Config * config) +{ + stats_file = config->Text("stats_file"); + req_save_freq = config->Int("stats_req_save_freq", req_save_freq); + + if( stats_file.empty() ) + { + log << log1 << "you should set stats_file in your config to keep statistics between restarting winix" << logend; + } + else + { + log << log2 << "Stats: stats_file: " << stats_file << logend; + log << log2 << "Stats: statistics will be saved after each " << req_save_freq << " requests" << logend; + } +} + + +void Stats::RemoveItem(long id) +{ + StatsTab::iterator i = stats_tab.find(id); + + if( i == stats_tab.end() ) + return; + + stats_tab.erase(i); + log << log3 << "Stats: statistics erased for item: " << id << logend; +} + + } // namespace diff --git a/plugins/stats/stats.h b/plugins/stats/stats.h index dd5c5cf..409fe50 100755 --- a/plugins/stats/stats.h +++ b/plugins/stats/stats.h @@ -11,50 +11,79 @@ #define headerfilecmsluplugin_stats_stats #include <string> +#include <map> +#include <fstream> +#include "core/config.h" + namespace Stats { -struct StatsGlobal -{ - int all; - int unique; - - int google; - int yahoo; - - StatsGlobal() - { - all = 0; - unique = 0; - google = 0; - yahoo = 0; - } -}; - struct Stats { - int all; - int google; - int yahoo; + Stats(); - Stats() + void ReadStats(); + void SaveStats(); + void PeriodicSave(); + void ReadConfig(Config * config); + void RemoveItem(long id); + + // file name for reading/saving statistics + std::string stats_file; + + // when the statistics start + time_t stats_start; + + int global_all; + int global_unique; + + int global_google; + int global_yahoo; + + + + // statistics for files/dirs + struct ItemStats { - all = 0; - google = 0; - yahoo = 0; - } + int all; + int google; + int yahoo; + + ItemStats() + { + all = 0; + google = 0; + yahoo = 0; + } + }; + + // <item_id, Item_stats> + typedef std::map<long, ItemStats> StatsTab; + StatsTab stats_tab; + + +private: + + // when to save the config (how many requests should have gone) + // (for safety: power failure etc) + // default: 1000 + // you can set: stats_req_save_freq in the config file to overwrite it + // 0 - turn it off + int req_save_freq; + int req_current; // helper + + + void ReadStats(std::ifstream & file); + void SaveStats(std::ofstream & file); + }; -extern std::string stats_file; -void ReadStats(); -void SaveStats(); + } // namespace - - #endif diff --git a/plugins/stats/data.h b/plugins/stats/statssession.h similarity index 61% rename from plugins/stats/data.h rename to plugins/stats/statssession.h index 1c9e16e..abb8ba0 100755 --- a/plugins/stats/data.h +++ b/plugins/stats/statssession.h @@ -10,10 +10,7 @@ #ifndef headerfilecmsluplugin_stats_data #define headerfilecmsluplugin_stats_data -#include "stats.h" -#include <map> #include "core/plugindata.h" -#include <ctime> namespace Stats @@ -21,31 +18,19 @@ namespace Stats // session data for the plugin -struct StatsData : public PluginDataBase +struct StatsSession : public PluginDataBase { // whether this session has been calculated bool calculated; long last_visited; - StatsData() + StatsSession() { calculated = false; last_visited = -1; } }; -extern time_t stats_start; - -// statistics for all pages -extern StatsGlobal stat_global; - -// statistics for one item -// <item_id, Stats> -extern std::map<long, Stats> stats_tab; - - -long ItemId(); - } // namespace diff --git a/plugins/stats/templates.cpp b/plugins/stats/templates.cpp index 4984ca3..c4c9072 100755 --- a/plugins/stats/templates.cpp +++ b/plugins/stats/templates.cpp @@ -9,56 +9,60 @@ #include "templates.h" #include "ezc.h" -#include "data.h" #include "core/misc.h" - +#include "stats.h" namespace Stats { +extern long current_item_id; +extern Stats stats; void stats_from(Ezc::Info & i) { - i.out << DateToStrWithoutHours(stats_start); + i.out << DateToStrWithoutHours(stats.stats_start); } void stats_all(Ezc::Info & i) { - i.out << stat_global.all; + i.out << stats.global_all; } + void stats_unique(Ezc::Info & i) { - i.out << stat_global.unique; + i.out << stats.global_unique; } + void stats_google(Ezc::Info & i) { - i.out << stat_global.google; + i.out << stats.global_google; } + void stats_yahoo(Ezc::Info & i) { - i.out << stat_global.yahoo; + i.out << stats.global_yahoo; } void stats_item_all(Ezc::Info & i) { - i.out << stats_tab[ItemId()].all; + i.out << stats.stats_tab[current_item_id].all; } void stats_item_google(Ezc::Info & i) { - i.out << stats_tab[ItemId()].google; + i.out << stats.stats_tab[current_item_id].google; } void stats_item_yahoo(Ezc::Info & i) { - i.out << stats_tab[ItemId()].yahoo; + i.out << stats.stats_tab[current_item_id].yahoo; } @@ -66,12 +70,6 @@ void stats_item_yahoo(Ezc::Info & i) void CreateFunctions(PluginInfo & info) { - if( !info.p1 ) - { - log << log1 << "S: functions object doesn't set" << logend; - return; - } - Ezc::Functions * fun = reinterpret_cast<Ezc::Functions*>(info.p1); fun->Insert("stats_from", stats_from); diff --git a/plugins/stats/templates.h b/plugins/stats/templates.h index 7f8be85..5961571 100755 --- a/plugins/stats/templates.h +++ b/plugins/stats/templates.h @@ -12,6 +12,8 @@ #include "core/plugin.h" + + namespace Stats { diff --git a/templates/Makefile.dep b/templates/Makefile.dep index 3f78c0e..ba5d6e0 100755 --- a/templates/Makefile.dep +++ b/templates/Makefile.dep @@ -1,255 +1,367 @@ # DO NOT DELETE adduser.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -adduser.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +adduser.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h adduser.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -adduser.o: indexpatterns.h ../core/request.h ../core/requesttypes.h -adduser.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h -adduser.o: ../core/user.h ../core/rebus.h ../core/plugindata.h -adduser.o: ../core/function.h ../core/thread.h ../core/compress.h -adduser.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -adduser.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h +adduser.o: indexpatterns.h ../core/locale.h ../core/config.h +adduser.o: ../core/request.h ../core/requesttypes.h ../core/session.h +adduser.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h +adduser.o: ../core/plugindata.h ../core/rebus.h ../core/thread.h +adduser.o: ../core/compress.h ../core/acceptencodingparser.h +adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +adduser.o: ../core/postmultiparser.h ../core/config.h ../core/ticket.h +adduser.o: ../core/db.h ../core/group.h ../core/dircontainer.h +adduser.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +adduser.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +adduser.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +adduser.o: ../core/sessionmanager.h ../core/sessioncontainer.h +adduser.o: ../core/system.h dir.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -dir.o: localefilter.h ../core/locale.h ../confparser/confparser.h +dir.o: localefilter.h ../core/locale.h ../core/confparser.h dir.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -dir.o: indexpatterns.h ../core/request.h ../core/requesttypes.h -dir.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h -dir.o: ../core/user.h ../core/rebus.h ../core/plugindata.h ../core/function.h -dir.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h -dir.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -dir.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h -dir.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h -dir.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h -dir.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -dir.o: ../core/mount.h ../core/loadavg.h ../core/db.h ../core/misc.h +dir.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +dir.o: ../core/requesttypes.h ../core/session.h ../core/item.h +dir.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +dir.o: ../core/rebus.h ../core/thread.h ../core/compress.h +dir.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +dir.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +dir.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +dir.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +dir.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +dir.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +dir.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +dir.o: ../core/misc.h ../functions/functions.h ../functions/functionbase.h +dir.o: ../core/item.h ../core/notify.h ../templatesnotify/templatesnotify.h +dir.o: ../core/mount.h ../templates/misc.h ../functions/functionparser.h +dir.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +dir.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +dir.o: ../functions/createthread.h ../functions/createticket.h +dir.o: ../functions/default.h ../functions/download.h +dir.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +dir.o: ../functions/login.h ../functions/logout.h ../functions/ls.h +dir.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h +dir.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h +dir.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h +dir.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +dir.o: ../functions/upload.h ../functions/who.h doc.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -doc.o: localefilter.h ../core/locale.h ../confparser/confparser.h +doc.o: localefilter.h ../core/locale.h ../core/confparser.h doc.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -doc.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -doc.o: ../core/dircontainer.h ../core/users.h ../core/user.h -doc.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -doc.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -doc.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -doc.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -doc.o: ../core/session.h ../core/plugindata.h ../core/thread.h -doc.o: ../core/compress.h ../core/acceptencodingparser.h -doc.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -doc.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -indexpatterns.o: indexpatterns.h ../../ezc/src/ezc.h ../core/locale.h -indexpatterns.o: ../confparser/confparser.h localefilter.h ../core/log.h -indexpatterns.o: ../core/data.h ../core/dirs.h ../core/item.h -indexpatterns.o: ../core/dircontainer.h ../core/users.h ../core/user.h -indexpatterns.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h -indexpatterns.o: ../core/group.h ../core/functions.h ../core/function.h -indexpatterns.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -indexpatterns.o: ../core/error.h ../core/rebus.h ../core/loadavg.h +doc.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +doc.o: ../core/requesttypes.h ../core/session.h ../core/item.h +doc.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +doc.o: ../core/rebus.h ../core/thread.h ../core/compress.h +doc.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +doc.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +doc.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +doc.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +doc.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +doc.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +doc.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +doc.o: ../core/request.h ../core/misc.h +indexpatterns.o: indexpatterns.h ../../ezc/src/ezc.h localefilter.h +indexpatterns.o: ../core/locale.h ../core/confparser.h ../core/locale.h +indexpatterns.o: ../core/config.h ../core/log.h item.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -item.o: localefilter.h ../core/locale.h ../confparser/confparser.h +item.o: localefilter.h ../core/locale.h ../core/confparser.h item.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -item.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -item.o: ../core/dircontainer.h ../core/users.h ../core/user.h -item.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -item.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -item.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -item.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -item.o: ../core/session.h ../core/plugindata.h ../core/thread.h -item.o: ../core/compress.h ../core/acceptencodingparser.h -item.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -item.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -item.o: ../core/bbcodeparser.h +item.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +item.o: ../core/requesttypes.h ../core/session.h ../core/item.h +item.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +item.o: ../core/rebus.h ../core/thread.h ../core/compress.h +item.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +item.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +item.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +item.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +item.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +item.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +item.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +item.o: ../core/request.h ../core/misc.h ../core/bbcodeparser.h last.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -last.o: localefilter.h ../core/locale.h ../confparser/confparser.h +last.o: localefilter.h ../core/locale.h ../core/confparser.h last.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -last.o: indexpatterns.h ../core/lastcontainer.h ../core/data.h ../core/dirs.h -last.o: ../core/item.h ../core/dircontainer.h ../core/users.h ../core/user.h -last.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -last.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -last.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -last.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -last.o: ../core/session.h ../core/plugindata.h ../core/thread.h -last.o: ../core/compress.h ../core/acceptencodingparser.h -last.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -last.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -localefilter.o: localefilter.h ../core/locale.h ../confparser/confparser.h +last.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +last.o: ../core/requesttypes.h ../core/session.h ../core/item.h +last.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +last.o: ../core/rebus.h ../core/thread.h ../core/compress.h +last.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +last.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +last.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +last.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +last.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +last.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +last.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +last.o: ../core/lastcontainer.h ../core/request.h ../core/misc.h +localefilter.o: localefilter.h ../core/locale.h ../core/confparser.h localefilter.o: ../../ezc/src/ezc.h ../core/misc.h ../core/item.h ls.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -ls.o: localefilter.h ../core/locale.h ../confparser/confparser.h +ls.o: localefilter.h ../core/locale.h ../core/confparser.h ls.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -ls.o: indexpatterns.h ../core/request.h ../core/requesttypes.h -ls.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h -ls.o: ../core/user.h ../core/rebus.h ../core/plugindata.h ../core/function.h +ls.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +ls.o: ../core/requesttypes.h ../core/session.h ../core/item.h ../core/error.h +ls.o: ../core/log.h ../core/user.h ../core/plugindata.h ../core/rebus.h ls.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h ls.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -ls.o: ../core/postmultiparser.h ../core/ticket.h -misc.o: ../core/data.h ../core/dirs.h ../core/item.h ../core/dircontainer.h -misc.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h -misc.o: ../core/groups.h ../core/group.h ../core/functions.h -misc.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -misc.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/loadavg.h -misc.o: ../core/misc.h ../core/request.h ../core/requesttypes.h -misc.o: ../core/session.h ../core/plugindata.h ../core/thread.h -misc.o: ../core/compress.h ../core/acceptencodingparser.h -misc.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -misc.o: ../core/postmultiparser.h ../core/ticket.h templates.h +ls.o: ../core/postmultiparser.h ../core/config.h ../core/ticket.h +ls.o: ../core/db.h ../core/group.h ../core/dircontainer.h +ls.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +ls.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +ls.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +ls.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +ls.o: ../core/request.h +misc.o: ../core/misc.h ../core/item.h ../core/request.h templates.h misc.o: ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -misc.o: localefilter.h ../core/locale.h ../confparser/confparser.h +misc.o: localefilter.h ../core/locale.h ../core/confparser.h misc.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -misc.o: indexpatterns.h +misc.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +misc.o: ../core/requesttypes.h ../core/session.h ../core/error.h +misc.o: ../core/log.h ../core/user.h ../core/plugindata.h ../core/rebus.h +misc.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h +misc.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +misc.o: ../core/postmultiparser.h ../core/config.h ../core/ticket.h +misc.o: ../core/db.h ../core/group.h ../core/dircontainer.h +misc.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +misc.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +misc.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +misc.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h mount.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -mount.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +mount.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h mount.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -mount.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -mount.o: ../core/dircontainer.h ../core/users.h ../core/user.h -mount.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -mount.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -mount.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -mount.o: ../core/loadavg.h +mount.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +mount.o: ../core/requesttypes.h ../core/session.h ../core/item.h +mount.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +mount.o: ../core/rebus.h ../core/thread.h ../core/compress.h +mount.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +mount.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +mount.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +mount.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +mount.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +mount.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +mount.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h patterncacher.o: patterncacher.h ../core/item.h ../../ezc/src/ezc.h -patterncacher.o: ../core/data.h ../core/dirs.h ../core/item.h -patterncacher.o: ../core/dircontainer.h ../core/users.h ../core/user.h -patterncacher.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h -patterncacher.o: ../core/group.h ../core/functions.h ../core/function.h -patterncacher.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -patterncacher.o: ../core/error.h ../core/rebus.h ../core/loadavg.h patterncacher.o: ../core/log.h priv.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -priv.o: localefilter.h ../core/locale.h ../confparser/confparser.h +priv.o: localefilter.h ../core/locale.h ../core/confparser.h priv.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -priv.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -priv.o: ../core/dircontainer.h ../core/users.h ../core/user.h -priv.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -priv.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -priv.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -priv.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -priv.o: ../core/session.h ../core/plugindata.h ../core/thread.h -priv.o: ../core/compress.h ../core/acceptencodingparser.h -priv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -priv.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h +priv.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +priv.o: ../core/requesttypes.h ../core/session.h ../core/item.h +priv.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +priv.o: ../core/rebus.h ../core/thread.h ../core/compress.h +priv.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +priv.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +priv.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +priv.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +priv.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +priv.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +priv.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +priv.o: ../core/misc.h ../functions/functions.h ../functions/functionbase.h +priv.o: ../core/item.h ../core/notify.h ../templatesnotify/templatesnotify.h +priv.o: ../core/mount.h ../templates/misc.h ../functions/functionparser.h +priv.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +priv.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +priv.o: ../functions/createthread.h ../functions/createticket.h +priv.o: ../functions/default.h ../functions/download.h +priv.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +priv.o: ../functions/login.h ../functions/logout.h ../functions/ls.h +priv.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h +priv.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h +priv.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h +priv.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +priv.o: ../functions/upload.h ../functions/who.h +rebus.o: ../core/request.h templates.h ../../ezc/src/ezc.h patterncacher.h +rebus.o: ../core/item.h misc.h localefilter.h ../core/locale.h +rebus.o: ../core/confparser.h ckeditorgetparser.h ../core/httpsimpleparser.h +rebus.o: ../core/log.h indexpatterns.h ../core/locale.h ../core/config.h rebus.o: ../core/request.h ../core/requesttypes.h ../core/session.h rebus.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h -rebus.o: ../core/rebus.h ../core/plugindata.h ../core/function.h -rebus.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h +rebus.o: ../core/plugindata.h ../core/rebus.h ../core/thread.h +rebus.o: ../core/compress.h ../core/acceptencodingparser.h rebus.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -rebus.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h -rebus.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h -rebus.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h -rebus.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -rebus.o: ../core/mount.h ../core/loadavg.h templates.h ../../ezc/src/ezc.h -rebus.o: patterncacher.h ../core/item.h misc.h localefilter.h -rebus.o: ../core/locale.h ../confparser/confparser.h ckeditorgetparser.h -rebus.o: ../core/httpsimpleparser.h ../core/log.h indexpatterns.h +rebus.o: ../core/postmultiparser.h ../core/config.h ../core/ticket.h +rebus.o: ../core/db.h ../core/group.h ../core/dircontainer.h +rebus.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +rebus.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +rebus.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +rebus.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h sys.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -sys.o: localefilter.h ../core/locale.h ../confparser/confparser.h +sys.o: localefilter.h ../core/locale.h ../core/confparser.h sys.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -sys.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -sys.o: ../core/dircontainer.h ../core/users.h ../core/user.h -sys.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -sys.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -sys.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -sys.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -sys.o: ../core/session.h ../core/plugindata.h ../core/thread.h -sys.o: ../core/compress.h ../core/acceptencodingparser.h -sys.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -sys.o: ../core/postmultiparser.h ../core/ticket.h ../core/version.h +sys.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +sys.o: ../core/requesttypes.h ../core/session.h ../core/item.h +sys.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +sys.o: ../core/rebus.h ../core/thread.h ../core/compress.h +sys.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +sys.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +sys.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +sys.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +sys.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +sys.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +sys.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +sys.o: ../core/request.h ../core/version.h templates.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -templates.o: misc.h localefilter.h ../core/locale.h -templates.o: ../confparser/confparser.h ckeditorgetparser.h -templates.o: ../core/httpsimpleparser.h ../core/log.h indexpatterns.h -templates.o: ../core/data.h ../core/dirs.h ../core/item.h -templates.o: ../core/dircontainer.h ../core/users.h ../core/user.h -templates.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h -templates.o: ../core/group.h ../core/functions.h ../core/function.h -templates.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -templates.o: ../core/error.h ../core/rebus.h ../core/loadavg.h +templates.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h +templates.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h +templates.o: indexpatterns.h ../core/locale.h ../core/config.h templates.o: ../core/request.h ../core/requesttypes.h ../core/session.h -templates.o: ../core/plugindata.h ../core/thread.h ../core/compress.h -templates.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -templates.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h -templates.o: ../core/misc.h ../core/plugin.h ../core/request.h ../core/data.h -templates.o: ../core/pluginmsg.h +templates.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h +templates.o: ../core/plugindata.h ../core/rebus.h ../core/thread.h +templates.o: ../core/compress.h ../core/acceptencodingparser.h +templates.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +templates.o: ../core/postmultiparser.h ../core/config.h ../core/ticket.h +templates.o: ../core/db.h ../core/group.h ../core/dircontainer.h +templates.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h +templates.o: ../core/db.h ../core/request.h ../core/mounts.h ../core/mount.h +templates.o: ../core/users.h ../core/lastcontainer.h ../core/groups.h +templates.o: ../core/loadavg.h ../core/sessionmanager.h +templates.o: ../core/sessioncontainer.h ../core/system.h ../core/misc.h +templates.o: ../core/plugin.h ../core/pluginmsg.h ../core/sessionmanager.h +templates.o: ../functions/functions.h ../functions/functionbase.h +templates.o: ../core/item.h ../core/notify.h +templates.o: ../templatesnotify/templatesnotify.h ../core/mount.h +templates.o: ../templates/misc.h ../functions/functionparser.h +templates.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +templates.o: ../functions/privchanger.h ../functions/chown.h +templates.o: ../functions/cp.h ../functions/createthread.h +templates.o: ../functions/createticket.h ../functions/default.h +templates.o: ../functions/download.h ../functions/editticket.h +templates.o: ../functions/emacs.h ../functions/last.h ../functions/login.h +templates.o: ../functions/logout.h ../functions/ls.h ../functions/mkdir.h +templates.o: ../functions/mv.h ../functions/node.h ../functions/priv.h +templates.o: ../functions/reload.h ../functions/rm.h ../functions/run.h +templates.o: ../functions/subject.h ../functions/funthread.h ../core/thread.h +templates.o: ../functions/funticket.h ../functions/uname.h +templates.o: ../functions/upload.h ../functions/who.h +templates.o: ../templates/templates.h thread.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -thread.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +thread.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h thread.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -thread.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -thread.o: ../core/dircontainer.h ../core/users.h ../core/user.h -thread.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h -thread.o: ../core/group.h ../core/functions.h ../core/function.h -thread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -thread.o: ../core/error.h ../core/rebus.h ../core/loadavg.h ../core/request.h -thread.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h -thread.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h -thread.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -thread.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h +thread.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +thread.o: ../core/requesttypes.h ../core/session.h ../core/item.h +thread.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +thread.o: ../core/rebus.h ../core/thread.h ../core/compress.h +thread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +thread.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +thread.o: ../core/ticket.h ../core/db.h ../core/group.h +thread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/system.h +thread.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +thread.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +thread.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h +thread.o: ../core/sessioncontainer.h ../core/system.h ../core/request.h +thread.o: ../core/misc.h ticket.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -ticket.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +ticket.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h ticket.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -ticket.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -ticket.o: ../core/dircontainer.h ../core/users.h ../core/user.h -ticket.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h -ticket.o: ../core/group.h ../core/functions.h ../core/function.h -ticket.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -ticket.o: ../core/error.h ../core/rebus.h ../core/loadavg.h ../core/request.h -ticket.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h -ticket.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h -ticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -ticket.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h +ticket.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +ticket.o: ../core/requesttypes.h ../core/session.h ../core/item.h +ticket.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +ticket.o: ../core/rebus.h ../core/thread.h ../core/compress.h +ticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +ticket.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +ticket.o: ../core/ticket.h ../core/db.h ../core/group.h +ticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/system.h +ticket.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +ticket.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +ticket.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h +ticket.o: ../core/sessioncontainer.h ../core/system.h ../core/misc.h +ticket.o: ../functions/functions.h ../functions/functionbase.h ../core/item.h +ticket.o: ../core/notify.h ../templatesnotify/templatesnotify.h +ticket.o: ../core/mount.h ../templates/misc.h ../functions/functionparser.h +ticket.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +ticket.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +ticket.o: ../functions/createthread.h ../functions/createticket.h +ticket.o: ../functions/default.h ../functions/download.h +ticket.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +ticket.o: ../functions/login.h ../functions/logout.h ../functions/ls.h +ticket.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h +ticket.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h +ticket.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h +ticket.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +ticket.o: ../functions/upload.h ../functions/who.h upload.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -upload.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +upload.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h upload.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -upload.o: indexpatterns.h ../core/request.h ../core/requesttypes.h -upload.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h -upload.o: ../core/user.h ../core/rebus.h ../core/plugindata.h -upload.o: ../core/function.h ../core/thread.h ../core/compress.h +upload.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +upload.o: ../core/requesttypes.h ../core/session.h ../core/item.h +upload.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +upload.o: ../core/rebus.h ../core/thread.h ../core/compress.h upload.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -upload.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h +upload.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +upload.o: ../core/ticket.h ../core/db.h ../core/group.h +upload.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/system.h +upload.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +upload.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +upload.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h +upload.o: ../core/sessioncontainer.h ../core/system.h ../core/request.h uptime.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -uptime.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +uptime.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h uptime.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -uptime.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -uptime.o: ../core/dircontainer.h ../core/users.h ../core/user.h -uptime.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h -uptime.o: ../core/group.h ../core/functions.h ../core/function.h -uptime.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -uptime.o: ../core/error.h ../core/rebus.h ../core/loadavg.h +uptime.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +uptime.o: ../core/requesttypes.h ../core/session.h ../core/item.h +uptime.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +uptime.o: ../core/rebus.h ../core/thread.h ../core/compress.h +uptime.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +uptime.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +uptime.o: ../core/ticket.h ../core/db.h ../core/group.h +uptime.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/system.h +uptime.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +uptime.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +uptime.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h +uptime.o: ../core/sessioncontainer.h ../core/system.h user.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -user.o: localefilter.h ../core/locale.h ../confparser/confparser.h +user.o: localefilter.h ../core/locale.h ../core/confparser.h user.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -user.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -user.o: ../core/dircontainer.h ../core/users.h ../core/user.h -user.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -user.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -user.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -user.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -user.o: ../core/session.h ../core/plugindata.h ../core/thread.h -user.o: ../core/compress.h ../core/acceptencodingparser.h -user.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -user.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h +user.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +user.o: ../core/requesttypes.h ../core/session.h ../core/item.h +user.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +user.o: ../core/rebus.h ../core/thread.h ../core/compress.h +user.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +user.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +user.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +user.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +user.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +user.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +user.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +user.o: ../core/request.h ../core/misc.h who.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h -who.o: localefilter.h ../core/locale.h ../confparser/confparser.h +who.o: localefilter.h ../core/locale.h ../core/confparser.h who.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -who.o: indexpatterns.h ../core/sessioncontainer.h ../core/session.h -who.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h -who.o: ../core/rebus.h ../core/plugindata.h ../core/requestcontroller.h -who.o: ../content/content.h ../templates/templates.h ../core/thread.h -who.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/thread.h -who.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h -who.o: ../core/sessionmanager.h ../core/sessioncontainer.h -who.o: ../core/functionparser.h ../core/requesttypes.h ../core/data.h -who.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h -who.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -who.o: ../core/mount.h ../core/loadavg.h ../core/request.h ../core/compress.h +who.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +who.o: ../core/requesttypes.h ../core/session.h ../core/item.h +who.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +who.o: ../core/rebus.h ../core/thread.h ../core/compress.h who.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -who.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/misc.h +who.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +who.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +who.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +who.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +who.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +who.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +who.o: ../core/misc.h winix.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h -winix.o: misc.h localefilter.h ../core/locale.h ../confparser/confparser.h +winix.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h winix.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h -winix.o: indexpatterns.h ../core/data.h ../core/dirs.h ../core/item.h -winix.o: ../core/dircontainer.h ../core/users.h ../core/user.h -winix.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h -winix.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -winix.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -winix.o: ../core/loadavg.h ../core/request.h ../core/requesttypes.h -winix.o: ../core/session.h ../core/plugindata.h ../core/thread.h -winix.o: ../core/compress.h ../core/acceptencodingparser.h -winix.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -winix.o: ../core/postmultiparser.h ../core/ticket.h +winix.o: indexpatterns.h ../core/locale.h ../core/config.h ../core/request.h +winix.o: ../core/requesttypes.h ../core/session.h ../core/item.h +winix.o: ../core/error.h ../core/log.h ../core/user.h ../core/plugindata.h +winix.o: ../core/rebus.h ../core/thread.h ../core/compress.h +winix.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +winix.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/config.h +winix.o: ../core/ticket.h ../core/db.h ../core/group.h ../core/dircontainer.h +winix.o: ../core/ugcontainer.h ../core/system.h ../core/dirs.h ../core/db.h +winix.o: ../core/request.h ../core/mounts.h ../core/mount.h ../core/users.h +winix.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +winix.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +winix.o: ../functions/functions.h ../functions/functionbase.h ../core/item.h +winix.o: ../core/notify.h ../templatesnotify/templatesnotify.h +winix.o: ../core/mount.h ../templates/misc.h ../functions/functionparser.h +winix.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h +winix.o: ../functions/privchanger.h ../functions/chown.h ../functions/cp.h +winix.o: ../functions/createthread.h ../functions/createticket.h +winix.o: ../functions/default.h ../functions/download.h +winix.o: ../functions/editticket.h ../functions/emacs.h ../functions/last.h +winix.o: ../functions/login.h ../functions/logout.h ../functions/ls.h +winix.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h +winix.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h +winix.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h +winix.o: ../core/thread.h ../functions/funticket.h ../functions/uname.h +winix.o: ../functions/upload.h ../functions/who.h diff --git a/templates/adduser.cpp b/templates/adduser.cpp index 787c1c2..69d33f6 100755 --- a/templates/adduser.cpp +++ b/templates/adduser.cpp @@ -9,7 +9,7 @@ #include <ctime> #include "templates.h" -#include "../core/request.h" +#include "core/request.h" namespace TemplatesFunctions @@ -17,7 +17,7 @@ namespace TemplatesFunctions void adduser_last_login(Info & i) { - std::string * last_login = request.PostVar("login"); + std::string * last_login = request->PostVar("login"); if( last_login ) i.out << *last_login; @@ -26,7 +26,7 @@ void adduser_last_login(Info & i) void adduser_last_email(Info & i) { - std::string * last_email = request.PostVar("email"); + std::string * last_email = request->PostVar("email"); if( last_email ) i.out << *last_email; diff --git a/templates/dir.cpp b/templates/dir.cpp index c508783..2fdbf72 100755 --- a/templates/dir.cpp +++ b/templates/dir.cpp @@ -8,12 +8,8 @@ */ #include "templates.h" -#include "../core/request.h" -#include "../core/data.h" -#include "../core/db.h" -#include "../core/log.h" -#include "../core/misc.h" - +#include "core/misc.h" +#include "functions/functions.h" namespace TemplatesFunctions @@ -23,9 +19,9 @@ namespace TemplatesFunctions void dir(Info & i) { - for(size_t a=0 ; a<request.dir_table.size() ; ++a) + for(size_t a=0 ; a<request->dir_table.size() ; ++a) { - HtmlEscape(i.out, request.dir_table[a]->url); + HtmlEscape(i.out, request->dir_table[a]->url); i.out << '/'; } } @@ -33,11 +29,11 @@ void dir(Info & i) void dir_without_slash(Info & i) { - for(size_t a=0 ; a<request.dir_table.size() ; ++a) + for(size_t a=0 ; a<request->dir_table.size() ; ++a) { - HtmlEscape(i.out, request.dir_table[a]->url); + HtmlEscape(i.out, request->dir_table[a]->url); - if( a < request.dir_table.size()-1 ) + if( a < request->dir_table.size()-1 ) i.out << '/'; } } @@ -45,12 +41,12 @@ void dir_without_slash(Info & i) void dir_parent(Info & i) { - if( request.dir_table.empty() ) + if( request->dir_table.empty() ) return; - for(size_t a=0 ; a<request.dir_table.size()-1 ; ++a) + for(size_t a=0 ; a<request->dir_table.size()-1 ; ++a) { - HtmlEscape(i.out, request.dir_table[a]->url); + HtmlEscape(i.out, request->dir_table[a]->url); i.out << '/'; } } @@ -58,14 +54,14 @@ void dir_parent(Info & i) void dir_parent_without_slash(Info & i) { - if( request.dir_table.empty() ) + if( request->dir_table.empty() ) return; - for(size_t a=0 ; a<request.dir_table.size()-1 ; ++a) + for(size_t a=0 ; a<request->dir_table.size()-1 ; ++a) { - HtmlEscape(i.out, request.dir_table[a]->url); + HtmlEscape(i.out, request->dir_table[a]->url); - if( request.dir_table.size()>=2 && a<request.dir_table.size()-2 ) + if( request->dir_table.size()>=2 && a<request->dir_table.size()-2 ) i.out << '/'; } } @@ -77,9 +73,9 @@ void dir_can_read_exec(Info & i) { bool result = true; - for(size_t a=0 ; a<request.dir_table.size() ; ++a) + for(size_t a=0 ; a<request->dir_table.size() ; ++a) { - if( !request.HasReadExecAccess(*request.dir_table[a]) ) + if( !system->HasReadExecAccess(*request->dir_table[a]) ) { result = false; break; @@ -92,7 +88,7 @@ bool result = true; void dir_can_write(Info & i) { - i.res = request.HasWriteAccess(*request.dir_table.back()); + i.res = system->HasWriteAccess(*request->dir_table.back()); } @@ -101,18 +97,18 @@ void dir_can_remove(Info & i) bool result = true; - if( request.dir_table.size() == 1 ) + if( request->dir_table.size() == 1 ) { // rm for the root dir // only the superuser can do it - if( !request.session->puser || !request.session->puser->super_user ) + if( !request->session->puser || !request->session->puser->super_user ) result = false; } else { - Item * last_but_one_dir = *(--(--request.dir_table.end())); + Item * last_but_one_dir = *(--(--request->dir_table.end())); - if( !request.HasWriteAccess(*last_but_one_dir) ) + if( !system->HasWriteAccess(*last_but_one_dir) ) result = false; } @@ -122,26 +118,20 @@ bool result = true; void dir_can_use_emacs(Info & i) { - if( !request.dir_table.empty() ) - i.res = request.CanUseEmacs(*request.dir_table.back(), true); - else - i.res = false; + i.res = functions->fun_emacs.HasAccess(); } void dir_can_use_mkdir(Info & i) { - if( !request.dir_table.empty() ) - i.res = request.CanUseMkdir(*request.dir_table.back(), true); - else - i.res = false; + i.res = functions->fun_mkdir.HasAccess(); } static std::vector<Item*> dir_childs_table; static size_t dir_childs_index; -// request.id is never 0 and we can start dir_childs_reqid from 0 +// request->id is never 0 and we can start dir_childs_reqid from 0 static size_t dir_childs_reqid = 0; // is the first directory the parent ('..') @@ -150,22 +140,22 @@ static bool dir_childs_has_parent; void dir_childs_tab(Info & i) { - if( dir_childs_reqid != request.id ) + if( dir_childs_reqid != request->id ) { - dir_childs_reqid = request.id; + dir_childs_reqid = request->id; dir_childs_table.clear(); dir_childs_has_parent = false; - if( !request.dir_table.empty() ) + if( !request->dir_table.empty() ) { - if( request.dir_table.size() >= 2 && i.par == "with_parent") + if( request->dir_table.size() >= 2 && i.par == "with_parent") { - Item * dir_up = request.dir_table[request.dir_table.size()-2]; + Item * dir_up = request->dir_table[request->dir_table.size()-2]; dir_childs_table.push_back(dir_up); dir_childs_has_parent = true; } - data.dirs.GetDirChilds(request.dir_table.back()->id, dir_childs_table); + system->dirs.GetDirChilds(request->dir_table.back()->id, dir_childs_table); } } @@ -201,7 +191,7 @@ void dir_childs_tab_user(Info & i) if( dir_childs_index < dir_childs_table.size() ) { long user_id = dir_childs_table[dir_childs_index]->user_id; - User * puser = data.users.GetUser(user_id); + User * puser = system->users.GetUser(user_id); if( puser ) HtmlEscape(i.out, puser->name); @@ -224,7 +214,7 @@ void dir_childs_tab_group(Info & i) if( dir_childs_index < dir_childs_table.size() ) { long group_id = dir_childs_table[dir_childs_index]->group_id; - Group * pgroup = data.groups.GetGroup(group_id); + Group * pgroup = system->groups.GetGroup(group_id); if( pgroup ) HtmlEscape(i.out, pgroup->name); @@ -244,24 +234,24 @@ static size_t dir_index; void dir_tab(Info & i) { dir_index = i.iter; - i.res = dir_index < request.dir_table.size(); + i.res = dir_index < request->dir_table.size(); } void dir_tab_url(Info & i) { - if( dir_index < request.dir_table.size() ) - HtmlEscape(i.out, request.dir_table[dir_index]->url); + if( dir_index < request->dir_table.size() ) + HtmlEscape(i.out, request->dir_table[dir_index]->url); } void dir_tab_link(Info & i) { - i.out << data.base_url; + i.out << config->base_url; - for(size_t a = 0 ; a <= dir_index && a < request.dir_table.size() ; ++a) + for(size_t a = 0 ; a <= dir_index && a < request->dir_table.size() ; ++a) { - HtmlEscape(i.out, request.dir_table[a]->url); + HtmlEscape(i.out, request->dir_table[a]->url); i.out << '/'; } } @@ -274,23 +264,23 @@ static size_t dir_last_default_item_reqid = 0; void dir_last_default_item_init() { - if( dir_last_default_item_reqid == request.id ) + if( dir_last_default_item_reqid == request->id ) return; - dir_last_default_item_reqid = request.id; + dir_last_default_item_reqid = request->id; dir_last_default_item.Clear(); - if( request.dir_table.empty() ) + if( request->dir_table.empty() ) return; - long default_item = request.dir_table.back()->default_item; + long default_item = request->dir_table.back()->default_item; if( default_item == -1 ) return; std::vector<Item> item_table; // !! tymczasowo, nie bedzie tego po zmianie interfejsu dla Db - db.GetItem(item_table, default_item); + db->GetItem(item_table, default_item); if( item_table.empty() ) return; @@ -307,7 +297,7 @@ void dir_last_default_item_dir(Info & i) std::string path; if( dir_last_default_item.parent_id != -1 ) - if( data.dirs.MakePath(dir_last_default_item.parent_id, path) ) + if( system->dirs.MakePath(dir_last_default_item.parent_id, path) ) HtmlEscape(i.out, path); } @@ -322,7 +312,7 @@ void dir_last_default_item_url(Info & i) void dir_last_subject(Info & i) { - HtmlEscape(i.out, request.dir_table.back()->subject); + HtmlEscape(i.out, request->dir_table.back()->subject); } @@ -331,14 +321,14 @@ void dir_last_info(Info & i) if( static_cast<size_t>(locale.GetLang()) >= patterns.size() ) return; - Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_dir_last_info], functions); + Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_dir_last_info], ezc_functions); gen.Generate(); } void dir_last_user(Info & i) { - User * puser = data.users.GetUser(request.dir_table.back()->user_id); + User * puser = system->users.GetUser(request->dir_table.back()->user_id); if( puser ) HtmlEscape(i.out, puser->name); @@ -346,8 +336,8 @@ void dir_last_user(Info & i) { i.out << "~"; - if( !request.dir_table.back()->guest_name.empty() ) - HtmlEscape(i.out, request.dir_table.back()->guest_name); + if( !request->dir_table.back()->guest_name.empty() ) + HtmlEscape(i.out, request->dir_table.back()->guest_name); else i.out << "guest"; // !! dodac do konfiga } @@ -356,19 +346,19 @@ void dir_last_user(Info & i) void dir_last_url(Info & i) { - HtmlEscape(i.out, request.dir_table.back()->url); + HtmlEscape(i.out, request->dir_table.back()->url); } void dir_last_url_is(Info & i) { - i.res = request.dir_table.back()->url == i.par; + i.res = request->dir_table.back()->url == i.par; } void dir_last_date_creation(Info & i) { - tm * ptm = &request.dir_table.back()->date_creation; + tm * ptm = &request->dir_table.back()->date_creation; i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); } @@ -376,7 +366,7 @@ void dir_last_date_creation(Info & i) void dir_last_date_modification(Info & i) { - tm * ptm = &request.dir_table.back()->date_modification; + tm * ptm = &request->dir_table.back()->date_modification; i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); } @@ -384,8 +374,8 @@ void dir_last_date_modification(Info & i) void dir_last_dates_equal(Info & i) { - tm * ptm1 = &request.dir_table.back()->date_creation; - tm * ptm2 = &request.dir_table.back()->date_modification; + tm * ptm1 = &request->dir_table.back()->date_creation; + tm * ptm2 = &request->dir_table.back()->date_modification; i.res = ptm1->tm_year == ptm2->tm_year && ptm1->tm_mon == ptm2->tm_mon && diff --git a/templates/doc.cpp b/templates/doc.cpp index 76f37a6..d483217 100755 --- a/templates/doc.cpp +++ b/templates/doc.cpp @@ -8,7 +8,6 @@ */ #include "templates.h" -#include "../core/data.h" #include "../core/request.h" #include "../core/misc.h" @@ -28,21 +27,21 @@ void doc_title(Info & i) bool was_dir = false; // from 1 means skipping the root directory - for(a = 1 ; a<request.dir_table.size() ; ++a) + for(a = 1 ; a<request->dir_table.size() ; ++a) { - HtmlEscape(i.out, request.dir_table[a]->subject); + HtmlEscape(i.out, request->dir_table[a]->subject); was_dir = true; - if( a < request.dir_table.size()-1 ) - i.out << data.title_separator; + if( a < request->dir_table.size()-1 ) + i.out << config->title_separator; } - if( request.is_item ) + if( request->is_item ) { if( was_dir ) - i.out << data.title_separator; + i.out << config->title_separator; - HtmlEscape(i.out, request.item.subject); + HtmlEscape(i.out, request->item.subject); } } @@ -53,32 +52,32 @@ void doc_title(Info & i) void doc_base_url(Info & i) { - i.out << data.base_url; + i.out << config->base_url; } void doc_base_url_auth(Info & i) { - i.out << data.base_url_auth; + i.out << config->base_url_auth; } void doc_base_url_static(Info & i) { - i.out << data.base_url_static; + i.out << config->base_url_static; } void doc_base_url_common(Info & i) { - i.out << data.base_url_common; + i.out << config->base_url_common; } void doc_current_url(Info & i) { - i.out << request.env_request_uri; + i.out << request->env_request_uri; } diff --git a/templates/indexpatterns.cpp b/templates/indexpatterns.cpp index f0ca0f0..c64478f 100755 --- a/templates/indexpatterns.cpp +++ b/templates/indexpatterns.cpp @@ -8,11 +8,15 @@ */ #include "indexpatterns.h" -#include "../core/log.h" -#include "../core/data.h" +#include "core/log.h" +void IndexPatterns::SetConfig(Config * pconfig) +{ + config = pconfig; +} + Ezc::Pattern * IndexPatterns::GetPattern(const std::string & file, Locale::Lang lang) { @@ -75,7 +79,7 @@ void IndexPatterns::ReadPattern(Tab::iterator & iter, Locale & locale, LocaleFil for(i=0 ; i<len ; ++i) { templ.patterns[i].DeleteWhiteTextItems(delete_white); - templ.patterns[i].Directory(data.templates_dir, data.templates_dir_default); + templ.patterns[i].Directory(config->templates_dir, config->templates_dir_default); templ.patterns[i].ParseFile(iter->first); locale_filter.Filter(templ.patterns[i], locale, static_cast<Locale::Lang>(i)); diff --git a/templates/indexpatterns.h b/templates/indexpatterns.h index b94cd8f..055736b 100755 --- a/templates/indexpatterns.h +++ b/templates/indexpatterns.h @@ -14,8 +14,9 @@ #include <vector> #include <map> #include "ezc.h" -#include "../core/locale.h" #include "localefilter.h" +#include "core/locale.h" +#include "core/config.h" @@ -23,6 +24,8 @@ class IndexPatterns { public: + void SetConfig(Config * pconfig); + // can return null pointer if there is not such a pattern Ezc::Pattern * GetPattern(const std::string & file, Locale::Lang lang); void AddPattern(const std::string & file, Locale & locale, LocaleFilter & locale_filter, bool delete_white); @@ -38,6 +41,7 @@ public: private: + Config * config; struct Template { diff --git a/templates/item.cpp b/templates/item.cpp index c667eca..617ef7c 100755 --- a/templates/item.cpp +++ b/templates/item.cpp @@ -9,7 +9,6 @@ #include "templates.h" #include "misc.h" -#include "../core/data.h" #include "../core/request.h" #include "../core/misc.h" #include "../core/bbcodeparser.h" @@ -45,41 +44,41 @@ void print_user_name(Info & i, const User * puser, const std::string & guest_nam void item_is(Info & i) { - i.res = request.is_item; + i.res = request->is_item; } void item_id(Info & i) { - i.out << request.item.id; + i.out << request->item.id; } void item_subject(Info & i) { - HtmlEscape(i.out, request.item.subject); + HtmlEscape(i.out, request->item.subject); } void item_subject_noescape(Info & i) { - i.out << request.item.subject; + i.out << request->item.subject; } void item_content(Info & i) { - HtmlEscape(i.out, request.item.content); + HtmlEscape(i.out, request->item.content); } void item_content_noescape(Info & i) { - i.out << request.item.content; + i.out << request->item.content; } @@ -87,19 +86,19 @@ void item_content_type_is(Info & i) { i.res = false; - if( request.item.content_type == Item::ct_text && i.par == "text" ) + if( request->item.content_type == Item::ct_text && i.par == "text" ) i.res = true; - if( request.item.content_type == Item::ct_formatted_text && i.par == "formatted text" ) + if( request->item.content_type == Item::ct_formatted_text && i.par == "formatted text" ) i.res = true; - if( request.item.content_type == Item::ct_html && i.par == "html" ) + if( request->item.content_type == Item::ct_html && i.par == "html" ) i.res = true; - if( request.item.content_type == Item::ct_bbcode && i.par == "bbcode" ) + if( request->item.content_type == Item::ct_bbcode && i.par == "bbcode" ) i.res = true; - if( request.item.content_type == Item::ct_raw && i.par == "raw" ) + if( request->item.content_type == Item::ct_raw && i.par == "raw" ) i.res = true; } @@ -136,19 +135,19 @@ void item_print_content(std::ostringstream & out, const std::string & content, I void item_content_is_empty(Info & i) { - i.res = request.item.content.empty(); + i.res = request->item.content.empty(); } void item_print_content(Info & i) { - item_print_content(i.out, request.item.content, request.item.content_type); + item_print_content(i.out, request->item.content, request->item.content_type); } void item_privileges(Info & i) { - i.out << std::setbase(8) << request.item.privileges << std::setbase(10); + i.out << std::setbase(8) << request->item.privileges << std::setbase(10); } @@ -160,22 +159,22 @@ void item_dir(Info & i) void item_url(Info & i) { - HtmlEscape(i.out, request.item.url); + HtmlEscape(i.out, request->item.url); } void item_url_is(Info & i) { - if( !request.is_item ) + if( !request->is_item ) return; // default false - i.res = (request.item.url == i.par); + i.res = (request->item.url == i.par); } void item_link(Info & i) { - HtmlEscape(i.out, data.base_url); + HtmlEscape(i.out, config->base_url); item_dir(i); item_url(i); } @@ -185,31 +184,33 @@ void item_link(Info & i) void item_auth_is_none(Info & i) { - i.res = request.item.auth == Item::auth_none; + i.res = request->item.auth == Item::auth_none; } void item_auth_is_image(Info & i) { - i.res = request.item.auth == Item::auth_image; + i.res = request->item.auth == Item::auth_image; } void item_can_read(Info & i) { - i.res = request.HasReadAccess(request.item); + i.res = system->HasReadAccess(request->item); } void item_can_write(Info & i) { - i.res = request.HasWriteAccess(request.item); + i.res = system->HasWriteAccess(request->item); } void item_can_remove(Info & i) { - i.res = request.CanRemove(request.item); + // !! tutaj trzeba bedzie cos innego zrobic + // zwlaszcza jak dojdzie sticky bit + i.res = system->HasWriteAccess(*request->dir_table.back()); } @@ -218,35 +219,35 @@ void item_info(Info & i) if( static_cast<size_t>(locale.GetLang()) >= patterns.size() ) return; - Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_item_info], functions); + Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_item_info], ezc_functions); gen.Generate(); } void item_user(Info & i) { - User * puser = data.users.GetUser(request.item.user_id); - print_user_name(i, puser, request.item.guest_name); + User * puser = system->users.GetUser(request->item.user_id); + print_user_name(i, puser, request->item.guest_name); } void item_modification_user(Info & i) { - User * puser = data.users.GetUser(request.item.modification_user_id); - print_user_name(i, puser, request.item.guest_name); + User * puser = system->users.GetUser(request->item.modification_user_id); + print_user_name(i, puser, request->item.guest_name); } void item_users_different(Info & i) { - i.res = (request.item.user_id != request.item.modification_user_id); + i.res = (request->item.user_id != request->item.modification_user_id); } void item_date_creation(Info & i) { - tm * ptm = &request.item.date_creation; + tm * ptm = &request->item.date_creation; i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); } @@ -254,7 +255,7 @@ void item_date_creation(Info & i) void item_date_modification(Info & i) { - tm * ptm = &request.item.date_modification; + tm * ptm = &request->item.date_modification; i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); } @@ -262,22 +263,22 @@ void item_date_modification(Info & i) void item_date_creation_nice(Info & i) { - tm * ptm = &request.item.date_creation; + tm * ptm = &request->item.date_creation; print_date_nice(i, ptm); } void item_date_modification_nice(Info & i) { - tm * ptm = &request.item.date_modification; + tm * ptm = &request->item.date_modification; print_date_nice(i, ptm); } void item_dates_equal(Info & i) { - tm * ptm1 = &request.item.date_creation; - tm * ptm2 = &request.item.date_modification; + tm * ptm1 = &request->item.date_creation; + tm * ptm2 = &request->item.date_modification; i.res = ptm1->tm_year == ptm2->tm_year && ptm1->tm_mon == ptm2->tm_mon && @@ -291,31 +292,31 @@ void item_dates_equal(Info & i) void item_run(Info & i) { - if( !request.is_item ) + if( !request->is_item ) { i.out << "<!-- there is no an item to run -->"; return; } - if( !request.HasReadExecAccess(request.item) ) + if( !system->HasReadExecAccess(request->item) ) { i.out << "<!-- run: permission denied -->"; return; } - Ezc::Pattern * p = pattern_cacher.GetPattern(request.item); + Ezc::Pattern * p = pattern_cacher.GetPattern(request->item); std::ostringstream item_run_content; - Ezc::Generator gen(item_run_content, *p, functions); + Ezc::Generator gen(item_run_content, *p, ezc_functions); gen.Generate(); - item_print_content(i.out, item_run_content.str(), request.item.content_type); + item_print_content(i.out, item_run_content.str(), request->item.content_type); } void item_guest_name(Info & i) { - HtmlEscape(i.out, request.item.guest_name); + HtmlEscape(i.out, request->item.guest_name); } @@ -330,51 +331,51 @@ static size_t item_index; void item_tab(Info & i) { item_index = i.iter; - i.res = item_index < request.item_table.size(); + i.res = item_index < request->item_table.size(); } void item_tab_id(Info & i) { - if( item_index < request.item_table.size() ) - i.out << request.item_table[item_index].id; + if( item_index < request->item_table.size() ) + i.out << request->item_table[item_index].id; } void item_tab_subject(Info & i) { - if( item_index < request.item_table.size() ) - HtmlEscape(i.out, request.item_table[item_index].subject); + if( item_index < request->item_table.size() ) + HtmlEscape(i.out, request->item_table[item_index].subject); } void item_tab_subject_noescape(Info & i) { - if( item_index < request.item_table.size() ) - i.out << request.item_table[item_index].subject; + if( item_index < request->item_table.size() ) + i.out << request->item_table[item_index].subject; } void item_tab_content(Info & i) { - if( item_index < request.item_table.size() ) - HtmlEscape(i.out, request.item_table[item_index].content); + if( item_index < request->item_table.size() ) + HtmlEscape(i.out, request->item_table[item_index].content); } void item_tab_content_noescape(Info & i) { - if( item_index < request.item_table.size() ) - i.out << request.item_table[item_index].content; + if( item_index < request->item_table.size() ) + i.out << request->item_table[item_index].content; } void item_tab_print_content(Info & i) { - if( item_index >= request.item_table.size() ) + if( item_index >= request->item_table.size() ) return; - std::string & content = request.item_table[item_index].content; - Item::ContentType type = request.item_table[item_index].content_type; + std::string & content = request->item_table[item_index].content; + Item::ContentType type = request->item_table[item_index].content_type; item_print_content(i.out, content, type); } @@ -382,19 +383,19 @@ void item_tab_print_content(Info & i) void item_tab_privileges(Info & i) { - if( item_index < request.item_table.size() ) - i.out << "0" << std::setbase(8) << request.item_table[item_index].privileges << std::setbase(10); + if( item_index < request->item_table.size() ) + i.out << "0" << std::setbase(8) << request->item_table[item_index].privileges << std::setbase(10); } void item_tab_dir(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { std::string path; - if( data.dirs.MakePath(request.item_table[item_index].parent_id, path) ) + if( system->dirs.MakePath(request->item_table[item_index].parent_id, path) ) HtmlEscape(i.out, path); else i.out << "/the path does not exist/"; @@ -404,16 +405,16 @@ void item_tab_dir(Info & i) void item_tab_url(Info & i) { - if( item_index < request.item_table.size() ) - HtmlEscape(i.out, request.item_table[item_index].url); + if( item_index < request->item_table.size() ) + HtmlEscape(i.out, request->item_table[item_index].url); } void item_tab_link(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - HtmlEscape(i.out, data.base_url); + HtmlEscape(i.out, config->base_url); item_tab_dir(i); item_tab_url(i); } @@ -422,9 +423,9 @@ void item_tab_link(Info & i) void item_tab_link_auth(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - HtmlEscape(i.out, data.base_url_auth); + HtmlEscape(i.out, config->base_url_auth); item_tab_dir(i); item_tab_url(i); } @@ -433,9 +434,9 @@ void item_tab_link_auth(Info & i) void item_tab_can_read(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - if( request.HasReadAccess(request.item_table[item_index]) ) + if( system->HasReadAccess(request->item_table[item_index]) ) i.res = true; } } @@ -443,9 +444,9 @@ void item_tab_can_read(Info & i) void item_tab_can_write(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - if( request.HasWriteAccess(request.item_table[item_index]) ) + if( system->HasWriteAccess(request->item_table[item_index]) ) i.res = true; } } @@ -456,17 +457,17 @@ void item_tab_info(Info & i) if( static_cast<size_t>(locale.GetLang()) >= patterns.size() ) return; - Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_item_tab_info], functions); + Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_item_tab_info], ezc_functions); gen.Generate(); } void item_tab_user(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - User * puser = data.users.GetUser(request.item_table[item_index].user_id); - print_user_name(i, puser, request.item_table[item_index].guest_name); + User * puser = system->users.GetUser(request->item_table[item_index].user_id); + print_user_name(i, puser, request->item_table[item_index].guest_name); } } @@ -474,10 +475,10 @@ void item_tab_user(Info & i) void item_tab_modification_user(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - User * puser = data.users.GetUser(request.item_table[item_index].modification_user_id); - print_user_name(i, puser, request.item_table[item_index].guest_name); + User * puser = system->users.GetUser(request->item_table[item_index].modification_user_id); + print_user_name(i, puser, request->item_table[item_index].guest_name); } } @@ -485,9 +486,9 @@ void item_tab_modification_user(Info & i) void item_tab_users_different(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - i.res = (request.item_table[item_index].user_id != request.item_table[item_index].modification_user_id); + i.res = (request->item_table[item_index].user_id != request->item_table[item_index].modification_user_id); } } @@ -495,10 +496,10 @@ void item_tab_users_different(Info & i) void item_tab_group(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - long group_id = request.item_table[item_index].group_id; - Group * pgroup = data.groups.GetGroup(group_id); + long group_id = request->item_table[item_index].group_id; + Group * pgroup = system->groups.GetGroup(group_id); if( pgroup ) HtmlEscape(i.out, pgroup->name); @@ -510,9 +511,9 @@ void item_tab_group(Info & i) void item_tab_date_creation(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - tm * ptm = &request.item_table[item_index].date_creation; + tm * ptm = &request->item_table[item_index].date_creation; i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); } @@ -521,9 +522,9 @@ void item_tab_date_creation(Info & i) void item_tab_date_modification(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - tm * ptm = &request.item_table[item_index].date_modification; + tm * ptm = &request->item_table[item_index].date_modification; i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); } @@ -532,9 +533,9 @@ void item_tab_date_modification(Info & i) void item_tab_date_creation_nice(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - tm * ptm = &request.item_table[item_index].date_creation; + tm * ptm = &request->item_table[item_index].date_creation; print_date_nice(i, ptm); } } @@ -543,9 +544,9 @@ void item_tab_date_creation_nice(Info & i) void item_tab_date_modification_nice(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - tm * ptm = &request.item_table[item_index].date_modification; + tm * ptm = &request->item_table[item_index].date_modification; print_date_nice(i, ptm); } } @@ -553,10 +554,10 @@ void item_tab_date_modification_nice(Info & i) void item_tab_dates_equal(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - tm * ptm1 = &request.item_table[item_index].date_creation; - tm * ptm2 = &request.item_table[item_index].date_modification; + tm * ptm1 = &request->item_table[item_index].date_creation; + tm * ptm2 = &request->item_table[item_index].date_modification; i.res = ptm1->tm_year == ptm2->tm_year && ptm1->tm_mon == ptm2->tm_mon && @@ -570,16 +571,16 @@ void item_tab_dates_equal(Info & i) void item_tab_run(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - if( !request.HasReadExecAccess(request.item) ) + if( !system->HasReadExecAccess(request->item) ) { i.out << "<!-- run: permission denied -->"; return; } - Ezc::Pattern * p = pattern_cacher.GetPattern(request.item_table[item_index]); - Ezc::Generator gen(i.out, *p, functions); + Ezc::Pattern * p = pattern_cacher.GetPattern(request->item_table[item_index]); + Ezc::Generator gen(i.out, *p, ezc_functions); gen.Generate(); } } @@ -587,9 +588,10 @@ void item_tab_run(Info & i) void item_tab_can_use_emacs(Info & i) { - if( item_index < request.item_table.size() ) + if( item_index < request->item_table.size() ) { - i.res = request.CanUseEmacs(request.item_table[item_index], true); + // !! + //i.res = request->CanUseEmacs(request->item_table[item_index], true); } } diff --git a/templates/last.cpp b/templates/last.cpp index 8ca795f..cb6acdd 100755 --- a/templates/last.cpp +++ b/templates/last.cpp @@ -9,7 +9,6 @@ #include "templates.h" #include "../core/lastcontainer.h" -#include "../core/data.h" #include "../core/request.h" #include "../core/misc.h" @@ -24,13 +23,13 @@ static LastContainer::Iterator last_iterator; bool last_init() { - if( last_reqid != request.id ) + if( last_reqid != request->id ) { - last_reqid = request.id; - last_iterator = data.last.Begin(); + last_reqid = request->id; + last_iterator = system->users.last.Begin(); } - return last_iterator != data.last.End(); + return last_iterator != system->users.last.End(); } @@ -39,10 +38,10 @@ void last_tab(Info & i) { last_init(); - if( i.iter != 0 && last_iterator != data.last.End() ) + if( i.iter != 0 && last_iterator != system->users.last.End() ) ++last_iterator; - i.res = last_iterator != data.last.End(); + i.res = last_iterator != system->users.last.End(); } diff --git a/templates/ls.cpp b/templates/ls.cpp index f503f0b..371add0 100755 --- a/templates/ls.cpp +++ b/templates/ls.cpp @@ -24,9 +24,9 @@ static int ls_ckeditor_funnum = 0; void ls_ckeditor_funnum_browse(Info & i) { - if( ls_ckeditor_reqid != request.id ) + if( ls_ckeditor_reqid != request->id ) { - ls_ckeditor_reqid = request.id; + ls_ckeditor_reqid = request->id; ls_ckeditor_funnum = ParseCKeditorFun(); } diff --git a/templates/misc.cpp b/templates/misc.cpp index 45e3a2c..aba0a85 100755 --- a/templates/misc.cpp +++ b/templates/misc.cpp @@ -8,7 +8,6 @@ */ -#include "../core/data.h" #include "../core/misc.h" #include "../core/request.h" #include "templates.h" @@ -40,13 +39,13 @@ int ParseCKeditorFun() { ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info - if( !request.get_table.empty() ) + if( !request->get_table.empty() ) { - size_t last = request.get_table.size()-1; + size_t last = request->get_table.size()-1; - if( !request.get_table[last].empty() ) + if( !request->get_table[last].empty() ) { - const char * str = request.get_table[last].c_str() + 1; // the first char is '?' + const char * str = request->get_table[last].c_str() + 1; // the first char is '?' ckeditor_getparser.Parse(str); } } @@ -70,7 +69,7 @@ void Read(Patterns & patterns, size_t pat, Locale & locale, LocaleFilter & local if( pat < patterns[i].size() ) { patterns[i][pat].DeleteWhiteTextItems(delete_white); - patterns[i][pat].Directory(data.templates_dir, data.templates_dir_default); + patterns[i][pat].Directory(config->templates_dir, config->templates_dir_default); patterns[i][pat].ParseFile(file); locale_filter.Filter(patterns[i][pat], locale, static_cast<Locale::Lang>(i)); diff --git a/templates/mount.cpp b/templates/mount.cpp index 16c6f23..41122d6 100755 --- a/templates/mount.cpp +++ b/templates/mount.cpp @@ -8,7 +8,7 @@ */ #include "templates.h" -#include "../core/data.h" + @@ -20,31 +20,31 @@ namespace TemplatesFunctions void mount_page_is(Info & i) { - i.res = data.mounts.pmount->IsArg(Mount::par_page, i.par); + i.res = system->mounts.pmount->IsArg(Mount::par_page, i.par); } void mount_thread_is(Info & i) { - i.res = data.mounts.pmount->IsArg(Mount::par_thread, i.par); + i.res = system->mounts.pmount->IsArg(Mount::par_thread, i.par); } void mount_type_is_thread(Info & i) { - i.res = data.mounts.pmount->type == Mount::thread; + i.res = system->mounts.pmount->type == Mount::thread; } void mount_type_is_ticket(Info & i) { - i.res = data.mounts.pmount->type == Mount::ticket; + i.res = system->mounts.pmount->type == Mount::ticket; } void mount_type_is_cms(Info & i) { - i.res = data.mounts.pmount->type == Mount::cms; + i.res = system->mounts.pmount->type == Mount::cms; } diff --git a/templates/patterncacher.cpp b/templates/patterncacher.cpp index 5688045..02085eb 100755 --- a/templates/patterncacher.cpp +++ b/templates/patterncacher.cpp @@ -8,7 +8,6 @@ */ #include "patterncacher.h" -#include "../core/data.h" #include "../core/log.h" diff --git a/templates/priv.cpp b/templates/priv.cpp index c5bf403..474db29 100755 --- a/templates/priv.cpp +++ b/templates/priv.cpp @@ -8,10 +8,9 @@ */ #include "templates.h" -#include "../core/data.h" -#include "../core/request.h" -#include "../core/misc.h" - +#include "core/request.h" +#include "core/misc.h" +#include "functions/functions.h" @@ -27,20 +26,20 @@ static size_t priv_user_reqid = 0; void priv_user_tab_init(Item & item) { - priv_user_reqid = request.id; + priv_user_reqid = request->id; priv_user_table.clear(); - if( !request.session->puser ) + if( !request->session->puser ) { // not logged priv_user_table.push_back(item.user_id); } else - if( request.session->puser->super_user ) + if( request->session->puser->super_user ) { // super user is allowed to change to any user - for(size_t i=0 ; i<data.users.Size() ; ++i) - priv_user_table.push_back( data.users[i].id ); + for(size_t i=0 ; i<system->users.Size() ; ++i) + priv_user_table.push_back( system->users[i].id ); // as well to nobody (-1) priv_user_table.push_back(-1); @@ -55,16 +54,16 @@ void priv_user_tab_init(Item & item) void priv_user_tab_init() { - if( request.is_item ) - priv_user_tab_init(request.item); + if( request->is_item ) + priv_user_tab_init(request->item); else - priv_user_tab_init(*request.dir_table.back()); + priv_user_tab_init(*request->dir_table.back()); } void priv_user_tab(Info & i) { - if( priv_user_reqid != request.id ) + if( priv_user_reqid != request->id ) priv_user_tab_init(); priv_user_index = i.iter; @@ -82,7 +81,7 @@ void priv_user_tab_name(Info & i) if( uid != -1 ) { - User * puser = data.users.GetUser( uid ); + User * puser = system->users.GetUser( uid ); if( puser ) HtmlEscape(i.out, puser->name); @@ -91,7 +90,7 @@ void priv_user_tab_name(Info & i) } else { - HtmlEscape(i.out, data.priv_no_user); + HtmlEscape(i.out, config->priv_no_user); } } } @@ -104,14 +103,14 @@ void priv_user_tab_isdefault(Info & i) { long uid = priv_user_table[priv_user_index]; - if( request.is_item ) + if( request->is_item ) { - if( uid == request.item.user_id ) + if( uid == request->item.user_id ) i.res = true; } else { - if( uid == request.dir_table.back()->user_id ) + if( uid == request->dir_table.back()->user_id ) i.res = true; } } @@ -132,34 +131,34 @@ static size_t priv_group_reqid = 0; void priv_group_tab_init(Item & item) { - priv_group_reqid = request.id; + priv_group_reqid = request->id; priv_group_table.clear(); - if( !request.session->puser ) + if( !request->session->puser ) { // not logged priv_group_table.push_back(item.group_id); } else - if( request.session->puser->super_user ) + if( request->session->puser->super_user ) { // super user is allowed to change to any group - for(size_t i=0 ; i<data.groups.Size() ; ++i) - priv_group_table.push_back( data.groups[i].id ); + for(size_t i=0 ; i<system->groups.Size() ; ++i) + priv_group_table.push_back( system->groups[i].id ); // as well to nogroup (-1) priv_group_table.push_back(-1); } else - if( request.session->puser->id == item.user_id ) + if( request->session->puser->id == item.user_id ) { bool was_current_group = false; // owner of the item -- is allowed to change only to a group in which he belongs to - for(size_t i=0 ; i<request.session->puser->groups.size() ; ++i) + for(size_t i=0 ; i<request->session->puser->groups.size() ; ++i) { - priv_group_table.push_back( request.session->puser->groups[i] ); + priv_group_table.push_back( request->session->puser->groups[i] ); - if( item.group_id == request.session->puser->groups[i] ) + if( item.group_id == request->session->puser->groups[i] ) was_current_group = true; } @@ -180,16 +179,16 @@ void priv_group_tab_init(Item & item) void priv_group_tab_init() { - if( request.is_item ) - priv_group_tab_init(request.item); + if( request->is_item ) + priv_group_tab_init(request->item); else - priv_group_tab_init(*request.dir_table.back()); + priv_group_tab_init(*request->dir_table.back()); } void priv_group_tab(Info & i) { - if( priv_group_reqid != request.id ) + if( priv_group_reqid != request->id ) priv_group_tab_init(); priv_group_index = i.iter; @@ -207,7 +206,7 @@ void priv_group_tab_name(Info & i) if( gid != -1 ) { - Group * pgroup = data.groups.GetGroup( gid ); + Group * pgroup = system->groups.GetGroup( gid ); if( pgroup ) HtmlEscape(i.out, pgroup->name); @@ -216,7 +215,7 @@ void priv_group_tab_name(Info & i) } else { - HtmlEscape(i.out, data.priv_no_group); + HtmlEscape(i.out, config->priv_no_group); } } } @@ -229,14 +228,14 @@ void priv_group_tab_isdefault(Info & i) { long gid = priv_group_table[priv_group_index]; - if( request.is_item ) + if( request->is_item ) { - if( gid == request.item.group_id ) + if( gid == request->item.group_id ) i.res = true; } else { - if( gid == request.dir_table.back()->group_id ) + if( gid == request->dir_table.back()->group_id ) i.res = true; } } @@ -245,10 +244,10 @@ void priv_group_tab_isdefault(Info & i) void priv_privileges(Info & i) { - if( request.is_item ) - i.out << std::setbase(8) << request.item.privileges << std::setbase(10); + if( request->is_item ) + i.out << std::setbase(8) << request->item.privileges << std::setbase(10); else - i.out << std::setbase(8) << request.dir_table.back()->privileges << std::setbase(10); + i.out << std::setbase(8) << request->dir_table.back()->privileges << std::setbase(10); } @@ -268,13 +267,13 @@ void priv_privileges_for_dirs(Info & i) void priv_show_form_chown(Info & i) { - i.res = (request.pfunction->code == FUN_PRIV || request.pfunction->code == FUN_CHOWN); + i.res = (request->pfunction->fun.url == "priv" || request->pfunction->fun.url == "chown"); } void priv_show_form_chmod(Info & i) { - i.res = (request.pfunction->code == FUN_PRIV || request.pfunction->code == FUN_CHMOD); + i.res = (request->pfunction->fun.url == "priv" || request->pfunction->fun.url == "chmod"); } diff --git a/templates/rebus.cpp b/templates/rebus.cpp index 975d840..3d4e905 100755 --- a/templates/rebus.cpp +++ b/templates/rebus.cpp @@ -9,7 +9,6 @@ #include "../core/request.h" -#include "../core/data.h" #include "templates.h" @@ -24,11 +23,11 @@ static size_t rebus_reqid = 0; void rebus_init() { - if( rebus_reqid != request.id ) + if( rebus_reqid != request->id ) { - request.session->rebus_item = data.rebus.Rand(); - request.session->rebus_checked = false; - rebus_reqid = request.id; + request->session->rebus_item = system->rebus.Rand(); + request->session->rebus_checked = false; + rebus_reqid = request->id; } } @@ -37,8 +36,8 @@ void rebus_question(Info & i) { rebus_init(); - if( request.session->rebus_item ) - i.out << request.session->rebus_item->question; + if( request->session->rebus_item ) + i.out << request->session->rebus_item->question; } diff --git a/templates/sys.cpp b/templates/sys.cpp index 2549027..0db9888 100755 --- a/templates/sys.cpp +++ b/templates/sys.cpp @@ -8,7 +8,6 @@ */ #include "templates.h" -#include "../core/data.h" #include "../core/request.h" #include "../core/version.h" diff --git a/templates/templates.cpp b/templates/templates.cpp index 51a0711..488329d 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -8,12 +8,10 @@ */ #include "templates.h" -#include "../core/data.h" -#include "../core/request.h" -#include "../core/misc.h" -#include "../core/plugin.h" +#include "core/misc.h" +#include "core/plugin.h" #include "localefilter.h" - +#include "functions/functions.h" @@ -22,7 +20,7 @@ namespace TemplatesFunctions IndexPatterns index_patterns; Patterns patterns; -Ezc::Functions functions; +Ezc::Functions ezc_functions; PatternCacher pattern_cacher; Locale locale; LocaleFilter locale_filter; @@ -32,7 +30,12 @@ CKEditorGetParser ckeditor_getparser; std::vector<std::string> empty_pars; const std::string empty_string; - +Config * config; +Request * request; +Db * db; +System * system; +Functions * functions; +SessionManager * session_manager; @@ -40,48 +43,48 @@ Ezc::Pattern * content_for_function() { Ezc::Pattern * p = 0; - if( !request.pfunction ) + if( !request->pfunction ) { log << log1 << "Templates: no function" << logend; return p; } static PatName pat_name_tab[] = { - {FUN_CAT, pat_fun_cat}, - {FUN_LS, pat_fun_ls}, - {FUN_RM, pat_fun_rm}, - {FUN_EMACS, pat_fun_emacs}, - {FUN_MKDIR, pat_fun_mkdir}, - {FUN_DEFAULT, pat_fun_default}, - {FUN_PRIV, pat_fun_priv}, - {FUN_CHMOD, pat_fun_priv}, - {FUN_CHOWN, pat_fun_priv}, - {FUN_RUN, pat_fun_run}, - {FUN_WHO, pat_fun_who}, - {FUN_LAST, pat_fun_last}, - {FUN_THREAD, pat_fun_thread}, - {FUN_RELOAD, pat_fun_reload}, - {FUN_CREATETHREAD, pat_fun_createthread}, - {FUN_TICKET, pat_fun_ticket}, - {FUN_CREATETICKET, pat_fun_createticket}, - {FUN_EDITTICKET, pat_fun_createticket}, - {FUN_UPLOAD, pat_fun_upload}, - {FUN_UPTIME, pat_fun_uptime}, - {FUN_LOGIN, pat_fun_login}, - {FUN_MV, pat_fun_mv}, - {FUN_UNAME, pat_fun_uname}, - {FUN_CKEDITOR, pat_fun_ckeditor}, - {FUN_SUBJECT, pat_fun_subject}, - {FUN_ADDUSER, pat_fun_adduser}, - {FUN_CP, pat_fun_cp}, - {FUN_TINYMCE, pat_fun_tinymce}, + {"cat", pat_fun_cat}, + {"ls", pat_fun_ls}, + {"rm", pat_fun_rm}, + {"emacs", pat_fun_emacs}, + {"mkdir", pat_fun_mkdir}, + {"default", pat_fun_default}, + {"priv", pat_fun_priv}, + {"chmod", pat_fun_priv}, + {"chown", pat_fun_priv}, + {"run", pat_fun_run}, + {"who", pat_fun_who}, + {"last", pat_fun_last}, + {"thread", pat_fun_thread}, + {"reload", pat_fun_reload}, + {"createthread",pat_fun_createthread}, + {"ticket", pat_fun_ticket}, + {"createticket",pat_fun_createticket}, + {"editticket", pat_fun_createticket}, + {"upload", pat_fun_upload}, + {"uptime", pat_fun_uptime}, + {"login", pat_fun_login}, + {"mv", pat_fun_mv}, + {"uname", pat_fun_uname}, + {"ckeditor", pat_fun_ckeditor}, + {"subject", pat_fun_subject}, + {"adduser", pat_fun_adduser}, + {"cp", pat_fun_cp}, + {"tinymce", pat_fun_tinymce}, }; size_t i, len = sizeof(pat_name_tab)/sizeof(PatName); for(i=0 ; i<len ; ++i) { - if( pat_name_tab[i].fun_code == request.pfunction->code ) + if( strcmp(pat_name_tab[i].fun_name, request->pfunction->fun.url.c_str()) == 0 ) { // !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika p = &patterns[locale.GetLang()][pat_name_tab[i].pat]; @@ -105,7 +108,7 @@ Ezc::Pattern * p = 0; } - switch( request.status ) + switch( request->status ) { //case WINIX_ERR_NO_ITEM: !! we need something like 'error::item_required' //p = &pat_err_item_required; @@ -142,7 +145,7 @@ Ezc::Pattern * p = 0; if( p ) { - Ezc::Generator gen(i.out, *p, functions); + Ezc::Generator gen(i.out, *p, ezc_functions); gen.Generate(); } else @@ -164,322 +167,322 @@ void Templates::CreateFunctions() { using namespace TemplatesFunctions; - functions.Clear(); + ezc_functions.Clear(); /* sys */ - functions.Insert("sys_ver_major", sys_ver_major); - functions.Insert("sys_ver_minor", sys_ver_minor); - functions.Insert("sys_ver_revision", sys_ver_revision); + ezc_functions.Insert("sys_ver_major", sys_ver_major); + ezc_functions.Insert("sys_ver_minor", sys_ver_minor); + ezc_functions.Insert("sys_ver_revision", sys_ver_revision); /* adduser */ - functions.Insert("adduser_last_login", adduser_last_login); - functions.Insert("adduser_last_email", adduser_last_email); + ezc_functions.Insert("adduser_last_login", adduser_last_login); + ezc_functions.Insert("adduser_last_email", adduser_last_email); /* doc */ - functions.Insert("doc_title", doc_title); - functions.Insert("doc_base_url", doc_base_url); - functions.Insert("doc_base_url_auth", doc_base_url_auth); - functions.Insert("doc_base_url_static", doc_base_url_static); - functions.Insert("doc_base_url_common", doc_base_url_common); - functions.Insert("doc_current_url", doc_current_url); + ezc_functions.Insert("doc_title", doc_title); + ezc_functions.Insert("doc_base_url", doc_base_url); + ezc_functions.Insert("doc_base_url_auth", doc_base_url_auth); + ezc_functions.Insert("doc_base_url_static", doc_base_url_static); + ezc_functions.Insert("doc_base_url_common", doc_base_url_common); + ezc_functions.Insert("doc_current_url", doc_current_url); /* item */ - functions.Insert("item_is", item_is); - functions.Insert("item_id", item_id); - functions.Insert("item_subject", item_subject); - functions.Insert("item_subject_noescape", item_subject_noescape); - functions.Insert("item_content_is_empty", item_content_is_empty); - functions.Insert("item_content", item_content); - functions.Insert("item_content_noescape", item_content_noescape); - functions.Insert("item_content_type_is", item_content_type_is); - functions.Insert("item_print_content", item_print_content); - functions.Insert("item_privileges", item_privileges); - functions.Insert("item_dir", item_dir); - functions.Insert("item_url", item_url); - functions.Insert("item_url_is", item_url_is); - functions.Insert("item_link", item_link); - functions.Insert("item_auth_is_none", item_auth_is_none); - functions.Insert("item_auth_is_image", item_auth_is_image); + ezc_functions.Insert("item_is", item_is); + ezc_functions.Insert("item_id", item_id); + ezc_functions.Insert("item_subject", item_subject); + ezc_functions.Insert("item_subject_noescape", item_subject_noescape); + ezc_functions.Insert("item_content_is_empty", item_content_is_empty); + ezc_functions.Insert("item_content", item_content); + ezc_functions.Insert("item_content_noescape", item_content_noescape); + ezc_functions.Insert("item_content_type_is", item_content_type_is); + ezc_functions.Insert("item_print_content", item_print_content); + ezc_functions.Insert("item_privileges", item_privileges); + ezc_functions.Insert("item_dir", item_dir); + ezc_functions.Insert("item_url", item_url); + ezc_functions.Insert("item_url_is", item_url_is); + ezc_functions.Insert("item_link", item_link); + ezc_functions.Insert("item_auth_is_none", item_auth_is_none); + ezc_functions.Insert("item_auth_is_image", item_auth_is_image); - functions.Insert("item_can_read", item_can_read); - functions.Insert("item_can_write", item_can_write); - functions.Insert("item_can_remove", item_can_remove); - functions.Insert("item_info", item_info); - functions.Insert("item_user", item_user); - functions.Insert("item_modification_user", item_modification_user); - functions.Insert("item_users_different", item_users_different); - functions.Insert("item_date_creation", item_date_creation); - functions.Insert("item_date_modification", item_date_modification); - functions.Insert("item_date_creation_nice", item_date_creation_nice); - functions.Insert("item_date_modification_nice",item_date_modification_nice); - functions.Insert("item_dates_equal", item_dates_equal); - functions.Insert("item_run", item_run); - functions.Insert("item_guest_name", item_guest_name); + ezc_functions.Insert("item_can_read", item_can_read); + ezc_functions.Insert("item_can_write", item_can_write); + ezc_functions.Insert("item_can_remove", item_can_remove); + ezc_functions.Insert("item_info", item_info); + ezc_functions.Insert("item_user", item_user); + ezc_functions.Insert("item_modification_user", item_modification_user); + ezc_functions.Insert("item_users_different", item_users_different); + ezc_functions.Insert("item_date_creation", item_date_creation); + ezc_functions.Insert("item_date_modification", item_date_modification); + ezc_functions.Insert("item_date_creation_nice", item_date_creation_nice); + ezc_functions.Insert("item_date_modification_nice",item_date_modification_nice); + ezc_functions.Insert("item_dates_equal", item_dates_equal); + ezc_functions.Insert("item_run", item_run); + ezc_functions.Insert("item_guest_name", item_guest_name); - functions.Insert("item_tab", item_tab); - functions.Insert("item_tab_id", item_tab_id); - functions.Insert("item_tab_subject", item_tab_subject); - functions.Insert("item_tab_subject_noescape", item_tab_subject_noescape); - functions.Insert("item_tab_content", item_tab_content); - functions.Insert("item_tab_content_noescape", item_tab_content_noescape); - functions.Insert("item_tab_print_content", item_tab_print_content); - functions.Insert("item_tab_privileges", item_tab_privileges); - functions.Insert("item_tab_dir", item_tab_dir); - functions.Insert("item_tab_url", item_tab_url); - functions.Insert("item_tab_link", item_tab_link); - functions.Insert("item_tab_link_auth", item_tab_link_auth); - functions.Insert("item_tab_can_read", item_tab_can_read); - functions.Insert("item_tab_can_write", item_tab_can_write); - functions.Insert("item_tab_info", item_tab_info); - functions.Insert("item_tab_user", item_tab_user); - functions.Insert("item_tab_modification_user", item_tab_modification_user); - functions.Insert("item_tab_users_different", item_tab_users_different); - functions.Insert("item_tab_group", item_tab_group); - functions.Insert("item_tab_date_creation", item_tab_date_creation); - functions.Insert("item_tab_date_modification", item_tab_date_modification); - functions.Insert("item_tab_date_creation_nice", item_tab_date_creation_nice); - functions.Insert("item_tab_date_modification_nice", item_tab_date_modification_nice); - functions.Insert("item_tab_dates_equal", item_tab_dates_equal); - functions.Insert("item_tab_run", item_tab_run); - functions.Insert("item_tab_can_use_emacs", item_tab_can_use_emacs); + ezc_functions.Insert("item_tab", item_tab); + ezc_functions.Insert("item_tab_id", item_tab_id); + ezc_functions.Insert("item_tab_subject", item_tab_subject); + ezc_functions.Insert("item_tab_subject_noescape", item_tab_subject_noescape); + ezc_functions.Insert("item_tab_content", item_tab_content); + ezc_functions.Insert("item_tab_content_noescape", item_tab_content_noescape); + ezc_functions.Insert("item_tab_print_content", item_tab_print_content); + ezc_functions.Insert("item_tab_privileges", item_tab_privileges); + ezc_functions.Insert("item_tab_dir", item_tab_dir); + ezc_functions.Insert("item_tab_url", item_tab_url); + ezc_functions.Insert("item_tab_link", item_tab_link); + ezc_functions.Insert("item_tab_link_auth", item_tab_link_auth); + ezc_functions.Insert("item_tab_can_read", item_tab_can_read); + ezc_functions.Insert("item_tab_can_write", item_tab_can_write); + ezc_functions.Insert("item_tab_info", item_tab_info); + ezc_functions.Insert("item_tab_user", item_tab_user); + ezc_functions.Insert("item_tab_modification_user", item_tab_modification_user); + ezc_functions.Insert("item_tab_users_different", item_tab_users_different); + ezc_functions.Insert("item_tab_group", item_tab_group); + ezc_functions.Insert("item_tab_date_creation", item_tab_date_creation); + ezc_functions.Insert("item_tab_date_modification", item_tab_date_modification); + ezc_functions.Insert("item_tab_date_creation_nice", item_tab_date_creation_nice); + ezc_functions.Insert("item_tab_date_modification_nice", item_tab_date_modification_nice); + ezc_functions.Insert("item_tab_dates_equal", item_tab_dates_equal); + ezc_functions.Insert("item_tab_run", item_tab_run); + ezc_functions.Insert("item_tab_can_use_emacs", item_tab_can_use_emacs); /* dir */ - functions.Insert("dir", dir); - functions.Insert("dir_without_slash", dir_without_slash); - functions.Insert("dir_parent", dir_parent); - functions.Insert("dir_parent_without_slash", dir_parent_without_slash); - functions.Insert("dir_can_read_exec", dir_can_read_exec); - functions.Insert("dir_can_write", dir_can_write); - functions.Insert("dir_can_remove", dir_can_remove); - functions.Insert("dir_can_use_emacs", dir_can_use_emacs); - functions.Insert("dir_can_use_mkdir", dir_can_use_mkdir); + ezc_functions.Insert("dir", dir); + ezc_functions.Insert("dir_without_slash", dir_without_slash); + ezc_functions.Insert("dir_parent", dir_parent); + ezc_functions.Insert("dir_parent_without_slash", dir_parent_without_slash); + ezc_functions.Insert("dir_can_read_exec", dir_can_read_exec); + ezc_functions.Insert("dir_can_write", dir_can_write); + ezc_functions.Insert("dir_can_remove", dir_can_remove); + ezc_functions.Insert("dir_can_use_emacs", dir_can_use_emacs); + ezc_functions.Insert("dir_can_use_mkdir", dir_can_use_mkdir); - functions.Insert("dir_childs_tab", dir_childs_tab); - functions.Insert("dir_childs_is_parent", dir_childs_is_parent); - functions.Insert("dir_childs_tab_url", dir_childs_tab_url); - functions.Insert("dir_childs_tab_privileges", dir_childs_tab_privileges); - functions.Insert("dir_childs_tab_user", dir_childs_tab_user); - functions.Insert("dir_childs_tab_group", dir_childs_tab_group); + ezc_functions.Insert("dir_childs_tab", dir_childs_tab); + ezc_functions.Insert("dir_childs_is_parent", dir_childs_is_parent); + ezc_functions.Insert("dir_childs_tab_url", dir_childs_tab_url); + ezc_functions.Insert("dir_childs_tab_privileges", dir_childs_tab_privileges); + ezc_functions.Insert("dir_childs_tab_user", dir_childs_tab_user); + ezc_functions.Insert("dir_childs_tab_group", dir_childs_tab_group); - functions.Insert("dir_tab", dir_tab); - functions.Insert("dir_tab_url", dir_tab_url); - functions.Insert("dir_tab_link", dir_tab_link); + ezc_functions.Insert("dir_tab", dir_tab); + ezc_functions.Insert("dir_tab_url", dir_tab_url); + ezc_functions.Insert("dir_tab_link", dir_tab_link); - functions.Insert("dir_last_default_item_dir", dir_last_default_item_dir); - functions.Insert("dir_last_default_item_url", dir_last_default_item_url); - functions.Insert("dir_last_subject", dir_last_subject); - functions.Insert("dir_last_info", dir_last_info); - functions.Insert("dir_last_user", dir_last_user); - functions.Insert("dir_last_url", dir_last_url); - functions.Insert("dir_last_url_is", dir_last_url_is); - functions.Insert("dir_last_date_creation", dir_last_date_creation); - functions.Insert("dir_last_date_modification", dir_last_date_modification); - functions.Insert("dir_last_dates_equal", dir_last_dates_equal); + ezc_functions.Insert("dir_last_default_item_dir", dir_last_default_item_dir); + ezc_functions.Insert("dir_last_default_item_url", dir_last_default_item_url); + ezc_functions.Insert("dir_last_subject", dir_last_subject); + ezc_functions.Insert("dir_last_info", dir_last_info); + ezc_functions.Insert("dir_last_user", dir_last_user); + ezc_functions.Insert("dir_last_url", dir_last_url); + ezc_functions.Insert("dir_last_url_is", dir_last_url_is); + ezc_functions.Insert("dir_last_date_creation", dir_last_date_creation); + ezc_functions.Insert("dir_last_date_modification", dir_last_date_modification); + ezc_functions.Insert("dir_last_dates_equal", dir_last_dates_equal); /* user */ - functions.Insert("ls_ckeditor_funnum_browse", ls_ckeditor_funnum_browse); + ezc_functions.Insert("ls_ckeditor_funnum_browse", ls_ckeditor_funnum_browse); /* user */ - functions.Insert("user_name", user_name); - functions.Insert("user_logged", user_logged); - functions.Insert("user_super_user", user_super_user); - functions.Insert("user_can_use_html", user_can_use_html); - functions.Insert("user_can_use_bbcode", user_can_use_bbcode); - functions.Insert("user_can_use_raw", user_can_use_raw); + ezc_functions.Insert("user_name", user_name); + ezc_functions.Insert("user_logged", user_logged); + ezc_functions.Insert("user_super_user", user_super_user); + ezc_functions.Insert("user_can_use_html", user_can_use_html); + ezc_functions.Insert("user_can_use_bbcode", user_can_use_bbcode); + ezc_functions.Insert("user_can_use_raw", user_can_use_raw); /* privileges */ - functions.Insert("priv_user_tab", priv_user_tab); - functions.Insert("priv_user_tab_name", priv_user_tab_name); - functions.Insert("priv_user_tab_isdefault", priv_user_tab_isdefault); + ezc_functions.Insert("priv_user_tab", priv_user_tab); + ezc_functions.Insert("priv_user_tab_name", priv_user_tab_name); + ezc_functions.Insert("priv_user_tab_isdefault", priv_user_tab_isdefault); - functions.Insert("priv_group_tab", priv_group_tab); - functions.Insert("priv_group_tab_name", priv_group_tab_name); - functions.Insert("priv_group_tab_isdefault", priv_group_tab_isdefault); + ezc_functions.Insert("priv_group_tab", priv_group_tab); + ezc_functions.Insert("priv_group_tab_name", priv_group_tab_name); + ezc_functions.Insert("priv_group_tab_isdefault", priv_group_tab_isdefault); - functions.Insert("priv_privileges", priv_privileges); - functions.Insert("priv_privileges_for_files", priv_privileges_for_files); - functions.Insert("priv_privileges_for_dirs", priv_privileges_for_dirs); - functions.Insert("priv_show_form_chown", priv_show_form_chown); - functions.Insert("priv_show_form_chmod", priv_show_form_chmod); + ezc_functions.Insert("priv_privileges", priv_privileges); + ezc_functions.Insert("priv_privileges_for_files", priv_privileges_for_files); + ezc_functions.Insert("priv_privileges_for_dirs", priv_privileges_for_dirs); + ezc_functions.Insert("priv_show_form_chown", priv_show_form_chown); + ezc_functions.Insert("priv_show_form_chmod", priv_show_form_chmod); /* others */ - functions.Insert("content", content); + ezc_functions.Insert("content", content); /* who */ - functions.Insert("who_tab", who_tab); - functions.Insert("who_tab_lp", who_tab_lp); - functions.Insert("who_tab_user", who_tab_user); - functions.Insert("who_tab_time", who_tab_time); - functions.Insert("who_tab_last_time", who_tab_last_time); + ezc_functions.Insert("who_tab", who_tab); + ezc_functions.Insert("who_tab_lp", who_tab_lp); + ezc_functions.Insert("who_tab_user", who_tab_user); + ezc_functions.Insert("who_tab_time", who_tab_time); + ezc_functions.Insert("who_tab_last_time", who_tab_last_time); /* last */ - functions.Insert("last_tab", last_tab); - functions.Insert("last_tab_name", last_tab_name); - functions.Insert("last_tab_ip", last_tab_ip); - functions.Insert("last_tab_start", last_tab_start); - functions.Insert("last_tab_end", last_tab_end); + ezc_functions.Insert("last_tab", last_tab); + ezc_functions.Insert("last_tab_name", last_tab_name); + ezc_functions.Insert("last_tab_ip", last_tab_ip); + ezc_functions.Insert("last_tab_start", last_tab_start); + ezc_functions.Insert("last_tab_end", last_tab_end); /* thread */ - functions.Insert("thread_is", thread_is); - functions.Insert("thread_tab", thread_tab); - functions.Insert("thread_tab_url", thread_tab_url); - functions.Insert("thread_tab_subject", thread_tab_subject); - functions.Insert("thread_tab_author", thread_tab_author); - functions.Insert("thread_tab_answers", thread_tab_answers); - functions.Insert("thread_tab_last_item_date_modification", thread_tab_last_item_date_modification); - functions.Insert("thread_tab_last_item_date_modification_nice", thread_tab_last_item_date_modification_nice); - functions.Insert("thread_tab_last_item_user", thread_tab_last_item_user); - functions.Insert("thread_can_create", thread_can_create); + ezc_functions.Insert("thread_is", thread_is); + ezc_functions.Insert("thread_tab", thread_tab); + ezc_functions.Insert("thread_tab_url", thread_tab_url); + ezc_functions.Insert("thread_tab_subject", thread_tab_subject); + ezc_functions.Insert("thread_tab_author", thread_tab_author); + ezc_functions.Insert("thread_tab_answers", thread_tab_answers); + ezc_functions.Insert("thread_tab_last_item_date_modification", thread_tab_last_item_date_modification); + ezc_functions.Insert("thread_tab_last_item_date_modification_nice", thread_tab_last_item_date_modification_nice); + ezc_functions.Insert("thread_tab_last_item_user", thread_tab_last_item_user); + ezc_functions.Insert("thread_can_create", thread_can_create); /* ticket */ - functions.Insert("ticket_is", ticket_is); - functions.Insert("ticket_can_create", ticket_can_create); - functions.Insert("ticket_can_edit", ticket_can_edit); - functions.Insert("ticket_type", ticket_type); - functions.Insert("ticket_status", ticket_status); - functions.Insert("ticket_priority", ticket_priority); - functions.Insert("ticket_category", ticket_category); - functions.Insert("ticket_expected", ticket_expected); - functions.Insert("ticket_progress", ticket_progress); - functions.Insert("ticket_progress_image_number", ticket_progress_image_number); + ezc_functions.Insert("ticket_is", ticket_is); + ezc_functions.Insert("ticket_can_create", ticket_can_create); + ezc_functions.Insert("ticket_can_edit", ticket_can_edit); + ezc_functions.Insert("ticket_type", ticket_type); + ezc_functions.Insert("ticket_status", ticket_status); + ezc_functions.Insert("ticket_priority", ticket_priority); + ezc_functions.Insert("ticket_category", ticket_category); + ezc_functions.Insert("ticket_expected", ticket_expected); + ezc_functions.Insert("ticket_progress", ticket_progress); + ezc_functions.Insert("ticket_progress_image_number", ticket_progress_image_number); - functions.Insert("ticket_tab", ticket_tab); - functions.Insert("ticket_tab_url", ticket_tab_url); - functions.Insert("ticket_tab_subject", ticket_tab_subject); - functions.Insert("ticket_tab_subject_empty", ticket_tab_subject_empty); - functions.Insert("ticket_tab_author", ticket_tab_author); - functions.Insert("ticket_tab_type", ticket_tab_type); - functions.Insert("ticket_tab_status", ticket_tab_status); - functions.Insert("ticket_tab_priority", ticket_tab_priority); - functions.Insert("ticket_tab_category", ticket_tab_category); - functions.Insert("ticket_tab_expected", ticket_tab_expected); - functions.Insert("ticket_tab_progress", ticket_tab_progress); - functions.Insert("ticket_tab_progress_image_number",ticket_tab_progress_image_number); + ezc_functions.Insert("ticket_tab", ticket_tab); + ezc_functions.Insert("ticket_tab_url", ticket_tab_url); + ezc_functions.Insert("ticket_tab_subject", ticket_tab_subject); + ezc_functions.Insert("ticket_tab_subject_empty", ticket_tab_subject_empty); + ezc_functions.Insert("ticket_tab_author", ticket_tab_author); + ezc_functions.Insert("ticket_tab_type", ticket_tab_type); + ezc_functions.Insert("ticket_tab_status", ticket_tab_status); + ezc_functions.Insert("ticket_tab_priority", ticket_tab_priority); + ezc_functions.Insert("ticket_tab_category", ticket_tab_category); + ezc_functions.Insert("ticket_tab_expected", ticket_tab_expected); + ezc_functions.Insert("ticket_tab_progress", ticket_tab_progress); + ezc_functions.Insert("ticket_tab_progress_image_number",ticket_tab_progress_image_number); - functions.Insert("ticket_type_tab", ticket_type_tab); - functions.Insert("ticket_type_tab_defined", ticket_type_tab_defined); - functions.Insert("ticket_type_tab_isdefault", ticket_type_tab_isdefault); - functions.Insert("ticket_type_tab_index", ticket_type_tab_index); - functions.Insert("ticket_type_tab_name", ticket_type_tab_name); + ezc_functions.Insert("ticket_type_tab", ticket_type_tab); + ezc_functions.Insert("ticket_type_tab_defined", ticket_type_tab_defined); + ezc_functions.Insert("ticket_type_tab_isdefault", ticket_type_tab_isdefault); + ezc_functions.Insert("ticket_type_tab_index", ticket_type_tab_index); + ezc_functions.Insert("ticket_type_tab_name", ticket_type_tab_name); - functions.Insert("ticket_status_tab", ticket_status_tab); - functions.Insert("ticket_status_tab_defined", ticket_status_tab_defined); - functions.Insert("ticket_status_tab_isdefault", ticket_status_tab_isdefault); - functions.Insert("ticket_status_tab_index", ticket_status_tab_index); - functions.Insert("ticket_status_tab_name", ticket_status_tab_name); + ezc_functions.Insert("ticket_status_tab", ticket_status_tab); + ezc_functions.Insert("ticket_status_tab_defined", ticket_status_tab_defined); + ezc_functions.Insert("ticket_status_tab_isdefault", ticket_status_tab_isdefault); + ezc_functions.Insert("ticket_status_tab_index", ticket_status_tab_index); + ezc_functions.Insert("ticket_status_tab_name", ticket_status_tab_name); - functions.Insert("ticket_priority_tab", ticket_priority_tab); - functions.Insert("ticket_priority_tab_defined", ticket_priority_tab_defined); - functions.Insert("ticket_priority_tab_isdefault", ticket_priority_tab_isdefault); - functions.Insert("ticket_priority_tab_index", ticket_priority_tab_index); - functions.Insert("ticket_priority_tab_name", ticket_priority_tab_name); + ezc_functions.Insert("ticket_priority_tab", ticket_priority_tab); + ezc_functions.Insert("ticket_priority_tab_defined", ticket_priority_tab_defined); + ezc_functions.Insert("ticket_priority_tab_isdefault", ticket_priority_tab_isdefault); + ezc_functions.Insert("ticket_priority_tab_index", ticket_priority_tab_index); + ezc_functions.Insert("ticket_priority_tab_name", ticket_priority_tab_name); - functions.Insert("ticket_category_tab", ticket_category_tab); - functions.Insert("ticket_category_tab_defined", ticket_category_tab_defined); - functions.Insert("ticket_category_tab_isdefault", ticket_category_tab_isdefault); - functions.Insert("ticket_category_tab_index", ticket_category_tab_index); - functions.Insert("ticket_category_tab_name", ticket_category_tab_name); + ezc_functions.Insert("ticket_category_tab", ticket_category_tab); + ezc_functions.Insert("ticket_category_tab_defined", ticket_category_tab_defined); + ezc_functions.Insert("ticket_category_tab_isdefault", ticket_category_tab_isdefault); + ezc_functions.Insert("ticket_category_tab_index", ticket_category_tab_index); + ezc_functions.Insert("ticket_category_tab_name", ticket_category_tab_name); - functions.Insert("ticket_expected_tab", ticket_expected_tab); - functions.Insert("ticket_expected_tab_defined", ticket_expected_tab_defined); - functions.Insert("ticket_expected_tab_isdefault", ticket_expected_tab_isdefault); - functions.Insert("ticket_expected_tab_index", ticket_expected_tab_index); - functions.Insert("ticket_expected_tab_name", ticket_expected_tab_name); + ezc_functions.Insert("ticket_expected_tab", ticket_expected_tab); + ezc_functions.Insert("ticket_expected_tab_defined", ticket_expected_tab_defined); + ezc_functions.Insert("ticket_expected_tab_isdefault", ticket_expected_tab_isdefault); + ezc_functions.Insert("ticket_expected_tab_index", ticket_expected_tab_index); + ezc_functions.Insert("ticket_expected_tab_name", ticket_expected_tab_name); /* mount */ - functions.Insert("mount_page_is", mount_page_is); - functions.Insert("mount_thread_is", mount_thread_is); - functions.Insert("mount_type_is_thread", mount_type_is_thread); - functions.Insert("mount_type_is_ticket", mount_type_is_ticket); - functions.Insert("mount_type_is_cms", mount_type_is_cms); + ezc_functions.Insert("mount_page_is", mount_page_is); + ezc_functions.Insert("mount_thread_is", mount_thread_is); + ezc_functions.Insert("mount_type_is_thread", mount_type_is_thread); + ezc_functions.Insert("mount_type_is_ticket", mount_type_is_ticket); + ezc_functions.Insert("mount_type_is_cms", mount_type_is_cms); /* rebus */ - functions.Insert("rebus_question", rebus_question); + ezc_functions.Insert("rebus_question", rebus_question); /* upload */ - functions.Insert("upload_ckeditor_funnum", upload_ckeditor_funnum); + ezc_functions.Insert("upload_ckeditor_funnum", upload_ckeditor_funnum); /* uptime */ - functions.Insert("uptime_more_than_one_day", uptime_more_than_one_day); - functions.Insert("uptime_days", uptime_days); - functions.Insert("uptime_hours", uptime_hours); + ezc_functions.Insert("uptime_more_than_one_day", uptime_more_than_one_day); + ezc_functions.Insert("uptime_days", uptime_days); + ezc_functions.Insert("uptime_hours", uptime_hours); /* winix */ - functions.Insert("winix_cur_time", winix_cur_time); - functions.Insert("winix_users_logged", winix_users_logged); - functions.Insert("winix_function", winix_function); - functions.Insert("winix_function_is", winix_function_is); - functions.Insert("winix_function_param_is", winix_function_param_is); - functions.Insert("winix_loadavg_now", winix_loadavg_now); - functions.Insert("winix_loadavg_1", winix_loadavg_1); - functions.Insert("winix_loadavg_5", winix_loadavg_5); - functions.Insert("winix_loadavg_15", winix_loadavg_15); - functions.Insert("winix_req_per_sec_now", winix_req_per_sec_now); - functions.Insert("winix_req_per_sec_1", winix_req_per_sec_1); - functions.Insert("winix_req_per_sec_5", winix_req_per_sec_5); - functions.Insert("winix_req_per_sec_15", winix_req_per_sec_15); - functions.Insert("winix_err_is", winix_err_is); - functions.Insert("winix_err_code", winix_err_code); - functions.Insert("winix_is_err_in_locales", winix_is_err_in_locales); - functions.Insert("winix_err_msg_from_locales",winix_err_msg_from_locales); - functions.Insert("winix_show_content_in_full_window", winix_show_content_in_full_window); + ezc_functions.Insert("winix_cur_time", winix_cur_time); + ezc_functions.Insert("winix_users_logged", winix_users_logged); + ezc_functions.Insert("winix_function", winix_function); + ezc_functions.Insert("winix_function_is", winix_function_is); + ezc_functions.Insert("winix_function_param_is", winix_function_param_is); + ezc_functions.Insert("winix_loadavg_now", winix_loadavg_now); + ezc_functions.Insert("winix_loadavg_1", winix_loadavg_1); + ezc_functions.Insert("winix_loadavg_5", winix_loadavg_5); + ezc_functions.Insert("winix_loadavg_15", winix_loadavg_15); + ezc_functions.Insert("winix_req_per_sec_now", winix_req_per_sec_now); + ezc_functions.Insert("winix_req_per_sec_1", winix_req_per_sec_1); + ezc_functions.Insert("winix_req_per_sec_5", winix_req_per_sec_5); + ezc_functions.Insert("winix_req_per_sec_15", winix_req_per_sec_15); + ezc_functions.Insert("winix_err_is", winix_err_is); + ezc_functions.Insert("winix_err_code", winix_err_code); + ezc_functions.Insert("winix_is_err_in_locales", winix_is_err_in_locales); + ezc_functions.Insert("winix_err_msg_from_locales",winix_err_msg_from_locales); + ezc_functions.Insert("winix_show_content_in_full_window", winix_show_content_in_full_window); - plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &functions); + plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &ezc_functions); } @@ -497,14 +500,14 @@ void Templates::ReadTemplates() { using namespace TemplatesFunctions; - Locale::Lang lang = Locale::StrToLang(data.locale_str); + Locale::Lang lang = Locale::StrToLang(config->locale_str); if( lang != Locale::lang_unknown ) locale.SetLang(lang); else locale.SetLang(Locale::lang_en); - locale.Read(data.locale_dir, data.locale_dir_default); + locale.Read(config->locale_dir, config->locale_dir_default); ClearPatterns(); @@ -555,7 +558,7 @@ Mounts::MountTab::const_iterator i; using namespace TemplatesFunctions; index_patterns.MarkAllToDelete(); - const Mounts::MountTab * pmount_tab = data.mounts.GetMountTab(); + const Mounts::MountTab * pmount_tab = TemplatesFunctions::system->mounts.GetMountTab(); for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i) { @@ -575,7 +578,7 @@ void Templates::ReadIndexFileNames() using namespace TemplatesFunctions; Mounts::MountTab::const_iterator i; - const Mounts::MountTab * pmount_tab = data.mounts.GetMountTab(); + const Mounts::MountTab * pmount_tab = TemplatesFunctions::system->mounts.GetMountTab(); for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i) { @@ -605,7 +608,7 @@ using namespace TemplatesFunctions; return; Ezc::Pattern * index = 0; - const std::string * index_file_local = data.mounts.pmount->HtmlTemplate(); + const std::string * index_file_local = TemplatesFunctions::system->mounts.pmount->HtmlTemplate(); if( index_file_local ) index = index_patterns.GetPattern(*index_file_local, locale.GetLang()); @@ -613,7 +616,7 @@ using namespace TemplatesFunctions; if( !index ) index = &patterns[locale.GetLang()][pat_index]; - Ezc::Generator generator(request.page, *index, functions); + Ezc::Generator generator(request->page, *index, ezc_functions); generator.Generate(); } @@ -626,7 +629,7 @@ using namespace TemplatesFunctions; if( !empty_pars.empty() ) empty_pars.clear(); - Ezc::Info info(request.page, empty_pars, empty_string); + Ezc::Info info(request->page, empty_pars, empty_string); info.iter = 0; info.res = false; @@ -635,6 +638,43 @@ using namespace TemplatesFunctions; } +void Templates::SetConfig(Config * pconfig) +{ + TemplatesFunctions::config = pconfig; + TemplatesFunctions::index_patterns.SetConfig(pconfig); +} + + +void Templates::SetRequest(Request * prequest) +{ + TemplatesFunctions::request = prequest; +} + + +void Templates::SetDb(Db * pdb) +{ + TemplatesFunctions::db = pdb; +} + + +void Templates::SetSystem(System * psystem) +{ + TemplatesFunctions::system = psystem; +} + + +void Templates::SetFunctions(Functions * pfunctions) +{ + TemplatesFunctions::functions = pfunctions; +} + + +void Templates::SetSessionManager(SessionManager * psession_manager) +{ + TemplatesFunctions::session_manager = psession_manager; +} + + Templates::Templates() { ClearPatterns(); diff --git a/templates/templates.h b/templates/templates.h index 258e778..08a3bd4 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -16,11 +16,19 @@ #include "patterncacher.h" #include "misc.h" #include "ckeditorgetparser.h" -#include "../core/locale.h" #include "indexpatterns.h" +#include "core/config.h" +#include "core/request.h" +#include "core/db.h" +#include "core/system.h" +#include "core/locale.h" +#include "core/sessionmanager.h" +class Functions; + + namespace TemplatesFunctions { @@ -64,7 +72,7 @@ namespace TemplatesFunctions struct PatName { - int fun_code; + const char * fun_name; Pat pat; }; @@ -73,9 +81,18 @@ namespace TemplatesFunctions extern Patterns patterns; extern PatternCacher pattern_cacher; extern Locale locale; - extern Ezc::Functions functions; + extern Ezc::Functions ezc_functions; extern CKEditorGetParser ckeditor_getparser; + extern Config * config; + extern Request * request; + extern Db * db; + extern System * system; + extern Functions * functions; + extern SessionManager * session_manager; + + + /* sys @@ -394,6 +411,13 @@ public: Templates(); + void SetConfig(Config * pconfig); + void SetRequest(Request * prequest); + void SetDb(Db * pdb); + void SetSystem(System * psystem); + void SetFunctions(Functions * pfunctions); + void SetSessionManager(SessionManager * psession_manager); + void ClearPatterns(); void ReadTemplates(); void ReadNewIndexTemplates(); diff --git a/templates/thread.cpp b/templates/thread.cpp index 2a5eb8e..c2d771a 100755 --- a/templates/thread.cpp +++ b/templates/thread.cpp @@ -9,7 +9,6 @@ #include "templates.h" #include "misc.h" -#include "../core/data.h" #include "../core/request.h" #include "../core/misc.h" @@ -20,7 +19,7 @@ namespace TemplatesFunctions void thread_is(Info & i) { - i.res = request.is_thread; + i.res = request->is_thread; } @@ -33,15 +32,15 @@ void thread_tab(Info & i) { thread_tab_index = i.iter; - i.res = thread_tab_index < request.thread_tab.size(); + i.res = thread_tab_index < request->thread_tab.size(); } void thread_tab_url(Info & i) { - if( thread_tab_index < request.thread_tab.size() ) + if( thread_tab_index < request->thread_tab.size() ) { - Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->thread_tab[thread_tab_index].dir_id ); if( dir ) { @@ -57,9 +56,9 @@ void thread_tab_url(Info & i) void thread_tab_subject(Info & i) { - if( thread_tab_index < request.thread_tab.size() ) + if( thread_tab_index < request->thread_tab.size() ) { - Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->thread_tab[thread_tab_index].dir_id ); if( dir ) { @@ -78,9 +77,9 @@ void thread_tab_subject(Info & i) void thread_tab_answers(Info & i) { - if( thread_tab_index < request.thread_tab.size() ) + if( thread_tab_index < request->thread_tab.size() ) { - long a = request.thread_tab[thread_tab_index].items; + long a = request->thread_tab[thread_tab_index].items; // the first is created by the author // we count only the rest @@ -97,13 +96,13 @@ void thread_tab_author(Info & i) bool unknown = true; - if( thread_tab_index < request.thread_tab.size() ) + if( thread_tab_index < request->thread_tab.size() ) { - Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->thread_tab[thread_tab_index].dir_id ); if( dir ) { - User * puser = data.users.GetUser(dir->user_id); + User * puser = system->users.GetUser(dir->user_id); unknown = false; if( puser ) @@ -130,27 +129,27 @@ bool unknown = true; void thread_tab_last_item_date_modification(Info & i) { - if( thread_tab_index < request.thread_tab.size() ) - if( request.thread_tab[thread_tab_index].last_item.id != -1 ) - i.out << DateToStr( &request.thread_tab[thread_tab_index].last_item.date_modification ); + if( thread_tab_index < request->thread_tab.size() ) + if( request->thread_tab[thread_tab_index].last_item.id != -1 ) + i.out << DateToStr( &request->thread_tab[thread_tab_index].last_item.date_modification ); } void thread_tab_last_item_date_modification_nice(Info & i) { - if( thread_tab_index < request.thread_tab.size() ) - if( request.thread_tab[thread_tab_index].last_item.id != -1 ) - print_date_nice(i, &request.thread_tab[thread_tab_index].last_item.date_modification); + if( thread_tab_index < request->thread_tab.size() ) + if( request->thread_tab[thread_tab_index].last_item.id != -1 ) + print_date_nice(i, &request->thread_tab[thread_tab_index].last_item.date_modification); } void thread_tab_last_item_user(Info & i) { - if( thread_tab_index < request.thread_tab.size() ) + if( thread_tab_index < request->thread_tab.size() ) { - if( request.thread_tab[thread_tab_index].last_item.id != -1 ) + if( request->thread_tab[thread_tab_index].last_item.id != -1 ) { - User * puser = data.users.GetUser( request.thread_tab[thread_tab_index].last_item.user_id ); + User * puser = system->users.GetUser( request->thread_tab[thread_tab_index].last_item.user_id ); if( puser ) HtmlEscape(i.out, puser->name); @@ -158,8 +157,8 @@ void thread_tab_last_item_user(Info & i) { i.out << "~"; - if( !request.thread_tab[thread_tab_index].last_item.guest_name.empty() ) - HtmlEscape(i.out, request.thread_tab[thread_tab_index].last_item.guest_name); + if( !request->thread_tab[thread_tab_index].last_item.guest_name.empty() ) + HtmlEscape(i.out, request->thread_tab[thread_tab_index].last_item.guest_name); else i.out << "guest"; // !! dodac do konfiga } @@ -170,7 +169,8 @@ void thread_tab_last_item_user(Info & i) void thread_can_create(Info & i) { - i.res = request.CanCreateThread(true); + //i.res = request->CanCreateThread(true); + i.res = true; // temporarily } diff --git a/templates/ticket.cpp b/templates/ticket.cpp index 8b28c92..ca9620b 100755 --- a/templates/ticket.cpp +++ b/templates/ticket.cpp @@ -8,10 +8,9 @@ */ #include "templates.h" -#include "../core/data.h" -#include "../core/request.h" -#include "../core/misc.h" - +#include "core/request.h" +#include "core/misc.h" +#include "functions/functions.h" namespace TemplatesFunctions @@ -35,7 +34,7 @@ return percent; void ticket_is(Info & i) { - i.res = request.is_ticket; + i.res = request->is_ticket; } @@ -43,61 +42,63 @@ void ticket_is(Info & i) void ticket_can_create(Info & i) { - i.res = request.CanCreateTicket(true); + //i.res = request->CanCreateTicket(true); + i.res = functions->fun_createticket.HasAccess(); } void ticket_can_edit(Info & i) { - i.res = request.CanEditTicket(); + //i.res = request->CanEditTicket(); + i.res = functions->fun_editticket.HasAccess(); } void ticket_type(Info & i) { - if( request.ticket.type < data.mounts.pmount->param[Mount::par_ticket_type].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_type].arg[request.ticket.type]); + if( request->ticket.type < system->mounts.pmount->param[Mount::par_ticket_type].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_type].arg[request->ticket.type]); } void ticket_status(Info & i) { - if( request.ticket.status < data.mounts.pmount->param[Mount::par_ticket_status].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_status].arg[request.ticket.status]); + if( request->ticket.status < system->mounts.pmount->param[Mount::par_ticket_status].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_status].arg[request->ticket.status]); } void ticket_priority(Info & i) { - if( request.ticket.priority < data.mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_priority].arg[request.ticket.priority]); + if( request->ticket.priority < system->mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_priority].arg[request->ticket.priority]); } void ticket_category(Info & i) { - if( request.ticket.category < data.mounts.pmount->param[Mount::par_ticket_category].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_category].arg[request.ticket.category]); + if( request->ticket.category < system->mounts.pmount->param[Mount::par_ticket_category].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_category].arg[request->ticket.category]); } void ticket_expected(Info & i) { - if( request.ticket.expected < data.mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_expected].arg[request.ticket.expected]); + if( request->ticket.expected < system->mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_expected].arg[request->ticket.expected]); } void ticket_progress(Info & i) { - i.out << request.ticket.progress; + i.out << request->ticket.progress; } void ticket_progress_image_number(Info & i) { - int percent = request.ticket.progress; + int percent = request->ticket.progress; i.out << ticket_calc_progress_image_number(percent); } @@ -115,15 +116,15 @@ void ticket_tab(Info & i) { ticket_tab_index = i.iter; - i.res = ticket_tab_index < request.ticket_tab.size(); + i.res = ticket_tab_index < request->ticket_tab.size(); } void ticket_tab_url(Info & i) { - if( ticket_tab_index < request.ticket_tab.size() ) + if( ticket_tab_index < request->ticket_tab.size() ) { - Item * dir = data.dirs.GetDir( request.ticket_tab[ticket_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->ticket_tab[ticket_tab_index].dir_id ); if( dir ) { @@ -139,9 +140,9 @@ void ticket_tab_url(Info & i) void ticket_tab_subject(Info & i) { - if( ticket_tab_index < request.ticket_tab.size() ) + if( ticket_tab_index < request->ticket_tab.size() ) { - Item * dir = data.dirs.GetDir( request.ticket_tab[ticket_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->ticket_tab[ticket_tab_index].dir_id ); if( dir ) { @@ -162,9 +163,9 @@ void ticket_tab_subject_empty(Info & i) { i.res = true; - if( ticket_tab_index < request.ticket_tab.size() ) + if( ticket_tab_index < request->ticket_tab.size() ) { - Item * dir = data.dirs.GetDir( request.ticket_tab[ticket_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->ticket_tab[ticket_tab_index].dir_id ); if( dir ) i.res = dir->subject.empty(); @@ -177,13 +178,13 @@ void ticket_tab_author(Info & i) bool unknown = true; - if( ticket_tab_index < request.ticket_tab.size() ) + if( ticket_tab_index < request->ticket_tab.size() ) { - Item * dir = data.dirs.GetDir( request.ticket_tab[ticket_tab_index].dir_id ); + Item * dir = system->dirs.GetDir( request->ticket_tab[ticket_tab_index].dir_id ); if( dir ) { - User * puser = data.users.GetUser(dir->user_id); + User * puser = system->users.GetUser(dir->user_id); unknown = false; if( puser ) @@ -211,79 +212,79 @@ bool unknown = true; void ticket_tab_type(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - Ticket & t = request.ticket_tab[ticket_tab_index]; + Ticket & t = request->ticket_tab[ticket_tab_index]; - if( t.type < data.mounts.pmount->param[Mount::par_ticket_type].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_type].arg[t.type]); + if( t.type < system->mounts.pmount->param[Mount::par_ticket_type].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_type].arg[t.type]); } void ticket_tab_status(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - Ticket & t = request.ticket_tab[ticket_tab_index]; + Ticket & t = request->ticket_tab[ticket_tab_index]; - if( t.status < data.mounts.pmount->param[Mount::par_ticket_status].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_status].arg[t.status]); + if( t.status < system->mounts.pmount->param[Mount::par_ticket_status].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_status].arg[t.status]); } void ticket_tab_priority(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - Ticket & t = request.ticket_tab[ticket_tab_index]; + Ticket & t = request->ticket_tab[ticket_tab_index]; - if( t.priority < data.mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_priority].arg[t.priority]); + if( t.priority < system->mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_priority].arg[t.priority]); } void ticket_tab_category(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - Ticket & t = request.ticket_tab[ticket_tab_index]; + Ticket & t = request->ticket_tab[ticket_tab_index]; - if( t.category < data.mounts.pmount->param[Mount::par_ticket_category].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_category].arg[t.category]); + if( t.category < system->mounts.pmount->param[Mount::par_ticket_category].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_category].arg[t.category]); } void ticket_tab_expected(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - Ticket & t = request.ticket_tab[ticket_tab_index]; + Ticket & t = request->ticket_tab[ticket_tab_index]; - if( t.expected < data.mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_expected].arg[t.expected]); + if( t.expected < system->mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_expected].arg[t.expected]); } void ticket_tab_progress(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - i.out << request.ticket_tab[ticket_tab_index].progress; + i.out << request->ticket_tab[ticket_tab_index].progress; } void ticket_tab_progress_image_number(Info & i) { - if( ticket_tab_index >= request.ticket_tab.size() ) + if( ticket_tab_index >= request->ticket_tab.size() ) return; - int percent = request.ticket_tab[ticket_tab_index].progress; + int percent = request->ticket_tab[ticket_tab_index].progress; i.out << ticket_calc_progress_image_number(percent); } @@ -298,25 +299,25 @@ void ticket_type_tab(Info & i) { ticket_type_tab_ind = i.iter; - i.res = ticket_type_tab_ind < data.mounts.pmount->param[Mount::par_ticket_type].arg.size(); + i.res = ticket_type_tab_ind < system->mounts.pmount->param[Mount::par_ticket_type].arg.size(); } void ticket_type_tab_defined(Info & i) { - i.res = data.mounts.pmount->param[Mount::par_ticket_type].defined; + i.res = system->mounts.pmount->param[Mount::par_ticket_type].defined; } void ticket_type_tab_isdefault(Info & i) { - if( request.is_ticket ) + if( request->is_ticket ) { - i.res = (ticket_type_tab_ind == request.ticket.type); + i.res = (ticket_type_tab_ind == request->ticket.type); } else { - Mount::ParamRow & p = data.mounts.pmount->param[Mount::par_ticket_type_default]; + Mount::ParamRow & p = system->mounts.pmount->param[Mount::par_ticket_type_default]; if( !p.defined || p.arg.empty() ) return; // default false @@ -335,8 +336,8 @@ void ticket_type_tab_index(Info & i) void ticket_type_tab_name(Info & i) { - if( ticket_type_tab_ind < data.mounts.pmount->param[Mount::par_ticket_type].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_type].arg[ticket_type_tab_ind]); + if( ticket_type_tab_ind < system->mounts.pmount->param[Mount::par_ticket_type].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_type].arg[ticket_type_tab_ind]); } @@ -350,25 +351,25 @@ void ticket_status_tab(Info & i) { ticket_status_tab_ind = i.iter; - i.res = ticket_status_tab_ind < data.mounts.pmount->param[Mount::par_ticket_status].arg.size(); + i.res = ticket_status_tab_ind < system->mounts.pmount->param[Mount::par_ticket_status].arg.size(); } void ticket_status_tab_defined(Info & i) { - i.res = data.mounts.pmount->param[Mount::par_ticket_status].defined; + i.res = system->mounts.pmount->param[Mount::par_ticket_status].defined; } void ticket_status_tab_isdefault(Info & i) { - if( request.is_ticket ) + if( request->is_ticket ) { - i.res = (ticket_status_tab_ind == request.ticket.status); + i.res = (ticket_status_tab_ind == request->ticket.status); } else { - Mount::ParamRow & p = data.mounts.pmount->param[Mount::par_ticket_status_default]; + Mount::ParamRow & p = system->mounts.pmount->param[Mount::par_ticket_status_default]; if( !p.defined || p.arg.empty() ) return; // default false @@ -387,8 +388,8 @@ void ticket_status_tab_index(Info & i) void ticket_status_tab_name(Info & i) { - if( ticket_status_tab_ind < data.mounts.pmount->param[Mount::par_ticket_status].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_status].arg[ticket_status_tab_ind]); + if( ticket_status_tab_ind < system->mounts.pmount->param[Mount::par_ticket_status].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_status].arg[ticket_status_tab_ind]); } @@ -401,25 +402,25 @@ void ticket_priority_tab(Info & i) { ticket_priority_tab_ind = i.iter; - i.res = ticket_priority_tab_ind < data.mounts.pmount->param[Mount::par_ticket_priority].arg.size(); + i.res = ticket_priority_tab_ind < system->mounts.pmount->param[Mount::par_ticket_priority].arg.size(); } void ticket_priority_tab_defined(Info & i) { - i.res = data.mounts.pmount->param[Mount::par_ticket_priority].defined; + i.res = system->mounts.pmount->param[Mount::par_ticket_priority].defined; } void ticket_priority_tab_isdefault(Info & i) { - if( request.is_ticket ) + if( request->is_ticket ) { - i.res = (ticket_priority_tab_ind == request.ticket.priority); + i.res = (ticket_priority_tab_ind == request->ticket.priority); } else { - Mount::ParamRow & p = data.mounts.pmount->param[Mount::par_ticket_priority_default]; + Mount::ParamRow & p = system->mounts.pmount->param[Mount::par_ticket_priority_default]; if( !p.defined || p.arg.empty() ) return; // default false @@ -438,8 +439,8 @@ void ticket_priority_tab_index(Info & i) void ticket_priority_tab_name(Info & i) { - if( ticket_priority_tab_ind < data.mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_priority].arg[ticket_priority_tab_ind]); + if( ticket_priority_tab_ind < system->mounts.pmount->param[Mount::par_ticket_priority].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_priority].arg[ticket_priority_tab_ind]); } @@ -452,25 +453,25 @@ void ticket_category_tab(Info & i) { ticket_category_tab_ind = i.iter; - i.res = ticket_category_tab_ind < data.mounts.pmount->param[Mount::par_ticket_category].arg.size(); + i.res = ticket_category_tab_ind < system->mounts.pmount->param[Mount::par_ticket_category].arg.size(); } void ticket_category_tab_defined(Info & i) { - i.res = data.mounts.pmount->param[Mount::par_ticket_category].defined; + i.res = system->mounts.pmount->param[Mount::par_ticket_category].defined; } void ticket_category_tab_isdefault(Info & i) { - if( request.is_ticket ) + if( request->is_ticket ) { - i.res = (ticket_category_tab_ind == request.ticket.category); + i.res = (ticket_category_tab_ind == request->ticket.category); } else { - Mount::ParamRow & p = data.mounts.pmount->param[Mount::par_ticket_category_default]; + Mount::ParamRow & p = system->mounts.pmount->param[Mount::par_ticket_category_default]; if( !p.defined || p.arg.empty() ) return; // default false @@ -489,8 +490,8 @@ void ticket_category_tab_index(Info & i) void ticket_category_tab_name(Info & i) { - if( ticket_category_tab_ind < data.mounts.pmount->param[Mount::par_ticket_category].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_category].arg[ticket_category_tab_ind]); + if( ticket_category_tab_ind < system->mounts.pmount->param[Mount::par_ticket_category].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_category].arg[ticket_category_tab_ind]); } @@ -504,25 +505,25 @@ void ticket_expected_tab(Info & i) { ticket_expected_tab_ind = i.iter; - i.res = ticket_expected_tab_ind < data.mounts.pmount->param[Mount::par_ticket_expected].arg.size(); + i.res = ticket_expected_tab_ind < system->mounts.pmount->param[Mount::par_ticket_expected].arg.size(); } void ticket_expected_tab_defined(Info & i) { - i.res = data.mounts.pmount->param[Mount::par_ticket_expected].defined; + i.res = system->mounts.pmount->param[Mount::par_ticket_expected].defined; } void ticket_expected_tab_isdefault(Info & i) { - if( request.is_ticket ) + if( request->is_ticket ) { - i.res = (ticket_expected_tab_ind == request.ticket.expected); + i.res = (ticket_expected_tab_ind == request->ticket.expected); } else { - Mount::ParamRow & p = data.mounts.pmount->param[Mount::par_ticket_expected_default]; + Mount::ParamRow & p = system->mounts.pmount->param[Mount::par_ticket_expected_default]; if( !p.defined || p.arg.empty() ) return; // default false @@ -541,8 +542,8 @@ void ticket_expected_tab_index(Info & i) void ticket_expected_tab_name(Info & i) { - if( ticket_expected_tab_ind < data.mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) - HtmlEscape(i.out, data.mounts.pmount->param[Mount::par_ticket_expected].arg[ticket_expected_tab_ind]); + if( ticket_expected_tab_ind < system->mounts.pmount->param[Mount::par_ticket_expected].arg.size() ) + HtmlEscape(i.out, system->mounts.pmount->param[Mount::par_ticket_expected].arg[ticket_expected_tab_ind]); } diff --git a/templates/upload.cpp b/templates/upload.cpp index 9e27b64..9f2d0e8 100755 --- a/templates/upload.cpp +++ b/templates/upload.cpp @@ -23,9 +23,9 @@ static int upload_fun_num = 0; void upload_ckeditor_funnum(Info & i) { - if( upload_ckeditor_reqid != request.id ) + if( upload_ckeditor_reqid != request->id ) { - upload_ckeditor_reqid = request.id; + upload_ckeditor_reqid = request->id; upload_fun_num = ParseCKeditorFun(); } diff --git a/templates/uptime.cpp b/templates/uptime.cpp index 972ad87..e5dc0a3 100755 --- a/templates/uptime.cpp +++ b/templates/uptime.cpp @@ -9,7 +9,7 @@ #include <ctime> #include "templates.h" -#include "../core/data.h" + namespace TemplatesFunctions @@ -19,7 +19,7 @@ namespace TemplatesFunctions void uptime_more_than_one_day(Info & i) { - time_t up = time(0) - data.system_start; + time_t up = time(0) - system->system_start; time_t days = up / 60 / 60 / 24; i.res = ( days > 1 ); @@ -28,7 +28,7 @@ void uptime_more_than_one_day(Info & i) void uptime_days(Info & i) { - time_t up = time(0) - data.system_start; + time_t up = time(0) - system->system_start; time_t days = up / 60 / 60 / 24; i.out << days; @@ -39,7 +39,7 @@ void uptime_hours(Info & i) { char buf[50]; - time_t sec = time(0) - data.system_start; + time_t sec = time(0) - system->system_start; time_t min = sec / 60; time_t hour = min / 60; diff --git a/templates/user.cpp b/templates/user.cpp index ef2bd96..eb9ef6e 100755 --- a/templates/user.cpp +++ b/templates/user.cpp @@ -8,7 +8,6 @@ */ #include "templates.h" -#include "../core/data.h" #include "../core/request.h" #include "../core/misc.h" @@ -22,51 +21,51 @@ namespace TemplatesFunctions void user_logged(Info & i) { - i.res = request.session->puser != 0; + i.res = request->session->puser != 0; } void user_name(Info & i) { - if( !request.session->puser ) + if( !request->session->puser ) return; - HtmlEscape(i.out, request.session->puser->name); + HtmlEscape(i.out, request->session->puser->name); } void user_super_user(Info & i) { - if( request.session->puser && request.session->puser->super_user ) + if( request->session->puser && request->session->puser->super_user ) i.res = true; } void user_can_use_html(Info & i) { - if( !request.session->puser ) + if( !request->session->puser ) i.res = false; else - i.res = request.CanUseHtml(request.session->puser->id); + i.res = system->CanUseHtml(request->session->puser->id); } void user_can_use_bbcode(Info & i) { - if( !request.session->puser ) + if( !request->session->puser ) i.res = false; else - i.res = request.CanUseBBCode(request.session->puser->id); + i.res = system->CanUseBBCode(request->session->puser->id); } void user_can_use_raw(Info & i) { - if( !request.session->puser ) + if( !request->session->puser ) i.res = false; else - i.res = request.CanUseRaw(request.session->puser->id); + i.res = system->CanUseRaw(request->session->puser->id); } diff --git a/templates/who.cpp b/templates/who.cpp index aa9c0b9..e093302 100755 --- a/templates/who.cpp +++ b/templates/who.cpp @@ -8,11 +8,8 @@ */ #include "templates.h" -#include "../core/sessioncontainer.h" -#include "../core/requestcontroller.h" -#include "../core/data.h" -#include "../core/request.h" -#include "../core/misc.h" +#include "core/request.h" +#include "core/misc.h" @@ -27,14 +24,14 @@ size_t who_lp; bool who_init() { - if( who_reqid != request.id ) + if( who_reqid != request->id ) { - who_reqid = request.id; - who_iterator = req_controller.SessionBegin(); + who_reqid = request->id; + who_iterator = session_manager->SessionBegin(); who_lp = 1; } - return who_iterator != req_controller.SessionEnd(); + return who_iterator != session_manager->SessionEnd(); } @@ -43,13 +40,13 @@ void who_tab(Info & i) { who_init(); - if( i.iter != 0 && who_iterator != req_controller.SessionEnd() ) + if( i.iter != 0 && who_iterator != session_manager->SessionEnd() ) { ++who_iterator; ++who_lp; } - i.res = who_iterator != req_controller.SessionEnd(); + i.res = who_iterator != session_manager->SessionEnd(); } diff --git a/templates/winix.cpp b/templates/winix.cpp index 902b3e8..6e7d895 100755 --- a/templates/winix.cpp +++ b/templates/winix.cpp @@ -9,8 +9,9 @@ #include <ctime> #include "templates.h" -#include "../core/data.h" -#include "../core/request.h" +#include "core/request.h" +#include "functions/functions.h" + namespace TemplatesFunctions @@ -33,28 +34,28 @@ static char buffer[100]; void winix_users_logged(Info & i) { - i.out << data.how_many_logged; + i.out << system->users.HowManyLogged(); } void winix_function(Info & i) { - i.out << request.pfunction->item.url; + i.out << request->pfunction->fun.url; } void winix_function_is(Info & i) { - if( !request.pfunction ) + if( !request->pfunction ) return; - i.res = (request.pfunction->item.url == i.par); + i.res = (request->pfunction->fun.url == i.par); } void winix_function_param_is(Info & i) { - i.res = request.IsParam(i.par.c_str()); + i.res = request->IsParam(i.par.c_str()); } @@ -63,7 +64,7 @@ void winix_loadavg_now(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.LoadAvgNow()); + sprintf(buf, "%.2f", (double)system->load_avg.LoadAvgNow()); i.out << buf; } @@ -72,7 +73,7 @@ void winix_loadavg_1(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.LoadAvg1()); + sprintf(buf, "%.2f", (double)system->load_avg.LoadAvg1()); i.out << buf; } @@ -81,7 +82,7 @@ void winix_loadavg_5(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.LoadAvg5()); + sprintf(buf, "%.2f", (double)system->load_avg.LoadAvg5()); i.out << buf; } @@ -90,7 +91,7 @@ void winix_loadavg_15(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.LoadAvg15()); + sprintf(buf, "%.2f", (double)system->load_avg.LoadAvg15()); i.out << buf; } @@ -99,7 +100,7 @@ void winix_req_per_sec_now(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSecNow()); + sprintf(buf, "%.2f", (double)system->load_avg.ReqPerSecNow()); i.out << buf; } @@ -108,7 +109,7 @@ void winix_req_per_sec_1(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSec1()); + sprintf(buf, "%.2f", (double)system->load_avg.ReqPerSec1()); i.out << buf; } @@ -117,7 +118,7 @@ void winix_req_per_sec_5(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSec5()); + sprintf(buf, "%.2f", (double)system->load_avg.ReqPerSec5()); i.out << buf; } @@ -126,7 +127,7 @@ void winix_req_per_sec_15(Info & i) { char buf[20]; - sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSec15()); + sprintf(buf, "%.2f", (double)system->load_avg.ReqPerSec15()); i.out << buf; } @@ -134,13 +135,13 @@ char buf[20]; void winix_err_is(Info & i) { int value = atoi( i.par.c_str() ); - i.res = (request.status == value); + i.res = (request->status == value); } void winix_err_code(Info & i) { - i.out << request.status; + i.out << request->status; } @@ -152,7 +153,7 @@ void winix_is_err_in_locales(Info & i) { char buff[40]; - sprintf(buff, "winix_err_%d", request.status); + sprintf(buff, "winix_err_%d", request->status); winix_error_key = buff; i.res = locale.IsKey(winix_error_key); @@ -163,7 +164,7 @@ void winix_err_msg_from_locales(Info & i) { char buff[40]; - sprintf(buff, "winix_err_%d", request.status); + sprintf(buff, "winix_err_%d", request->status); winix_error_key = buff; i.out << locale.Get(winix_error_key); @@ -172,8 +173,8 @@ char buff[40]; void winix_show_content_in_full_window(Info & i) { - if( request.pfunction ) - i.res = (request.pfunction->code == FUN_CKEDITOR || request.pfunction->code == FUN_TINYMCE); + if( request->pfunction ) + i.res = (request->pfunction->fun.url == "ckeditor" || request->pfunction->fun.url == "tinymce"); } diff --git a/templatesnotify/Makefile.dep b/templatesnotify/Makefile.dep index eda72a4..2afe215 100755 --- a/templatesnotify/Makefile.dep +++ b/templatesnotify/Makefile.dep @@ -1,16 +1,21 @@ # DO NOT DELETE -notify.o: templatesnotify.h ../core/mount.h ../core/locale.h -notify.o: ../confparser/confparser.h ../templates/misc.h -notify.o: ../templates/localefilter.h ../../ezc/src/ezc.h ../core/notify.h -notify.o: ../templatesnotify/templatesnotify.h -templatesnotify.o: templatesnotify.h ../core/mount.h ../core/locale.h -templatesnotify.o: ../confparser/confparser.h ../templates/misc.h -templatesnotify.o: ../templates/localefilter.h ../../ezc/src/ezc.h -templatesnotify.o: ../core/misc.h ../core/item.h ../core/data.h -templatesnotify.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h -templatesnotify.o: ../core/user.h ../core/ugcontainer.h ../core/log.h -templatesnotify.o: ../core/groups.h ../core/group.h ../core/functions.h -templatesnotify.o: ../core/function.h ../core/lastcontainer.h -templatesnotify.o: ../core/mounts.h ../core/mount.h ../core/error.h -templatesnotify.o: ../core/rebus.h ../core/loadavg.h ../core/log.h +notify.o: templatesnotify.h ../../ezc/src/ezc.h ../core/mount.h +notify.o: ../core/locale.h ../core/confparser.h ../core/config.h +notify.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +notify.o: ../core/notify.h ../templatesnotify/templatesnotify.h +notify.o: ../core/request.h ../core/requesttypes.h ../core/session.h +notify.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h +notify.o: ../core/plugindata.h ../core/rebus.h ../core/thread.h +notify.o: ../core/compress.h ../core/acceptencodingparser.h +notify.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +notify.o: ../core/postmultiparser.h ../core/config.h ../core/ticket.h +notify.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h ../core/db.h +notify.o: ../core/group.h ../core/ugcontainer.h ../core/mounts.h +notify.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +notify.o: ../core/groups.h ../core/loadavg.h +templatesnotify.o: templatesnotify.h ../../ezc/src/ezc.h ../core/mount.h +templatesnotify.o: ../core/locale.h ../core/confparser.h ../core/config.h +templatesnotify.o: ../templates/misc.h ../templates/localefilter.h +templatesnotify.o: ../core/locale.h ../core/misc.h ../core/item.h +templatesnotify.o: ../core/log.h diff --git a/templatesnotify/templatesnotify.cpp b/templatesnotify/templatesnotify.cpp index 2d07f05..d70573c 100755 --- a/templatesnotify/templatesnotify.cpp +++ b/templatesnotify/templatesnotify.cpp @@ -8,10 +8,9 @@ */ #include "templatesnotify.h" -#include "../core/misc.h" -#include "../core/locale.h" -#include "../core/data.h" -#include "../core/log.h" +#include "core/misc.h" +#include "core/locale.h" +#include "core/log.h" @@ -20,10 +19,11 @@ namespace TemplatesNotifyFunctions { Patterns patterns; -Ezc::Functions functions; +Ezc::Functions ezc_functions; Locale locale; LocaleFilter locale_filter; +Config * config; // you can use this pointer in template functions (will be always valid) @@ -35,24 +35,30 @@ NotifyMsg * notify_msg; +void TemplatesNotify::SetConfig(Config * pconfig) +{ + TemplatesNotifyFunctions::config = pconfig; +} + + void TemplatesNotify::CreateFunctions() { using namespace TemplatesNotifyFunctions; - functions.Clear(); + ezc_functions.Clear(); - functions.Insert("notify_item_added", notify_item_added); - functions.Insert("notify_item_edited", notify_item_edited); - functions.Insert("notify_item_deleted", notify_item_deleted); - functions.Insert("notify_dir_added", notify_dir_added); - functions.Insert("notify_to", notify_to); - functions.Insert("notify_mount_type_is_thread", notify_mount_type_is_thread); - functions.Insert("notify_mount_type_is_cms", notify_mount_type_is_cms); - functions.Insert("notify_doc_base_url", notify_doc_base_url); - functions.Insert("notify_item_dir", notify_item_dir); - functions.Insert("notify_item_link", notify_item_link); + ezc_functions.Insert("notify_item_added", notify_item_added); + ezc_functions.Insert("notify_item_edited", notify_item_edited); + ezc_functions.Insert("notify_item_deleted", notify_item_deleted); + ezc_functions.Insert("notify_dir_added", notify_dir_added); + ezc_functions.Insert("notify_to", notify_to); + ezc_functions.Insert("notify_mount_type_is_thread", notify_mount_type_is_thread); + ezc_functions.Insert("notify_mount_type_is_cms", notify_mount_type_is_cms); + ezc_functions.Insert("notify_doc_base_url", notify_doc_base_url); + ezc_functions.Insert("notify_item_dir", notify_item_dir); + ezc_functions.Insert("notify_item_link", notify_item_link); } @@ -74,7 +80,7 @@ void TemplatesNotify::Read() { using namespace TemplatesNotifyFunctions; - Locale::Lang lang = Locale::StrToLang(data.locale_str); + Locale::Lang lang = Locale::StrToLang(config->locale_str); if( lang != Locale::lang_unknown ) locale.SetLang(lang); @@ -82,7 +88,7 @@ using namespace TemplatesNotifyFunctions; locale.SetLang(Locale::lang_en); ClearPatterns(); - locale.Read(data.locale_dir, data.locale_dir_default); + locale.Read(config->locale_dir, config->locale_dir_default); TemplatesFunctions::Read(patterns, pat_email_notify, locale, locale_filter, "notify_email.txt", true); notify_msg = 0; @@ -105,7 +111,7 @@ using namespace TemplatesNotifyFunctions; return; } - Ezc::Generator generator(notify_str, patterns[lang][pat_email_notify], functions); + Ezc::Generator generator(notify_str, patterns[lang][pat_email_notify], ezc_functions); generator.Generate(); } diff --git a/templatesnotify/templatesnotify.h b/templatesnotify/templatesnotify.h index 613c75a..0b2c582 100755 --- a/templatesnotify/templatesnotify.h +++ b/templatesnotify/templatesnotify.h @@ -13,10 +13,12 @@ #include <iomanip> #include <set> #include <string> -#include "../core/mount.h" -#include "../core/locale.h" -#include "../templates/misc.h" #include "ezc.h" +#include "core/mount.h" +#include "core/locale.h" +#include "core/config.h" +#include "templates/misc.h" + struct NotifyMsg @@ -46,6 +48,8 @@ namespace TemplatesNotifyFunctions extern Patterns patterns; extern NotifyMsg * notify_msg; + extern Config * config; + void notify_item_added(Info & i); void notify_item_edited(Info & i); void notify_item_deleted(Info & i); @@ -68,6 +72,8 @@ public: TemplatesNotify(); + void SetConfig(Config * pconfig); + void Read(); void CreateFunctions(); void Generate(Locale::Lang lang);