added support for UTF-8
now the UTF-8 is a default charset git-svn-id: svn://ttmath.org/publicrep/winix/trunk@677 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
f1f0fa34cb
commit
8e72a820dd
|
@ -3,16 +3,19 @@
|
|||
acceptbaseparser.o: acceptbaseparser.h
|
||||
app.o: app.h config.h confparser.h htmlfilter.h system.h dirs.h item.h
|
||||
app.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
app.o: ../db/dbtextstream.h ../core/textstream.h ../core/error.h log.h
|
||||
app.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
app.o: ../db/dbtextstream.h ../core/textstream.h misc.h ../core/error.h log.h
|
||||
app.o: textstream.h ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
app.o: ../core/user.h ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
app.o: ../core/ugcontainer.h request.h requesttypes.h session.h error.h
|
||||
app.o: user.h plugindata.h rebus.h mounts.h mount.h mountparser.h users.h
|
||||
app.o: ugcontainer.h lastcontainer.h groups.h group.h loadavg.h
|
||||
app.o: 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: ../../ezc/src/utf8.h ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
app.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
app.o: ../../ezc/src/funinfo.h ../core/mount.h ../core/config.h
|
||||
app.o: ../templates/misc.h ../templates/localefilter.h ../templates/locale.h
|
||||
app.o: ../core/confparser.h ../functions/functions.h
|
||||
app.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
app.o: ../core/notify.h ../functions/functionparser.h ../functions/adduser.h
|
||||
app.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
|
@ -26,7 +29,7 @@ app.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
|||
app.o: ../functions/funthread.h ../functions/template.h
|
||||
app.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
app.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
app.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
app.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
app.o: ../templates/patterncacher.h ../core/item.h
|
||||
app.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
||||
app.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h
|
||||
|
@ -34,12 +37,12 @@ app.o: compress.h getparser.h httpsimpleparser.h postparser.h cookieparser.h
|
|||
app.o: postmultiparser.h acceptencodingparser.h acceptbaseparser.h plugin.h
|
||||
app.o: pluginmsg.h
|
||||
bbcodeparser.o: bbcodeparser.h htmlfilter.h
|
||||
compress.o: compress.h log.h
|
||||
config.o: config.h confparser.h htmlfilter.h log.h plugin.h pluginmsg.h
|
||||
config.o: plugindata.h request.h requesttypes.h session.h item.h error.h
|
||||
config.o: user.h rebus.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
compress.o: compress.h log.h textstream.h
|
||||
config.o: config.h confparser.h htmlfilter.h log.h textstream.h plugin.h
|
||||
config.o: pluginmsg.h plugindata.h request.h requesttypes.h session.h item.h
|
||||
config.o: error.h user.h rebus.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
config.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
config.o: ../core/textstream.h ../core/error.h ../db/dbitemquery.h
|
||||
config.o: ../core/textstream.h misc.h ../core/error.h ../db/dbitemquery.h
|
||||
config.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
config.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
config.o: mounts.h mount.h mountparser.h users.h ugcontainer.h
|
||||
|
@ -47,6 +50,9 @@ config.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
|
|||
config.o: sessioncontainer.h ../functions/functions.h
|
||||
config.o: ../functions/functionbase.h ../core/request.h ../core/config.h
|
||||
config.o: ../core/system.h ../core/notify.h ../../ezc/src/ezc.h
|
||||
config.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
config.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
config.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
config.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
config.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
config.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
|
@ -59,59 +65,84 @@ config.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
|||
config.o: ../functions/funthread.h ../functions/template.h
|
||||
config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
config.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
config.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
config.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
config.o: ../templates/patterncacher.h ../core/item.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
|
||||
dircontainer.o: dircontainer.h item.h log.h
|
||||
config.o: ../templates/localefilter.h ../templates/locale.h
|
||||
config.o: ../core/confparser.h ../core/sessionmanager.h
|
||||
confparser.o: confparser.h misc.h item.h ../../ezc/src/ezc.h
|
||||
confparser.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
confparser.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
confparser.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
dircontainer.o: dircontainer.h item.h log.h textstream.h
|
||||
dirs.o: dirs.h item.h dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
dirs.o: ../db/dbtextstream.h ../core/textstream.h ../core/error.h log.h
|
||||
dirs.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
dirs.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
dirs.o: ../db/dbtextstream.h ../core/textstream.h misc.h ../core/error.h
|
||||
dirs.o: log.h textstream.h ../db/dbitemquery.h ../core/item.h
|
||||
dirs.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
|
||||
dirs.o: ../core/dircontainer.h ../core/ugcontainer.h request.h requesttypes.h
|
||||
dirs.o: session.h error.h user.h plugindata.h rebus.h config.h confparser.h
|
||||
dirs.o: htmlfilter.h notify.h ../templatesnotify/templatesnotify.h
|
||||
dirs.o: ../../ezc/src/ezc.h ../core/mount.h ../core/locale.h ../core/config.h
|
||||
dirs.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
||||
dirs.o: system.h mounts.h mount.h mountparser.h users.h ugcontainer.h
|
||||
dirs.o: lastcontainer.h groups.h group.h loadavg.h
|
||||
dirs.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
dirs.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
dirs.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h ../core/mount.h
|
||||
dirs.o: ../core/config.h ../templates/misc.h ../templates/localefilter.h
|
||||
dirs.o: ../templates/locale.h ../core/confparser.h system.h mounts.h mount.h
|
||||
dirs.o: mountparser.h users.h ugcontainer.h lastcontainer.h groups.h group.h
|
||||
dirs.o: loadavg.h
|
||||
groups.o: groups.h group.h ugcontainer.h ../db/db.h ../db/dbbase.h
|
||||
groups.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
groups.o: ../core/error.h log.h ../db/dbitemquery.h ../core/item.h
|
||||
groups.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
groups.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
|
||||
groups.o: item.h ../core/error.h log.h textstream.h ../db/dbitemquery.h
|
||||
groups.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
groups.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
htmlfilter.o: htmlfilter.h
|
||||
httpsimpleparser.o: httpsimpleparser.h
|
||||
item.o: item.h misc.h
|
||||
lastcontainer.o: lastcontainer.h log.h misc.h item.h
|
||||
loadavg.o: loadavg.h log.h
|
||||
locale.o: locale.h confparser.h log.h
|
||||
log.o: log.h
|
||||
misc.o: misc.h item.h log.h
|
||||
mount.o: mount.h
|
||||
lastcontainer.o: lastcontainer.h log.h textstream.h misc.h item.h
|
||||
loadavg.o: loadavg.h log.h textstream.h
|
||||
log.o: log.h textstream.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
log.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h item.h
|
||||
log.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
log.o: ../../ezc/src/funinfo.h
|
||||
misc.o: misc.h item.h log.h textstream.h ../templates/templates.h
|
||||
misc.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
misc.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
misc.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
misc.o: ../templates/patterncacher.h ../core/item.h
|
||||
misc.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
||||
misc.o: ../core/log.h ../templates/indexpatterns.h
|
||||
misc.o: ../templates/localefilter.h ../templates/locale.h
|
||||
misc.o: ../core/confparser.h ../core/config.h ../db/db.h ../db/dbbase.h
|
||||
misc.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
misc.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
misc.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
|
||||
misc.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/request.h
|
||||
misc.o: ../core/system.h ../core/sessionmanager.h
|
||||
mount.o: mount.h misc.h item.h
|
||||
mountparser.o: mountparser.h mount.h item.h error.h dirs.h dircontainer.h
|
||||
mountparser.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
mountparser.o: ../core/textstream.h ../core/error.h log.h ../db/dbitemquery.h
|
||||
mountparser.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h
|
||||
mountparser.o: ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
mountparser.o: ../core/ugcontainer.h request.h requesttypes.h session.h
|
||||
mountparser.o: user.h plugindata.h rebus.h config.h confparser.h htmlfilter.h
|
||||
mountparser.o: misc.h
|
||||
mountparser.o: ../core/textstream.h misc.h ../core/error.h log.h textstream.h
|
||||
mountparser.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
mountparser.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
mountparser.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
|
||||
mountparser.o: requesttypes.h session.h user.h plugindata.h rebus.h config.h
|
||||
mountparser.o: confparser.h htmlfilter.h
|
||||
mounts.o: mounts.h mount.h error.h dirs.h item.h dircontainer.h ../db/db.h
|
||||
mounts.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
mounts.o: ../core/textstream.h ../core/error.h log.h ../db/dbitemquery.h
|
||||
mounts.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
mounts.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
mounts.o: request.h requesttypes.h session.h user.h plugindata.h rebus.h
|
||||
mounts.o: config.h confparser.h htmlfilter.h mountparser.h plugin.h
|
||||
mounts.o: pluginmsg.h system.h users.h ugcontainer.h lastcontainer.h groups.h
|
||||
mounts.o: group.h loadavg.h sessionmanager.h sessioncontainer.h
|
||||
mounts.o: ../core/textstream.h misc.h ../core/error.h log.h textstream.h
|
||||
mounts.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
mounts.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
mounts.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
|
||||
mounts.o: requesttypes.h session.h user.h plugindata.h rebus.h config.h
|
||||
mounts.o: confparser.h htmlfilter.h mountparser.h plugin.h pluginmsg.h
|
||||
mounts.o: system.h users.h ugcontainer.h lastcontainer.h groups.h group.h
|
||||
mounts.o: loadavg.h sessionmanager.h sessioncontainer.h
|
||||
mounts.o: ../functions/functions.h ../functions/functionbase.h
|
||||
mounts.o: ../core/request.h ../core/config.h ../core/system.h
|
||||
mounts.o: ../core/notify.h ../../ezc/src/ezc.h ../functions/functionparser.h
|
||||
mounts.o: ../core/notify.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
mounts.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
mounts.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
mounts.o: ../../ezc/src/funinfo.h ../functions/functionparser.h
|
||||
mounts.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
mounts.o: ../functions/privchanger.h ../functions/chown.h
|
||||
mounts.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
|
@ -124,29 +155,31 @@ mounts.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
|||
mounts.o: ../functions/funthread.h ../functions/template.h
|
||||
mounts.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
mounts.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
mounts.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
mounts.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
mounts.o: ../templates/patterncacher.h ../core/item.h
|
||||
mounts.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
||||
mounts.o: ../core/log.h ../templates/indexpatterns.h
|
||||
mounts.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h
|
||||
mounts.o: ../core/sessionmanager.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 ../core/user.h request.h requesttypes.h session.h
|
||||
notify.o: item.h error.h user.h plugindata.h rebus.h config.h htmlfilter.h
|
||||
notify.o: system.h dirs.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
notify.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
notify.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
notify.o: ../db/dbitemcolumns.h ../core/group.h ../core/thread.h
|
||||
notify.o: ../core/dircontainer.h ../core/ugcontainer.h mounts.h mount.h
|
||||
notify.o: mountparser.h users.h ugcontainer.h lastcontainer.h groups.h
|
||||
notify.o: group.h loadavg.h misc.h
|
||||
plugin.o: plugin.h pluginmsg.h log.h plugindata.h config.h confparser.h
|
||||
plugin.o: htmlfilter.h request.h requesttypes.h session.h item.h error.h
|
||||
plugin.o: user.h rebus.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
mounts.o: ../templates/localefilter.h ../templates/locale.h
|
||||
mounts.o: ../core/confparser.h ../core/sessionmanager.h
|
||||
notify.o: log.h textstream.h notify.h ../templatesnotify/templatesnotify.h
|
||||
notify.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
notify.o: ../../ezc/src/pattern.h item.h ../../ezc/src/stringconv.h
|
||||
notify.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h ../core/mount.h
|
||||
notify.o: ../core/config.h ../core/textstream.h misc.h ../templates/misc.h
|
||||
notify.o: ../templates/localefilter.h ../templates/locale.h
|
||||
notify.o: ../core/confparser.h ../core/user.h request.h requesttypes.h
|
||||
notify.o: session.h error.h user.h plugindata.h rebus.h config.h confparser.h
|
||||
notify.o: htmlfilter.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
notify.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
notify.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
notify.o: ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
notify.o: ../core/ugcontainer.h mounts.h mount.h mountparser.h users.h
|
||||
notify.o: ugcontainer.h lastcontainer.h groups.h group.h loadavg.h
|
||||
plugin.o: plugin.h pluginmsg.h log.h textstream.h plugindata.h config.h
|
||||
plugin.o: confparser.h htmlfilter.h request.h requesttypes.h session.h item.h
|
||||
plugin.o: error.h user.h rebus.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
plugin.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
plugin.o: ../core/textstream.h ../core/error.h ../db/dbitemquery.h
|
||||
plugin.o: ../core/textstream.h misc.h ../core/error.h ../db/dbitemquery.h
|
||||
plugin.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
plugin.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
plugin.o: mounts.h mount.h mountparser.h users.h ugcontainer.h
|
||||
|
@ -154,6 +187,9 @@ plugin.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
|
|||
plugin.o: sessioncontainer.h ../functions/functions.h
|
||||
plugin.o: ../functions/functionbase.h ../core/request.h ../core/config.h
|
||||
plugin.o: ../core/system.h ../core/notify.h ../../ezc/src/ezc.h
|
||||
plugin.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
plugin.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
plugin.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
plugin.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
plugin.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
plugin.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
|
@ -166,17 +202,17 @@ plugin.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
|||
plugin.o: ../functions/funthread.h ../functions/template.h
|
||||
plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
plugin.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
plugin.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
plugin.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
plugin.o: ../templates/patterncacher.h ../core/item.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: htmlfilter.h request.h requesttypes.h session.h item.h error.h
|
||||
plugindata.o: user.h rebus.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
plugindata.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
plugindata.o: ../core/textstream.h ../core/error.h ../db/dbitemquery.h
|
||||
plugin.o: ../templates/localefilter.h ../templates/locale.h
|
||||
plugin.o: ../core/confparser.h ../core/sessionmanager.h
|
||||
plugindata.o: plugindata.h plugin.h pluginmsg.h log.h textstream.h config.h
|
||||
plugindata.o: confparser.h htmlfilter.h request.h requesttypes.h session.h
|
||||
plugindata.o: item.h error.h user.h rebus.h system.h dirs.h dircontainer.h
|
||||
plugindata.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
plugindata.o: ../core/textstream.h misc.h ../core/error.h ../db/dbitemquery.h
|
||||
plugindata.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h
|
||||
plugindata.o: ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
plugindata.o: ../core/ugcontainer.h mounts.h mount.h mountparser.h users.h
|
||||
|
@ -184,6 +220,9 @@ plugindata.o: ugcontainer.h lastcontainer.h groups.h group.h loadavg.h
|
|||
plugindata.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/config.h
|
||||
plugindata.o: ../core/system.h ../core/notify.h ../../ezc/src/ezc.h
|
||||
plugindata.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
plugindata.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
plugindata.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.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
|
||||
|
@ -198,31 +237,40 @@ plugindata.o: ../functions/subject.h ../functions/funthread.h
|
|||
plugindata.o: ../functions/template.h ../functions/tinymce.h
|
||||
plugindata.o: ../functions/uname.h ../functions/upload.h
|
||||
plugindata.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
plugindata.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
plugindata.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
plugindata.o: ../templates/patterncacher.h ../core/item.h
|
||||
plugindata.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
||||
plugindata.o: ../core/log.h ../templates/indexpatterns.h
|
||||
plugindata.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h
|
||||
plugindata.o: ../core/sessionmanager.h
|
||||
plugindata.o: ../templates/localefilter.h ../templates/locale.h
|
||||
plugindata.o: ../core/confparser.h ../core/sessionmanager.h
|
||||
postmultiparser.o: postmultiparser.h error.h requesttypes.h config.h
|
||||
postmultiparser.o: confparser.h htmlfilter.h log.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 config.h confparser.h htmlfilter.h
|
||||
postmultiparser.o: confparser.h htmlfilter.h log.h textstream.h
|
||||
postmultiparser.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
postmultiparser.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h item.h
|
||||
postmultiparser.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
postmultiparser.o: ../../ezc/src/funinfo.h misc.h
|
||||
rebus.o: log.h textstream.h rebus.h misc.h item.h request.h requesttypes.h
|
||||
rebus.o: session.h error.h user.h plugindata.h config.h confparser.h
|
||||
rebus.o: htmlfilter.h
|
||||
request.o: request.h requesttypes.h session.h item.h error.h user.h
|
||||
request.o: plugindata.h rebus.h config.h confparser.h htmlfilter.h log.h
|
||||
request.o: plugin.h pluginmsg.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
request.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
request.o: ../core/textstream.h ../core/error.h ../db/dbitemquery.h
|
||||
request.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h
|
||||
request.o: ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
request.o: ../core/ugcontainer.h mounts.h mount.h mountparser.h users.h
|
||||
request.o: ugcontainer.h lastcontainer.h groups.h group.h loadavg.h
|
||||
request.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
request.o: ../functions/functionbase.h ../core/request.h ../core/config.h
|
||||
request.o: ../core/system.h ../core/notify.h ../../ezc/src/ezc.h
|
||||
request.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
request.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
request.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
request.o: plugindata.h rebus.h config.h confparser.h htmlfilter.h
|
||||
request.o: textstream.h log.h plugin.h pluginmsg.h system.h dirs.h
|
||||
request.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
request.o: ../db/dbtextstream.h ../core/textstream.h misc.h ../core/error.h
|
||||
request.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
request.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
request.o: ../core/dircontainer.h ../core/ugcontainer.h mounts.h mount.h
|
||||
request.o: mountparser.h users.h ugcontainer.h lastcontainer.h groups.h
|
||||
request.o: group.h loadavg.h sessionmanager.h sessioncontainer.h
|
||||
request.o: ../functions/functions.h ../functions/functionbase.h
|
||||
request.o: ../core/request.h ../core/config.h ../core/system.h
|
||||
request.o: ../core/notify.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
request.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
request.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
request.o: ../../ezc/src/funinfo.h ../functions/functionparser.h
|
||||
request.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
request.o: ../functions/privchanger.h ../functions/chown.h
|
||||
request.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
request.o: ../functions/createthread.h ../functions/default.h
|
||||
request.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
request.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
|
@ -232,81 +280,87 @@ request.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
|||
request.o: ../functions/funthread.h ../functions/template.h
|
||||
request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
request.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
request.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
request.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
request.o: ../templates/patterncacher.h ../core/item.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
|
||||
request.o: ../templates/localefilter.h ../templates/locale.h
|
||||
request.o: ../core/confparser.h ../core/sessionmanager.h
|
||||
session.o: session.h item.h error.h user.h plugindata.h rebus.h misc.h
|
||||
sessioncontainer.o: sessioncontainer.h session.h item.h error.h user.h
|
||||
sessioncontainer.o: plugindata.h rebus.h lastcontainer.h log.h misc.h
|
||||
sessioncontainer.o: plugindata.h rebus.h lastcontainer.h log.h textstream.h
|
||||
sessioncontainer.o: misc.h
|
||||
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h
|
||||
sessionmanager.o: error.h user.h plugindata.h rebus.h lastcontainer.h
|
||||
sessionmanager.o: config.h confparser.h htmlfilter.h request.h requesttypes.h
|
||||
sessionmanager.o: system.h dirs.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
sessionmanager.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
sessionmanager.o: ../core/error.h log.h ../db/dbitemquery.h ../core/item.h
|
||||
sessionmanager.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
sessionmanager.o: ../core/thread.h ../core/dircontainer.h
|
||||
sessionmanager.o: ../core/ugcontainer.h mounts.h mount.h mountparser.h
|
||||
sessionmanager.o: users.h ugcontainer.h groups.h group.h loadavg.h
|
||||
sessionmanager.o: sessionparser.h plugin.h pluginmsg.h
|
||||
sessionmanager.o: textstream.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
sessionmanager.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
sessionmanager.o: ../core/textstream.h misc.h ../core/error.h log.h
|
||||
sessionmanager.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
sessionmanager.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
sessionmanager.o: ../core/dircontainer.h ../core/ugcontainer.h mounts.h
|
||||
sessionmanager.o: mount.h mountparser.h users.h ugcontainer.h groups.h
|
||||
sessionmanager.o: group.h loadavg.h sessionparser.h plugin.h pluginmsg.h
|
||||
sessionmanager.o: ../functions/functions.h ../functions/functionbase.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/ckeditor.h ../functions/cp.h
|
||||
sessionmanager.o: ../functions/createthread.h ../functions/default.h
|
||||
sessionmanager.o: ../functions/download.h ../functions/emacs.h
|
||||
sessionmanager.o: ../functions/last.h ../functions/login.h
|
||||
sessionmanager.o: ../functions/logout.h ../functions/ls.h
|
||||
sessionmanager.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h
|
||||
sessionmanager.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h
|
||||
sessionmanager.o: ../functions/run.h ../functions/stat.h
|
||||
sessionmanager.o: ../functions/subject.h ../functions/funthread.h
|
||||
sessionmanager.o: ../functions/template.h ../functions/tinymce.h
|
||||
sessionmanager.o: ../functions/uname.h ../functions/upload.h
|
||||
sessionmanager.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
sessionmanager.o: ../core/htmlfilter.h ../templates/templates.h misc.h
|
||||
sessionmanager.o: ../templates/patterncacher.h ../core/item.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
|
||||
sessionmanager.o: ../core/notify.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
sessionmanager.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
sessionmanager.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
sessionmanager.o: ../../ezc/src/funinfo.h ../functions/functionparser.h
|
||||
sessionmanager.o: ../functions/adduser.h ../functions/cat.h
|
||||
sessionmanager.o: ../functions/chmod.h ../functions/privchanger.h
|
||||
sessionmanager.o: ../functions/chown.h ../functions/ckeditor.h
|
||||
sessionmanager.o: ../functions/cp.h ../functions/createthread.h
|
||||
sessionmanager.o: ../functions/default.h ../functions/download.h
|
||||
sessionmanager.o: ../functions/emacs.h ../functions/last.h
|
||||
sessionmanager.o: ../functions/login.h ../functions/logout.h
|
||||
sessionmanager.o: ../functions/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/stat.h ../functions/subject.h
|
||||
sessionmanager.o: ../functions/funthread.h ../functions/template.h
|
||||
sessionmanager.o: ../functions/tinymce.h ../functions/uname.h
|
||||
sessionmanager.o: ../functions/upload.h ../functions/uptime.h
|
||||
sessionmanager.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
|
||||
sessionmanager.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
sessionmanager.o: ../core/item.h ../templates/ckeditorgetparser.h
|
||||
sessionmanager.o: ../core/httpsimpleparser.h ../core/log.h
|
||||
sessionmanager.o: ../templates/indexpatterns.h ../templates/localefilter.h
|
||||
sessionmanager.o: ../templates/locale.h ../core/confparser.h
|
||||
sessionmanager.o: ../core/sessionmanager.h
|
||||
sessionparser.o: sessionparser.h session.h item.h error.h user.h plugindata.h
|
||||
sessionparser.o: rebus.h sessioncontainer.h lastcontainer.h users.h
|
||||
sessionparser.o: ugcontainer.h request.h requesttypes.h config.h confparser.h
|
||||
sessionparser.o: htmlfilter.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
sessionparser.o: ../db/dbtextstream.h ../core/textstream.h ../core/error.h
|
||||
sessionparser.o: log.h ../db/dbitemquery.h ../core/item.h
|
||||
sessionparser.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
sessionparser.o: ../core/thread.h ../core/dircontainer.h
|
||||
sessionparser.o: ../core/ugcontainer.h misc.h
|
||||
sessionparser.o: htmlfilter.h textstream.h ../db/db.h ../db/dbbase.h
|
||||
sessionparser.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
sessionparser.o: misc.h ../core/error.h log.h ../db/dbitemquery.h
|
||||
sessionparser.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h
|
||||
sessionparser.o: ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
sessionparser.o: ../core/ugcontainer.h
|
||||
system.o: system.h dirs.h item.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
system.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
system.o: ../core/error.h log.h ../db/dbitemquery.h ../core/item.h
|
||||
system.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
system.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
|
||||
system.o: ../core/error.h log.h textstream.h ../db/dbitemquery.h
|
||||
system.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
system.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
system.o: request.h requesttypes.h session.h error.h user.h plugindata.h
|
||||
system.o: rebus.h config.h confparser.h htmlfilter.h mounts.h mount.h
|
||||
system.o: mountparser.h users.h ugcontainer.h lastcontainer.h groups.h
|
||||
system.o: group.h loadavg.h misc.h notify.h
|
||||
system.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h
|
||||
system.o: ../core/mount.h ../core/locale.h ../core/config.h
|
||||
system.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
||||
system.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
system.o: ../core/item.h ../templates/ckeditorgetparser.h
|
||||
system.o: ../core/httpsimpleparser.h ../core/log.h
|
||||
system.o: ../templates/indexpatterns.h ../core/request.h ../core/system.h
|
||||
system.o: ../core/sessionmanager.h
|
||||
textstream.o: textstream.h
|
||||
system.o: group.h loadavg.h notify.h ../templatesnotify/templatesnotify.h
|
||||
system.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
system.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
system.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h ../core/mount.h
|
||||
system.o: ../core/config.h ../templates/misc.h ../templates/localefilter.h
|
||||
system.o: ../templates/locale.h ../core/confparser.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/request.h
|
||||
system.o: ../core/system.h ../core/sessionmanager.h
|
||||
textstream.o: textstream.h misc.h item.h
|
||||
users.o: users.h user.h ugcontainer.h lastcontainer.h request.h
|
||||
users.o: requesttypes.h session.h item.h error.h plugindata.h rebus.h
|
||||
users.o: config.h confparser.h htmlfilter.h ../db/db.h ../db/dbbase.h
|
||||
users.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
users.o: ../core/error.h log.h ../db/dbitemquery.h ../core/item.h
|
||||
users.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
users.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
users.o: config.h confparser.h htmlfilter.h textstream.h ../db/db.h
|
||||
users.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
users.o: ../core/textstream.h misc.h ../core/error.h log.h
|
||||
users.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
users.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
users.o: ../core/dircontainer.h ../core/ugcontainer.h
|
||||
|
|
|
@ -1 +1 @@
|
|||
o = acceptbaseparser.o app.o bbcodeparser.o compress.o config.o confparser.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o item.o lastcontainer.o loadavg.o 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 textstream.o users.o
|
||||
o = acceptbaseparser.o app.o bbcodeparser.o compress.o config.o confparser.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o item.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o plugindata.o postmultiparser.o rebus.o request.o session.o sessioncontainer.o sessionmanager.o sessionparser.o system.o textstream.o users.o
|
||||
|
|
68
core/app.cpp
68
core/app.cpp
|
@ -16,7 +16,7 @@
|
|||
#include "plugin.h"
|
||||
#include "misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -161,11 +161,11 @@ bool App::Init()
|
|||
2 ); // !! chwilowo
|
||||
//system.mounts.MountTypeTicket() );
|
||||
|
||||
|
||||
// init templates after functions are created
|
||||
templates.ReadIndexFileNames();
|
||||
templates.ReadTemplates();
|
||||
templates.CreateFunctions();
|
||||
|
||||
session_manager.LoadSessions();
|
||||
|
||||
plugin.Call(WINIX_PLUGIN_INIT);
|
||||
|
@ -190,10 +190,11 @@ bool App::BaseUrlRedirect()
|
|||
if( config.base_url_http_host.empty() )
|
||||
return false;
|
||||
|
||||
if( config.base_url_http_host == request.env_http_host )
|
||||
if( Equal(config.base_url_http_host.c_str(), request.env_http_host) )
|
||||
return false;
|
||||
|
||||
request.redirect_to = config.base_url + request.env_request_uri;
|
||||
request.redirect_to = config.base_url;
|
||||
AssignString(request.env_request_uri, request.redirect_to, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -202,10 +203,11 @@ bool App::BaseUrlRedirect()
|
|||
if( config.base_url_auth_http_host.empty() )
|
||||
return false;
|
||||
|
||||
if( config.base_url_auth_http_host == request.env_http_host )
|
||||
if( Equal(config.base_url_auth_http_host.c_str(), request.env_http_host) )
|
||||
return false;
|
||||
|
||||
request.redirect_to = config.base_url_auth + request.env_request_uri;
|
||||
request.redirect_to = config.base_url_auth;
|
||||
AssignString(request.env_request_uri, request.redirect_to, false);
|
||||
}
|
||||
|
||||
log << log3 << "RC: BaseUrlRedirect from: " << request.env_http_host << logend;
|
||||
|
@ -309,13 +311,13 @@ bool sent = false;
|
|||
if( request.is_item && request.item.auth == Item::auth_none &&
|
||||
request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.function )
|
||||
{
|
||||
if( request.function->fun.url == "cat" )
|
||||
if( request.function == &functions.fun_cat )
|
||||
{
|
||||
request.page << request.item.content;
|
||||
sent = true;
|
||||
}
|
||||
else
|
||||
if( request.function->fun.url == "run" )
|
||||
if( request.function == &functions.fun_run )
|
||||
{
|
||||
templates.GenerateRunRaw();
|
||||
sent = true;
|
||||
|
@ -358,7 +360,7 @@ void App::Make()
|
|||
if( request.session->spam_score > 0 )
|
||||
log << log1 << "App: spam score: " << request.session->spam_score << logend;
|
||||
|
||||
if( request.IsParam("noredirect") )
|
||||
if( request.IsParam(L"noredirect") )
|
||||
request.redirect_to.clear();
|
||||
|
||||
if( request.status == WINIX_ERR_OK )
|
||||
|
@ -484,6 +486,7 @@ void App::LogAccess()
|
|||
void App::ReadGetPostVars()
|
||||
{
|
||||
// get parameters we have always
|
||||
get_parser.UTF8(config.utf8);
|
||||
get_parser.Parse(request.env_request_uri, request.get_tab);
|
||||
|
||||
if( request.method == Request::post )
|
||||
|
@ -491,10 +494,14 @@ void App::ReadGetPostVars()
|
|||
if( IsSubStringNoCase("multipart/form-data", request.env_content_type) )
|
||||
{
|
||||
log << log3 << "Request: post content type: multipart/form-data" << logend;
|
||||
// !! dodac metode UTF8 do post_multi_parsera
|
||||
// (narazie bierze bezposrednio z konfigu)
|
||||
// w ogole wywalic zaleznosc od konfiga
|
||||
post_multi_parser.Parse(request.in, request.post_tab, request.post_file_tab);
|
||||
}
|
||||
else
|
||||
{
|
||||
post_parser.UTF8(config.utf8);
|
||||
post_parser.Parse(request.in, request.post_tab);
|
||||
}
|
||||
}
|
||||
|
@ -560,14 +567,19 @@ void App::SendHeaders(bool compressing, Header header)
|
|||
if( !request.redirect_to.empty() )
|
||||
{
|
||||
FCGX_PutS("Status: 301 Moved Permanently\r\n", request.out);
|
||||
FCGX_FPrintF(request.out, "Location: %s\r\n", request.redirect_to.c_str());
|
||||
AssignString(request.redirect_to, request.aredirect_to);
|
||||
FCGX_FPrintF(request.out, "Location: %s\r\n", request.aredirect_to.c_str());
|
||||
log << log2 << "Redirect to: " << request.redirect_to << logend;
|
||||
}
|
||||
else
|
||||
if( !request.x_sendfile.empty() )
|
||||
{
|
||||
FCGX_FPrintF(request.out, "%s: %s\r\n", config.http_header_send_file.c_str(),
|
||||
request.x_sendfile.c_str());
|
||||
static std::string temp, temp2; // !! wrzucic gdzies to
|
||||
|
||||
AssignString(config.http_header_send_file, temp);
|
||||
AssignString(request.x_sendfile, temp2);
|
||||
FCGX_FPrintF(request.out, "%s: %s\r\n", temp.c_str(), temp2.c_str());
|
||||
|
||||
FCGX_PutS("Status: 200 OK\r\n", request.out);
|
||||
log << log2 << "Sending file: " << request.x_sendfile << logend;
|
||||
}
|
||||
|
@ -598,7 +610,7 @@ void App::SendHeaders(bool compressing, Header header)
|
|||
if( compressing )
|
||||
FCGX_PutS("Content-Encoding: deflate\r\n", request.out);
|
||||
|
||||
FCGX_PutS(request.headers.str().c_str(), request.out);
|
||||
FCGX_PutS(request.headers.CStr(), request.out);
|
||||
FCGX_PutS("\r\n", request.out);
|
||||
}
|
||||
|
||||
|
@ -617,12 +629,12 @@ void App::SetHtmlFilterConf()
|
|||
|
||||
// !! kopiowanie tych stringow bedzie zmienione
|
||||
// gdy bedziemy korzystac w przyszlosci z wlasnego stringstream
|
||||
void App::FilterCompressSend(bool compressing, const std::string & source_ref)
|
||||
void App::FilterCompressSend(bool compressing, const std::wstring & source_ref)
|
||||
{
|
||||
const std::string * source = &source_ref;
|
||||
const std::wstring * source = &source_ref;
|
||||
|
||||
bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK &&
|
||||
request.function && (request.function->fun.url == "cat" || request.function->fun.url == "run");
|
||||
request.function && (request.function == &functions.fun_cat || request.function == &functions.fun_run);
|
||||
|
||||
if( config.html_filter && !raw )
|
||||
{
|
||||
|
@ -639,15 +651,19 @@ void App::FilterCompressSend(bool compressing, const std::string & source_ref)
|
|||
}
|
||||
|
||||
|
||||
// !! zrobic z tym porzadek
|
||||
std::string temp;
|
||||
Ezc::WideToUTF8(*source, temp);
|
||||
|
||||
if( compressing )
|
||||
compress.CompressAndPut(source->c_str(), source->length(), request.out);
|
||||
compress.CompressAndPut(temp.c_str(), temp.length(), request.out);
|
||||
else
|
||||
FCGX_PutS(source->c_str(), request.out);
|
||||
FCGX_PutS(temp.c_str(), request.out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool App::IsCompressionAllowed(const std::string & source)
|
||||
bool App::IsCompressionAllowed(const std::wstring & source)
|
||||
{
|
||||
return( config.compression &&
|
||||
request.role == Request::responder &&
|
||||
|
@ -681,17 +697,15 @@ return true;
|
|||
}
|
||||
|
||||
|
||||
void App::AddDebugInfo(std::string & out)
|
||||
void App::AddDebugInfo(std::wstring & out)
|
||||
{
|
||||
if( config.debug_info )
|
||||
{
|
||||
const std::string & d = request.debug.str();
|
||||
|
||||
if( !d.empty() )
|
||||
if( !request.debug.Empty() )
|
||||
{
|
||||
out += "\n<!--\n";
|
||||
out += d;
|
||||
out += "\n-->\n";
|
||||
out += L"\n<!--\n";
|
||||
out += request.debug.Str();
|
||||
out += L"\n-->\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -700,7 +714,7 @@ void App::AddDebugInfo(std::string & out)
|
|||
|
||||
void App::SendAnswer()
|
||||
{
|
||||
const std::string & source = request.page.str();
|
||||
const std::wstring & source = request.page.Str();
|
||||
Header header = h_200;
|
||||
bool compressing = IsCompressionAllowed(source);
|
||||
Error status = request.status;
|
||||
|
|
|
@ -119,7 +119,7 @@ private:
|
|||
AcceptEncodingParser accept_encoding_parser;
|
||||
Compress compress;
|
||||
HTMLFilter html_filter;
|
||||
std::string clean_html, html_with_debug;
|
||||
std::wstring clean_html, html_with_debug;
|
||||
|
||||
bool CreateFCGISocket();
|
||||
void ProcessRequestThrow();
|
||||
|
@ -145,10 +145,10 @@ private:
|
|||
|
||||
void SetHtmlFilterConf();
|
||||
void PrepareSessionCookie();
|
||||
void AddDebugInfo(std::string & out);
|
||||
void FilterCompressSend(bool compressing, const std::string & source_ref);
|
||||
void AddDebugInfo(std::wstring & out);
|
||||
void FilterCompressSend(bool compressing, const std::wstring & source_ref);
|
||||
void SendHeaders(bool compressing, Header header);
|
||||
bool IsCompressionAllowed(const std::string & source);
|
||||
bool IsCompressionAllowed(const std::wstring & source);
|
||||
bool CanSendContent(Header header);
|
||||
|
||||
void LogUser(const char * msg, uid_t id);
|
||||
|
|
|
@ -10,6 +10,17 @@
|
|||
#include "bbcodeparser.h"
|
||||
|
||||
|
||||
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
|
||||
{
|
||||
while( *str1 == *str2 && *str1 != 0 )
|
||||
{
|
||||
str1 += 1;
|
||||
str2 += 1;
|
||||
}
|
||||
|
||||
return *str1 == *str2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -58,7 +69,7 @@ bool BBCODEParser::IsClosingXmlSimpleTagMark()
|
|||
|
||||
// one enter will generate one <br>
|
||||
// two enters or more will generate only two br (<br><br>)
|
||||
void BBCODEParser::PutNormalText(const char * str, const char * end)
|
||||
void BBCODEParser::PutNormalText(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
int br_len;
|
||||
|
||||
|
@ -93,7 +104,7 @@ int br_len;
|
|||
if( !has_open_ol_tag && !has_open_ul_tag && !has_open_li_tag )
|
||||
{
|
||||
for(int i=0 ; i < br_len ; ++i)
|
||||
(*out_string) += "<br>\n";
|
||||
(*out_string) += L"<br>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -105,14 +116,14 @@ int br_len;
|
|||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutNormalTextTrim(const char * str, const char * end)
|
||||
void BBCODEParser::PutNormalTextTrim(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
// we don't use trimming in bbcode parser
|
||||
PutNormalText(str, end);
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::ReadNormalTextSkipWhite(const char * & start, const char * & last_non_white)
|
||||
void BBCODEParser::ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -123,8 +134,8 @@ void BBCODEParser::CheckExceptions()
|
|||
{
|
||||
if( pstack[stack_len-1].type == Item::opening &&
|
||||
pstack[stack_len-2].type == Item::opening &&
|
||||
IsNameEqual("*", pstack[stack_len-1].name) &&
|
||||
IsNameEqual("*", pstack[stack_len-2].name) )
|
||||
IsNameEqual(L"*", pstack[stack_len-1].name) &&
|
||||
IsNameEqual(L"*", pstack[stack_len-2].name) )
|
||||
{
|
||||
// removing the last [*] from the stack
|
||||
// </li> was put automatically
|
||||
|
@ -162,20 +173,20 @@ void BBCODEParser::CheckExceptions()
|
|||
at the beginning and at the end
|
||||
(because otherwise a space would be changed to %20 and this were probably not what you really wanted)
|
||||
*/
|
||||
const BBCODEParser::Tags * BBCODEParser::FindTag(const char * tag)
|
||||
const BBCODEParser::Tags * BBCODEParser::FindTag(const wchar_t * tag)
|
||||
{
|
||||
static Tags tags[] = {
|
||||
{"*", "li", ">", false},
|
||||
{"b", "em", ">", true},
|
||||
{"i", "span", " class=\"bbitalic\">", true},
|
||||
{"u", "span", " class=\"bbunderline\">", true},
|
||||
{"s", "span", " class=\"bbstrike\">", true},
|
||||
{"code", "code", " class=\"bbcode\">", false},
|
||||
{"list", "ul", " class=\"bblist\">", false},
|
||||
{"color", "span", " class=\"bbcol%1\">", true},
|
||||
{"url", "a", " href=\"%u1\">", true},
|
||||
{"img", "img", " alt=\"%1\" src=\"%u2\">", true},
|
||||
{"quote", "div", " class=\"bbquote\">\n<span class=\"bbquotewho\">%1</span><br>\n", false},
|
||||
{L"*", L"li", L">", false},
|
||||
{L"b", L"em", L">", true},
|
||||
{L"i", L"span", L" class=\"bbitalic\">", true},
|
||||
{L"u", L"span", L" class=\"bbunderline\">", true},
|
||||
{L"s", L"span", L" class=\"bbstrike\">", true},
|
||||
{L"code", L"code", L" class=\"bbcode\">", false},
|
||||
{L"list", L"ul", L" class=\"bblist\">", false},
|
||||
{L"color", L"span", L" class=\"bbcol%1\">", true},
|
||||
{L"url", L"a", L" href=\"%u1\">", true},
|
||||
{L"img", L"img", L" alt=\"%1\" src=\"%u2\">", true},
|
||||
{L"quote", L"div", L" class=\"bbquote\">\n<span class=\"bbquotewho\">%1</span><br>\n", false},
|
||||
};
|
||||
|
||||
size_t i;
|
||||
|
@ -183,7 +194,7 @@ const BBCODEParser::Tags * BBCODEParser::FindTag(const char * tag)
|
|||
|
||||
for(i=0 ; i<len ; ++i)
|
||||
{
|
||||
if( strcmp(tag, tags[i].bbcode) == 0 )
|
||||
if( Equal(tag, tags[i].bbcode) )
|
||||
return &tags[i];
|
||||
}
|
||||
|
||||
|
@ -191,7 +202,7 @@ return 0;
|
|||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentCheckQuotes(const char * & start, const char * & end)
|
||||
void BBCODEParser::PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end)
|
||||
{
|
||||
// skipping white characters from the argument
|
||||
while( start<end && IsWhite(*start) )
|
||||
|
@ -230,7 +241,7 @@ void BBCODEParser::PrintEncode(int c)
|
|||
{
|
||||
if( c == '&' )
|
||||
{
|
||||
(*out_string) += "&";
|
||||
(*out_string) += L"&";
|
||||
}
|
||||
else
|
||||
if( (c>='a' && c<='z') ||
|
||||
|
@ -244,8 +255,8 @@ void BBCODEParser::PrintEncode(int c)
|
|||
}
|
||||
else
|
||||
{
|
||||
char buffer[20];
|
||||
sprintf(buffer, "%02X", c);
|
||||
wchar_t buffer[20];
|
||||
swprintf(buffer, 20, L"%02X", c);
|
||||
|
||||
(*out_string) += '%';
|
||||
(*out_string) += buffer;
|
||||
|
@ -257,22 +268,22 @@ void BBCODEParser::PrintEscape(int c, bool change_quote)
|
|||
{
|
||||
if( c == '<' )
|
||||
{
|
||||
(*out_string) += "<";
|
||||
(*out_string) += L"<";
|
||||
}
|
||||
else
|
||||
if( c == '>' )
|
||||
{
|
||||
(*out_string) += ">";
|
||||
(*out_string) += L">";
|
||||
}
|
||||
else
|
||||
if( c == '&' )
|
||||
{
|
||||
(*out_string) += "&";
|
||||
(*out_string) += L"&";
|
||||
}
|
||||
else
|
||||
if( c == '\"' && change_quote )
|
||||
{
|
||||
(*out_string) += """;
|
||||
(*out_string) += L""";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -281,7 +292,7 @@ void BBCODEParser::PrintEscape(int c, bool change_quote)
|
|||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentEncode(const char * start, const char * end)
|
||||
void BBCODEParser::PrintArgumentEncode(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
PrintArgumentCheckQuotes(start, end);
|
||||
TrimWhiteWithNewLines(start, end);
|
||||
|
@ -291,7 +302,7 @@ void BBCODEParser::PrintArgumentEncode(const char * start, const char * end)
|
|||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentEscape(const char * start, const char * end)
|
||||
void BBCODEParser::PrintArgumentEscape(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
PrintArgumentCheckQuotes(start, end);
|
||||
|
||||
|
@ -300,9 +311,9 @@ void BBCODEParser::PrintArgumentEscape(const char * start, const char * end)
|
|||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckOpeningTag(const Tags * tag, const char * tag_name, bool & condition)
|
||||
void BBCODEParser::CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition)
|
||||
{
|
||||
if( strcmp(tag->html_tag, tag_name) == 0 )
|
||||
if( Equal(tag->html_tag, tag_name) )
|
||||
{
|
||||
if( condition )
|
||||
{
|
||||
|
@ -319,13 +330,13 @@ void BBCODEParser::CheckOpeningTag(const Tags * tag)
|
|||
{
|
||||
bool has_list_tag = has_open_ul_tag || has_open_ol_tag;
|
||||
|
||||
CheckOpeningTag(tag, "li", has_open_li_tag);
|
||||
CheckOpeningTag(tag, "ul", has_open_ul_tag);
|
||||
CheckOpeningTag(tag, "ol", has_open_ol_tag);
|
||||
CheckOpeningTag(tag, L"li", has_open_li_tag);
|
||||
CheckOpeningTag(tag, L"ul", has_open_ul_tag);
|
||||
CheckOpeningTag(tag, L"ol", has_open_ol_tag);
|
||||
|
||||
if( has_open_li_tag && !has_list_tag )
|
||||
{
|
||||
(*out_string) += "<ul>\n";
|
||||
(*out_string) += L"<ul>\n";
|
||||
has_open_ul_tag = true;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +345,7 @@ void BBCODEParser::CheckOpeningTag(const Tags * tag)
|
|||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEscape(const char * start, const char * end, bool change_quote)
|
||||
void BBCODEParser::PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote)
|
||||
{
|
||||
for( ; start < end ; ++start)
|
||||
PrintEscape(*start, change_quote);
|
||||
|
@ -342,7 +353,7 @@ void BBCODEParser::PrintEscape(const char * start, const char * end, bool change
|
|||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEncode(const char * start, const char * end)
|
||||
void BBCODEParser::PrintEncode(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
for( ; start < end ; ++start)
|
||||
PrintEncode(*start);
|
||||
|
@ -350,7 +361,7 @@ void BBCODEParser::PrintEncode(const char * start, const char * end)
|
|||
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTagFromEzc(const char * start, const char * end)
|
||||
void BBCODEParser::PutOpeningTagFromEzc(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
// this can be a tag from Ezc templates system
|
||||
(*out_string) += '[';
|
||||
|
@ -369,7 +380,7 @@ void BBCODEParser::PutOpeningTagFromEzc(const char * start, const char * end)
|
|||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument1(const char * arg_start, const char * arg_end, bool has_u)
|
||||
void BBCODEParser::PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u)
|
||||
{
|
||||
if( has_u )
|
||||
PrintArgumentEncode(arg_start, arg_end);
|
||||
|
@ -379,7 +390,7 @@ void BBCODEParser::PutHtmlArgument1(const char * arg_start, const char * arg_end
|
|||
|
||||
|
||||
|
||||
void BBCODEParser::TrimWhiteWithNewLines(const char * & start, const char * & end)
|
||||
void BBCODEParser::TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end)
|
||||
{
|
||||
while( start < end && (IsWhite(*start) || *start==10) )
|
||||
++start;
|
||||
|
@ -392,8 +403,8 @@ void BBCODEParser::TrimWhiteWithNewLines(const char * & start, const char * & en
|
|||
|
||||
void BBCODEParser::PutHtmlArgument2(const Tags * tag, bool has_u)
|
||||
{
|
||||
const char * start = pchar;
|
||||
const char * end = pchar;
|
||||
const wchar_t * start = pchar;
|
||||
const wchar_t * end = pchar;
|
||||
bool first_tag_removed = false;
|
||||
|
||||
while( *pchar != 0 )
|
||||
|
@ -432,9 +443,9 @@ bool first_tag_removed = false;
|
|||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument(const Tags * tag, const char * arg_start, const char * arg_end)
|
||||
void BBCODEParser::PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end)
|
||||
{
|
||||
const char * pattern = tag->html_argument;
|
||||
const wchar_t * pattern = tag->html_argument;
|
||||
bool has_u;
|
||||
|
||||
while( *pattern )
|
||||
|
@ -478,7 +489,7 @@ bool has_u;
|
|||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag, const char * start, const char * end)
|
||||
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag, const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
CheckOpeningTag(tag);
|
||||
PutOpeningTagMark();
|
||||
|
@ -487,13 +498,13 @@ void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag, const char * start,
|
|||
|
||||
if( !tag->inline_tag )
|
||||
{
|
||||
(*out_string) += "\n";
|
||||
(*out_string) += L"\n";
|
||||
SkipWhiteLines();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTag(const char * start, const char * end)
|
||||
void BBCODEParser::PutOpeningTag(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
const Tags * tag = FindTag(LastItem().name);
|
||||
|
||||
|
@ -520,22 +531,22 @@ void BBCODEParser::PutClosingTag(const Tags * tag)
|
|||
|
||||
if( !tag->inline_tag )
|
||||
{
|
||||
(*out_string) += "\n";
|
||||
(*out_string) += L"\n";
|
||||
SkipWhiteLines();
|
||||
}
|
||||
|
||||
if( strcmp(tag->html_tag, "li") == 0 )
|
||||
if( Equal(tag->html_tag, L"li") )
|
||||
has_open_li_tag = false;
|
||||
|
||||
if( strcmp(tag->html_tag, "ol") == 0 )
|
||||
if( Equal(tag->html_tag, L"ol") )
|
||||
has_open_ol_tag = false;
|
||||
|
||||
if( strcmp(tag->html_tag, "ul") == 0 )
|
||||
if( Equal(tag->html_tag, L"ul") )
|
||||
has_open_ul_tag = false;
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutClosingTag(const char * tag_name)
|
||||
void BBCODEParser::PutClosingTag(const wchar_t * tag_name)
|
||||
{
|
||||
const Tags * tag = FindTag(tag_name);
|
||||
PutClosingTag(tag);
|
||||
|
@ -556,11 +567,11 @@ void BBCODEParser::Init()
|
|||
void BBCODEParser::Deinit()
|
||||
{
|
||||
if( has_open_li_tag )
|
||||
(*out_string) += "</li>\n";
|
||||
(*out_string) += L"</li>\n";
|
||||
|
||||
if( has_open_ol_tag )
|
||||
(*out_string) += "</ol>\n";
|
||||
(*out_string) += L"</ol>\n";
|
||||
|
||||
if( has_open_ul_tag )
|
||||
(*out_string) += "</ul>\n";
|
||||
(*out_string) += L"</ul>\n";
|
||||
}
|
||||
|
|
|
@ -22,20 +22,22 @@ class BBCODEParser : public HTMLFilter
|
|||
struct Tags
|
||||
{
|
||||
/*
|
||||
const char * bbcode;
|
||||
const char * html_tag;
|
||||
const char * html_arg_prefix;
|
||||
const char * html_arg_postfix;
|
||||
const char * additional_html_tag_prefix;
|
||||
const char * additional_html_tag_postfix;
|
||||
const wchar_t * bbcode;
|
||||
const wchar_t * html_tag;
|
||||
const wchar_t * html_arg_prefix;
|
||||
const wchar_t * html_arg_postfix;
|
||||
const wchar_t * additional_html_tag_prefix;
|
||||
const wchar_t * additional_html_tag_postfix;
|
||||
bool inline_tag;
|
||||
*/
|
||||
const char * bbcode;
|
||||
const char * html_tag;
|
||||
const char * html_argument; // with closing '>'
|
||||
const wchar_t * bbcode;
|
||||
const wchar_t * html_tag;
|
||||
const wchar_t * html_argument; // with closing '>'
|
||||
bool inline_tag;
|
||||
};
|
||||
|
||||
bool Equal(const wchar_t * str1, const wchar_t * str2);
|
||||
|
||||
virtual bool IsValidCharForName(int c);
|
||||
|
||||
virtual bool IsOpeningTagMark();
|
||||
|
@ -45,32 +47,32 @@ class BBCODEParser : public HTMLFilter
|
|||
virtual bool IsClosingXmlSimpleTagMark();
|
||||
|
||||
|
||||
void PutHtmlArgument1(const char * arg_start, const char * arg_end, bool has_u);
|
||||
void PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u);
|
||||
void PutHtmlArgument2(const Tags * tag, bool has_u);
|
||||
void PutHtmlArgument(const Tags * tag, const char * arg_start, const char * arg_end);
|
||||
void PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end);
|
||||
|
||||
void PutOpeningTagFromEzc(const char * start, const char * end);
|
||||
void PutOpeningTagFromBBCode(const Tags * tag, const char * start, const char * end);
|
||||
void PutOpeningTagFromEzc(const wchar_t * start, const wchar_t * end);
|
||||
void PutOpeningTagFromBBCode(const Tags * tag, const wchar_t * start, const wchar_t * end);
|
||||
|
||||
virtual void PutOpeningTag(const char * start, const char * end);
|
||||
virtual void PutClosingTag(const char * tag);
|
||||
virtual void PutOpeningTag(const wchar_t * start, const wchar_t * end);
|
||||
virtual void PutClosingTag(const wchar_t * tag);
|
||||
|
||||
const Tags * FindTag(const char * tag);
|
||||
void PrintArgumentCheckQuotes(const char * & start, const char * & end);
|
||||
const Tags * FindTag(const wchar_t * tag);
|
||||
void PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end);
|
||||
|
||||
|
||||
void PrintEscape(int c, bool change_quote = false);
|
||||
void PrintEncode(int c);
|
||||
|
||||
void PrintEscape(const char * start, const char * end, bool change_quote = false);
|
||||
void PrintEncode(const char * start, const char * end);
|
||||
void PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote = false);
|
||||
void PrintEncode(const wchar_t * start, const wchar_t * end);
|
||||
|
||||
void PrintArgumentEncode(const char * start, const char * end);
|
||||
void PrintArgumentEscape(const char * start, const char * end);
|
||||
void PrintArgumentEncode(const wchar_t * start, const wchar_t * end);
|
||||
void PrintArgumentEscape(const wchar_t * start, const wchar_t * end);
|
||||
|
||||
virtual void ReadNormalTextSkipWhite(const char * & start, const char * & last_non_white);
|
||||
virtual void PutNormalText(const char * str, const char * end);
|
||||
virtual void PutNormalTextTrim(const char * str, const char * end);
|
||||
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
|
||||
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
|
||||
virtual void PutNormalTextTrim(const wchar_t * str, const wchar_t * end);
|
||||
|
||||
virtual void CheckExceptions();
|
||||
|
||||
|
@ -80,10 +82,10 @@ class BBCODEParser : public HTMLFilter
|
|||
void PutClosingTag(const Tags * tag);
|
||||
|
||||
|
||||
void CheckOpeningTag(const Tags * tag, const char * tag_name, bool & condition);
|
||||
void CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition);
|
||||
void CheckOpeningTag(const Tags * tag);
|
||||
|
||||
void TrimWhiteWithNewLines(const char * & start, const char * & end);
|
||||
void TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end);
|
||||
|
||||
bool has_open_ol_tag; // has open html <ol> tag
|
||||
bool has_open_ul_tag; // has open html <ul> tag
|
||||
|
|
225
core/config.cpp
225
core/config.cpp
|
@ -68,6 +68,7 @@ bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed)
|
|||
log << log2 << "Config: reading a config file" << logend;
|
||||
|
||||
parser.SplitSingle(true);
|
||||
parser.UTF8(true); // config is always read in UTF-8
|
||||
ConfParser::Status status = parser.Parse( config_file );
|
||||
|
||||
|
||||
|
@ -89,47 +90,47 @@ bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed)
|
|||
|
||||
void Config::AssignValues(bool stdout_is_closed)
|
||||
{
|
||||
demonize = Bool("demonize", true);
|
||||
demonize = Bool(L"demonize", true);
|
||||
|
||||
user = Text("user");
|
||||
group = Text("group");
|
||||
additional_groups = Bool("additional_groups", true);
|
||||
user = AText(L"user");
|
||||
group = AText(L"group");
|
||||
additional_groups = Bool(L"additional_groups", true);
|
||||
|
||||
log_file = Text("log_file");
|
||||
log_notify_file = Text("log_notify_file");
|
||||
log_delimiter = Text("log_delimiter", "---------------------------------------------------------------------------------");
|
||||
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);
|
||||
log_db_query = Bool("log_db_query", false);
|
||||
log_file = AText(L"log_file");
|
||||
log_notify_file = AText(L"log_notify_file");
|
||||
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
|
||||
fcgi_socket = AText(L"fcgi_socket");
|
||||
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
|
||||
fcgi_socket_user = AText(L"fcgi_socket_user");
|
||||
fcgi_socket_group = AText(L"fcgi_socket_group");
|
||||
log_level = Int(L"log_level", 1);
|
||||
log_request = Int(L"log_request", 1);
|
||||
log_stdout = Bool(L"log_stdout", false);
|
||||
log_db_query = Bool(L"log_db_query", 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");
|
||||
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
|
||||
auth_simplefs_dir = Text(L"auth_simplefs_dir");
|
||||
auth_hashfs_dir = Text(L"auth_hashfs_dir");
|
||||
auth_tmp_dir = Text(L"auth_tmp_dir");
|
||||
|
||||
templates_dir = Text("templates_dir");
|
||||
templates_dir_default = Text("templates_dir_default");
|
||||
templates_fun_prefix = Text("templates_fun_prefix", "fun_");
|
||||
templates_fun_postfix = Text("templates_fun_postfix", ".html");
|
||||
templates_index = Text("templates_index", "index.html");
|
||||
template_only_root_use_template_fun = Bool("template_only_root_use_template_fun", false);
|
||||
templates_dir = Text(L"templates_dir");
|
||||
templates_dir_default = Text(L"templates_dir_default");
|
||||
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
||||
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
||||
templates_index = Text(L"templates_index", L"index.html");
|
||||
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
||||
|
||||
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");
|
||||
http_session_id_name = AText(L"http_session_id_name");
|
||||
db_database = AText(L"db_database");
|
||||
db_user = AText(L"db_user");
|
||||
db_pass = AText(L"db_pass");
|
||||
item_url_empty = Text(L"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");
|
||||
base_server = Text(L"base_server");
|
||||
base_url = Text(L"base_url");
|
||||
base_url_auth = Text(L"base_url_auth");
|
||||
base_url_static = Text(L"base_url_static");
|
||||
base_url_common = Text(L"base_url_common");
|
||||
|
||||
NoLastSlash(base_server);
|
||||
NoLastSlash(base_url);
|
||||
|
@ -137,43 +138,45 @@ void Config::AssignValues(bool stdout_is_closed)
|
|||
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 --");
|
||||
priv_no_user = Text(L"priv_no_user", L"-- no user --");
|
||||
priv_no_group = Text(L"priv_no_group", L"-- no group --");
|
||||
|
||||
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");
|
||||
session_max_idle = Int(L"session_max_idle", 10800); // 3h
|
||||
session_remember_max_idle = Int(L"session_remember_max_idle", 16070400); // 3 months
|
||||
session_file = AText(L"session_file");
|
||||
|
||||
compression = Bool("compression", true);
|
||||
compression_page_min_size = Int("compression_page_min_size", 512);
|
||||
compression = Bool(L"compression", true);
|
||||
compression_page_min_size = Int(L"compression_page_min_size", 512);
|
||||
|
||||
html_filter = Bool("html_filter", true);
|
||||
html_filter_trim_white = Bool("html_filter_trim_white", true);
|
||||
html_filter_break_lines = Int("html_filter_break_lines", 60);
|
||||
html_filter_tabs = Size("html_filter_tabs", 2);
|
||||
html_filter_orphans = Bool("html_filter_orphans", false);
|
||||
html_filter_orphans_lang_str = Text("html_filter_orphans_lang", "pl");
|
||||
html_filter_orphans_mode_str = Text("html_filter_orphans_mode_str", "nbsp");
|
||||
html_filter = Bool(L"html_filter", true);
|
||||
html_filter_trim_white = Bool(L"html_filter_trim_white", true);
|
||||
html_filter_break_lines = Int(L"html_filter_break_lines", 60);
|
||||
html_filter_tabs = Size(L"html_filter_tabs", 2);
|
||||
html_filter_orphans = Bool(L"html_filter_orphans", false);
|
||||
html_filter_orphans_lang_str = AText(L"html_filter_orphans_lang", L"pl");
|
||||
html_filter_orphans_mode_str = AText(L"html_filter_orphans_mode_str", L"nbsp");
|
||||
|
||||
locale_str = Text("locale", "en");
|
||||
locale_dir = Text("locale_dir");
|
||||
locale_dir_default = Text("locale_dir_default");
|
||||
locale_str = Text(L"locale", L"en");
|
||||
locale_dir = Text(L"locale_dir");
|
||||
locale_dir_default = Text(L"locale_dir_default");
|
||||
|
||||
title_separator = Text("title_separator", " / ");
|
||||
title_separator = Text(L"title_separator", L" / ");
|
||||
|
||||
http_header_send_file = Text("http_header_send_file", "X-LIGHTTPD-send-file");
|
||||
password_min_size = Size("password_min_size", 5);
|
||||
debug_info = Bool("debug_info", false);
|
||||
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file");
|
||||
password_min_size = Size(L"password_min_size", 5);
|
||||
debug_info = Bool(L"debug_info", false);
|
||||
|
||||
editors_html_safe_mode = Bool("editors_html_safe_mode", true);
|
||||
editors_html_safe_mode_skip_root = Bool("editors_html_safe_mode_skip_root", true);
|
||||
editors_html_safe_mode = Bool(L"editors_html_safe_mode", true);
|
||||
editors_html_safe_mode_skip_root = Bool(L"editors_html_safe_mode_skip_root", true);
|
||||
|
||||
plugins_dir = Text("plugins_dir", "/usr/local/winix/plugins");
|
||||
plugins_dir = Text(L"plugins_dir", L"/usr/local/winix/plugins");
|
||||
NoLastSlash(plugins_dir);
|
||||
parser.ListText("plugins", plugin_file);
|
||||
parser.ListText(L"plugins", plugin_file);
|
||||
|
||||
time_zone_offset = Int("time_zone_offset", 0);
|
||||
time_zone_offset_guest = Int("time_zone_offset_guest", 0);
|
||||
time_zone_offset = Int(L"time_zone_offset", 0);
|
||||
time_zone_offset_guest = Int(L"time_zone_offset_guest", 0);
|
||||
|
||||
utf8 = Bool(L"utf8", true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,137 +205,130 @@ void Config::SetAdditionalVariables()
|
|||
|
||||
|
||||
|
||||
void Config::SetHttpHost(const std::string & in, std::string & out)
|
||||
void Config::SetHttpHost(const std::wstring & in, std::wstring & out)
|
||||
{
|
||||
if( strncmp(in.c_str(), "http://", 7) == 0 )
|
||||
out = in.substr(7);
|
||||
const char http[] = "http://";
|
||||
const char https[] = "https://";
|
||||
size_t http_len = sizeof(http) / sizeof(char) - 1;
|
||||
size_t https_len = sizeof(https) / sizeof(char) - 1;
|
||||
|
||||
if( IsSubString(http, in.c_str()) )
|
||||
out = in.substr(http_len);
|
||||
else
|
||||
if( strncmp(in.c_str(), "https://", 8) == 0 )
|
||||
out = in.substr(8);
|
||||
if( IsSubString(https, in.c_str()) )
|
||||
out = in.substr(https_len);
|
||||
else
|
||||
out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done
|
||||
}
|
||||
|
||||
|
||||
std::string Config::Text(const char * name)
|
||||
std::wstring Config::Text(const wchar_t * name)
|
||||
{
|
||||
return parser.Text(name);
|
||||
}
|
||||
|
||||
|
||||
std::string Config::Text(const char * name, const char * def)
|
||||
std::wstring Config::Text(const wchar_t * name, const wchar_t * def)
|
||||
{
|
||||
return parser.Text(name, def);
|
||||
}
|
||||
|
||||
|
||||
std::string Config::Text(const std::string & name, const std::string & def)
|
||||
std::wstring Config::Text(const std::wstring & name, const std::wstring & def)
|
||||
{
|
||||
return parser.Text(name, def);
|
||||
}
|
||||
|
||||
|
||||
int Config::Int(const char * name)
|
||||
std::string Config::AText(const wchar_t * name)
|
||||
{
|
||||
return parser.AText(name);
|
||||
}
|
||||
|
||||
|
||||
std::string Config::AText(const wchar_t * name, const wchar_t * def)
|
||||
{
|
||||
return parser.AText(name, def);
|
||||
}
|
||||
|
||||
|
||||
std::string Config::AText(const std::wstring & name, const std::wstring & def)
|
||||
{
|
||||
return parser.AText(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Config::Int(const wchar_t * name)
|
||||
{
|
||||
return parser.Int(name);
|
||||
}
|
||||
|
||||
|
||||
int Config::Int(const char * name, int def)
|
||||
int Config::Int(const wchar_t * name, int def)
|
||||
{
|
||||
return parser.Int(name, def);
|
||||
}
|
||||
|
||||
|
||||
int Config::Int(const std::string & name, int def)
|
||||
int Config::Int(const std::wstring & name, int def)
|
||||
{
|
||||
return parser.Int(name, def);
|
||||
}
|
||||
|
||||
|
||||
size_t Config::Size(const char * name)
|
||||
size_t Config::Size(const wchar_t * name)
|
||||
{
|
||||
return parser.Size(name);
|
||||
}
|
||||
|
||||
|
||||
size_t Config::Size(const char * name, size_t def)
|
||||
size_t Config::Size(const wchar_t * name, size_t def)
|
||||
{
|
||||
return parser.Size(name, def);
|
||||
}
|
||||
|
||||
|
||||
size_t Config::Size(const std::string & name, size_t def)
|
||||
size_t Config::Size(const std::wstring & name, size_t def)
|
||||
{
|
||||
return parser.Size(name, def);
|
||||
}
|
||||
|
||||
|
||||
bool Config::Bool(const char * name)
|
||||
bool Config::Bool(const wchar_t * name)
|
||||
{
|
||||
return parser.Bool(name);
|
||||
}
|
||||
|
||||
|
||||
bool Config::Bool(const char * name, bool def)
|
||||
bool Config::Bool(const wchar_t * name, bool def)
|
||||
{
|
||||
return parser.Bool(name, def);
|
||||
}
|
||||
|
||||
|
||||
bool Config::Bool(const std::string & name, bool def)
|
||||
bool Config::Bool(const std::wstring & name, bool def)
|
||||
{
|
||||
return parser.Bool(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Config::ListText(const char * name, std::vector<std::string> & list)
|
||||
void Config::ListText(const wchar_t * name, std::vector<std::wstring> & list)
|
||||
{
|
||||
parser.ListText(name, list);
|
||||
}
|
||||
|
||||
|
||||
void Config::ListText(const std::string & name, std::vector<std::string> & list)
|
||||
void Config::ListText(const std::wstring & name, std::vector<std::wstring> & list)
|
||||
{
|
||||
parser.ListText(name, list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Config::NoLastSlash(std::string & s)
|
||||
void Config::Print(std::ostream & out)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
|
||||
size_t i = s.size();
|
||||
|
||||
for( ; i>0 && s[i-1]=='/' ; --i);
|
||||
|
||||
if( i < s.size() )
|
||||
s.erase(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Config::NoFirstHttp(std::string & s)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
const char http[] = "http://";
|
||||
const char https[] = "https://";
|
||||
|
||||
if( IsSubStringNoCase(http, s.c_str()) )
|
||||
{
|
||||
s.erase(0, sizeof(http)/sizeof(char));
|
||||
}
|
||||
else
|
||||
if( IsSubStringNoCase(https, s.c_str()) )
|
||||
{
|
||||
s.erase(0, sizeof(https)/sizeof(char));
|
||||
}
|
||||
parser.Print(out);
|
||||
}
|
||||
|
||||
|
||||
|
@ -341,4 +337,3 @@ void Config::NoFirstHttp(std::string & s)
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
100
core/config.h
100
core/config.h
|
@ -65,7 +65,7 @@ public:
|
|||
bool log_db_query;
|
||||
|
||||
// request delimiter in the log file, default "---------"
|
||||
std::string log_delimiter;
|
||||
std::wstring log_delimiter;
|
||||
|
||||
// fast cgi: socket (unix domain)
|
||||
std::string fcgi_socket;
|
||||
|
@ -79,19 +79,19 @@ public:
|
|||
// fast cgi: group of the socket
|
||||
std::string fcgi_socket_group;
|
||||
|
||||
std::string templates_dir;
|
||||
std::string templates_dir_default; // templates from winix
|
||||
std::wstring templates_dir;
|
||||
std::wstring templates_dir_default; // templates from winix
|
||||
|
||||
// prefix and postfix for functions templates
|
||||
// default:
|
||||
// prefix: "fun_"
|
||||
// postfix: ".html"
|
||||
std::string templates_fun_prefix;
|
||||
std::string templates_fun_postfix;
|
||||
std::wstring templates_fun_prefix;
|
||||
std::wstring templates_fun_postfix;
|
||||
|
||||
// main html template
|
||||
// default: index.html
|
||||
std::string templates_index;
|
||||
std::wstring templates_index;
|
||||
|
||||
// if true then only root can use 'template' function
|
||||
// default: false
|
||||
|
@ -109,8 +109,8 @@ public:
|
|||
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;
|
||||
std::wstring priv_no_user;
|
||||
std::wstring priv_no_group;
|
||||
|
||||
// time in seconds when the user will be automatically logged out (iddle time)
|
||||
int session_max_idle;
|
||||
|
@ -130,12 +130,12 @@ public:
|
|||
|
||||
// plugins directory
|
||||
// default: /usr/local/winix/plugins
|
||||
std::string plugins_dir;
|
||||
std::wstring plugins_dir;
|
||||
|
||||
// plugins
|
||||
// you can provide either a relative path (plugins_dir will be used)
|
||||
// or a full path to a plugin
|
||||
std::vector<std::string> plugin_file;
|
||||
std::vector<std::wstring> plugin_file;
|
||||
|
||||
// should the html code be cleaned by the html filter
|
||||
bool html_filter;
|
||||
|
@ -169,50 +169,51 @@ public:
|
|||
HTMLFilter::OrphanMode html_filter_orphans_mode;
|
||||
|
||||
// the url of a new empty item (if there is not the subject too)
|
||||
std::string item_url_empty;
|
||||
std::wstring item_url_empty;
|
||||
|
||||
// maximum length of a file send by post multipart form
|
||||
// 0 - not used
|
||||
int post_file_max;
|
||||
size_t post_file_max;
|
||||
|
||||
// directories for static files
|
||||
std::string auth_simplefs_dir;
|
||||
std::string auth_hashfs_dir;
|
||||
std::wstring auth_simplefs_dir;
|
||||
std::wstring 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;
|
||||
std::wstring auth_tmp_dir;
|
||||
|
||||
// default locale: en pl
|
||||
std::string locale_str;
|
||||
// locale: en, pl
|
||||
// default: en
|
||||
std::wstring locale_str;
|
||||
|
||||
// directory with locale files
|
||||
std::string locale_dir;
|
||||
std::wstring locale_dir;
|
||||
|
||||
// directory with default locale files (those from winix)
|
||||
std::string locale_dir_default;
|
||||
std::wstring locale_dir_default;
|
||||
|
||||
// the main address of the server (e.g. someserver.com) (without the 'www' part etc)
|
||||
std::string base_server;
|
||||
std::wstring base_server;
|
||||
|
||||
// the main address of the site (e.g. http://www.someserver.com)
|
||||
std::string base_url;
|
||||
std::wstring base_url;
|
||||
|
||||
// static content authorized by winix
|
||||
std::string base_url_auth;
|
||||
std::wstring base_url_auth;
|
||||
|
||||
// static content not authorized by winix
|
||||
std::string base_url_static;
|
||||
std::wstring base_url_static;
|
||||
|
||||
// additional static server for common content (not authorized)
|
||||
std::string base_url_common;
|
||||
std::wstring base_url_common;
|
||||
|
||||
// separator used in <title> html tag
|
||||
std::string title_separator;
|
||||
std::wstring title_separator;
|
||||
|
||||
// http header recognized by www server as a file to send back
|
||||
// default: X-LIGHTTPD-send-file
|
||||
std::string http_header_send_file;
|
||||
std::wstring http_header_send_file;
|
||||
|
||||
// the minimum size of a password for new users (function: adduser)
|
||||
// default: 5
|
||||
|
@ -240,6 +241,11 @@ public:
|
|||
// default: 0
|
||||
int time_zone_offset_guest;
|
||||
|
||||
// charset used in templates, locales, logs etc.
|
||||
// default: true (UTF-8)
|
||||
// if false it means 8-bit ASCII
|
||||
bool utf8;
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
|
@ -247,35 +253,39 @@ public:
|
|||
// 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;
|
||||
std::wstring base_url_http_host;
|
||||
std::wstring 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);
|
||||
size_t Size(const char *);
|
||||
size_t Size(const char * name, size_t def);
|
||||
size_t Size(const std::string & name, size_t def);
|
||||
bool Bool(const char *);
|
||||
bool Bool(const char * name, bool def);
|
||||
bool Bool(const std::string & name, bool def);
|
||||
void ListText(const char * name, std::vector<std::string> & list);
|
||||
void ListText(const std::string & name, std::vector<std::string> & list);
|
||||
std::wstring Text(const wchar_t * name);
|
||||
std::wstring Text(const wchar_t * name, const wchar_t * def);
|
||||
std::wstring Text(const std::wstring & name, const std::wstring & def);
|
||||
std::string AText(const wchar_t * name);
|
||||
std::string AText(const wchar_t * name, const wchar_t * def);
|
||||
std::string AText(const std::wstring & name, const std::wstring & def);
|
||||
|
||||
void NoLastSlash(std::string & s);
|
||||
void NoFirstHttp(std::string & s);
|
||||
int Int(const wchar_t *);
|
||||
int Int(const wchar_t * name, int def);
|
||||
int Int(const std::wstring & name, int def);
|
||||
size_t Size(const wchar_t *);
|
||||
size_t Size(const wchar_t * name, size_t def);
|
||||
size_t Size(const std::wstring & name, size_t def);
|
||||
bool Bool(const wchar_t *);
|
||||
bool Bool(const wchar_t * name, bool def);
|
||||
bool Bool(const std::wstring & name, bool def);
|
||||
void ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
||||
void ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
||||
|
||||
// for debug
|
||||
void Print(std::ostream & out);
|
||||
|
||||
private:
|
||||
void ShowError();
|
||||
void AssignValues(bool stdout_is_closed);
|
||||
void SetHttpHost(const std::string & in, std::string & out);
|
||||
void SetHttpHost(const std::wstring & in, std::wstring & out);
|
||||
void SetAdditionalVariables();
|
||||
|
||||
ConfParser parser;
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <wchar.h>
|
||||
#include "confparser.h"
|
||||
#include "misc.h"
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -26,8 +28,9 @@ ConfParser::ConfParser()
|
|||
split_single = false;
|
||||
skip_empty = false;
|
||||
use_escape_char = true;
|
||||
input_as_utf8 = false;
|
||||
|
||||
default_str = "";
|
||||
default_str = L"";
|
||||
default_int = 0;
|
||||
default_size = 0;
|
||||
default_bool = false;
|
||||
|
@ -52,6 +55,9 @@ void ConfParser::UseEscapeChar(bool escape)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ConfParser::Status ConfParser::Parse(const char * file_name)
|
||||
{
|
||||
line = 1;
|
||||
|
@ -83,6 +89,23 @@ ConfParser::Status ConfParser::Parse(const std::string & file_name)
|
|||
|
||||
|
||||
|
||||
|
||||
ConfParser::Status ConfParser::Parse(const wchar_t * file_name)
|
||||
{
|
||||
Ezc::WideToUTF8(file_name, afile_name);
|
||||
return Parse(afile_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
ConfParser::Status ConfParser::Parse(const std::wstring & file_name)
|
||||
{
|
||||
return Parse(file_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ConfParser::Status ConfParser::ParseFile()
|
||||
{
|
||||
ReadChar();
|
||||
|
@ -149,7 +172,7 @@ void ConfParser::AddOption()
|
|||
|
||||
|
||||
|
||||
void ConfParser::DeleteFromTable(const std::string & var)
|
||||
void ConfParser::DeleteFromTable(const std::wstring & var)
|
||||
{
|
||||
Table::iterator i = table.find(var);
|
||||
|
||||
|
@ -159,7 +182,7 @@ void ConfParser::DeleteFromTable(const std::string & var)
|
|||
|
||||
|
||||
|
||||
void ConfParser::DeleteFromTableSingle(const std::string & var)
|
||||
void ConfParser::DeleteFromTableSingle(const std::wstring & var)
|
||||
{
|
||||
TableSingle::iterator i = table_single.find(var);
|
||||
|
||||
|
@ -303,7 +326,33 @@ return true;
|
|||
}
|
||||
|
||||
|
||||
int ConfParser::ReadChar()
|
||||
int ConfParser::ReadUTF8Char()
|
||||
{
|
||||
int c;
|
||||
bool correct;
|
||||
|
||||
lastc = -1;
|
||||
|
||||
do
|
||||
{
|
||||
Ezc::UTF8ToInt(file, c, correct);
|
||||
|
||||
if( !file )
|
||||
return lastc;
|
||||
}
|
||||
while( !correct );
|
||||
|
||||
lastc = c;
|
||||
|
||||
if( lastc == '\n' )
|
||||
++line;
|
||||
|
||||
return lastc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ConfParser::ReadASCIIChar()
|
||||
{
|
||||
lastc = file.get();
|
||||
|
||||
|
@ -314,6 +363,15 @@ return lastc;
|
|||
}
|
||||
|
||||
|
||||
int ConfParser::ReadChar()
|
||||
{
|
||||
if( input_as_utf8 )
|
||||
return ReadUTF8Char();
|
||||
|
||||
return ReadASCIIChar();
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::IsWhite(int c)
|
||||
{
|
||||
// dont use '\n' here
|
||||
|
@ -359,9 +417,9 @@ void ConfParser::SkipLine()
|
|||
|
||||
|
||||
|
||||
void ConfParser::Trim(std::string & s)
|
||||
void ConfParser::Trim(std::wstring & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
std::wstring::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
@ -378,7 +436,7 @@ std::string::size_type i;
|
|||
|
||||
// deleting white characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, std::string::npos);
|
||||
s.erase(i+1, std::wstring::npos);
|
||||
|
||||
// looking for white characters at the beginning
|
||||
for(i=0 ; i<s.size() && IsWhite(s[i]) ; ++i);
|
||||
|
@ -393,20 +451,20 @@ std::string::size_type i;
|
|||
|
||||
|
||||
|
||||
std::string ConfParser::Text(const char * name)
|
||||
std::wstring ConfParser::Text(const wchar_t * name)
|
||||
{
|
||||
return Text(std::string(name), default_str);
|
||||
return Text(std::wstring(name), default_str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string ConfParser::Text(const char * name, const char * def)
|
||||
std::wstring ConfParser::Text(const wchar_t * name, const wchar_t * def)
|
||||
{
|
||||
return Text(std::string(name), std::string(def));
|
||||
return Text(std::wstring(name), std::wstring(def));
|
||||
}
|
||||
|
||||
|
||||
std::string ConfParser::Text(const std::string & name, const std::string & def)
|
||||
std::wstring ConfParser::Text(const std::wstring & name, const std::wstring & def)
|
||||
{
|
||||
TableSingle::iterator i = table_single.find(name);
|
||||
|
||||
|
@ -425,27 +483,63 @@ return i->second;
|
|||
|
||||
|
||||
|
||||
int ConfParser::Int(const char * name)
|
||||
std::string ConfParser::AText(const wchar_t * name)
|
||||
{
|
||||
return Int(std::string(name), default_int);
|
||||
std::wstring res = Text(name);
|
||||
std::string ares;
|
||||
|
||||
Ezc::WideToUTF8(res, ares);
|
||||
|
||||
return ares;
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::Int(const char * name, int def)
|
||||
|
||||
std::string ConfParser::AText(const wchar_t * name, const wchar_t * def)
|
||||
{
|
||||
return Int(std::string(name), def);
|
||||
std::wstring res = Text(name, def);
|
||||
std::string ares;
|
||||
|
||||
Ezc::WideToUTF8(res, ares);
|
||||
|
||||
return ares;
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::ToInt(const std::string & value)
|
||||
std::string ConfParser::AText(const std::wstring & name, const std::wstring & def)
|
||||
{
|
||||
long res = (value[0] == '0')? strtol(value.c_str() + 1, 0, 8) : strtol(value.c_str(), 0, 10);
|
||||
std::wstring res = Text(name, def);
|
||||
std::string ares;
|
||||
|
||||
return res;
|
||||
Ezc::WideToUTF8(res, ares);
|
||||
|
||||
return ares;
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::Int(const std::string & name, int def)
|
||||
|
||||
|
||||
int ConfParser::Int(const wchar_t * name)
|
||||
{
|
||||
return Int(std::wstring(name), default_int);
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::Int(const wchar_t * name, int def)
|
||||
{
|
||||
return Int(std::wstring(name), def);
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::ToInt(const std::wstring & value)
|
||||
{
|
||||
long res = (value[0] == '0')? wcstol(value.c_str() + 1, 0, 8) : wcstol(value.c_str(), 0, 10);
|
||||
|
||||
return static_cast<int>(res);
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::Int(const std::wstring & name, int def)
|
||||
{
|
||||
TableSingle::iterator i = table_single.find(name);
|
||||
|
||||
|
@ -464,28 +558,28 @@ return ToInt(i->second);
|
|||
|
||||
|
||||
|
||||
size_t ConfParser::Size(const char * name)
|
||||
size_t ConfParser::Size(const wchar_t * name)
|
||||
{
|
||||
return Size(std::string(name), default_size);
|
||||
return Size(std::wstring(name), default_size);
|
||||
}
|
||||
|
||||
|
||||
size_t ConfParser::Size(const char * name, size_t def)
|
||||
size_t ConfParser::Size(const wchar_t * name, size_t def)
|
||||
{
|
||||
return Size(std::string(name), def);
|
||||
return Size(std::wstring(name), def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t ConfParser::ToSize(const std::string & value)
|
||||
size_t ConfParser::ToSize(const std::wstring & value)
|
||||
{
|
||||
long res = (value[0] == '0')? strtoul(value.c_str() + 1, 0, 8) : strtoul(value.c_str(), 0, 10);
|
||||
unsigned long res = (value[0] == '0')? wcstoul(value.c_str() + 1, 0, 8) : wcstoul(value.c_str(), 0, 10);
|
||||
|
||||
return (size_t)res;
|
||||
return static_cast<size_t>(res);
|
||||
}
|
||||
|
||||
|
||||
size_t ConfParser::Size(const std::string & name, size_t def)
|
||||
size_t ConfParser::Size(const std::wstring & name, size_t def)
|
||||
{
|
||||
TableSingle::iterator i = table_single.find(name);
|
||||
|
||||
|
@ -505,28 +599,28 @@ return ToSize(i->second);
|
|||
|
||||
|
||||
|
||||
bool ConfParser::Bool(const char * name)
|
||||
bool ConfParser::Bool(const wchar_t * name)
|
||||
{
|
||||
return Bool(std::string(name), default_bool);
|
||||
return Bool(std::wstring(name), default_bool);
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::Bool(const char * name, bool def)
|
||||
bool ConfParser::Bool(const wchar_t * name, bool def)
|
||||
{
|
||||
return Bool(std::string(name), def);
|
||||
return Bool(std::wstring(name), def);
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::ToBool(const std::string & value)
|
||||
bool ConfParser::ToBool(const std::wstring & value)
|
||||
{
|
||||
return ( EqualNoCase(value.c_str(), "true") ||
|
||||
EqualNoCase(value.c_str(), "yes") ||
|
||||
EqualNoCase(value.c_str(), "1")
|
||||
return ( EqualNoCase(value.c_str(), L"true") ||
|
||||
EqualNoCase(value.c_str(), L"yes") ||
|
||||
EqualNoCase(value.c_str(), L"1")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::Bool(const std::string & name, bool def)
|
||||
bool ConfParser::Bool(const std::wstring & name, bool def)
|
||||
{
|
||||
TableSingle::iterator i = table_single.find(name);
|
||||
|
||||
|
@ -544,7 +638,7 @@ return ToBool(i->second);
|
|||
}
|
||||
|
||||
|
||||
void ConfParser::SetDefaultText(const std::string & def)
|
||||
void ConfParser::SetDefaultText(const std::wstring & def)
|
||||
{
|
||||
default_str = def;
|
||||
}
|
||||
|
@ -568,13 +662,13 @@ void ConfParser::SetDefaultBool(bool def)
|
|||
|
||||
|
||||
// in lists we don't use default values
|
||||
void ConfParser::ListText(const char * name, std::vector<std::string> & list)
|
||||
void ConfParser::ListText(const wchar_t * name, std::vector<std::wstring> & list)
|
||||
{
|
||||
ListText(std::string(name), list);
|
||||
ListText(std::wstring(name), list);
|
||||
}
|
||||
|
||||
|
||||
void ConfParser::ListText(const std::string & name, std::vector<std::string> & list)
|
||||
void ConfParser::ListText(const std::wstring & name, std::vector<std::wstring> & list)
|
||||
{
|
||||
list.clear();
|
||||
|
||||
|
@ -595,3 +689,41 @@ void ConfParser::ListText(const std::string & name, std::vector<std::string> & l
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConfParser::UTF8(bool utf)
|
||||
{
|
||||
input_as_utf8 = utf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConfParser::Print(std::ostream & out)
|
||||
{
|
||||
TableSingle::iterator i1;
|
||||
|
||||
for(i1 = table_single.begin() ; i1 != table_single.end() ; ++i1)
|
||||
{
|
||||
Ezc::WideToUTF8(i1->first, out);
|
||||
out << '=';
|
||||
Ezc::WideToUTF8(i1->second, out);
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
Table::iterator i2;
|
||||
Value::iterator i3;
|
||||
|
||||
for(i2 = table.begin() ; i2 != table.end() ; ++i2)
|
||||
{
|
||||
Ezc::WideToUTF8(i2->first, out);
|
||||
out << '=';
|
||||
|
||||
for(i3 = i2->second.begin() ; i3 != i2->second.end() ; ++i3)
|
||||
{
|
||||
Ezc::WideToUTF8(*i3, out);
|
||||
out << ',';
|
||||
}
|
||||
|
||||
out << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,6 +151,8 @@ public:
|
|||
*/
|
||||
Status Parse(const char * file_name);
|
||||
Status Parse(const std::string & file_name);
|
||||
Status Parse(const wchar_t * file_name);
|
||||
Status Parse(const std::wstring & file_name);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -163,8 +165,8 @@ public:
|
|||
this is the table which represents your config file
|
||||
in the Table map: the first (key) is your 'option' and the second is 'list'
|
||||
*/
|
||||
typedef std::vector<std::string> Value;
|
||||
typedef std::map<std::string, Value> Table;
|
||||
typedef std::vector<std::wstring> Value;
|
||||
typedef std::map<std::wstring, Value> Table;
|
||||
Table table;
|
||||
|
||||
|
||||
|
@ -174,10 +176,10 @@ public:
|
|||
option2 = value2
|
||||
then you can call SplitSingle(true) for not inserting single values to
|
||||
previous 'table' but instead to 'table_single'
|
||||
table_single as the second parameter takes only std::string (instead of the whole std::vector)
|
||||
table_single as the second parameter takes only std::wstring (instead of the whole std::vector)
|
||||
so you can save a little memory from not using std::vector
|
||||
*/
|
||||
typedef std::map<std::string, std::string> TableSingle;
|
||||
typedef std::map<std::wstring, std::wstring> TableSingle;
|
||||
TableSingle table_single;
|
||||
|
||||
|
||||
|
@ -219,18 +221,21 @@ public:
|
|||
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);
|
||||
size_t Size(const char *);
|
||||
size_t Size(const char * name, size_t def);
|
||||
size_t Size(const std::string & name, size_t def);
|
||||
bool Bool(const char *);
|
||||
bool Bool(const char * name, bool def);
|
||||
bool Bool(const std::string & name, bool def);
|
||||
std::wstring Text(const wchar_t * name);
|
||||
std::wstring Text(const wchar_t * name, const wchar_t * def);
|
||||
std::wstring Text(const std::wstring & name, const std::wstring & def);
|
||||
std::string AText(const wchar_t * name);
|
||||
std::string AText(const wchar_t * name, const wchar_t * def);
|
||||
std::string AText(const std::wstring & name, const std::wstring & def);
|
||||
int Int(const wchar_t *);
|
||||
int Int(const wchar_t * name, int def);
|
||||
int Int(const std::wstring & name, int def);
|
||||
size_t Size(const wchar_t *);
|
||||
size_t Size(const wchar_t * name, size_t def);
|
||||
size_t Size(const std::wstring & name, size_t def);
|
||||
bool Bool(const wchar_t *);
|
||||
bool Bool(const wchar_t * name, bool def);
|
||||
bool Bool(const std::wstring & name, bool def);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -242,7 +247,7 @@ public:
|
|||
default int or size is: 0
|
||||
default bool is: false
|
||||
*/
|
||||
void SetDefaultText(const std::string & def);
|
||||
void SetDefaultText(const std::wstring & def);
|
||||
void SetDefaultInt(int def);
|
||||
void SetDefaultSize(size_t def);
|
||||
void SetDefaultBool(bool def);
|
||||
|
@ -252,8 +257,21 @@ public:
|
|||
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);
|
||||
void ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
||||
void ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
||||
|
||||
|
||||
/*
|
||||
if true then the input file is treated as UTF-8
|
||||
*/
|
||||
void UTF8(bool utf);
|
||||
|
||||
|
||||
/*
|
||||
printing the content
|
||||
(for debug purposes)
|
||||
*/
|
||||
void Print(std::ostream & out);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -261,13 +279,13 @@ private:
|
|||
/*
|
||||
last read variable (option)
|
||||
*/
|
||||
std::string variable;
|
||||
std::wstring variable;
|
||||
|
||||
|
||||
/*
|
||||
last read list item
|
||||
*/
|
||||
std::string value_item;
|
||||
std::wstring value_item;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -308,6 +326,7 @@ private:
|
|||
|
||||
/*
|
||||
last read char
|
||||
or -1 if the end
|
||||
*/
|
||||
int lastc;
|
||||
|
||||
|
@ -335,25 +354,34 @@ private:
|
|||
bool skip_empty;
|
||||
|
||||
|
||||
/*
|
||||
input file is in UTF-8
|
||||
default: false
|
||||
*/
|
||||
bool input_as_utf8;
|
||||
|
||||
|
||||
/*
|
||||
if true you can use an escape character '\' in quoted values
|
||||
*/
|
||||
bool use_escape_char;
|
||||
|
||||
std::string default_str;
|
||||
std::string afile_name;
|
||||
|
||||
std::wstring default_str;
|
||||
int default_int;
|
||||
size_t default_size;
|
||||
bool default_bool;
|
||||
|
||||
int ToInt(const std::string & value);
|
||||
size_t ToSize(const std::string & value);
|
||||
bool ToBool(const std::string & value);
|
||||
int ToInt(const std::wstring & value);
|
||||
size_t ToSize(const std::wstring & value);
|
||||
bool ToBool(const std::wstring & value);
|
||||
|
||||
Status ParseFile();
|
||||
void AddOption();
|
||||
|
||||
void DeleteFromTable(const std::string & var);
|
||||
void DeleteFromTableSingle(const std::string & var);
|
||||
void DeleteFromTable(const std::wstring & var);
|
||||
void DeleteFromTableSingle(const std::wstring & var);
|
||||
|
||||
bool ReadVariable();
|
||||
bool ReadValue();
|
||||
|
@ -362,13 +390,15 @@ private:
|
|||
bool ReadValueQuoted();
|
||||
bool ReadValueSimple(bool use_list_delimiter = false);
|
||||
|
||||
int ReadUTF8Char();
|
||||
int ReadASCIIChar();
|
||||
int ReadChar();
|
||||
bool IsWhite(int c);
|
||||
bool IsVariableChar(int c);
|
||||
void SkipWhite();
|
||||
void SkipWhiteLines();
|
||||
void SkipLine();
|
||||
void Trim(std::string & s);
|
||||
void Trim(std::wstring & s);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include "log.h"
|
||||
|
||||
|
||||
std::string DirContainer::dir_etc = "etc";
|
||||
std::string DirContainer::dir_var = "var";
|
||||
std::wstring DirContainer::dir_etc = L"etc";
|
||||
std::wstring DirContainer::dir_var = L"var";
|
||||
|
||||
|
||||
DirContainer::DirContainer()
|
||||
|
@ -74,6 +74,12 @@ bool DirContainer::Empty()
|
|||
}
|
||||
|
||||
|
||||
bool DirContainer::IsNameOfSpecialFolder(const std::wstring & name)
|
||||
{
|
||||
return name == dir_etc || name == dir_var;
|
||||
}
|
||||
|
||||
|
||||
// looking for '/etc'
|
||||
// 'root' is found beforehand
|
||||
// CheckSpecialFolder() may not find everything (when the first is a special folder and then the root)
|
||||
|
@ -182,7 +188,7 @@ bool DirContainer::ChangeParent(long dir_id, long new_parent_id)
|
|||
|
||||
found = true;
|
||||
|
||||
if( i->url == "etc" ) // !! in the future can be more special folders
|
||||
if( IsNameOfSpecialFolder(i->url) )
|
||||
FindSpecialFolders();
|
||||
|
||||
break; // that iterator (p) is only one
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
ParentIterator FindFirstParent(long parent);
|
||||
ParentIterator NextParent(ParentIterator pi);
|
||||
|
||||
bool IsNameOfSpecialFolder(const std::wstring & name);
|
||||
void FindSpecialFolders();
|
||||
|
||||
private:
|
||||
|
@ -87,7 +88,7 @@ private:
|
|||
TableParent table_parent;
|
||||
|
||||
// names of folders
|
||||
static std::string dir_etc, dir_var;
|
||||
static std::wstring dir_etc, dir_var;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ void Dirs::ReadDirs()
|
|||
}
|
||||
|
||||
|
||||
bool Dirs::ExtractName(const char * & s, std::string & name)
|
||||
bool Dirs::ExtractName(const wchar_t * & s, std::wstring & name)
|
||||
{
|
||||
name.clear();
|
||||
|
||||
|
@ -157,7 +157,7 @@ DirContainer::ParentIterator Dirs::ParentEnd()
|
|||
// albo tutaj stringa nie czyscic?
|
||||
// O(m * log n) (m- how many parts are in 'id')
|
||||
// path with a slash at the end
|
||||
bool Dirs::MakePath(long id, std::string & path)
|
||||
bool Dirs::MakePath(long id, std::wstring & path)
|
||||
{
|
||||
DirContainer::Iterator i;
|
||||
|
||||
|
@ -248,7 +248,7 @@ return &(*etc);
|
|||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & name, long parent)
|
||||
Item * Dirs::GetDir(const std::wstring & name, long parent)
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_tab.FindFirstParent(parent);
|
||||
|
||||
|
@ -261,7 +261,7 @@ return 0;
|
|||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & path)
|
||||
Item * Dirs::GetDir(const std::wstring & path)
|
||||
{
|
||||
DirContainer::Iterator root = dir_tab.GetRoot();
|
||||
|
||||
|
@ -271,8 +271,8 @@ Item * Dirs::GetDir(const std::string & path)
|
|||
|
||||
Item * pitem = &(*root);
|
||||
|
||||
std::string name;
|
||||
const char * s = path.c_str();
|
||||
std::wstring name;
|
||||
const wchar_t * s = path.c_str();
|
||||
|
||||
while( ExtractName(s, name) )
|
||||
{
|
||||
|
@ -308,7 +308,7 @@ Item * Dirs::AddDir(const Item & item)
|
|||
|
||||
|
||||
|
||||
size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir)
|
||||
size_t Dirs::AnalyzeDir(Item * pdir, const std::wstring & path, long & dir_id, std::wstring & dir)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t old_i;
|
||||
|
@ -354,7 +354,7 @@ size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, st
|
|||
2 - the path is empty
|
||||
3 - there is not such a directory
|
||||
*/
|
||||
int Dirs::AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file)
|
||||
int Dirs::AnalyzePath(const std::wstring & path, long & dir_id, std::wstring & dir, std::wstring & file)
|
||||
{
|
||||
Item * pdir = GetRootDir();
|
||||
dir = '/';
|
||||
|
@ -388,9 +388,9 @@ return 0;
|
|||
|
||||
|
||||
|
||||
void Dirs::SplitPath(const std::string & path, std::string & dir, std::string & file)
|
||||
void Dirs::SplitPath(const std::wstring & path, std::wstring & dir, std::wstring & file)
|
||||
{
|
||||
std::string::size_type i;
|
||||
std::wstring::size_type i;
|
||||
|
||||
dir.clear();
|
||||
file.clear();
|
||||
|
@ -465,8 +465,8 @@ Item * Dirs::CreateVarDir()
|
|||
v.user_id = -1;
|
||||
v.group_id = -1;
|
||||
v.privileges = 0755;
|
||||
v.subject = "var";
|
||||
v.url = "var";
|
||||
v.subject = L"var";
|
||||
v.url = L"var";
|
||||
v.type = Item::dir;
|
||||
|
||||
AddDirectory(v, false, &var);
|
||||
|
|
16
core/dirs.h
16
core/dirs.h
|
@ -37,13 +37,13 @@ public:
|
|||
// these methods return false if there is no such a dir
|
||||
bool IsDir(long dir_id);
|
||||
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_tab); // !! zamienic na GetChilds()
|
||||
bool MakePath(long dir_id, std::string & path);
|
||||
bool MakePath(long dir_id, std::wstring & path);
|
||||
bool ChangeParent(long dir_id, long new_parent_id);
|
||||
bool HasParent(long dir_id, long parent_id);
|
||||
bool DelDir(long dir_id);
|
||||
|
||||
int AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file);
|
||||
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
|
||||
int AnalyzePath(const std::wstring & path, long & dir_id, std::wstring & dir, std::wstring & file);
|
||||
static void SplitPath(const std::wstring & path, std::wstring & dir, std::wstring & file);
|
||||
|
||||
DirContainer::ParentIterator FindFirstParent(long parent_id); // !! zmienic w koncu nazwe na FindFirstChild
|
||||
DirContainer::ParentIterator NextParent(DirContainer::ParentIterator i);
|
||||
|
@ -55,8 +55,8 @@ public:
|
|||
Item * GetRootDir();
|
||||
Item * GetEtcDir();
|
||||
Item * GetVarDir();
|
||||
Item * GetDir(const std::string & name, long parent);
|
||||
Item * GetDir(const std::string & path);
|
||||
Item * GetDir(const std::wstring & name, long parent);
|
||||
Item * GetDir(const std::wstring & path);
|
||||
Item * GetDir(long id);
|
||||
Item * AddDir(const Item & item);
|
||||
|
||||
|
@ -74,10 +74,10 @@ private:
|
|||
|
||||
DirContainer dir_tab;
|
||||
|
||||
size_t AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir);
|
||||
std::string analyze_temp;
|
||||
size_t AnalyzeDir(Item * pdir, const std::wstring & path, long & dir_id, std::wstring & dir);
|
||||
std::wstring analyze_temp;
|
||||
|
||||
bool ExtractName(const char * & s, std::string & name);
|
||||
bool ExtractName(const wchar_t * & s, std::wstring & name);
|
||||
bool HasReadExecAccessForRoot(const Item & item);
|
||||
|
||||
};
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include "httpsimpleparser.h"
|
||||
#include "requesttypes.h"
|
||||
#include "misc.h"
|
||||
#include "utf8.h"
|
||||
|
||||
|
||||
class GetParser : public HttpSimpleParser
|
||||
|
@ -19,6 +21,8 @@ class GetParser : public HttpSimpleParser
|
|||
|
||||
const char * get_string;
|
||||
GetTab * get_tab;
|
||||
std::wstring temp;
|
||||
bool input_as_utf8;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -33,8 +37,13 @@ protected:
|
|||
|
||||
virtual void Parameter(std::string &, std::string & value)
|
||||
{
|
||||
get_tab->push_back(value);
|
||||
log << log2 << "Get, value: \"" << value << "\"" << logend;
|
||||
if( input_as_utf8 )
|
||||
Ezc::UTF8ToWide(value, temp);
|
||||
else
|
||||
AssignString(value, temp);
|
||||
|
||||
get_tab->push_back(temp);
|
||||
log << log2 << "Get, value: \"" << temp << "\"" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,6 +55,13 @@ public:
|
|||
{
|
||||
HttpSimpleParser::separator = '/';
|
||||
HttpSimpleParser::read_name = false;
|
||||
input_as_utf8 = false;
|
||||
}
|
||||
|
||||
|
||||
void UTF8(bool utf)
|
||||
{
|
||||
input_as_utf8 = utf;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
struct Group
|
||||
{
|
||||
long id;
|
||||
std::string name; // group name
|
||||
std::wstring name; // group name
|
||||
std::vector<long> members; // users id
|
||||
|
||||
Group()
|
||||
|
|
|
@ -43,7 +43,7 @@ return &(*i);
|
|||
}
|
||||
|
||||
|
||||
Group * Groups::GetGroup(const std::string & name)
|
||||
Group * Groups::GetGroup(const std::wstring & name)
|
||||
{
|
||||
Table::Iterator i = table.FindName(name);
|
||||
|
||||
|
@ -54,7 +54,7 @@ return &(*i);
|
|||
}
|
||||
|
||||
|
||||
long Groups::GetGroupId(const std::string & name)
|
||||
long Groups::GetGroupId(const std::wstring & name)
|
||||
{
|
||||
Group * pgroup = GetGroup(name);
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ public:
|
|||
void Clear();
|
||||
void ReadGroups(Db * db);
|
||||
Group * GetGroup(long group_id);
|
||||
Group * GetGroup(const std::string & name);
|
||||
long GetGroupId(const std::string & name);
|
||||
Group * GetGroup(const std::wstring & name);
|
||||
long GetGroupId(const std::wstring & name);
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
|
|
|
@ -27,7 +27,7 @@ HTMLFilter::Item::Item()
|
|||
|
||||
|
||||
|
||||
void HTMLFilter::Filter(const char * in, std::string & out)
|
||||
void HTMLFilter::Filter(const wchar_t * in, std::wstring & out)
|
||||
{
|
||||
pchar = in;
|
||||
stack_len = 0;
|
||||
|
@ -53,7 +53,7 @@ void HTMLFilter::Deinit()
|
|||
|
||||
|
||||
|
||||
void HTMLFilter::Filter(const std::string & in, std::string & out)
|
||||
void HTMLFilter::Filter(const std::wstring & in, std::wstring & out)
|
||||
{
|
||||
out.reserve(in.size() * 2 + 1);
|
||||
Filter(in.c_str(), out);
|
||||
|
@ -63,7 +63,7 @@ void HTMLFilter::Filter(const std::string & in, std::string & out)
|
|||
HTMLFilter::HTMLFilter()
|
||||
{
|
||||
pstack = new Item[WINIX_HTMLFILTER_STACK_MAXLEN];
|
||||
buffer = new char[WINIX_HTMLFILTER_BUFFER_MAXLEN];
|
||||
buffer = new wchar_t[WINIX_HTMLFILTER_BUFFER_MAXLEN];
|
||||
|
||||
tab_size = 2;
|
||||
trim_white = false;
|
||||
|
@ -78,7 +78,7 @@ HTMLFilter::HTMLFilter(const HTMLFilter & f)
|
|||
{
|
||||
// don't need to copy the stack
|
||||
pstack = new Item[WINIX_HTMLFILTER_STACK_MAXLEN];
|
||||
buffer = new char[WINIX_HTMLFILTER_BUFFER_MAXLEN];
|
||||
buffer = new wchar_t[WINIX_HTMLFILTER_BUFFER_MAXLEN];
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,7 +86,7 @@ HTMLFilter & HTMLFilter::operator=(const HTMLFilter & f)
|
|||
{
|
||||
// don't need to copy the stack
|
||||
pstack = new Item[WINIX_HTMLFILTER_STACK_MAXLEN];
|
||||
buffer = new char[WINIX_HTMLFILTER_BUFFER_MAXLEN];
|
||||
buffer = new wchar_t[WINIX_HTMLFILTER_BUFFER_MAXLEN];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void HTMLFilter::SkipWhiteWithFirstNewLine()
|
|||
|
||||
void HTMLFilter::CheckNewLine()
|
||||
{
|
||||
const char * start = pchar;
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
SkipWhite();
|
||||
last_new_line = (*pchar==10);
|
||||
|
@ -269,7 +269,7 @@ return false;
|
|||
// used for such tags as: script, pre, textarea
|
||||
void HTMLFilter::PutLastTagWithClosingTag()
|
||||
{
|
||||
const char * start = pchar;
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
|
||||
while( *pchar != 0 )
|
||||
|
@ -296,9 +296,9 @@ const char * start = pchar;
|
|||
|
||||
|
||||
|
||||
const char * HTMLFilter::SkipItemCheckXmlSimple()
|
||||
const wchar_t * HTMLFilter::SkipItemCheckXmlSimple()
|
||||
{
|
||||
const char * end = pchar;
|
||||
const wchar_t * end = pchar;
|
||||
|
||||
|
||||
while( *pchar!=0 )
|
||||
|
@ -361,7 +361,7 @@ size_t i;
|
|||
|
||||
|
||||
|
||||
void HTMLFilter::Put(const char * str, const char * end)
|
||||
void HTMLFilter::Put(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
if( str>=end )
|
||||
return;
|
||||
|
@ -372,22 +372,22 @@ void HTMLFilter::Put(const char * str, const char * end)
|
|||
|
||||
|
||||
|
||||
int HTMLFilter::CheckOrphan(const char * str, const char * end, const char * orphan)
|
||||
int HTMLFilter::CheckOrphan(const wchar_t * str, const wchar_t * end, const wchar_t * orphan)
|
||||
{
|
||||
size_t res;
|
||||
|
||||
for( ; str<end && *orphan!=0 ; ++str, ++orphan )
|
||||
{
|
||||
res = ToLower(*(unsigned const char*)str) - ToLower(*(unsigned const char*)orphan);
|
||||
res = ToLower(*str) - ToLower(*orphan);
|
||||
|
||||
if( res != 0 )
|
||||
return res;
|
||||
}
|
||||
|
||||
if( str < end )
|
||||
return ToLower(*(unsigned const char*)str);
|
||||
return ToLower(*str);
|
||||
|
||||
return -ToLower(*(unsigned const char*)orphan);
|
||||
return -int(ToLower(*orphan));
|
||||
}
|
||||
|
||||
|
||||
|
@ -395,7 +395,7 @@ return -ToLower(*(unsigned const char*)orphan);
|
|||
// binary search in table
|
||||
// o1 - index of the first element
|
||||
// o2 - index of the last element
|
||||
bool HTMLFilter::CheckOrphanTable(const char * str, const char * end, const char ** table, size_t o1, size_t o2)
|
||||
bool HTMLFilter::CheckOrphanTable(const wchar_t * str, const wchar_t * end, const wchar_t ** table, size_t o1, size_t o2)
|
||||
{
|
||||
int res;
|
||||
|
||||
|
@ -435,19 +435,33 @@ return false;
|
|||
}
|
||||
|
||||
|
||||
bool HTMLFilter::CheckOrphanLangPl(const char * str, const char * end)
|
||||
bool HTMLFilter::CheckOrphanLangPl(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
// the table must be sorted in alphabetical order
|
||||
// polish letters coded in iso-8859-2
|
||||
static const char * orphans[] = {
|
||||
"(np.", "s.", "a", "ale", "bo", "by", "co", "czy", "do", "go", "i",
|
||||
"ich", "ja", "je", "jej", "jest", "ju¿", "j±", "ku", "li", "mi", "na",
|
||||
"nie", "np.", "nr", "o", "od", "po", "s±", "ta", "to", "tu", "t±",
|
||||
"tê", "u", "w", "we", "wy", "z", "za", "ze", "¿e", "ów"
|
||||
// !! wymieniæ na unikode
|
||||
|
||||
/*
|
||||
tak jak bylo oryginalnie (tylko bez L):
|
||||
static const wchar_t * orphans[] = {
|
||||
L"(np.", L"s.", L"a", L"ale", L"bo", L"by", L"co", L"czy", L"do", L"go", L"i",
|
||||
L"ich", L"ja", L"je", L"jej", L"jest", L"ju¿", L"j±", L"ku", L"li", L"mi", L"na",
|
||||
L"nie", L"np.", L"nr", L"o", L"od", L"po", L"s±", L"ta", L"to", L"tu", L"t±",
|
||||
L"tê", L"u", L"w", L"we", L"wy", L"z", L"za", L"ze", L"¿e", L"ów"
|
||||
};
|
||||
*/
|
||||
|
||||
static const wchar_t * orphans[] = {
|
||||
L"(np.", L"s.", L"a", L"ale", L"bo", L"by", L"co", L"czy", L"do", L"go", L"i",
|
||||
L"ich", L"ja", L"je", L"jej", L"jest", L"juz", L"ja", L"ku", L"li", L"mi", L"na",
|
||||
L"nie", L"np.", L"nr", L"o", L"od", L"po", L"sa", L"ta", L"to", L"tu", L"ta",
|
||||
L"te", L"u", L"w", L"we", L"wy", L"z", L"za", L"ze", L"ze", L"ow"
|
||||
};
|
||||
|
||||
|
||||
|
||||
size_t o1 = 0;
|
||||
size_t o2 = sizeof(orphans) / sizeof(const char*) - 1;
|
||||
size_t o2 = sizeof(orphans) / sizeof(const wchar_t*) - 1;
|
||||
|
||||
return CheckOrphanTable(str, end, orphans, o1, o2);
|
||||
}
|
||||
|
@ -455,21 +469,21 @@ return CheckOrphanTable(str, end, orphans, o1, o2);
|
|||
|
||||
|
||||
// SK i CZ
|
||||
bool HTMLFilter::CheckOrphanLangCz(const char * str, const char * end)
|
||||
bool HTMLFilter::CheckOrphanLangCz(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
// the table must be sorted in alphabetical order
|
||||
static const char * orphans[] = {
|
||||
"a", "i", "k", "o", "s", "u", "v", "z"
|
||||
static const wchar_t * orphans[] = {
|
||||
L"a", L"i", L"k", L"o", L"s", L"u", L"v", L"z"
|
||||
};
|
||||
|
||||
size_t o1 = 0;
|
||||
size_t o2 = sizeof(orphans) / sizeof(const char*) - 1;
|
||||
size_t o2 = sizeof(orphans) / sizeof(const wchar_t*) - 1;
|
||||
|
||||
return CheckOrphanTable(str, end, orphans, o1, o2);
|
||||
}
|
||||
|
||||
|
||||
bool HTMLFilter::CheckOrphan(const char * str, const char * end)
|
||||
bool HTMLFilter::CheckOrphan(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
if( str == end || lang == lang_none )
|
||||
return false;
|
||||
|
@ -482,9 +496,9 @@ return CheckOrphanLangPl(str, end);
|
|||
|
||||
|
||||
|
||||
size_t HTMLFilter::PutNormalTextFillBuffer(const char * & str, const char * & end)
|
||||
size_t HTMLFilter::PutNormalTextFillBuffer(const wchar_t * & str, const wchar_t * & end)
|
||||
{
|
||||
const char * word = str; // pointing at the beginning of a word
|
||||
const wchar_t * word = str; // pointing at the beginning of a word
|
||||
size_t i = 0;
|
||||
// some space in the buffer for non break spaces (orphans) and spaces at the beginning of a line
|
||||
size_t epsilon = WINIX_HTMLFILTER_BUFFER_MAXLEN / 10 + 1;
|
||||
|
@ -552,9 +566,9 @@ return i;
|
|||
}
|
||||
|
||||
|
||||
size_t HTMLFilter::PutNormalTextTrimFillBuffer(const char * & str, const char * & end)
|
||||
size_t HTMLFilter::PutNormalTextTrimFillBuffer(const wchar_t * & str, const wchar_t * & end)
|
||||
{
|
||||
const char * word = str; // pointint at the beginning of a word
|
||||
const wchar_t * word = str; // pointint at the beginning of a word
|
||||
size_t non_whites = 0;
|
||||
size_t i = 0;
|
||||
bool is_white;
|
||||
|
@ -608,7 +622,7 @@ return i;
|
|||
|
||||
|
||||
|
||||
void HTMLFilter::PutNormalText(const char * str, const char * end)
|
||||
void HTMLFilter::PutNormalText(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
size_t buf_len;
|
||||
|
||||
|
@ -620,7 +634,7 @@ size_t buf_len;
|
|||
}
|
||||
|
||||
|
||||
void HTMLFilter::PutNormalTextTrim(const char * str, const char * end)
|
||||
void HTMLFilter::PutNormalTextTrim(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
size_t buf_len;
|
||||
|
||||
|
@ -646,23 +660,23 @@ void HTMLFilter::PutClosingTagMark()
|
|||
|
||||
|
||||
|
||||
void HTMLFilter::PutTagName(const char * name)
|
||||
void HTMLFilter::PutTagName(const wchar_t * name)
|
||||
{
|
||||
(*out_string) += name;
|
||||
}
|
||||
|
||||
|
||||
bool HTMLFilter::IsTagSafe(const char * tag)
|
||||
bool HTMLFilter::IsTagSafe(const wchar_t * tag)
|
||||
{
|
||||
if( !safe_mode )
|
||||
return true;
|
||||
|
||||
static const char * unsafe_tags[] = {
|
||||
"script", "iframe", "frame", "frameset",
|
||||
"applet", "head", "meta", "html", "link", "body"
|
||||
static const wchar_t * unsafe_tags[] = {
|
||||
L"script", L"iframe", L"frame", L"frameset",
|
||||
L"applet", L"head", L"meta", L"html", L"link", L"body"
|
||||
};
|
||||
|
||||
size_t len = sizeof(unsafe_tags) / sizeof(const char*);
|
||||
size_t len = sizeof(unsafe_tags) / sizeof(const wchar_t*);
|
||||
size_t i;
|
||||
|
||||
for(i=0 ; i<len ; ++i)
|
||||
|
@ -679,7 +693,7 @@ return true;
|
|||
|
||||
|
||||
// start, end - arguments
|
||||
void HTMLFilter::PutOpeningTag(const char * start, const char * end)
|
||||
void HTMLFilter::PutOpeningTag(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
if( !IsTagSafe(LastItem().name) )
|
||||
return;
|
||||
|
@ -698,7 +712,7 @@ void HTMLFilter::PutOpeningTag(const char * start, const char * end)
|
|||
|
||||
|
||||
|
||||
void HTMLFilter::PutClosingTag(const char * tag)
|
||||
void HTMLFilter::PutClosingTag(const wchar_t * tag)
|
||||
{
|
||||
if( !IsTagSafe(tag) )
|
||||
return;
|
||||
|
@ -739,8 +753,8 @@ size_t i = 0;
|
|||
|
||||
if( orphan_mode == orphan_nbsp )
|
||||
{
|
||||
static const char nb[] = " ";
|
||||
size_t len = sizeof(nb) / sizeof(char) - 1; // '0' at the end
|
||||
static const wchar_t nb[] = L" ";
|
||||
size_t len = sizeof(nb) / sizeof(wchar_t) - 1; // '0' at the end
|
||||
|
||||
if( index+len < WINIX_HTMLFILTER_BUFFER_MAXLEN-1 )
|
||||
{
|
||||
|
@ -753,7 +767,7 @@ size_t i = 0;
|
|||
if( index+1 < WINIX_HTMLFILTER_BUFFER_MAXLEN-1 )
|
||||
{
|
||||
i = 1;
|
||||
buffer[index] = (char)160;
|
||||
buffer[index] = (wchar_t)160;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -799,8 +813,8 @@ bool HTMLFilter::IsClosingXmlSimpleTagMark()
|
|||
|
||||
bool HTMLFilter::IsOpeningCommentaryTagMark()
|
||||
{
|
||||
static char comm_open[] = "<!--";
|
||||
size_t comm_open_len = sizeof(comm_open) / sizeof(char) - 1;
|
||||
static wchar_t comm_open[] = L"<!--";
|
||||
size_t comm_open_len = sizeof(comm_open) / sizeof(wchar_t) - 1;
|
||||
|
||||
return IsNameEqual(pchar, comm_open, comm_open_len);
|
||||
}
|
||||
|
@ -816,8 +830,8 @@ size_t HTMLFilter::OpeningCommentaryTagMarkSize()
|
|||
// skipping the commentary tag if exists
|
||||
bool HTMLFilter::SkipCommentaryTagIfExists()
|
||||
{
|
||||
static char comm_close[] = "-->";
|
||||
size_t comm_close_len = sizeof(comm_close) / sizeof(char) - 1;
|
||||
static wchar_t comm_close[] = L"-->";
|
||||
size_t comm_close_len = sizeof(comm_close) / sizeof(wchar_t) - 1;
|
||||
|
||||
if( !IsOpeningCommentaryTagMark() )
|
||||
return false;
|
||||
|
@ -837,7 +851,7 @@ return true;
|
|||
}
|
||||
|
||||
|
||||
void HTMLFilter::ReadNormalTextSkipWhite(const char * & start, const char * & last_non_white)
|
||||
void HTMLFilter::ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white)
|
||||
{
|
||||
if( trim_white )
|
||||
{
|
||||
|
@ -875,8 +889,8 @@ void HTMLFilter::ReadNormalTextSkipWhite(const char * & start, const char * & la
|
|||
// reading text between html tags
|
||||
void HTMLFilter::ReadNormalText()
|
||||
{
|
||||
const char * start = pchar;
|
||||
const char * last_non_white = pchar;
|
||||
const wchar_t * start = pchar;
|
||||
const wchar_t * last_non_white = pchar;
|
||||
|
||||
if( last_new_line )
|
||||
ReadNormalTextSkipWhite(start, last_non_white);
|
||||
|
@ -912,7 +926,7 @@ const char * last_non_white = pchar;
|
|||
|
||||
|
||||
// start, end - parameters to a tag
|
||||
void HTMLFilter::PrintItem(const char * start, const char * end)
|
||||
void HTMLFilter::PrintItem(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
if( last_new_line )
|
||||
{
|
||||
|
@ -930,7 +944,7 @@ void HTMLFilter::PrintItem(const char * start, const char * end)
|
|||
|
||||
bool HTMLFilter::ReadItem()
|
||||
{
|
||||
const char * start = pchar;
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
if( *pchar == 0 )
|
||||
return false;
|
||||
|
@ -956,7 +970,7 @@ const char * start = pchar;
|
|||
if( LastItem().type != Item::closing )
|
||||
LastItem().type = (LastItem().name[0] == '!') ? Item::special : Item::opening;
|
||||
|
||||
const char * end = SkipItemCheckXmlSimple();
|
||||
const wchar_t * end = SkipItemCheckXmlSimple();
|
||||
|
||||
if( LastItem().type != Item::closing )
|
||||
PrintItem(start, end);
|
||||
|
@ -969,7 +983,7 @@ return true;
|
|||
|
||||
|
||||
|
||||
int HTMLFilter::ToLower(int c)
|
||||
wchar_t HTMLFilter::ToLower(wchar_t c)
|
||||
{
|
||||
if( c>='A' && c<='Z' )
|
||||
return c - 'A' + 'a';
|
||||
|
@ -978,7 +992,7 @@ return c;
|
|||
}
|
||||
|
||||
|
||||
bool HTMLFilter::IsNameEqual(const char * name1, const char * name2)
|
||||
bool HTMLFilter::IsNameEqual(const wchar_t * name1, const wchar_t * name2)
|
||||
{
|
||||
for( ; *name1!=0 && *name2!=0 ; ++name1, ++name2 )
|
||||
if( ToLower(*name1) != ToLower(*name2) )
|
||||
|
@ -993,7 +1007,7 @@ return false;
|
|||
|
||||
|
||||
// len characters from both strings must be equal
|
||||
bool HTMLFilter::IsNameEqual(const char * name1, const char * name2, size_t len)
|
||||
bool HTMLFilter::IsNameEqual(const wchar_t * name1, const wchar_t * name2, size_t len)
|
||||
{
|
||||
for( ; *name1!=0 && *name2!=0 && len>0 ; ++name1, ++name2, --len )
|
||||
if( ToLower(*name1) != ToLower(*name2) )
|
||||
|
@ -1007,9 +1021,9 @@ return false;
|
|||
|
||||
|
||||
|
||||
bool HTMLFilter::IsLastTag(const char * name)
|
||||
bool HTMLFilter::IsLastTag(const wchar_t * name)
|
||||
{
|
||||
const char * tag = LastItem().name;
|
||||
const wchar_t * tag = LastItem().name;
|
||||
|
||||
return IsNameEqual(name, tag);
|
||||
}
|
||||
|
@ -1019,14 +1033,14 @@ bool HTMLFilter::IsLastTag(const char * name)
|
|||
// checking exceptions for opening tags
|
||||
void HTMLFilter::CheckExceptions()
|
||||
{
|
||||
if( IsLastTag("meta") ||
|
||||
IsLastTag("input") ||
|
||||
IsLastTag("br") ||
|
||||
IsLastTag("hr") ||
|
||||
IsLastTag("img") ||
|
||||
IsLastTag("link") ||
|
||||
IsLastTag("param") ||
|
||||
IsLastTag("area") )
|
||||
if( IsLastTag(L"meta") ||
|
||||
IsLastTag(L"input") ||
|
||||
IsLastTag(L"br") ||
|
||||
IsLastTag(L"hr") ||
|
||||
IsLastTag(L"img") ||
|
||||
IsLastTag(L"link") ||
|
||||
IsLastTag(L"param") ||
|
||||
IsLastTag(L"area") )
|
||||
{
|
||||
LastItem().type = Item::simple;
|
||||
PopStack();
|
||||
|
@ -1034,10 +1048,10 @@ void HTMLFilter::CheckExceptions()
|
|||
}
|
||||
|
||||
// in safe_mode the script tag is ignored
|
||||
if( !safe_mode && IsLastTag("script") )
|
||||
if( !safe_mode && IsLastTag(L"script") )
|
||||
PutLastTagWithClosingTag();
|
||||
|
||||
if( IsLastTag("pre") || IsLastTag("textarea") )
|
||||
if( IsLastTag(L"pre") || IsLastTag(L"textarea") )
|
||||
PutLastTagWithClosingTag();
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1152,7 @@ void HTMLFilter::CheckClosingTags()
|
|||
|
||||
bool HTMLFilter::PrintRest()
|
||||
{
|
||||
const char * start = pchar;
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
// in safe mode we do not print the rest html code
|
||||
if( safe_mode )
|
||||
|
|
|
@ -72,8 +72,8 @@ public:
|
|||
|
||||
|
||||
// main methods used for filtering
|
||||
void Filter(const char * in, std::string & out);
|
||||
void Filter(const std::string & in, std::string & out);
|
||||
void Filter(const wchar_t * in, std::wstring & out);
|
||||
void Filter(const std::wstring & in, std::wstring & out);
|
||||
|
||||
|
||||
// insert a white space into long lines
|
||||
|
@ -114,7 +114,7 @@ protected:
|
|||
|
||||
struct Item
|
||||
{
|
||||
char name[WINIX_HTMLFILTER_ITEM_MAXLEN];
|
||||
wchar_t name[WINIX_HTMLFILTER_ITEM_MAXLEN];
|
||||
size_t name_len;
|
||||
|
||||
enum Type
|
||||
|
@ -135,24 +135,24 @@ protected:
|
|||
|
||||
|
||||
// only this method have direct access to the output string
|
||||
// you can easily change the output from a std::string to something else
|
||||
virtual void Put(const char * str, const char * end);
|
||||
// you can easily change the output from a std::wstring to something else
|
||||
virtual void Put(const wchar_t * str, const wchar_t * end);
|
||||
|
||||
|
||||
Item & GetItem(size_t i);
|
||||
Item & LastItem();
|
||||
|
||||
int ToLower(int c);
|
||||
bool IsNameEqual(const char * name1, const char * name2);
|
||||
bool IsNameEqual(const char * name1, const char * name2, size_t len);
|
||||
bool IsLastTag(const char * name);
|
||||
bool IsTagSafe(const char * tag);
|
||||
wchar_t ToLower(wchar_t c);
|
||||
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2);
|
||||
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2, size_t len);
|
||||
bool IsLastTag(const wchar_t * name);
|
||||
bool IsTagSafe(const wchar_t * tag);
|
||||
|
||||
int CheckOrphan(const char * str, const char * end, const char * orphan);
|
||||
bool CheckOrphanTable(const char * str, const char * end, const char ** table, size_t o1, size_t o2);
|
||||
bool CheckOrphanLangPl(const char * str, const char * end);
|
||||
bool CheckOrphanLangCz(const char * str, const char * end);
|
||||
bool CheckOrphan(const char * str, const char * end);
|
||||
int CheckOrphan(const wchar_t * str, const wchar_t * end, const wchar_t * orphan);
|
||||
bool CheckOrphanTable(const wchar_t * str, const wchar_t * end, const wchar_t ** table, size_t o1, size_t o2);
|
||||
bool CheckOrphanLangPl(const wchar_t * str, const wchar_t * end);
|
||||
bool CheckOrphanLangCz(const wchar_t * str, const wchar_t * end);
|
||||
bool CheckOrphan(const wchar_t * str, const wchar_t * end);
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
|
@ -165,7 +165,7 @@ protected:
|
|||
virtual bool IsClosingTagMark();
|
||||
virtual bool IsClosingXmlSimpleTagMark();
|
||||
bool SkipCommentaryTagIfExists();
|
||||
const char * SkipItemCheckXmlSimple();
|
||||
const wchar_t * SkipItemCheckXmlSimple();
|
||||
|
||||
void PopStack();
|
||||
bool PushStack();
|
||||
|
@ -175,37 +175,37 @@ protected:
|
|||
void CheckStackPrintRest();
|
||||
void AddForgottenTags();
|
||||
void CheckClosingTags();
|
||||
virtual void ReadNormalTextSkipWhite(const char * & start, const char * & last_non_white);
|
||||
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
|
||||
void ReadNormalText();
|
||||
bool PrintRest();
|
||||
void PrintItem(const char * start, const char * end);
|
||||
void PrintItem(const wchar_t * start, const wchar_t * end);
|
||||
void ReadItemName();
|
||||
bool ReadItem();
|
||||
virtual void Init();
|
||||
virtual void Deinit();
|
||||
void Read();
|
||||
|
||||
size_t PutNormalTextTrimFillBuffer(const char * & str, const char * & end);
|
||||
size_t PutNormalTextFillBuffer(const char * & str, const char * & end);
|
||||
virtual void PutNormalText(const char * str, const char * end);
|
||||
virtual void PutNormalTextTrim(const char * str, const char * end);
|
||||
size_t PutNormalTextTrimFillBuffer(const wchar_t * & str, const wchar_t * & end);
|
||||
size_t PutNormalTextFillBuffer(const wchar_t * & str, const wchar_t * & end);
|
||||
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
|
||||
virtual void PutNormalTextTrim(const wchar_t * str, const wchar_t * end);
|
||||
void PutLastTagWithClosingTag();
|
||||
virtual void PutOpeningTagMark();
|
||||
virtual void PutClosingTagMark();
|
||||
virtual void PutTagName(const char * name);
|
||||
virtual void PutOpeningTag(const char * start, const char * end);
|
||||
virtual void PutClosingTag(const char * tag);
|
||||
virtual void PutTagName(const wchar_t * name);
|
||||
virtual void PutOpeningTag(const wchar_t * start, const wchar_t * end);
|
||||
virtual void PutClosingTag(const wchar_t * tag);
|
||||
size_t PutTabsToBuffer(size_t index, size_t len);
|
||||
size_t PutNonBreakSpaceToBuffer(size_t index);
|
||||
void PutTabs(size_t len);
|
||||
void PutNewLine();
|
||||
|
||||
const char * pchar;
|
||||
const wchar_t * pchar;
|
||||
Item empty;
|
||||
Item * pstack; // stack pointer
|
||||
size_t stack_len; // length of the stack
|
||||
char * buffer; // buffer used when printing
|
||||
std::string * out_string;
|
||||
wchar_t * buffer; // buffer used when printing
|
||||
std::wstring * out_string;
|
||||
bool last_new_line;
|
||||
size_t break_after; // insert a space into long lines after break_after characters
|
||||
bool trim_white; // trimming white characters
|
||||
|
|
12
core/item.h
12
core/item.h
|
@ -22,7 +22,7 @@ long parent_id;
|
|||
|
||||
long user_id;
|
||||
long group_id;
|
||||
std::string guest_name; // used as a user name when user_id is equal -1
|
||||
std::wstring guest_name; // used as a user name when user_id is equal -1
|
||||
|
||||
long modification_user_id; // who has modified the item last (not taken into account when checking permissions)
|
||||
|
||||
|
@ -31,10 +31,10 @@ int privileges;
|
|||
tm date_creation;
|
||||
tm date_modification;
|
||||
|
||||
std::string subject;
|
||||
std::string content;
|
||||
std::wstring subject;
|
||||
std::wstring content;
|
||||
long content_id; // used by the database
|
||||
std::string url;
|
||||
std::wstring url;
|
||||
|
||||
enum ContentType
|
||||
{
|
||||
|
@ -77,10 +77,10 @@ enum Auth
|
|||
|
||||
|
||||
Auth auth;
|
||||
std::string auth_path; // path to a file (if auth!=auth_none)
|
||||
std::wstring auth_path; // path to a file (if auth!=auth_none)
|
||||
|
||||
|
||||
std::string html_template;
|
||||
std::wstring html_template;
|
||||
|
||||
|
||||
// methods
|
||||
|
|
|
@ -68,7 +68,7 @@ return last_tab.end();
|
|||
|
||||
|
||||
|
||||
void LastContainer::UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id)
|
||||
void LastContainer::UserLogin(long user_id, const std::wstring & name, unsigned int ip, long session_id)
|
||||
{
|
||||
LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ struct LastItem
|
|||
|
||||
// additional we store the whole string-name
|
||||
// (you can delete a user from the database but we can still print the name)
|
||||
std::string name;
|
||||
std::wstring name;
|
||||
|
||||
// ip address
|
||||
unsigned int ip;
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
void UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id);
|
||||
void UserLogin(long user_id, const std::wstring & name, unsigned int ip, long session_id);
|
||||
void UserLogout(long user_id, long session_id);
|
||||
|
||||
|
||||
|
|
57
core/log.cpp
57
core/log.cpp
|
@ -10,6 +10,7 @@
|
|||
#include "log.h"
|
||||
#include <ctime>
|
||||
#include <string.h>
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
Log::Log()
|
||||
|
@ -64,6 +65,12 @@ void Log::PutDate(Manipulators m)
|
|||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(const void * s)
|
||||
{
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const char * s)
|
||||
|
@ -81,7 +88,6 @@ return *this;
|
|||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -90,23 +96,47 @@ Log & Log::operator<<(const std::string & s)
|
|||
Log & Log::operator<<(const std::string * s)
|
||||
{
|
||||
buffer << *s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(const void * s)
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const wchar_t * s)
|
||||
{
|
||||
if( !s )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::wstring & s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::wstring * s)
|
||||
{
|
||||
buffer << *s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -115,7 +145,6 @@ Log & Log::operator<<(int s)
|
|||
Log & Log::operator<<(long s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -125,7 +154,6 @@ Log & Log::operator<<(long s)
|
|||
Log & Log::operator<<(char s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -134,7 +162,6 @@ Log & Log::operator<<(char s)
|
|||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -143,7 +170,6 @@ Log & Log::operator<<(size_t s)
|
|||
Log & Log::operator<<(double s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -160,7 +186,7 @@ Log & Log::operator<<(Manipulators m)
|
|||
|
||||
case logsavenow:
|
||||
SaveLog();
|
||||
buffer.str( "" );
|
||||
buffer.Clear();
|
||||
item = 0;
|
||||
lines = 0;
|
||||
break;
|
||||
|
@ -171,7 +197,7 @@ Log & Log::operator<<(Manipulators m)
|
|||
if( item >= item_save || lines > 3000 )
|
||||
{
|
||||
SaveLog();
|
||||
buffer.str( "" );
|
||||
buffer.Clear();
|
||||
item = 0;
|
||||
lines = 0;
|
||||
}
|
||||
|
@ -205,18 +231,17 @@ void Log::SystemErr(int err)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void Log::SaveLog()
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return;
|
||||
|
||||
const std::string & source = buffer.str();
|
||||
|
||||
if( source.empty() )
|
||||
if( buffer.Str().empty() )
|
||||
return;
|
||||
|
||||
if( log_stdout )
|
||||
std::cout << source;
|
||||
Ezc::WideToUTF8(buffer.Str(), std::cout);
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
@ -232,7 +257,7 @@ void Log::SaveLog()
|
|||
return;
|
||||
}
|
||||
|
||||
file << source;
|
||||
Ezc::WideToUTF8(buffer.Str(), file);
|
||||
file.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "textstream.h"
|
||||
|
||||
|
||||
// !! dodac manipulator logsave, logi zostana zapisane pod koniec wykonywania jednego requesta (albo po kilku w zaleznosci od jakiejs opcji w konfigu)
|
||||
|
@ -32,10 +33,13 @@ public:
|
|||
void Init(int log_l, const std::string & log_f, bool log_std, int log_request);
|
||||
|
||||
void PutDate(Manipulators m);
|
||||
Log & operator<<(const char * s);
|
||||
Log & operator<<(const void * s);
|
||||
Log & operator<<(const char * s);
|
||||
Log & operator<<(const std::string * s);
|
||||
Log & operator<<(const std::string & s);
|
||||
Log & operator<<(const wchar_t * s);
|
||||
Log & operator<<(const std::wstring * s);
|
||||
Log & operator<<(const std::wstring & s);
|
||||
Log & operator<<(int s);
|
||||
Log & operator<<(long s);
|
||||
Log & operator<<(char s);
|
||||
|
@ -47,7 +51,7 @@ public:
|
|||
void SaveLog();
|
||||
|
||||
private:
|
||||
std::ostringstream buffer;
|
||||
TextStream<std::wstring> buffer;
|
||||
int log_level, current_level;
|
||||
int item, item_save;
|
||||
std::string log_file;
|
||||
|
|
630
core/misc.cpp
630
core/misc.cpp
|
@ -11,10 +11,177 @@
|
|||
#include <sys/stat.h>
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
int Atoi(const std::string & str, int base)
|
||||
{
|
||||
return Atoi(str.c_str(), base);
|
||||
}
|
||||
|
||||
int Atoi(const std::wstring & str, int base)
|
||||
{
|
||||
return Atoi(str.c_str(), base);
|
||||
}
|
||||
|
||||
int Atoi(const char * str, int base)
|
||||
{
|
||||
return static_cast<int>(strtol(str, 0, base));
|
||||
}
|
||||
|
||||
int Atoi(const wchar_t * str, int base)
|
||||
{
|
||||
return static_cast<int>(wcstol(str, 0, base));
|
||||
}
|
||||
|
||||
|
||||
|
||||
long Atol(const std::string & str, int base)
|
||||
{
|
||||
return Atol(str.c_str(), base);
|
||||
}
|
||||
|
||||
long Atol(const std::wstring & str, int base)
|
||||
{
|
||||
return Atol(str.c_str(), base);
|
||||
}
|
||||
|
||||
long Atol(const char * str, int base)
|
||||
{
|
||||
return strtol(str, 0, base);
|
||||
}
|
||||
|
||||
long Atol(const wchar_t * str, int base)
|
||||
{
|
||||
return wcstol(str, 0, base);
|
||||
}
|
||||
|
||||
|
||||
const wchar_t * Itoa(int value, int base)
|
||||
{
|
||||
return Ltoa(value, base);
|
||||
}
|
||||
|
||||
|
||||
const wchar_t * Ltoa(long value, int base)
|
||||
{
|
||||
static wchar_t digits[] = L"0123456789ABCDEF";
|
||||
static wchar_t buffer_[50];
|
||||
wchar_t * buffer = buffer_;
|
||||
size_t i1, i2;
|
||||
long rest;
|
||||
|
||||
i1 = i2 = 0;
|
||||
|
||||
if( base < 2 )
|
||||
base = 2;
|
||||
|
||||
if( base > 16 )
|
||||
base = 16;
|
||||
|
||||
if( value < 0 )
|
||||
{
|
||||
buffer[0] = '-';
|
||||
buffer += 1;
|
||||
value = -value;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
rest = value % base;
|
||||
value = value / base;
|
||||
buffer[i2++] = digits[rest];
|
||||
}
|
||||
while(value != 0);
|
||||
|
||||
buffer[i2--] = 0;
|
||||
|
||||
for( ; i1 < i2 ; ++i1, --i2)
|
||||
{
|
||||
wchar_t temp = buffer[i1];
|
||||
buffer[i1] = buffer[i2];
|
||||
buffer[i2] = temp;
|
||||
}
|
||||
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AssignString(const char * src, std::wstring & dst, bool clear)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if( clear )
|
||||
dst.clear();
|
||||
|
||||
for(len=0 ; src[len] ; ++len){}
|
||||
dst.reserve(len);
|
||||
|
||||
for( ; *src ; ++src )
|
||||
dst += static_cast<unsigned char>(*src);
|
||||
}
|
||||
|
||||
|
||||
void AssignString(const std::string & src, std::wstring & dst, bool clear)
|
||||
{
|
||||
if( clear )
|
||||
dst.clear();
|
||||
|
||||
dst.reserve(src.size());
|
||||
|
||||
for(size_t i=0 ; i<src.size() ; ++i )
|
||||
dst += static_cast<unsigned char>(src[i]);
|
||||
}
|
||||
|
||||
|
||||
void AssignString(const wchar_t * src, std::string & dst, bool clear)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if( clear )
|
||||
dst.clear();
|
||||
|
||||
for(len=0 ; src[len] ; ++len){}
|
||||
dst.reserve(len);
|
||||
|
||||
for( ; *src ; ++src )
|
||||
dst += static_cast<char>(*src);
|
||||
}
|
||||
|
||||
|
||||
void AssignString(const std::wstring & src, std::string & dst, bool clear)
|
||||
{
|
||||
if( clear )
|
||||
dst.clear();
|
||||
|
||||
dst.reserve(src.size());
|
||||
|
||||
for(size_t i=0 ; i<src.size() ; ++i )
|
||||
dst += static_cast<char>(src[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AssignString(const std::string & src, std::string & dst, bool clear)
|
||||
{
|
||||
if( clear )
|
||||
dst.clear();
|
||||
|
||||
dst += src;
|
||||
}
|
||||
|
||||
|
||||
void AssignString(const std::wstring & src, std::wstring & dst, bool clear)
|
||||
{
|
||||
if( clear )
|
||||
dst.clear();
|
||||
|
||||
dst += src;
|
||||
}
|
||||
|
||||
// !! skasowac, jest juz Itoa
|
||||
void ToString(std::string & s, int value)
|
||||
{
|
||||
static char buffer[50];
|
||||
|
@ -33,27 +200,38 @@ static char buffer[50];
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CorrectUrlChar(char c)
|
||||
void ToString(std::wstring & s, int value)
|
||||
{
|
||||
if( (c >= 'a' && c <='z') ||
|
||||
(c >= 'A' && c <='Z') ||
|
||||
(c >= '0' && c <='9') ||
|
||||
(c == '(' || c == ')' || c == '.' || c == ',' || c == '_' )
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static wchar_t buffer[50];
|
||||
|
||||
return false;
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%d", value);
|
||||
s = buffer;
|
||||
}
|
||||
|
||||
|
||||
void ToString(std::wstring & s, long value)
|
||||
{
|
||||
static wchar_t buffer[50];
|
||||
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%ld", value);
|
||||
s = buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CorrectUrlChar(wchar_t c)
|
||||
{
|
||||
return (c >= 'a' && c <='z') ||
|
||||
(c >= 'A' && c <='Z') ||
|
||||
(c >= '0' && c <='9') ||
|
||||
c == '(' || c == ')' || c == '.' || c == ',' || c == '_' || c == '-';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this function checks how many dots there are in the url
|
||||
// if there are more than one (last) dot then the first dots will be changed into '_'
|
||||
void CorrectUrlDots(std::string & url)
|
||||
void CorrectUrlDots(std::wstring & url)
|
||||
{
|
||||
size_t i = url.size();
|
||||
bool was_dot = false;
|
||||
|
@ -64,45 +242,49 @@ bool was_dot = false;
|
|||
{
|
||||
if( was_dot )
|
||||
// only one dot is allowed
|
||||
url[i] = '_';
|
||||
url[i] = '_'; // !! do konfiga
|
||||
|
||||
was_dot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CorrectUrlChars(std::string & url)
|
||||
// !! pomyslec o lepszej nazwie
|
||||
void CorrectUrlChars(std::wstring & url)
|
||||
{
|
||||
std::string::iterator i;
|
||||
std::wstring::iterator i;
|
||||
|
||||
for(i=url.begin(); i != url.end() ; ++i)
|
||||
{
|
||||
if( !CorrectUrlChar(*i) )
|
||||
{
|
||||
int c = ChangeLocalChar(*i);
|
||||
//wchar_t c = ChangeLocalChar(*i);
|
||||
wchar_t c = TemplatesFunctions::locale.Subst(*i);
|
||||
|
||||
if( CorrectUrlChar(c) )
|
||||
*i = c;
|
||||
else
|
||||
*i = '_';
|
||||
*i = '_'; // !! dodac do konfiga
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CorrectUrlOnlyAllowedChar(std::string & url)
|
||||
// !! pomyslec o lepszej nazwie
|
||||
// przerzucic do funkcji - tam gdzie jest PrepareUrl()
|
||||
// bo tutaj nie mamy wskaznika na config
|
||||
void CorrectUrlOnlyAllowedChar(std::wstring & url)
|
||||
{
|
||||
CorrectUrlDots(url);
|
||||
CorrectUrlChars(url);
|
||||
ToSmall(url);
|
||||
Trim(url, '_');
|
||||
|
||||
if( url.empty() || url == "." )
|
||||
if( url.empty() || url == L"." )
|
||||
{
|
||||
// !! brakuje config->
|
||||
//if( config->item_url_empty.empty() )
|
||||
url = "unnamed";
|
||||
url = L"unnamed";
|
||||
//else
|
||||
//{
|
||||
// url = config->item_url_empty;
|
||||
|
@ -121,7 +303,7 @@ void CorrectUrlOnlyAllowedChar(std::string & url)
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int polish_letters_simple[] =
|
||||
{ 'a', 'A',
|
||||
'c', 'C',
|
||||
|
@ -165,110 +347,14 @@ int ChangeLocalChar(unsigned char c)
|
|||
|
||||
return c;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
bool HtmlTryChar(std::ostringstream & out, int c)
|
||||
|
||||
const wchar_t * DateToStr(int year, int month, int day)
|
||||
{
|
||||
if( c == '<' )
|
||||
{
|
||||
out << "<";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( c == '>' )
|
||||
{
|
||||
out << ">";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( c == '&' )
|
||||
{
|
||||
out << "&";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HtmlEscape(std::ostringstream & out, const std::string & in)
|
||||
{
|
||||
std::string::const_iterator i;
|
||||
|
||||
for(i = in.begin() ; i != in.end() ; ++i)
|
||||
{
|
||||
if( !HtmlTryChar(out, *i) )
|
||||
out << *i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string HtmlEscape(const std::string & in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
HtmlEscape(out, in);
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
void HtmlEscapeFormTxt(std::ostringstream & out, const std::string & in)
|
||||
{
|
||||
std::string::const_iterator i;
|
||||
int was_enter = 0; // how many enteres there were before
|
||||
|
||||
if( in.empty() )
|
||||
return;
|
||||
|
||||
out << "<p>";
|
||||
|
||||
// skipping first new line characters
|
||||
for(i = in.begin() ; i != in.end() && (*i==13 || *i==10) ; ++i);
|
||||
|
||||
for( ; i != in.end() ; ++i )
|
||||
{
|
||||
if( *i == 13 ) // skipping stupid characters (\r\n\ in dos mode)
|
||||
continue;
|
||||
|
||||
if( *i == 10 )
|
||||
{
|
||||
++was_enter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( was_enter == 1 )
|
||||
out << "<br>\n";
|
||||
else
|
||||
if( was_enter > 1 )
|
||||
out << "</p>\n<p>";
|
||||
|
||||
was_enter = 0;
|
||||
}
|
||||
|
||||
if( !HtmlTryChar(out, *i) )
|
||||
out << *i;
|
||||
}
|
||||
|
||||
out << "</p>\n";
|
||||
}
|
||||
|
||||
|
||||
std::string HtmlEscapeFormTxt(const std::string & in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
HtmlEscapeFormTxt(out, in);
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(int year, int month, int day)
|
||||
{
|
||||
static const char * month_letter[] = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" };
|
||||
static char buffer[100];
|
||||
static const wchar_t * month_letter[] = { L"I", L"II", L"III", L"IV", L"V", L"VI", L"VII", L"VIII", L"IX", L"X", L"XI", L"XII" };
|
||||
static wchar_t buffer[100];
|
||||
|
||||
--month;
|
||||
|
||||
|
@ -279,19 +365,19 @@ static char buffer[100];
|
|||
month = 11;
|
||||
|
||||
if( year == 0 )
|
||||
sprintf(buffer, "%s %02d", month_letter[month], day);
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%ls %02d", month_letter[month], day);
|
||||
else
|
||||
sprintf(buffer, "%02d %s %02d", year, month_letter[month], day);
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%02d %ls %02d", year, month_letter[month], day);
|
||||
|
||||
// warning: not thread safe (we do not use threads)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(int year, int month, int day, int hour, int min, int sec)
|
||||
const wchar_t * DateToStr(int year, int month, int day, int hour, int min, int sec)
|
||||
{
|
||||
static const char * month_letter[] = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" };
|
||||
static char buffer[100];
|
||||
static const wchar_t * month_letter[] = { L"I", L"II", L"III", L"IV", L"V", L"VI", L"VII", L"VIII", L"IX", L"X", L"XI", L"XII" };
|
||||
static wchar_t buffer[100];
|
||||
|
||||
--month;
|
||||
|
||||
|
@ -302,28 +388,28 @@ static char buffer[100];
|
|||
month = 11;
|
||||
|
||||
if( year == 0 )
|
||||
sprintf(buffer, "%s %02d %02d:%02d:%02d", month_letter[month], day, hour, min, sec);
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%ls %02d %02d:%02d:%02d", month_letter[month], day, hour, min, sec);
|
||||
else
|
||||
sprintf(buffer, "%02d %s %02d %02d:%02d:%02d", year, month_letter[month], day, hour, min, sec);
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%02d %ls %02d %02d:%02d:%02d", year, month_letter[month], day, hour, min, sec);
|
||||
|
||||
// warning: not thread safe (we do not use threads)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(const tm * ptm)
|
||||
const wchar_t * DateToStr(const tm * ptm)
|
||||
{
|
||||
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(const tm & rtm)
|
||||
const wchar_t * DateToStr(const tm & rtm)
|
||||
{
|
||||
return DateToStr(rtm.tm_year + 1900, rtm.tm_mon+1, rtm.tm_mday, rtm.tm_hour, rtm.tm_min, rtm.tm_sec);
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(time_t t)
|
||||
const wchar_t * DateToStr(time_t t)
|
||||
{
|
||||
tm rtm = Time(t);
|
||||
|
||||
|
@ -331,19 +417,19 @@ return DateToStr(rtm);
|
|||
}
|
||||
|
||||
|
||||
const char * DateToStrWithoutHours(const tm * ptm)
|
||||
const wchar_t * DateToStrWithoutHours(const tm * ptm)
|
||||
{
|
||||
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday);
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStrWithoutHours(const tm & rtm)
|
||||
const wchar_t * DateToStrWithoutHours(const tm & rtm)
|
||||
{
|
||||
return DateToStr(rtm.tm_year + 1900, rtm.tm_mon+1, rtm.tm_mday);
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStrWithoutHours(time_t t)
|
||||
const wchar_t * DateToStrWithoutHours(time_t t)
|
||||
{
|
||||
tm rtm = Time(t);
|
||||
|
||||
|
@ -392,9 +478,9 @@ return DateToStrCookie(rtm);
|
|||
}
|
||||
|
||||
|
||||
const char * IpToStr(unsigned int ip_)
|
||||
const wchar_t * IpToStr(unsigned int ip_)
|
||||
{
|
||||
static char buffer[100];
|
||||
static wchar_t buffer[100];
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -404,23 +490,23 @@ static char buffer[100];
|
|||
|
||||
ip.ip = ip_;
|
||||
|
||||
sprintf(buffer, "%u.%u.%u.%u", (int)ip.c[0], (int)ip.c[1], (int)ip.c[2], (int)ip.c[3]);
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%u.%u.%u.%u", (int)ip.c[0], (int)ip.c[1], (int)ip.c[2], (int)ip.c[3]);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * ToStr(int value)
|
||||
const wchar_t * ToStr(int value)
|
||||
{
|
||||
static char buffer[100];
|
||||
static wchar_t buffer[100];
|
||||
|
||||
sprintf(buffer, "%d", value);
|
||||
swprintf(buffer, sizeof(buffer)/sizeof(wchar_t), L"%d", value);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
bool IsWhite(int s)
|
||||
bool IsWhite(wchar_t s)
|
||||
{
|
||||
if( s==' ' || s=='\t' || s==13 || s==160 )
|
||||
return true;
|
||||
|
@ -430,64 +516,8 @@ return false;
|
|||
|
||||
|
||||
|
||||
void TrimWhite(std::string & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for white characters at the end
|
||||
for(i=s.size()-1 ; i>0 && IsWhite(s[i]) ; --i);
|
||||
|
||||
if( i==0 && IsWhite(s[i]) )
|
||||
{
|
||||
// the whole string has white characters
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting white characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, std::string::npos);
|
||||
|
||||
// looking for white characters at the beginning
|
||||
for(i=0 ; i<s.size() && IsWhite(s[i]) ; ++i);
|
||||
|
||||
// deleting white characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
void Trim(std::string & s, char c)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for the 'c' characters at the end
|
||||
for(i=s.size()-1 ; i>0 && s[i]==c ; --i);
|
||||
|
||||
if( i==0 && s[i]==c )
|
||||
{
|
||||
// the whole string has the 'c' characters
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting 'c' characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, std::string::npos);
|
||||
|
||||
// looking for the 'c' characters at the beginning
|
||||
for(i=0 ; i<s.size() && s[i]==c ; ++i);
|
||||
|
||||
// deleting the 'c' characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
const char * SkipWhite(const char * s)
|
||||
|
@ -499,7 +529,16 @@ return s;
|
|||
}
|
||||
|
||||
|
||||
int ToSmall(int c)
|
||||
const wchar_t * SkipWhite(const wchar_t * s)
|
||||
{
|
||||
while( IsWhite(*s) )
|
||||
++s;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
wchar_t ToSmall(wchar_t c)
|
||||
{
|
||||
if( c>='A' && c<='Z' )
|
||||
c = c - 'A' + 'a';
|
||||
|
@ -508,87 +547,24 @@ return c;
|
|||
}
|
||||
|
||||
|
||||
void ToSmall(std::string & s)
|
||||
void ToSmall(std::wstring & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
std::wstring::size_type i;
|
||||
|
||||
for(i=0 ; i<s.size() ; ++i)
|
||||
s[i] = ToSmall(s[i]);
|
||||
}
|
||||
|
||||
|
||||
bool IsSubString(const char * short_str, const char * long_str)
|
||||
{
|
||||
while( *short_str && *long_str && *short_str == *long_str )
|
||||
{
|
||||
++short_str;
|
||||
++long_str;
|
||||
}
|
||||
|
||||
if( *short_str == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool IsSubString(const std::string & short_str, const std::string & long_str)
|
||||
{
|
||||
return IsSubString(short_str.c_str(), long_str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsSubStringNoCase(const char * short_str, const char * long_str)
|
||||
{
|
||||
while( *short_str && *long_str && ToSmall(*short_str) == ToSmall(*long_str) )
|
||||
{
|
||||
++short_str;
|
||||
++long_str;
|
||||
}
|
||||
|
||||
if( *short_str == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool IsSubStringNoCase(const std::string & short_str, const std::string & long_str)
|
||||
{
|
||||
return IsSubStringNoCase(short_str.c_str(), long_str.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool EqualNoCase(const char * str1, const char * str2)
|
||||
{
|
||||
while( *str1 && *str2 && ToSmall(*str1) == ToSmall(*str2) )
|
||||
{
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
|
||||
if( *str1 == 0 && *str2 == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool EqualNoCase(const std::string & str1, const std::string & str2)
|
||||
{
|
||||
return EqualNoCase(str1.c_str(), str2.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool ValidateEmail(const std::string & email)
|
||||
bool ValidateEmail(const std::wstring & email)
|
||||
{
|
||||
if( email.empty() )
|
||||
return false;
|
||||
|
||||
bool correct = true;
|
||||
size_t i;
|
||||
char allowed_chars[] = "!#$%&'*+-/=?^_`{|}~.@";
|
||||
wchar_t allowed_chars[] = L"!#$%&'*+-/=?^_`{|}~.@";
|
||||
int at = 0;
|
||||
|
||||
for(i=0 ; i<email.length() && correct ; ++i)
|
||||
|
@ -625,26 +601,39 @@ return correct;
|
|||
|
||||
|
||||
|
||||
bool IsFile(const char * file)
|
||||
bool IsFile(const wchar_t * file)
|
||||
{
|
||||
struct stat sb;
|
||||
static std::string afile;
|
||||
|
||||
return (stat(file, &sb) == 0);
|
||||
AssignString(file, afile); // or it can be UTF-8 used
|
||||
|
||||
return (stat(afile.c_str(), &sb) == 0);
|
||||
}
|
||||
|
||||
bool IsFile(const std::string & file)
|
||||
bool IsFile(const std::wstring & file)
|
||||
{
|
||||
return IsFile(file.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool CreateDir(const char * dir, int priv)
|
||||
bool CreateDir(const wchar_t * dir, int priv)
|
||||
{
|
||||
static std::string adir;
|
||||
|
||||
if( !IsFile(dir) )
|
||||
{
|
||||
if( mkdir(dir, priv) < 0 )
|
||||
AssignString(dir, adir);
|
||||
|
||||
if( mkdir(adir.c_str(), priv) < 0 )
|
||||
{
|
||||
log << log1 << "Can't create a directory on fs: " << dir << logend;
|
||||
log << log1 << "Can't create a directory on fs: " << adir;
|
||||
|
||||
if( !Equal(dir, adir.c_str()) )
|
||||
log << " original name was: " << dir;
|
||||
|
||||
log << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +642,7 @@ return true;
|
|||
}
|
||||
|
||||
|
||||
bool CreateDir(const std::string & dir, int priv)
|
||||
bool CreateDir(const std::wstring & dir, int priv)
|
||||
{
|
||||
return CreateDir(dir.c_str(), priv);
|
||||
}
|
||||
|
@ -662,10 +651,10 @@ bool CreateDir(const std::string & dir, int priv)
|
|||
|
||||
// creating directories (can be more than one)
|
||||
// 'dirs' can begin with a slash (will be skipped)
|
||||
bool CreateDirs(const char * base_dir, const char * dirs, int priv)
|
||||
bool CreateDirs(const wchar_t * base_dir, const wchar_t * dirs, int priv)
|
||||
{
|
||||
static std::string temp;
|
||||
const char * p = dirs;
|
||||
static std::wstring temp;
|
||||
const wchar_t * p = dirs;
|
||||
|
||||
temp = base_dir; // we start creating from 'base_dir'
|
||||
|
||||
|
@ -698,7 +687,7 @@ return true;
|
|||
|
||||
|
||||
|
||||
bool CreateDirs(const std::string & base_dir, const std::string & dirs, int priv)
|
||||
bool CreateDirs(const std::wstring & base_dir, const std::wstring & dirs, int priv)
|
||||
{
|
||||
return CreateDirs(base_dir.c_str(), dirs.c_str(), priv);
|
||||
}
|
||||
|
@ -727,16 +716,20 @@ return true;
|
|||
}
|
||||
|
||||
|
||||
bool CopyFile(const char * src, const char * dst)
|
||||
bool CopyFile(const wchar_t * src, const wchar_t * dst)
|
||||
{
|
||||
static std::string asrc, adst;
|
||||
FILE * in, * out;
|
||||
|
||||
in = fopen(src, "rb");
|
||||
AssignString(src, asrc);
|
||||
AssignString(dst, adst);
|
||||
|
||||
in = fopen(asrc.c_str(), "rb");
|
||||
|
||||
if( !in )
|
||||
return false;
|
||||
|
||||
out = fopen(dst, "wb");
|
||||
out = fopen(adst.c_str(), "wb");
|
||||
|
||||
if( !out )
|
||||
{
|
||||
|
@ -753,20 +746,55 @@ FILE * in, * out;
|
|||
res = false;
|
||||
|
||||
if( !res )
|
||||
remove(dst);
|
||||
remove(adst.c_str());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool CopyFile(const std::string & src, const std::string & dst)
|
||||
bool CopyFile(const std::wstring & src, const std::wstring & dst)
|
||||
{
|
||||
return CopyFile(src.c_str(), dst.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RemoveFile(const wchar_t * file)
|
||||
{
|
||||
static std::string afile;
|
||||
|
||||
AssignString(file, afile);
|
||||
|
||||
return unlink(afile.c_str()) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool RemoveFile(const std::wstring & file)
|
||||
{
|
||||
return RemoveFile(file.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RenameFile(const wchar_t * from, const wchar_t * to)
|
||||
{
|
||||
static std::string afrom, ato;
|
||||
|
||||
AssignString(from, afrom);
|
||||
AssignString(to, ato);
|
||||
|
||||
return rename(afrom.c_str(), ato.c_str()) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool RenameFile(const std::wstring & from, const std::wstring & to)
|
||||
{
|
||||
return RenameFile(from.c_str(), to.c_str());
|
||||
}
|
||||
|
||||
|
||||
// if there is not an extension it returns a pointer to the last '\0' character
|
||||
const char * GetFileExt(const char * name)
|
||||
const wchar_t * GetFileExt(const wchar_t * name)
|
||||
{
|
||||
size_t i, ilast;
|
||||
|
||||
|
@ -792,28 +820,28 @@ return name + i + 1;
|
|||
}
|
||||
|
||||
|
||||
Item::Auth SelectFileType(const char * file_name)
|
||||
Item::Auth SelectFileType(const wchar_t * file_name)
|
||||
{
|
||||
const char * ext = GetFileExt(file_name);
|
||||
const wchar_t * ext = GetFileExt(file_name);
|
||||
|
||||
// as an image we're using only those types which can be rendered
|
||||
// by a web browser
|
||||
if( EqualNoCase(ext, "jpg") ||
|
||||
EqualNoCase(ext, "jpeg") ||
|
||||
EqualNoCase(ext, "jpe") ||
|
||||
EqualNoCase(ext, "pic") ||
|
||||
EqualNoCase(ext, "tga") ||
|
||||
EqualNoCase(ext, "gif") ||
|
||||
EqualNoCase(ext, "bmp") ||
|
||||
EqualNoCase(ext, "png") )
|
||||
if( EqualNoCase(ext, L"jpg") ||
|
||||
EqualNoCase(ext, L"jpeg") ||
|
||||
EqualNoCase(ext, L"jpe") ||
|
||||
EqualNoCase(ext, L"pic") ||
|
||||
EqualNoCase(ext, L"tga") ||
|
||||
EqualNoCase(ext, L"gif") ||
|
||||
EqualNoCase(ext, L"bmp") ||
|
||||
EqualNoCase(ext, L"png") )
|
||||
return Item::auth_image;
|
||||
|
||||
if( EqualNoCase(ext, "pdf") ||
|
||||
EqualNoCase(ext, "doc") ||
|
||||
EqualNoCase(ext, "xls") ||
|
||||
EqualNoCase(ext, "txt") ||
|
||||
EqualNoCase(ext, "ods") ||
|
||||
EqualNoCase(ext, "odt") )
|
||||
if( EqualNoCase(ext, L"pdf") ||
|
||||
EqualNoCase(ext, L"doc") ||
|
||||
EqualNoCase(ext, L"xls") ||
|
||||
EqualNoCase(ext, L"txt") ||
|
||||
EqualNoCase(ext, L"ods") ||
|
||||
EqualNoCase(ext, L"odt") )
|
||||
return Item::auth_document;
|
||||
|
||||
return Item::auth_other;
|
||||
|
|
310
core/misc.h
310
core/misc.h
|
@ -18,66 +18,306 @@
|
|||
#include "item.h"
|
||||
|
||||
|
||||
int Atoi(const std::string & str, int base = 10);
|
||||
int Atoi(const std::wstring & str, int base = 10);
|
||||
int Atoi(const char * str, int base = 10);
|
||||
int Atoi(const wchar_t * str, int base = 10);
|
||||
|
||||
long Atol(const std::string & str, int base = 10);
|
||||
long Atol(const std::wstring & str, int base = 10);
|
||||
long Atol(const char * str, int base = 10);
|
||||
long Atol(const wchar_t * str, int base = 10);
|
||||
|
||||
|
||||
// warning: it uses its own static buffer
|
||||
// one buffer for both these functions
|
||||
const wchar_t * Itoa(int value, int base = 10);
|
||||
const wchar_t * Ltoa(long value, int base = 10);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AssignString(const char * src, std::wstring & dst, bool clear = true);
|
||||
void AssignString(const std::string & src, std::wstring & dst, bool clear = true);
|
||||
void AssignString(const wchar_t * src, std::string & dst, bool clear = true);
|
||||
void AssignString(const std::wstring & src, std::string & dst, bool clear = true);
|
||||
void AssignString(const std::string & src, std::string & dst, bool clear = true);
|
||||
void AssignString(const std::wstring & src, std::wstring & dst, bool clear = true);
|
||||
|
||||
|
||||
|
||||
void ToString(std::string & s, int value);
|
||||
void ToString(std::string & s, long value);
|
||||
int ChangeLocalChar(unsigned char c);
|
||||
void ToString(std::wstring & s, int value);
|
||||
void ToString(std::wstring & s, long value);
|
||||
|
||||
bool CorrectUrlChar(char c);
|
||||
void CorrectUrlDots(std::string & url);
|
||||
void CorrectUrlChars(std::string & url);
|
||||
void CorrectUrlOnlyAllowedChar(std::string & url);
|
||||
//int ChangeLocalChar(unsigned char c);
|
||||
|
||||
void HtmlEscape(std::ostringstream & out, const std::string & in);
|
||||
void HtmlEscapeFormTxt(std::ostringstream & out, const std::string & in);
|
||||
std::string HtmlEscape(const std::string & in);
|
||||
std::string HtmlEscapeFormTxt(const std::string & in);
|
||||
bool CorrectUrlChar(wchar_t c);
|
||||
void CorrectUrlDots(std::wstring & url);
|
||||
void CorrectUrlChars(std::wstring & url);
|
||||
void CorrectUrlOnlyAllowedChar(std::wstring & url);
|
||||
|
||||
const char * DateToStr(int year, int month, int day);
|
||||
const char * DateToStr(int year, int month, int day, int hour, int min, int sec);
|
||||
const char * DateToStr(const tm * ptm);
|
||||
const char * DateToStr(const tm & rtm);
|
||||
const char * DateToStr(time_t t);
|
||||
const char * DateToStrWithoutHours(const tm * ptm);
|
||||
const char * DateToStrWithoutHours(const tm & rtm);
|
||||
const char * DateToStrWithoutHours(time_t t);
|
||||
|
||||
const wchar_t * DateToStr(int year, int month, int day);
|
||||
const wchar_t * DateToStr(int year, int month, int day, int hour, int min, int sec);
|
||||
const wchar_t * DateToStr(const tm * ptm);
|
||||
const wchar_t * DateToStr(const tm & rtm);
|
||||
const wchar_t * DateToStr(time_t t);
|
||||
const wchar_t * DateToStrWithoutHours(const tm * ptm);
|
||||
const wchar_t * DateToStrWithoutHours(const tm & rtm);
|
||||
const wchar_t * DateToStrWithoutHours(time_t t);
|
||||
|
||||
const char * DateToStrCookie(int year, int month, int day, int hour, int min, int sec);
|
||||
const char * DateToStrCookie(const tm * ptm);
|
||||
const char * DateToStrCookie(const tm & rtm);
|
||||
const char * DateToStrCookie(time_t t);
|
||||
|
||||
const char * IpToStr(unsigned int ip_);
|
||||
const wchar_t * IpToStr(unsigned int ip_);
|
||||
|
||||
bool IsWhite(wchar_t s);
|
||||
|
||||
template<class StringType>
|
||||
void TrimWhite(StringType & s)
|
||||
{
|
||||
typename StringType::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for white characters at the end
|
||||
for(i=s.size()-1 ; i>0 && IsWhite(s[i]) ; --i);
|
||||
|
||||
if( i==0 && IsWhite(s[i]) )
|
||||
{
|
||||
// the whole string has white characters
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting white characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, StringType::npos);
|
||||
|
||||
// looking for white characters at the beginning
|
||||
for(i=0 ; i<s.size() && IsWhite(s[i]) ; ++i);
|
||||
|
||||
// deleting white characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void Trim(StringType & s, wchar_t c)
|
||||
{
|
||||
typename StringType::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for the 'c' characters at the end
|
||||
for(i=s.size()-1 ; i>0 && s[i]==c ; --i);
|
||||
|
||||
if( i==0 && s[i]==c )
|
||||
{
|
||||
// the whole string has the 'c' characters
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting 'c' characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, StringType::npos);
|
||||
|
||||
// looking for the 'c' characters at the beginning
|
||||
for(i=0 ; i<s.size() && s[i]==c ; ++i);
|
||||
|
||||
// deleting the 'c' characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
wchar_t ToSmall(wchar_t c);
|
||||
void ToSmall(std::wstring & s);
|
||||
|
||||
bool IsWhite(int s);
|
||||
void TrimWhite(std::string & s);
|
||||
void Trim(std::string & s, char c);
|
||||
int ToSmall(int c);
|
||||
void ToSmall(std::string & s);
|
||||
const char * SkipWhite(const char * s);
|
||||
const char * ToStr(int value);
|
||||
const wchar_t * SkipWhite(const wchar_t * s);
|
||||
|
||||
const wchar_t * ToStr(int value); // !! zamienic na ToString() tak jak pozosta³e metody (na poczatku)
|
||||
|
||||
/*
|
||||
bool IsSubString(const char * short_str, const char * long_str);
|
||||
bool IsSubString(const std::string & short_str, const std::string & long_str);
|
||||
bool IsSubStringNoCase(const char * short_str, const char * long_str);
|
||||
bool IsSubStringNoCase(const std::string & short_str, const std::string & long_str);
|
||||
bool EqualNoCase(const char * str1, const char * str2);
|
||||
bool EqualNoCase(const std::string & str1, const std::string & str2);
|
||||
*/
|
||||
|
||||
bool ValidateEmail(const std::string & email);
|
||||
template<class StringType1, class StringType2>
|
||||
bool IsSubString(const StringType1 * short_str, const StringType2 * long_str)
|
||||
{
|
||||
while( *short_str && *long_str && wchar_t(*short_str) == wchar_t(*long_str) )
|
||||
{
|
||||
++short_str;
|
||||
++long_str;
|
||||
}
|
||||
|
||||
bool IsFile(const char * file);
|
||||
bool IsFile(const std::string & file);
|
||||
bool CreateDir(const char * dir, int priv);
|
||||
bool CreateDir(const std::string & dir, int priv);
|
||||
bool CreateDirs(const char * base_dir, const char * dirs, int priv);
|
||||
bool CreateDirs(const std::string & base_dir, const std::string & dirs, int priv);
|
||||
if( *short_str == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool IsSubString(const StringType1 & short_str, const StringType2 & long_str)
|
||||
{
|
||||
return IsSubString(short_str.c_str(), long_str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool IsSubStringNoCase(const StringType1 * short_str, const StringType2 * long_str)
|
||||
{
|
||||
while( *short_str && *long_str && ToSmall(*short_str) == ToSmall(*long_str) )
|
||||
{
|
||||
++short_str;
|
||||
++long_str;
|
||||
}
|
||||
|
||||
if( *short_str == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool IsSubStringNoCase(const StringType1 & short_str, const StringType2 & long_str)
|
||||
{
|
||||
return IsSubStringNoCase(short_str.c_str(), long_str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool Equal(const StringType1 * str1, const StringType2 * str2)
|
||||
{
|
||||
while( *str1 && *str2 && wchar_t(*str1) == wchar_t(*str2) )
|
||||
{
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
|
||||
if( *str1 == 0 && *str2 == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool Equal(const StringType1 & str1, const StringType2 & str2)
|
||||
{
|
||||
return Equal(str1.c_str(), str2.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool EqualNoCase(const StringType1 * str1, const StringType2 * str2)
|
||||
{
|
||||
while( *str1 && *str2 && ToSmall(*str1) == ToSmall(*str2) )
|
||||
{
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
|
||||
if( *str1 == 0 && *str2 == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool EqualNoCase(const StringType1 & str1, const StringType2 & str2)
|
||||
{
|
||||
return EqualNoCase(str1.c_str(), str2.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void NoLastSlash(StringType & s)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
size_t i = s.size();
|
||||
|
||||
for( ; i>0 && s[i-1]=='/' ; --i);
|
||||
|
||||
if( i < s.size() )
|
||||
s.erase(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void NoFirstHttp(StringType & s)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
const char http[] = "http://";
|
||||
const char https[] = "https://";
|
||||
|
||||
if( IsSubStringNoCase(http, s.c_str()) )
|
||||
{
|
||||
s.erase(0, sizeof(http)/sizeof(char));
|
||||
}
|
||||
else
|
||||
if( IsSubStringNoCase(https, s.c_str()) )
|
||||
{
|
||||
s.erase(0, sizeof(https)/sizeof(char));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool ValidateEmail(const std::wstring & email);
|
||||
|
||||
bool IsFile(const wchar_t * file);
|
||||
bool IsFile(const std::wstring & file);
|
||||
bool CreateDir(const wchar_t * dir, int priv);
|
||||
bool CreateDir(const std::wstring & dir, int priv);
|
||||
bool CreateDirs(const wchar_t * base_dir, const wchar_t * dirs, int priv);
|
||||
bool CreateDirs(const std::wstring & base_dir, const std::wstring & dirs, int priv);
|
||||
|
||||
bool CopyFile(FILE * in, FILE * out);
|
||||
bool CopyFile(const char * src, const char * dst);
|
||||
bool CopyFile(const std::string & src, const std::string & dst);
|
||||
bool CopyFile(const wchar_t * src, const wchar_t * dst);
|
||||
bool CopyFile(const std::wstring & src, const std::wstring & dst);
|
||||
|
||||
const char * GetFileExt(const char * name);
|
||||
Item::Auth SelectFileType(const char * file_name);
|
||||
bool RemoveFile(const wchar_t * file);
|
||||
bool RemoveFile(const std::wstring & file);
|
||||
|
||||
bool RenameFile(const wchar_t * from, const wchar_t * to);
|
||||
bool RenameFile(const std::wstring & from, const std::wstring & to);
|
||||
|
||||
const wchar_t * GetFileExt(const wchar_t * name);
|
||||
Item::Auth SelectFileType(const wchar_t * file_name);
|
||||
|
||||
time_t Time(const tm & par);
|
||||
time_t Time(const tm * par);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "mount.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ return true;
|
|||
|
||||
|
||||
|
||||
bool Mount::IsArg(int code, const char * arg)
|
||||
bool Mount::IsArg(int code, const wchar_t * arg)
|
||||
{
|
||||
ParamRow::ParamArg::iterator i;
|
||||
|
||||
|
@ -63,7 +63,7 @@ return false;
|
|||
}
|
||||
|
||||
|
||||
bool Mount::IsArg(int code, const std::string & arg)
|
||||
bool Mount::IsArg(int code, const std::wstring & arg)
|
||||
{
|
||||
return IsArg(code, arg.c_str());
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ bool Mount::IsArg(int code, int arg)
|
|||
|
||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
||||
{
|
||||
if( atoi(i->c_str()) == arg )
|
||||
if( Atoi(*i) == arg )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ return false;
|
|||
}
|
||||
|
||||
|
||||
const std::string & Mount::Arg(int code, int arg) const
|
||||
const std::wstring & Mount::Arg(int code, int arg) const
|
||||
{
|
||||
if( code < 0 || code >= (int)param.size() )
|
||||
return empty_str;
|
||||
|
@ -104,7 +104,7 @@ return param[code].arg[arg];
|
|||
}
|
||||
|
||||
|
||||
const std::string & Mount::FirstArg(int code) const
|
||||
const std::wstring & Mount::FirstArg(int code) const
|
||||
{
|
||||
return Arg(code, 0);
|
||||
}
|
||||
|
|
12
core/mount.h
12
core/mount.h
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
struct ParamRow
|
||||
{
|
||||
typedef std::vector<std::string> ParamArg;
|
||||
typedef std::vector<std::wstring> ParamArg;
|
||||
|
||||
bool defined;
|
||||
ParamArg arg;
|
||||
|
@ -48,21 +48,21 @@ public:
|
|||
|
||||
bool IsPar(int code);
|
||||
|
||||
bool IsArg(int code, const char * arg);
|
||||
bool IsArg(int code, const std::string & arg);
|
||||
bool IsArg(int code, const wchar_t * arg);
|
||||
bool IsArg(int code, const std::wstring & arg);
|
||||
bool IsArg(int code, int arg);
|
||||
|
||||
// returning the arg argument if defined (or an empty string)
|
||||
const std::string & Arg(int code, int arg) const;
|
||||
const std::wstring & Arg(int code, int arg) const;
|
||||
|
||||
// returning the first argument (arg=0) if defined (or an empty string)
|
||||
const std::string & FirstArg(int code) const;
|
||||
const std::wstring & FirstArg(int code) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// for Arg() methods when the argument is not defined
|
||||
const std::string empty_str;
|
||||
const std::wstring empty_str;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,19 +27,19 @@ void MountParser::SetDirs(Dirs * pdirs)
|
|||
}
|
||||
|
||||
|
||||
void MountParser::SetMountTypeTab(const std::vector<std::string> & tab)
|
||||
void MountParser::SetMountTypeTab(const std::vector<std::wstring> & tab)
|
||||
{
|
||||
mount_type_tab = &tab;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetMountFsTab(const std::vector<std::string> & tab)
|
||||
void MountParser::SetMountFsTab(const std::vector<std::wstring> & tab)
|
||||
{
|
||||
mount_fs_tab = &tab;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetMountParTab(const std::vector<std::string> & tab)
|
||||
void MountParser::SetMountParTab(const std::vector<std::wstring> & tab)
|
||||
{
|
||||
mount_par_tab = &tab;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void MountParser::SkipLine()
|
|||
}
|
||||
|
||||
|
||||
void MountParser::ReadWordQuote(std::string & res)
|
||||
void MountParser::ReadWordQuote(std::wstring & res)
|
||||
{
|
||||
++pinput;
|
||||
|
||||
|
@ -102,7 +102,7 @@ void MountParser::ReadWordQuote(std::string & res)
|
|||
|
||||
|
||||
// a white character is the separator
|
||||
void MountParser::ReadWordWhite(std::string & res)
|
||||
void MountParser::ReadWordWhite(std::wstring & res)
|
||||
{
|
||||
while( *pinput && *pinput!=10 && !IsWhite(*pinput) )
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ void MountParser::ReadWordWhite(std::string & res)
|
|||
|
||||
|
||||
// the comma or the second bracket ')' are the separators
|
||||
void MountParser::ReadWordComma(std::string & res)
|
||||
void MountParser::ReadWordComma(std::wstring & res)
|
||||
{
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!=')' )
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ void MountParser::ReadWordComma(std::string & res)
|
|||
}
|
||||
|
||||
|
||||
void MountParser::ReadWord(std::string & res, bool comma_bracket_separator)
|
||||
void MountParser::ReadWord(std::wstring & res, bool comma_bracket_separator)
|
||||
{
|
||||
res.clear();
|
||||
SkipWhite();
|
||||
|
@ -192,7 +192,7 @@ void MountParser::ReadParamArgs(Mount::ParamRow::ParamArg & args)
|
|||
|
||||
|
||||
|
||||
void MountParser::ReadParamName(std::string & res)
|
||||
void MountParser::ReadParamName(std::wstring & res)
|
||||
{
|
||||
SkipWhite();
|
||||
res.clear();
|
||||
|
@ -205,7 +205,7 @@ void MountParser::ReadParamName(std::string & res)
|
|||
}
|
||||
|
||||
|
||||
void MountParser::ReadParam(std::string & res, Mount::ParamRow::ParamArg & args)
|
||||
void MountParser::ReadParam(std::wstring & res, Mount::ParamRow::ParamArg & args)
|
||||
{
|
||||
ReadParamName(res);
|
||||
|
||||
|
@ -221,7 +221,7 @@ void MountParser::ReadParam(std::string & res, Mount::ParamRow::ParamArg & args)
|
|||
}
|
||||
|
||||
|
||||
int MountParser::FindIndex(const std::vector<std::string> * tab, const std::string & value)
|
||||
int MountParser::FindIndex(const std::vector<std::wstring> * tab, const std::wstring & value)
|
||||
{
|
||||
for(size_t i=0 ; i < tab->size() ; ++i)
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
|
|||
|
||||
|
||||
|
||||
Error MountParser::Parse(const std::string & input, std::map<long, Mount> & output)
|
||||
Error MountParser::Parse(const std::wstring & input, std::map<long, Mount> & output)
|
||||
{
|
||||
if( !dirs || !mount_type_tab || !mount_fs_tab || !mount_par_tab )
|
||||
{
|
||||
|
|
|
@ -28,32 +28,32 @@ class MountParser
|
|||
public:
|
||||
|
||||
MountParser();
|
||||
Error Parse(const std::string & input, std::map<long, Mount> & output);
|
||||
Error Parse(const std::wstring & input, std::map<long, Mount> & output);
|
||||
void SetDirs(Dirs * pdirs);
|
||||
void SetMountTypeTab(const std::vector<std::string> & tab);
|
||||
void SetMountFsTab(const std::vector<std::string> & tab);
|
||||
void SetMountParTab(const std::vector<std::string> & tab);
|
||||
void SetMountTypeTab(const std::vector<std::wstring> & tab);
|
||||
void SetMountFsTab(const std::vector<std::wstring> & tab);
|
||||
void SetMountParTab(const std::vector<std::wstring> & tab);
|
||||
|
||||
private:
|
||||
|
||||
Dirs * dirs;
|
||||
|
||||
const std::vector<std::string> * mount_type_tab;
|
||||
const std::vector<std::string> * mount_fs_tab;
|
||||
const std::vector<std::string> * mount_par_tab;
|
||||
const std::vector<std::wstring> * mount_type_tab;
|
||||
const std::vector<std::wstring> * mount_fs_tab;
|
||||
const std::vector<std::wstring> * mount_par_tab;
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipLine();
|
||||
void ReadWordQuote(std::string & res);
|
||||
void ReadWordWhite(std::string & res);
|
||||
void ReadWordComma(std::string & res);
|
||||
void ReadWord(std::string & res, bool comma_bracket_separator = false);
|
||||
void ReadWordQuote(std::wstring & res);
|
||||
void ReadWordWhite(std::wstring & res);
|
||||
void ReadWordComma(std::wstring & res);
|
||||
void ReadWord(std::wstring & res, bool comma_bracket_separator = false);
|
||||
void ReadParamArgsLoop(Mount::ParamRow::ParamArg & args);
|
||||
void ReadParamArgs(Mount::ParamRow::ParamArg & args);
|
||||
void ReadParamName(std::string & res);
|
||||
void ReadParam(std::string & res, Mount::ParamRow::ParamArg & args);
|
||||
int FindIndex(const std::vector<std::string> * tab, const std::string & value);
|
||||
void ReadParamName(std::wstring & res);
|
||||
void ReadParam(std::wstring & res, Mount::ParamRow::ParamArg & args);
|
||||
int FindIndex(const std::vector<std::wstring> * tab, const std::wstring & value);
|
||||
void ReadMountType();
|
||||
void ReadMountPoint();
|
||||
void ReadFs();
|
||||
|
@ -61,9 +61,9 @@ private:
|
|||
void ReadMountParams();
|
||||
void ReadRow(std::map<long, Mount> & output);
|
||||
|
||||
const char * pinput;
|
||||
std::string temp;
|
||||
std::string temp_arg;
|
||||
const wchar_t * pinput;
|
||||
std::wstring temp;
|
||||
std::wstring temp_arg;
|
||||
Mount::ParamRow::ParamArg param_args;
|
||||
|
||||
|
||||
|
|
|
@ -24,28 +24,28 @@ Mounts::Mounts()
|
|||
|
||||
void Mounts::CreateMountType()
|
||||
{
|
||||
mount_type_cms = AddMountType("cms");
|
||||
mount_type_thread = AddMountType("thread");
|
||||
mount_type_cms = AddMountType(L"cms");
|
||||
mount_type_thread = AddMountType(L"thread");
|
||||
}
|
||||
|
||||
|
||||
void Mounts::CreateMountFs()
|
||||
{
|
||||
mount_fs_simplefs = AddMountFs("simplefs");
|
||||
mount_fs_hashfs = AddMountFs("hashfs");
|
||||
mount_fs_simplefs = AddMountFs(L"simplefs");
|
||||
mount_fs_hashfs = AddMountFs(L"hashfs");
|
||||
}
|
||||
|
||||
|
||||
void Mounts::CreateMountPar()
|
||||
{
|
||||
mount_par_page = AddMountPar("page");
|
||||
mount_par_thread = AddMountPar("thread");
|
||||
mount_par_createthread_on = AddMountPar("createthread_on");
|
||||
mount_par_only_root_remove = AddMountPar("only_root_remove");
|
||||
mount_par_emacs_on = AddMountPar("emacs_on");
|
||||
mount_par_mkdir_on = AddMountPar("mkdir_on");
|
||||
mount_par_app = AddMountPar("app");
|
||||
mount_par_html_template = AddMountPar("html_template");
|
||||
mount_par_page = AddMountPar(L"page");
|
||||
mount_par_thread = AddMountPar(L"thread");
|
||||
mount_par_createthread_on = AddMountPar(L"createthread_on");
|
||||
mount_par_only_root_remove = AddMountPar(L"only_root_remove");
|
||||
mount_par_emacs_on = AddMountPar(L"emacs_on");
|
||||
mount_par_mkdir_on = AddMountPar(L"mkdir_on");
|
||||
mount_par_app = AddMountPar(L"app");
|
||||
mount_par_html_template = AddMountPar(L"html_template");
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ void Mounts::SetRequest(Request * prequest)
|
|||
|
||||
|
||||
|
||||
int Mounts::AddMountType(const char * type)
|
||||
int Mounts::AddMountType(const wchar_t * type)
|
||||
{
|
||||
mount_type_tab.push_back(type);
|
||||
|
||||
|
@ -86,13 +86,13 @@ return static_cast<int>(mount_type_tab.size()) - 1;
|
|||
}
|
||||
|
||||
|
||||
int Mounts::AddMountType(const std::string & type)
|
||||
int Mounts::AddMountType(const std::wstring & type)
|
||||
{
|
||||
return AddMountType(type.c_str());
|
||||
}
|
||||
|
||||
|
||||
int Mounts::AddMountFs(const char * fs)
|
||||
int Mounts::AddMountFs(const wchar_t * fs)
|
||||
{
|
||||
mount_fs_tab.push_back(fs);
|
||||
|
||||
|
@ -100,7 +100,7 @@ return static_cast<int>(mount_fs_tab.size()) - 1;
|
|||
}
|
||||
|
||||
|
||||
const std::string & Mounts::GetMountType(int id)
|
||||
const std::wstring & Mounts::GetMountType(int id)
|
||||
{
|
||||
if( id < 0 || id >= (int)mount_type_tab.size() )
|
||||
return empty_str;
|
||||
|
@ -109,7 +109,7 @@ const std::string & Mounts::GetMountType(int id)
|
|||
}
|
||||
|
||||
|
||||
int Mounts::FindMountType(const std::string & type)
|
||||
int Mounts::FindMountType(const std::wstring & type)
|
||||
{
|
||||
for(size_t i=0 ; i<mount_type_tab.size() ; ++i)
|
||||
if( mount_type_tab[i] == type )
|
||||
|
@ -120,13 +120,13 @@ return -1;
|
|||
|
||||
|
||||
|
||||
int Mounts::AddMountFs(const std::string & fs)
|
||||
int Mounts::AddMountFs(const std::wstring & fs)
|
||||
{
|
||||
return AddMountFs(fs.c_str());
|
||||
}
|
||||
|
||||
|
||||
const std::string & Mounts::GetMountFs(int id)
|
||||
const std::wstring & Mounts::GetMountFs(int id)
|
||||
{
|
||||
if( id < 0 || id >= (int)mount_fs_tab.size() )
|
||||
return empty_str;
|
||||
|
@ -135,7 +135,7 @@ const std::string & Mounts::GetMountFs(int id)
|
|||
}
|
||||
|
||||
|
||||
int Mounts::AddMountPar(const char * par)
|
||||
int Mounts::AddMountPar(const wchar_t * par)
|
||||
{
|
||||
mount_par_tab.push_back(par);
|
||||
|
||||
|
@ -144,13 +144,13 @@ return static_cast<int>(mount_par_tab.size()) - 1;
|
|||
|
||||
|
||||
|
||||
int Mounts::AddMountPar(const std::string & par)
|
||||
int Mounts::AddMountPar(const std::wstring & par)
|
||||
{
|
||||
return AddMountPar(par.c_str());
|
||||
}
|
||||
|
||||
|
||||
const std::string & Mounts::GetMountPar(int id)
|
||||
const std::wstring & Mounts::GetMountPar(int id)
|
||||
{
|
||||
if( id < 0 || id >= (int)mount_par_tab.size() )
|
||||
return empty_str;
|
||||
|
@ -161,7 +161,7 @@ const std::string & Mounts::GetMountPar(int id)
|
|||
|
||||
|
||||
// reading from 'mounts'
|
||||
Error Mounts::ReadMounts(const std::string & mounts)
|
||||
Error Mounts::ReadMounts(const std::wstring & mounts)
|
||||
{
|
||||
mount_parser.SetDirs(dirs);
|
||||
mount_parser.SetMountTypeTab(mount_type_tab);
|
||||
|
@ -187,7 +187,7 @@ return err;
|
|||
// reading from /etc/fstab
|
||||
Error Mounts::ReadMounts()
|
||||
{
|
||||
static std::string file = "fstab";
|
||||
static std::wstring file = L"fstab";
|
||||
|
||||
Item * etc = dirs->GetEtcDir();
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ public:
|
|||
/*
|
||||
mount point's types
|
||||
*/
|
||||
int AddMountType(const char * type);
|
||||
int AddMountType(const std::string & type);
|
||||
const std::string & GetMountType(int id);
|
||||
int AddMountType(const wchar_t * type);
|
||||
int AddMountType(const std::wstring & type);
|
||||
const std::wstring & GetMountType(int id);
|
||||
|
||||
// id of a specific mount type (the id is always valid)
|
||||
int MountTypeCms() { return mount_type_cms; }
|
||||
|
@ -41,15 +41,15 @@ public:
|
|||
|
||||
// return -1 if there is no such a mount type
|
||||
// or index otherwhise
|
||||
int FindMountType(const std::string & type);
|
||||
int FindMountType(const std::wstring & type);
|
||||
|
||||
|
||||
/*
|
||||
file systems
|
||||
*/
|
||||
int AddMountFs(const char * fs);
|
||||
int AddMountFs(const std::string & fs);
|
||||
const std::string & GetMountFs(int id);
|
||||
int AddMountFs(const wchar_t * fs);
|
||||
int AddMountFs(const std::wstring & fs);
|
||||
const std::wstring & GetMountFs(int id);
|
||||
|
||||
// id of a specific file system (the id is always valid)
|
||||
int MountFsSimplefs() { return mount_fs_simplefs; }
|
||||
|
@ -59,9 +59,9 @@ public:
|
|||
/*
|
||||
mount point's parameters
|
||||
*/
|
||||
int AddMountPar(const char * par);
|
||||
int AddMountPar(const std::string & par);
|
||||
const std::string & GetMountPar(int id);
|
||||
int AddMountPar(const wchar_t * par);
|
||||
int AddMountPar(const std::wstring & par);
|
||||
const std::wstring & GetMountPar(int id);
|
||||
|
||||
int MountParPage() { return mount_par_page; }
|
||||
int MountParThread() { return mount_par_thread; }
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
Mounts();
|
||||
void CreateMounts();
|
||||
|
||||
Error ReadMounts(const std::string & mounts);
|
||||
Error ReadMounts(const std::wstring & mounts);
|
||||
Error ReadMounts();
|
||||
|
||||
void CalcCurMount();
|
||||
|
@ -102,27 +102,27 @@ private:
|
|||
Dirs * dirs;
|
||||
Request * request;
|
||||
|
||||
const std::string empty_str;
|
||||
const std::wstring empty_str;
|
||||
|
||||
MountParser mount_parser;
|
||||
|
||||
// cms
|
||||
// thread
|
||||
std::vector<std::string> mount_type_tab;
|
||||
std::vector<std::wstring> mount_type_tab;
|
||||
|
||||
int mount_type_cms;
|
||||
int mount_type_thread;
|
||||
|
||||
// simplefs
|
||||
// hashfs
|
||||
std::vector<std::string> mount_fs_tab;
|
||||
std::vector<std::wstring> mount_fs_tab;
|
||||
|
||||
int mount_fs_simplefs;
|
||||
int mount_fs_hashfs;
|
||||
|
||||
// page
|
||||
// thread
|
||||
std::vector<std::string> mount_par_tab;
|
||||
std::vector<std::wstring> mount_par_tab;
|
||||
|
||||
int mount_par_page;
|
||||
int mount_par_thread;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "notify.h"
|
||||
#include "misc.h"
|
||||
#include "request.h"
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -97,12 +98,12 @@ void Notify::SendEmail(NotifyMsg & n)
|
|||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Notify::SendEmail(const std::string & email, const std::string & message)
|
||||
void Notify::SendEmail(const std::wstring & email, const std::wstring & message)
|
||||
{
|
||||
nlog.PutDate(log1);
|
||||
|
||||
|
@ -112,7 +113,8 @@ void Notify::SendEmail(const std::string & email, const std::string & message)
|
|||
return;
|
||||
}
|
||||
|
||||
obj->command = "sendmail " + email;
|
||||
obj->command = "sendmail ";
|
||||
AssignString(email, obj->command, false);
|
||||
FILE * sendmail = popen(obj->command.c_str(), "w");
|
||||
|
||||
if( !sendmail )
|
||||
|
@ -129,14 +131,24 @@ void Notify::SendEmail(const std::string & email, const std::string & message)
|
|||
}
|
||||
|
||||
|
||||
void Notify::SendMessage(FILE * sendmail, const std::string & message)
|
||||
void Notify::SendMessage(FILE * sendmail, const std::wstring & message)
|
||||
{
|
||||
char buf[10];
|
||||
size_t len;
|
||||
|
||||
for(size_t i=0 ; i<message.length() ; ++i)
|
||||
{
|
||||
if( message[i] == '\n' )
|
||||
{
|
||||
fprintf(sendmail, "\r\n");
|
||||
}
|
||||
else
|
||||
fputc(message[i], sendmail);
|
||||
{
|
||||
len = Ezc::IntToUTF8(int(message[i]), buf, sizeof(buf));
|
||||
|
||||
for(size_t a=0 ; a<len ; ++a)
|
||||
fputc(buf[a], sendmail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +218,7 @@ void Notify::Unlock()
|
|||
|
||||
|
||||
|
||||
void Notify::CreateItemDir(std::string & dir, bool clear)
|
||||
void Notify::CreateItemDir(std::wstring & dir, bool clear)
|
||||
{
|
||||
if( clear )
|
||||
dir.clear();
|
||||
|
@ -219,7 +231,7 @@ void Notify::CreateItemDir(std::string & dir, bool clear)
|
|||
}
|
||||
|
||||
|
||||
void Notify::CreateItemLink(std::string & link)
|
||||
void Notify::CreateItemLink(std::wstring & link)
|
||||
{
|
||||
link = config->base_url;
|
||||
CreateItemDir(link, false);
|
||||
|
|
|
@ -63,11 +63,11 @@ private:
|
|||
void Unlock();
|
||||
static void CheckQueue();
|
||||
static void SendEmail(NotifyMsg & n);
|
||||
static void SendEmail(const std::string & email);
|
||||
static void SendEmail(const std::string & email, const std::string & message);
|
||||
static void SendMessage(FILE * sendmail, const std::string & message);
|
||||
void CreateItemDir(std::string & dir, bool clear = true);
|
||||
void CreateItemLink(std::string & link);
|
||||
static void SendEmail(const std::wstring & email);
|
||||
static void SendEmail(const std::wstring & email, const std::wstring & message);
|
||||
static void SendMessage(FILE * sendmail, const std::wstring & message);
|
||||
void CreateItemDir(std::wstring & dir, bool clear = true);
|
||||
void CreateItemLink(std::wstring & link);
|
||||
|
||||
pthread_t thread;
|
||||
pthread_mutex_t mutex;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <string.h>
|
||||
#include "plugin.h"
|
||||
#include "pluginmsg.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -110,7 +111,7 @@ return res;
|
|||
}
|
||||
|
||||
|
||||
void Plugin::LoadPlugins(const std::string & plugins_dir, const std::vector<std::string> & plugins)
|
||||
void Plugin::LoadPlugins(const std::wstring & plugins_dir, const std::vector<std::wstring> & plugins)
|
||||
{
|
||||
for(size_t i=0 ; i<plugins.size() ; ++i)
|
||||
{
|
||||
|
@ -187,7 +188,7 @@ int old_current_plugin;
|
|||
|
||||
PluginsItem item;
|
||||
item.handle = plugin_handle;
|
||||
item.plugin_name = reinterpret_cast<const char *>(info.p1);
|
||||
item.plugin_name = reinterpret_cast<const wchar_t *>(info.p1);
|
||||
|
||||
plugins.push_back(item);
|
||||
|
||||
|
@ -195,15 +196,27 @@ int old_current_plugin;
|
|||
}
|
||||
|
||||
|
||||
void Plugin::LoadPlugin(const wchar_t * filename)
|
||||
{
|
||||
AssignString(filename, afilename);
|
||||
LoadPlugin(afilename.c_str());
|
||||
}
|
||||
|
||||
bool Plugin::HasPlugin(const char * name)
|
||||
|
||||
void Plugin::LoadPlugin(const std::wstring & filename)
|
||||
{
|
||||
LoadPlugin(filename.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool Plugin::HasPlugin(const wchar_t * name)
|
||||
{
|
||||
if( *name == 0 )
|
||||
return false;
|
||||
|
||||
for(size_t i=0 ; i<plugins.size() ; ++i)
|
||||
{
|
||||
if( plugins[i].plugin_name && strcmp(plugins[i].plugin_name, name) == 0 )
|
||||
if( plugins[i].plugin_name && Equal(plugins[i].plugin_name, name) )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -212,7 +225,7 @@ return false;
|
|||
|
||||
|
||||
|
||||
bool Plugin::HasPlugin(const std::string & name)
|
||||
bool Plugin::HasPlugin(const std::wstring & name)
|
||||
{
|
||||
return HasPlugin(name.c_str());
|
||||
}
|
||||
|
|
|
@ -136,11 +136,14 @@ public:
|
|||
|
||||
void LoadPlugin(const char * filename);
|
||||
void LoadPlugin(const std::string & filename);
|
||||
void LoadPlugins(const std::string & plugins_dir, const std::vector<std::string> & plugins);
|
||||
void LoadPlugin(const wchar_t * filename);
|
||||
void LoadPlugin(const std::wstring & filename);
|
||||
|
||||
void LoadPlugins(const std::wstring & plugins_dir, const std::vector<std::wstring> & plugins);
|
||||
void UnloadPlugins();
|
||||
|
||||
bool HasPlugin(const char * name);
|
||||
bool HasPlugin(const std::string & name);
|
||||
bool HasPlugin(const wchar_t * name);
|
||||
bool HasPlugin(const std::wstring & name);
|
||||
|
||||
void Call(int message);
|
||||
void Call(int message, void * p1_);
|
||||
|
@ -170,12 +173,12 @@ private:
|
|||
Templates * templates;
|
||||
SessionManager * session_manager;
|
||||
|
||||
std::string temp_path;
|
||||
std::wstring temp_path;
|
||||
|
||||
struct PluginsItem
|
||||
{
|
||||
void * handle;
|
||||
const char * plugin_name; // plugin name (can be null if was not set by the plugin)
|
||||
const wchar_t * plugin_name; // plugin name (can be null if was not set by the plugin)
|
||||
};
|
||||
|
||||
typedef std::vector<PluginsItem> Plugins;
|
||||
|
@ -186,6 +189,8 @@ private:
|
|||
|
||||
PluginInfo info;
|
||||
|
||||
std::string afilename;
|
||||
|
||||
void * LoadInitFun(const char * filename, Fun1 & fun_init);
|
||||
void Call(int message, Slots::iterator & slot);
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
#include "postmultiparser.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "ezc.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
PostMultiParser::PostMultiParser()
|
||||
|
@ -283,7 +284,7 @@ bool has_boundary = false;
|
|||
content.clear();
|
||||
}
|
||||
|
||||
if( config->post_file_max != 0 && content_len > (size_t)config->post_file_max )
|
||||
if( config->post_file_max != 0 && content_len > config->post_file_max )
|
||||
{
|
||||
err = WINIX_ERR_INPUT_TOO_LARGE;
|
||||
log << log1 << "PMP: content greater than " << config->post_file_max << " (skipping)" << logend;
|
||||
|
@ -369,10 +370,22 @@ void PostMultiParser::AddNormalPostVar()
|
|||
return;
|
||||
}
|
||||
|
||||
std::pair<PostTab::iterator, bool> res = post_tab->insert( std::make_pair(name, content) );
|
||||
|
||||
if( config->utf8 )
|
||||
{
|
||||
Ezc::UTF8ToWide(name, namew);
|
||||
Ezc::UTF8ToWide(content, contentw);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignString(name, namew);
|
||||
AssignString(content, contentw);
|
||||
}
|
||||
|
||||
std::pair<PostTab::iterator, bool> res = post_tab->insert( std::make_pair(namew, contentw) );
|
||||
bool added = res.second;
|
||||
|
||||
log << log2 << "PMP: POST var, name: \"" << name << "\"";
|
||||
log << log2 << "PMP: POST var, name: \"" << namew << "\"";
|
||||
|
||||
if( !added )
|
||||
log << log2 << " (skipped)";
|
||||
|
@ -390,12 +403,22 @@ void PostMultiParser::AddFilePostVar()
|
|||
return;
|
||||
}
|
||||
|
||||
post_file_temp.filename = filename;
|
||||
if( config->utf8 )
|
||||
{
|
||||
Ezc::UTF8ToWide(name, namew);
|
||||
Ezc::UTF8ToWide(filename, post_file_temp.filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignString(name, namew);
|
||||
AssignString(filename, post_file_temp.filename);
|
||||
}
|
||||
|
||||
post_file_temp.tmp_filename = tmp_filename;
|
||||
std::pair<PostFileTab::iterator, bool> res = post_file_tab->insert( std::make_pair(name, post_file_temp) );
|
||||
std::pair<PostFileTab::iterator, bool> res = post_file_tab->insert( std::make_pair(namew, post_file_temp) );
|
||||
bool added = res.second;
|
||||
|
||||
log << log2 << "PMP: POST FILE var, name: \"" << name << "\"";
|
||||
log << log2 << "PMP: POST FILE var, name: \"" << namew << "\"";
|
||||
|
||||
if( !added )
|
||||
log << log2 << " (skipped)";
|
||||
|
@ -450,7 +473,8 @@ void PostMultiParser::CheckBoundaryEnd()
|
|||
|
||||
void PostMultiParser::CreateTmpFile()
|
||||
{
|
||||
char buf[100];
|
||||
wchar_t buf[1024];
|
||||
size_t buf_len = sizeof(buf)/sizeof(wchar_t);
|
||||
|
||||
if( config->auth_tmp_dir.empty() )
|
||||
{
|
||||
|
@ -459,11 +483,13 @@ char buf[100];
|
|||
return;
|
||||
}
|
||||
|
||||
sprintf(buf, "%s/winix_%u_%d_%u", config->auth_tmp_dir.c_str(), (unsigned)getpid(), tmp_filename_postfix, rand());
|
||||
swprintf(buf, buf_len, L"%ls/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);
|
||||
tmp_filename = buf;
|
||||
AssignString(buf, atmp_filename);
|
||||
AssignString(atmp_filename, tmp_filename); // this make sure that the names are exactly the same
|
||||
|
||||
tmp_file.open(atmp_filename.c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
|
||||
if( !tmp_file )
|
||||
{
|
||||
|
@ -509,7 +535,7 @@ void PostMultiParser::ReadPart()
|
|||
if( err != WINIX_ERR_OK && !filename.empty() )
|
||||
{
|
||||
log << log1 << "PMP: deleting the tmp file: " << tmp_filename << logend;
|
||||
unlink(tmp_filename.c_str());
|
||||
RemoveFile(tmp_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,6 +570,7 @@ void PostMultiParser::ReadChar()
|
|||
|
||||
|
||||
|
||||
|
||||
Error PostMultiParser::Parse(FCGX_Stream * in_, PostTab & post_tab_, PostFileTab & post_file_tab_)
|
||||
{
|
||||
in = in_;
|
||||
|
|
|
@ -43,7 +43,8 @@ private:
|
|||
FCGX_Stream * in;
|
||||
unsigned char * in_buffer;
|
||||
std::ofstream tmp_file;
|
||||
std::string tmp_filename;
|
||||
std::wstring tmp_filename;
|
||||
std::string atmp_filename;
|
||||
int tmp_filename_postfix;
|
||||
size_t in_buffer_ind;
|
||||
size_t in_buffer_len;
|
||||
|
@ -62,6 +63,7 @@ private:
|
|||
Error err;
|
||||
|
||||
std::string name, filename;
|
||||
std::wstring namew, contentw;
|
||||
PostFile post_file_temp;
|
||||
|
||||
void LogFirst(const std::string & to_log, size_t len);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <string>
|
||||
#include "httpsimpleparser.h"
|
||||
#include "requesttypes.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +23,8 @@ class PostParser : public HttpSimpleParser
|
|||
|
||||
FCGX_Stream * in;
|
||||
PostTab * post_tab;
|
||||
std::wstring temp_name, temp_value;
|
||||
bool input_as_utf8;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -35,9 +37,20 @@ protected:
|
|||
|
||||
virtual void Parameter(std::string & name, std::string & value)
|
||||
{
|
||||
std::pair<PostTab::iterator, bool> res = post_tab->insert( std::make_pair(name, value) );
|
||||
if( input_as_utf8 )
|
||||
{
|
||||
Ezc::UTF8ToWide(name, temp_name);
|
||||
Ezc::UTF8ToWide(value, temp_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignString(name, temp_name);
|
||||
AssignString(value, temp_value);
|
||||
}
|
||||
|
||||
log << log2 << "Method POST, name: \"" << name << "\", value: \"" << value << "\"";
|
||||
std::pair<PostTab::iterator, bool> res = post_tab->insert( std::make_pair(temp_name, temp_value) );
|
||||
|
||||
log << log2 << "Method POST, name: \"" << temp_name << "\", value: \"" << temp_value << "\"";
|
||||
|
||||
if( res.second == false )
|
||||
log << log2 << " (skipped)";
|
||||
|
@ -48,6 +61,18 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
PostParser()
|
||||
{
|
||||
input_as_utf8 = false;
|
||||
}
|
||||
|
||||
|
||||
void UTF8(bool utf)
|
||||
{
|
||||
input_as_utf8 = utf;
|
||||
}
|
||||
|
||||
|
||||
void Parse(FCGX_Stream * in_, PostTab & post_tab_)
|
||||
{
|
||||
in = in_;
|
||||
|
|
|
@ -24,12 +24,13 @@ void Rebus::SetRequest(Request * prequest)
|
|||
|
||||
bool Rebus::InitPair(int a, int b, Item & item)
|
||||
{
|
||||
char buffer[100];
|
||||
wchar_t buffer[100];
|
||||
size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
|
||||
bool add = false;
|
||||
|
||||
if( a+b <= 15 )
|
||||
{
|
||||
sprintf(buffer, "%d+%d", a, b);
|
||||
swprintf(buffer, buffer_len, L"%d+%d", a, b);
|
||||
item.question = buffer;
|
||||
item.answer = a+b;
|
||||
add = true;
|
||||
|
@ -37,7 +38,7 @@ bool add = false;
|
|||
|
||||
if( a-b >= 0 )
|
||||
{
|
||||
sprintf(buffer, "%d-%d", a, b);
|
||||
swprintf(buffer, buffer_len, L"%d-%d", a, b);
|
||||
item.question = buffer;
|
||||
item.answer = a-b;
|
||||
add = true;
|
||||
|
@ -91,23 +92,23 @@ return &table[0] + i;
|
|||
|
||||
|
||||
|
||||
bool Rebus::IsAnswerOk(Rebus::Item * item, const std::string & answer)
|
||||
bool Rebus::IsAnswerOk(Rebus::Item * item, const std::wstring & answer)
|
||||
{
|
||||
if( item == 0 )
|
||||
return false;
|
||||
|
||||
char * end;
|
||||
const char * a = answer.c_str();
|
||||
wchar_t * end;
|
||||
const wchar_t * a = answer.c_str();
|
||||
a = SkipWhite(a);
|
||||
|
||||
int value = (int)strtol(a, &end, 10);
|
||||
int value = (int)wcstol(a, &end, 10);
|
||||
|
||||
if( a == end )
|
||||
// nothing has been read
|
||||
return false;
|
||||
|
||||
log << log2 << "Rebus: your answer is: " << value << logend;
|
||||
end = (char*)SkipWhite(end);
|
||||
end = (wchar_t*)SkipWhite(end);
|
||||
|
||||
if( *end != 0 )
|
||||
{
|
||||
|
@ -145,7 +146,7 @@ bool Rebus::CheckRebus()
|
|||
return false;
|
||||
}
|
||||
|
||||
if( IsAnswerOk(request->session->rebus_item, request->PostVar("rebus")) )
|
||||
if( IsAnswerOk(request->session->rebus_item, request->PostVar(L"rebus")) )
|
||||
return true;
|
||||
|
||||
log << log1 << "Rebus: rebus has an incorrect answer" << logend;
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
struct Item
|
||||
{
|
||||
int key;
|
||||
std::string question;
|
||||
std::wstring question;
|
||||
int answer;
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
void SetRequest(Request * prequest);
|
||||
void Init();
|
||||
Item * Rand();
|
||||
bool IsAnswerOk(Item * item, const std::string & answer);
|
||||
bool IsAnswerOk(Item * item, const std::wstring & answer);
|
||||
bool CheckRebus();
|
||||
|
||||
private:
|
||||
|
|
|
@ -38,9 +38,9 @@ void Request::ClearPostFileTmp()
|
|||
|
||||
while( !post_file_tab.empty() )
|
||||
{
|
||||
const std::string & tmp_filename = post_file_tab.begin()->second.tmp_filename;
|
||||
const std::wstring & tmp_filename = post_file_tab.begin()->second.tmp_filename;
|
||||
|
||||
if( unlink(tmp_filename.c_str()) == 0 )
|
||||
if( RemoveFile(tmp_filename) )
|
||||
log << log3 << "Request: deleted tmp file: " << tmp_filename << logend;
|
||||
|
||||
post_file_tab.erase(post_file_tab.begin());
|
||||
|
@ -66,9 +66,9 @@ void Request::Clear()
|
|||
method = none;
|
||||
role = responder;
|
||||
|
||||
headers.str("");
|
||||
page.str("");
|
||||
debug.str("");
|
||||
headers.Clear();
|
||||
page.Clear();
|
||||
debug.Clear();
|
||||
|
||||
env_request_method = &char_empty;
|
||||
env_request_uri = &char_empty;
|
||||
|
@ -133,7 +133,7 @@ void Request::SetCookie(const char * name, long value, tm * expires)
|
|||
|
||||
|
||||
|
||||
bool Request::IsPostVar(const char * var)
|
||||
bool Request::IsPostVar(const wchar_t * var)
|
||||
{
|
||||
PostTab::iterator p;
|
||||
|
||||
|
@ -147,7 +147,7 @@ return true;
|
|||
|
||||
|
||||
|
||||
const std::string & Request::PostVar(const char * var)
|
||||
const std::wstring & Request::PostVar(const wchar_t * var)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
|
@ -159,7 +159,7 @@ return p->second;
|
|||
|
||||
|
||||
|
||||
bool Request::PostVar(const char * var, std::string & result)
|
||||
bool Request::PostVar(const wchar_t * var, std::wstring & result)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
|
@ -175,7 +175,7 @@ return true;
|
|||
}
|
||||
|
||||
|
||||
std::string * Request::PostVarp(const char * var)
|
||||
std::wstring * Request::PostVarp(const wchar_t * var)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
|
@ -194,7 +194,7 @@ void Request::PrintGetTab()
|
|||
for(GetTab::iterator i = get_tab.begin() ; i != get_tab.end() ; ++i)
|
||||
debug << " \"" << *i << "\"\n";
|
||||
|
||||
debug << std::endl;
|
||||
debug << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,7 +207,7 @@ char ** e;
|
|||
for( e = env ; *e ; ++e )
|
||||
debug << ' ' << *e << "\n";
|
||||
|
||||
debug << std::endl;
|
||||
debug << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,14 +225,12 @@ return true;
|
|||
|
||||
|
||||
|
||||
bool Request::IsParam(const char * param_name)
|
||||
bool Request::IsParam(const wchar_t * param_name)
|
||||
{
|
||||
ParamTab::iterator i;
|
||||
|
||||
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
||||
{
|
||||
// !! make sure that exists std::string::operator==(const char*)
|
||||
// (optimization)
|
||||
if( i->name == param_name )
|
||||
return true;
|
||||
}
|
||||
|
@ -241,16 +239,28 @@ return false;
|
|||
}
|
||||
|
||||
|
||||
const std::string & Request::ParamValue(const char * param_name)
|
||||
bool Request::IsParam(const std::wstring & param_name)
|
||||
{
|
||||
ParamTab::iterator i;
|
||||
|
||||
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
||||
{
|
||||
if( i->name == param_name )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Request::ParamValue(const wchar_t * param_name)
|
||||
{
|
||||
ParamTab::iterator i;
|
||||
|
||||
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
||||
{
|
||||
if( i->name == param_name )
|
||||
{
|
||||
return i->value;
|
||||
}
|
||||
}
|
||||
|
||||
return str_empty;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "item.h"
|
||||
#include "error.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "textstream.h"
|
||||
|
||||
|
||||
class FunctionBase;
|
||||
|
@ -43,7 +43,9 @@ struct Request
|
|||
enum Role { responder, authorizer } role;
|
||||
|
||||
// headers, page and debug
|
||||
std::ostringstream headers, page, debug;
|
||||
//std::ostringstream headers, page, debug;
|
||||
TextStream<std::string> headers;
|
||||
TextStream<std::wstring> page, debug;
|
||||
|
||||
// raw parameters
|
||||
GetTab get_tab;
|
||||
|
@ -99,10 +101,11 @@ struct Request
|
|||
std::vector<Item> item_tab;
|
||||
|
||||
// if not empty means an address for redirecting to
|
||||
std::string redirect_to;
|
||||
std::wstring redirect_to;
|
||||
std::string aredirect_to;
|
||||
|
||||
// send header X-LIGHTTPD-send-file with path to a file
|
||||
std::string x_sendfile;
|
||||
std::wstring x_sendfile;
|
||||
|
||||
// send as attachment (causing header: content-disposition: attachment)
|
||||
bool send_as_attachment;
|
||||
|
@ -120,16 +123,17 @@ struct Request
|
|||
void PrintEnv();
|
||||
|
||||
|
||||
bool IsParam(const char * param_name);
|
||||
const std::string & ParamValue(const char * param_name); // returns empty string if there is no such a parameter
|
||||
bool IsParam(const wchar_t * param_name);
|
||||
bool IsParam(const std::wstring & param_name);
|
||||
const std::wstring & ParamValue(const wchar_t * param_name); // returns empty string if there is no such a parameter
|
||||
|
||||
void SetCookie(const char * name, const char * value, tm * expires = 0);
|
||||
void SetCookie(const char * name, long value, tm * expires = 0);
|
||||
|
||||
bool IsPostVar(const char * var);
|
||||
const std::string & PostVar(const char * var); // !! zamienic na referencje nie do sta³ej (bez const)
|
||||
bool PostVar(const char * var, std::string & result);
|
||||
std::string * PostVarp(const char * var);
|
||||
bool IsPostVar(const wchar_t * var);
|
||||
const std::wstring & PostVar(const wchar_t * var); // !! zamienic na referencje nie do sta³ej (bez const)
|
||||
bool PostVar(const wchar_t * var, std::wstring & result);
|
||||
std::wstring * PostVarp(const wchar_t * var);
|
||||
|
||||
bool AllPostVarEmpty(); // returning true if all post vars are empty
|
||||
|
||||
|
@ -147,7 +151,7 @@ private:
|
|||
const char char_empty;
|
||||
|
||||
// used in ParamValue() and PostVar() when there is no such a param
|
||||
const std::string str_empty;
|
||||
const std::wstring str_empty;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -20,25 +20,26 @@
|
|||
|
||||
struct PostFile
|
||||
{
|
||||
std::string filename; // original file name
|
||||
std::string tmp_filename; // file with content (in /tmp)
|
||||
std::wstring filename; // original file name
|
||||
std::wstring tmp_filename; // file with content (in /tmp)
|
||||
};
|
||||
|
||||
|
||||
// parameters from get name:value
|
||||
struct Param
|
||||
{
|
||||
std::string name;
|
||||
std::string value;
|
||||
std::wstring name;
|
||||
std::wstring value;
|
||||
};
|
||||
|
||||
|
||||
// some global types used by Request class
|
||||
typedef std::vector<std::string> GetTab;
|
||||
typedef std::map<std::string, std::string> PostTab;
|
||||
typedef std::map<std::string, PostFile> PostFileTab;
|
||||
typedef std::map<std::string, std::string> CookieTab;
|
||||
typedef std::vector<Param> ParamTab;
|
||||
typedef std::vector<std::wstring> GetTab;
|
||||
typedef std::map<std::wstring, std::wstring> PostTab;
|
||||
typedef std::map<std::wstring, PostFile> PostFileTab;
|
||||
typedef std::vector<Param> ParamTab;
|
||||
|
||||
typedef std::map<std::string, std::string> CookieTab;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void System::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)
|
||||
void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
{
|
||||
request->redirect_to = config->base_url;
|
||||
|
||||
|
@ -86,9 +86,8 @@ void System::RedirectTo(const Item & item, const char * postfix)
|
|||
|
||||
|
||||
|
||||
void System::RedirectTo(long item_id, const char * postfix)
|
||||
void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
{
|
||||
std::string path;
|
||||
Item * pdir;
|
||||
|
||||
request->redirect_to = config->base_url;
|
||||
|
@ -339,7 +338,7 @@ size_t i = 0;
|
|||
|
||||
bool System::CanUseHtml(long user_id)
|
||||
{
|
||||
return IsMemberOfGroup(user_id, "allow_html");
|
||||
return IsMemberOfGroup(user_id, L"allow_html");
|
||||
}
|
||||
|
||||
|
||||
|
@ -352,12 +351,12 @@ bool System::CanUseBBCode(long user_id)
|
|||
|
||||
bool System::CanUseRaw(long user_id)
|
||||
{
|
||||
return IsMemberOfGroup(user_id, "allow_raw");
|
||||
return IsMemberOfGroup(user_id, L"allow_raw");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool System::IsMemberOfGroup(long user_id, const char * group_name)
|
||||
bool System::IsMemberOfGroup(long user_id, const wchar_t * group_name)
|
||||
{
|
||||
User * puser = users.GetUser(user_id);
|
||||
|
||||
|
@ -365,7 +364,7 @@ bool System::IsMemberOfGroup(long user_id, const char * group_name)
|
|||
return false;
|
||||
|
||||
if( puser->super_user )
|
||||
return true;
|
||||
return true; // !! ?? zakladamy ze administrator jest czlonkiem wszystkich grup? dlaczego?
|
||||
|
||||
long group = groups.GetGroupId(group_name);
|
||||
|
||||
|
@ -373,10 +372,7 @@ bool System::IsMemberOfGroup(long user_id, const char * group_name)
|
|||
// there is no such a group
|
||||
return false;
|
||||
|
||||
if( puser->IsMemberOf(group) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return puser->IsMemberOf(group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -384,7 +380,7 @@ return false;
|
|||
|
||||
|
||||
|
||||
bool System::MakePathSimpleFs(std::string & path, long dir_id, bool create_dir)
|
||||
bool System::MakePathSimpleFs(std::wstring & path, long dir_id, bool create_dir)
|
||||
{
|
||||
if( config->auth_simplefs_dir.empty() )
|
||||
{
|
||||
|
@ -407,16 +403,18 @@ return true;
|
|||
|
||||
|
||||
// the path depends on id
|
||||
bool System::MakePathHashFs(std::string & path, long id, bool create_dir)
|
||||
bool System::MakePathHashFs(std::wstring & path, long id, bool create_dir)
|
||||
{
|
||||
char buffer[50];
|
||||
char * hash = buffer;
|
||||
wchar_t buffer[50];
|
||||
wchar_t * hash = buffer;
|
||||
size_t buffer_len = sizeof(buffer)/sizeof(wchar_t);
|
||||
|
||||
// get 'id' as hexadecimal
|
||||
buffer[0] = '0';
|
||||
sprintf(buffer+1, "%lx", (unsigned long)id);
|
||||
swprintf(buffer+1, buffer_len, L"%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;
|
||||
|
@ -426,7 +424,7 @@ char * hash = buffer;
|
|||
path += '/';
|
||||
|
||||
// make sure that the length is even
|
||||
if( (strlen(hash) & 1) != 0 )
|
||||
if( (wcslen(hash) & 1) != 0 )
|
||||
hash = buffer + 1; // the first character was zero
|
||||
|
||||
// creating dirs without the last part
|
||||
|
@ -447,14 +445,14 @@ char * hash = buffer;
|
|||
|
||||
// one character more to make sure the path is unique
|
||||
// (we can have a directory without the character)
|
||||
path += "_";
|
||||
path += '_';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// making a complete path to a static file
|
||||
bool System::MakePath(const Item & item, std::string & path, bool create_dir)
|
||||
bool System::MakePath(const Item & item, std::wstring & path, bool create_dir)
|
||||
{
|
||||
bool res;
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
void SetDb(Db * pdb);
|
||||
void Init();
|
||||
|
||||
void RedirectTo(const Item & item, const char * postfix = 0);
|
||||
void RedirectTo(long item_id, const char * postfix = 0);
|
||||
void RedirectTo(const Item & item, const wchar_t * postfix = 0);
|
||||
void RedirectTo(long item_id, const wchar_t * postfix = 0);
|
||||
void RedirectToLastDir();
|
||||
void RedirectToLastItem(); // redirect to an item if exists or to the last directory
|
||||
|
||||
|
@ -78,9 +78,9 @@ public:
|
|||
bool CanUseBBCode(long user_id);
|
||||
bool CanUseRaw(long user_id);
|
||||
|
||||
bool IsMemberOfGroup(long user_id, const char * group_name);
|
||||
bool IsMemberOfGroup(long user_id, const wchar_t * group_name);
|
||||
|
||||
bool MakePath(const Item & item, std::string & path, bool create_dir);
|
||||
bool MakePath(const Item & item, std::wstring & path, bool create_dir);
|
||||
bool MakePath(Item & item, bool create_dir); // output path is: item.auth_path
|
||||
|
||||
Error AddFile(Item & item, bool notify = true);
|
||||
|
@ -98,9 +98,9 @@ private:
|
|||
Config * config;
|
||||
Db * db;
|
||||
|
||||
std::string path;
|
||||
bool MakePathSimpleFs(std::string & path, long dir_id, bool create_dir);
|
||||
bool MakePathHashFs(std::string & path, long id, bool create_dir);
|
||||
std::wstring path;
|
||||
bool MakePathSimpleFs(std::wstring & path, long dir_id, bool create_dir);
|
||||
bool MakePathHashFs(std::wstring & path, long id, bool create_dir);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -8,119 +8,6 @@
|
|||
*/
|
||||
|
||||
#include "textstream.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void TextStream::Clear()
|
||||
{
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
const std::string & TextStream::Str() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * TextStream::CStr() const
|
||||
{
|
||||
return buffer.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(const char * str)
|
||||
{
|
||||
buffer += str;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TextStream & TextStream::operator<<(const std::string * str)
|
||||
{
|
||||
buffer += *str;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TextStream & TextStream::operator<<(const std::string & str)
|
||||
{
|
||||
buffer += str;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TextStream & TextStream::operator<<(char v)
|
||||
{
|
||||
buffer += v;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(int v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%d", v);
|
||||
buffer += buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(long v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%ld", v);
|
||||
buffer += buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(unsigned int v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%u", v);
|
||||
buffer += buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(unsigned long v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%lu", v);
|
||||
buffer += buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(double v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%f", v);
|
||||
buffer += buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TextStream & TextStream::operator<<(const void * v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%p", v);
|
||||
buffer += buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,22 +11,33 @@
|
|||
#define headerfile_winix_core_textstream
|
||||
|
||||
#include <string>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
class TextStream
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename StringType::value_type CharType;
|
||||
typedef typename StringType::value_type char_type;
|
||||
|
||||
void Clear();
|
||||
const std::string & Str() const;
|
||||
const char * CStr() const;
|
||||
bool Empty() const;
|
||||
size_t Size() const;
|
||||
const StringType & Str() const;
|
||||
const CharType * CStr() const;
|
||||
|
||||
TextStream & operator<<(const char * str);
|
||||
TextStream & operator<<(const std::string * str);
|
||||
TextStream & operator<<(const std::string & str);
|
||||
|
||||
TextStream & operator<<(const wchar_t * str);
|
||||
TextStream & operator<<(const std::wstring * str);
|
||||
TextStream & operator<<(const std::wstring & str);
|
||||
|
||||
TextStream & operator<<(char);
|
||||
TextStream & operator<<(wchar_t);
|
||||
TextStream & operator<<(int);
|
||||
TextStream & operator<<(long);
|
||||
TextStream & operator<<(unsigned int);
|
||||
|
@ -34,14 +45,214 @@ public:
|
|||
TextStream & operator<<(double);
|
||||
TextStream & operator<<(const void *);// printing a pointer
|
||||
|
||||
TextStream & Write(const CharType * buf, size_t len);
|
||||
TextStream & write(const CharType * buf, size_t len); // for compatibility with standard library (Ezc uses it)
|
||||
|
||||
protected:
|
||||
|
||||
std::string buffer;
|
||||
StringType buffer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Clear()
|
||||
{
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
template<class StringType>
|
||||
bool TextStream<StringType>::Empty() const
|
||||
{
|
||||
return buffer.empty();
|
||||
}
|
||||
|
||||
template<class StringType>
|
||||
size_t TextStream<StringType>::Size() const
|
||||
{
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
template<class StringType>
|
||||
const StringType & TextStream<StringType>::Str() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
const typename TextStream<StringType>::CharType * TextStream<StringType>::CStr() const
|
||||
{
|
||||
return buffer.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const char * str)
|
||||
{
|
||||
AssignString(str, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::string * str)
|
||||
{
|
||||
AssignString(*str, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::string & str)
|
||||
{
|
||||
AssignString(str, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const wchar_t * str)
|
||||
{
|
||||
AssignString(str, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::wstring * str)
|
||||
{
|
||||
AssignString(*str, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::wstring & str)
|
||||
{
|
||||
AssignString(str, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(char v)
|
||||
{
|
||||
buffer += v;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(wchar_t v)
|
||||
{
|
||||
buffer += static_cast<CharType>(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(int v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%d", v);
|
||||
AssignString(buf, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(long v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%ld", v);
|
||||
AssignString(buf, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(unsigned int v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%u", v);
|
||||
AssignString(buf, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(unsigned long v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%lu", v);
|
||||
AssignString(buf, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(double v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%f", v);
|
||||
AssignString(buf, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const void * v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%p", v);
|
||||
AssignString(buf, buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::Write(const TextStream<StringType>::CharType * buf, size_t len)
|
||||
{
|
||||
buffer.reserve(buffer.size() + len);
|
||||
|
||||
for(size_t i=0 ; i<len ; ++i)
|
||||
buffer += buf[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::write(const TextStream<StringType>::CharType * buf, size_t len)
|
||||
{
|
||||
return Write(buf, len);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
typedef typename Table::size_type SizeType;
|
||||
|
||||
typedef typename std::map<long, SizeType> TableId;
|
||||
typedef typename std::map<std::string, SizeType> TableName;
|
||||
typedef typename std::map<std::wstring, SizeType> TableName;
|
||||
|
||||
|
||||
UGContainer();
|
||||
|
@ -41,10 +41,10 @@ public:
|
|||
void Clear();
|
||||
|
||||
bool Is(long id);
|
||||
bool Is(const std::string & name);
|
||||
bool Is(const std::wstring & name);
|
||||
|
||||
Iterator FindId(long id);
|
||||
Iterator FindName(const std::string & name);
|
||||
Iterator FindName(const std::wstring & name);
|
||||
|
||||
Type & operator[](SizeType pos);
|
||||
|
||||
|
@ -141,7 +141,7 @@ return true;
|
|||
|
||||
|
||||
template<class Type>
|
||||
bool UGContainer<Type>::Is(const std::string & name)
|
||||
bool UGContainer<Type>::Is(const std::wstring & name)
|
||||
{
|
||||
typename TableName::iterator i = table_name.find(name);
|
||||
|
||||
|
@ -167,7 +167,7 @@ return table.begin() + i->second;
|
|||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::FindName(const std::string & name)
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::FindName(const std::wstring & name)
|
||||
{
|
||||
typename TableName::iterator i = table_name.find(name);
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
struct User
|
||||
{
|
||||
long id;
|
||||
std::string name;
|
||||
std::wstring name;
|
||||
bool super_user;
|
||||
std::vector<long> groups;
|
||||
std::string email;
|
||||
std::wstring email;
|
||||
|
||||
int cms_notify;
|
||||
int thread_notify;
|
||||
|
|
|
@ -58,7 +58,7 @@ return (i != table.End());
|
|||
}
|
||||
|
||||
|
||||
bool Users::IsUser(const std::string & name)
|
||||
bool Users::IsUser(const std::wstring & name)
|
||||
{
|
||||
return table.Is(name);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ return &(*i);
|
|||
}
|
||||
|
||||
|
||||
User * Users::GetUser(const std::string & name)
|
||||
User * Users::GetUser(const std::wstring & name)
|
||||
{
|
||||
Table::Iterator i = table.FindName(name);
|
||||
|
||||
|
@ -87,7 +87,7 @@ return &(*i);
|
|||
|
||||
|
||||
|
||||
long Users::GetUserId(const std::string & name)
|
||||
long Users::GetUserId(const std::wstring & name)
|
||||
{
|
||||
User * puser = GetUser(name);
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ public:
|
|||
void ReadUsers(Db * db);
|
||||
void SetTimeZoneOffset(int offset); // !! temporarily one time_zone for all users
|
||||
bool AddUser(const User & user);
|
||||
bool IsUser(const std::string & name);
|
||||
bool IsUser(const std::wstring & name);
|
||||
User * GetUser(long user_id);
|
||||
User * GetUser(const std::string & name);
|
||||
long GetUserId(const std::string & name);
|
||||
User * GetUser(const std::wstring & name);
|
||||
long GetUserId(const std::wstring & name);
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
# DO NOT DELETE
|
||||
|
||||
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
|
||||
db.o: ../core/error.h ../core/log.h dbitemquery.h ../core/item.h
|
||||
db.o: dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
|
||||
db.o: ../core/dircontainer.h ../core/item.h ../core/ugcontainer.h
|
||||
db.o: ../core/log.h ../core/misc.h
|
||||
db.o: ../core/misc.h ../core/item.h ../core/error.h ../core/log.h
|
||||
db.o: ../core/textstream.h dbitemquery.h ../core/item.h dbitemcolumns.h
|
||||
db.o: ../core/user.h ../core/group.h ../core/thread.h ../core/dircontainer.h
|
||||
db.o: ../core/ugcontainer.h ../core/log.h ../core/misc.h
|
||||
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
|
||||
dbbase.o: ../core/error.h ../core/log.h ../core/log.h
|
||||
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/log.h
|
||||
dbconn.o: ../core/error.h ../core/log.h
|
||||
dbbase.o: ../core/misc.h ../core/item.h ../core/error.h ../core/log.h
|
||||
dbbase.o: ../core/textstream.h ../core/log.h ../../ezc/src/ezc.h
|
||||
dbbase.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
|
||||
dbbase.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
|
||||
dbbase.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbconn.o: ../core/item.h ../core/log.h ../core/error.h ../core/log.h
|
||||
dbconn.o: ../core/textstream.h
|
||||
dbitemcolumns.o: dbitemcolumns.h ../core/item.h dbbase.h dbconn.h
|
||||
dbitemcolumns.o: dbtextstream.h ../core/textstream.h ../core/error.h
|
||||
dbitemcolumns.o: ../core/log.h
|
||||
dbitemcolumns.o: dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbitemcolumns.o: ../core/item.h ../core/error.h ../core/log.h
|
||||
dbitemcolumns.o: ../core/textstream.h
|
||||
dbitemquery.o: dbitemquery.h ../core/item.h
|
||||
dbtextstream.o: dbtextstream.h ../core/textstream.h
|
||||
dbtextstream.o: dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbtextstream.o: ../core/item.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
dbtextstream.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
dbtextstream.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
|
||||
dbtextstream.o: ../../ezc/src/funinfo.h
|
||||
|
|
33
db/db.cpp
33
db/db.cpp
|
@ -15,7 +15,7 @@
|
|||
|
||||
|
||||
|
||||
bool Db::CheckUser(const std::string & login, const std::string & password, long & user_id)
|
||||
bool Db::CheckUser(const std::wstring & login, const std::wstring & password, long & user_id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
bool user_ok = false;
|
||||
|
@ -60,7 +60,7 @@ return user_ok;
|
|||
|
||||
|
||||
|
||||
Error Db::AddUser(User & user, const std::string & password)
|
||||
Error Db::AddUser(User & user, const std::wstring & password)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
@ -107,7 +107,8 @@ bool is_that_url;
|
|||
PGresult * r = 0;
|
||||
int index = 1;
|
||||
const int max_index = 99;
|
||||
char appendix[20];
|
||||
wchar_t appendix[20];
|
||||
size_t appendix_len = sizeof(appendix) / sizeof(wchar_t);
|
||||
appendix[0] = 0;
|
||||
|
||||
try
|
||||
|
@ -131,7 +132,7 @@ appendix[0] = 0;
|
|||
|
||||
if( Rows(r) != 0 )
|
||||
{
|
||||
sprintf(appendix, "_(%d)", ++index);
|
||||
swprintf(appendix, appendix_len, L"_(%d)", ++index);
|
||||
is_that_url = true;
|
||||
}
|
||||
else
|
||||
|
@ -213,8 +214,8 @@ void Db::CheckAllUrlSubject()
|
|||
|
||||
for(int i = 0 ; i<rows ; ++i)
|
||||
{
|
||||
item.id = atol( AssertValue(r, i, cid) );
|
||||
item.subject = AssertValue(r, i, csubject);
|
||||
item.id = AssertValueLong(r, i, cid);
|
||||
item.subject = AssertValueWide(r, i, csubject);
|
||||
|
||||
CheckAllUrlSubjectModifyItem(item);
|
||||
}
|
||||
|
@ -573,7 +574,7 @@ return result;
|
|||
}
|
||||
|
||||
|
||||
Error Db::EditTemplateItemById(long id, const std::string & new_html_template)
|
||||
Error Db::EditTemplateItemById(long id, const std::wstring & new_html_template)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
|
@ -810,7 +811,7 @@ void Db::GetItem(std::vector<Item> & item_tab, long id)
|
|||
|
||||
|
||||
// !! nowy interfejs
|
||||
Error Db::GetItem(long parent_id, const std::string & url, Item & item)
|
||||
Error Db::GetItem(long parent_id, const std::wstring & url, Item & item)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
|
@ -883,7 +884,7 @@ return result;
|
|||
|
||||
|
||||
|
||||
long Db::GetItemId(long parent_id, const std::string & url, Item::Type type)
|
||||
long Db::GetItemId(long parent_id, const std::wstring & url, Item::Type type)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
long result = -1;
|
||||
|
@ -916,13 +917,13 @@ return result;
|
|||
|
||||
|
||||
|
||||
long Db::GetFileId(long parent_id, const std::string & url)
|
||||
long Db::GetFileId(long parent_id, const std::wstring & url)
|
||||
{
|
||||
return GetItemId(parent_id, url, Item::file);
|
||||
}
|
||||
|
||||
|
||||
long Db::GetDirId(long parent_id, const std::string & url)
|
||||
long Db::GetDirId(long parent_id, const std::wstring & url)
|
||||
{
|
||||
return GetItemId(parent_id, url, Item::dir);
|
||||
}
|
||||
|
@ -1321,9 +1322,9 @@ void Db::GetUsers(UGContainer<User> & user_tab)
|
|||
|
||||
if( u.id != last_id )
|
||||
{
|
||||
u.name = AssertValue(r, i, cname);
|
||||
u.super_user = static_cast<bool>( atoi( AssertValue(r, i, csuper_user) ) );
|
||||
u.email = AssertValue(r, i, cemail);
|
||||
u.name = AssertValueWide(r, i, cname);
|
||||
u.super_user = static_cast<bool>(AssertValueInt(r, i, csuper_user));
|
||||
u.email = AssertValueWide(r, i, cemail);
|
||||
u.cms_notify = AssertValueInt(r, i, ccms_notify);
|
||||
u.thread_notify = AssertValueInt(r, i, cthread_notify);
|
||||
|
||||
|
@ -1384,7 +1385,7 @@ void Db::GetGroups(UGContainer<Group> & group_tab)
|
|||
|
||||
if( g.id != last_id )
|
||||
{
|
||||
g.name = AssertValue(r, i, cname);
|
||||
g.name = AssertValueWide(r, i, cname);
|
||||
log << log3 << "Db: get group, id:" << g.id << ", group:" << g.name << logend;
|
||||
|
||||
iter = group_tab.PushBack( g );
|
||||
|
@ -1510,7 +1511,7 @@ Error Db::GetThreads(long parent_id, std::vector<Thread> & thread_tab)
|
|||
thread.last_item.id = AssertValueLong(r, i, clast_item);
|
||||
thread.last_item.date_modification = AssertValueTm(r, i, cdate_modification);
|
||||
thread.last_item.user_id = AssertValueLong(r, i, cuser_id);
|
||||
thread.last_item.guest_name = AssertValue(r, i, cguest_name);
|
||||
thread.last_item.guest_name = AssertValueWide(r, i, cguest_name);
|
||||
|
||||
thread_tab.push_back(thread);
|
||||
}
|
||||
|
|
16
db/db.h
16
db/db.h
|
@ -42,8 +42,8 @@ public:
|
|||
|
||||
|
||||
|
||||
bool CheckUser(const std::string & login, const std::string & password, long & user_id);
|
||||
Error AddUser(User & user, const std::string & password);
|
||||
bool CheckUser(const std::wstring & login, const std::wstring & password, long & user_id);
|
||||
Error AddUser(User & user, const std::wstring & password);
|
||||
|
||||
Error AddItem(Item & item);
|
||||
Error EditItemById(Item & item, bool with_url = true);
|
||||
|
@ -78,13 +78,13 @@ public:
|
|||
long Size(long parent_id, Item::Type type = Item::none);
|
||||
|
||||
Error GetItemById(long item_id, Item & item);
|
||||
Error GetItem(long parent_id, const std::string & url, Item & item);
|
||||
Error GetItem(long parent_id, const std::wstring & url, Item & item);
|
||||
Error EditDefaultItem(long id, long new_default_item);
|
||||
Error EditTemplateItemById(long id, const std::string & new_html_template);
|
||||
Error EditTemplateItemById(long id, const std::wstring & new_html_template);
|
||||
|
||||
long GetItemId(long parent_id, const std::string & url, Item::Type type);
|
||||
long GetFileId(long parent_id, const std::string & url);
|
||||
long GetDirId(long parent_id, const std::string & url);
|
||||
long GetItemId(long parent_id, const std::wstring & url, Item::Type type);
|
||||
long GetFileId(long parent_id, const std::wstring & url);
|
||||
long GetDirId(long parent_id, const std::wstring & url);
|
||||
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
protected:
|
||||
|
||||
DbTextStream query, query_create_url;
|
||||
std::string temp_url;
|
||||
std::wstring temp_url;
|
||||
|
||||
bool AddItemCreateUrlSubject(Item & item);
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dbbase.h"
|
||||
#include "core/log.h"
|
||||
#include "core/error.h"
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <limits>
|
||||
|
||||
#include "dbbase.h"
|
||||
#include "core/log.h"
|
||||
#include "core/error.h"
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
DbBase::DbBase()
|
||||
|
@ -86,7 +86,7 @@ return r;
|
|||
}
|
||||
|
||||
|
||||
PGresult * DbBase::AssertQuery(const std::string & q)
|
||||
PGresult * DbBase::AssertQuery(const std::wstring & q)
|
||||
{
|
||||
return AssertQuery(q.c_str());
|
||||
}
|
||||
|
@ -117,7 +117,6 @@ int DbBase::AssertColumn(PGresult * r, const char * column_name)
|
|||
if( c == -1 )
|
||||
{
|
||||
log << log1 << "Db: there is no column: " << column_name << logend;
|
||||
|
||||
throw Error(WINIX_ERR_DB_NO_COLUMN);
|
||||
}
|
||||
|
||||
|
@ -132,7 +131,6 @@ const char * DbBase::AssertValue(PGresult * r, int row, int col)
|
|||
if( !res )
|
||||
{
|
||||
log << log1 << "Db: there is no such an item in the result, row:" << row << ", col:" << col << logend;
|
||||
|
||||
throw Error(WINIX_ERR_NO_ITEM);
|
||||
}
|
||||
|
||||
|
@ -140,6 +138,24 @@ return res;
|
|||
}
|
||||
|
||||
|
||||
const std::wstring & DbBase::AssertValueWide(PGresult * r, int row, int col)
|
||||
{
|
||||
const char * res = AssertValue(r, row, col);
|
||||
static std::wstring temp_wide_value;
|
||||
|
||||
Ezc::UTF8ToWide(res, temp_wide_value);
|
||||
|
||||
return temp_wide_value;
|
||||
}
|
||||
|
||||
|
||||
void DbBase::AssertValueWide(PGresult * r, int row, int col, std::wstring & result)
|
||||
{
|
||||
const char * res = AssertValue(r, row, col);
|
||||
Ezc::UTF8ToWide(res, result);
|
||||
}
|
||||
|
||||
|
||||
long DbBase::AssertValueLong(PGresult * r, int row, int col)
|
||||
{
|
||||
return strtol( AssertValue(r, row, col), 0, 10 );
|
||||
|
@ -300,9 +316,10 @@ return buffer;
|
|||
|
||||
|
||||
|
||||
void DbBase::CreateIdList(const std::vector<long> & id_tab, std::string & list, bool add_parentheses)
|
||||
void DbBase::CreateIdList(const std::vector<long> & id_tab, std::wstring & list, bool add_parentheses)
|
||||
{
|
||||
char buffer[50];
|
||||
wchar_t buffer[50];
|
||||
size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
|
||||
|
||||
list.clear();
|
||||
|
||||
|
@ -311,7 +328,7 @@ char buffer[50];
|
|||
|
||||
for(size_t i=0 ; i<id_tab.size() ; ++i)
|
||||
{
|
||||
sprintf(buffer, "%lu", (unsigned long)id_tab[i]);
|
||||
swprintf(buffer, buffer_len, L"%lu", (unsigned long)id_tab[i]);
|
||||
list += buffer;
|
||||
|
||||
if( i+1 < id_tab.size() )
|
||||
|
|
|
@ -31,12 +31,14 @@ public:
|
|||
void LogQueries(bool log_q);
|
||||
|
||||
PGresult * AssertQuery(const char * query);
|
||||
PGresult * AssertQuery(const std::string & query);
|
||||
PGresult * AssertQuery(const std::wstring & query);
|
||||
PGresult * AssertQuery(const DbTextStream & query);
|
||||
void AssertResult(PGresult * r, ExecStatusType t);
|
||||
static int AssertColumn(PGresult * r, const char * column_name);
|
||||
|
||||
static const char * AssertValue(PGresult * r, int row, int col);
|
||||
static const std::wstring & AssertValueWide(PGresult * r, int row, int col); // warning: this method uses a static buffer
|
||||
static void AssertValueWide(PGresult * r, int row, int col, std::wstring & result);
|
||||
static long AssertValueLong(PGresult * r, int row, int col);
|
||||
static int AssertValueInt(PGresult * r, int row, int col);
|
||||
static unsigned long AssertValueULong(PGresult * r, int row, int col);
|
||||
|
@ -53,7 +55,7 @@ public:
|
|||
|
||||
static tm ConvertTime(const char * str);
|
||||
static const char * ConvertTime(const tm & t); // warning: it uses its own static buffer
|
||||
void CreateIdList(const std::vector<long> & id_tab, std::string & list, bool add_parentheses = true);
|
||||
void CreateIdList(const std::vector<long> & id_tab, std::wstring & list, bool add_parentheses = true);
|
||||
|
||||
Error DoCommand(const char * command);
|
||||
Error BeginTrans();
|
||||
|
@ -76,6 +78,7 @@ private:
|
|||
|
||||
DbTextStream bquery;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ bool was_connection = true;
|
|||
|
||||
void DbConn::SetDbParameters()
|
||||
{
|
||||
if( PQsetClientEncoding(pg_conn, "LATIN2") == -1 )
|
||||
if( PQsetClientEncoding(pg_conn, "UTF8") == -1 )
|
||||
log << log1 << "Db: Can't set the proper client encoding" << logend;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,18 +46,18 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
|
|||
if( privileges != -1 ) item.privileges = DbBase::AssertValueInt(r, row, privileges);
|
||||
if( date_creation != -1 ) item.date_creation = DbBase::AssertValueTm(r, row, date_creation);
|
||||
if( date_modification != -1 ) item.date_modification = DbBase::AssertValueTm(r, row, date_modification);
|
||||
if( url != -1 ) item.url = DbBase::AssertValue(r, row, url);
|
||||
if( url != -1 ) item.url = DbBase::AssertValueWide(r, row, url);
|
||||
if( type != -1 ) item.type = static_cast<Item::Type>( DbBase::AssertValueInt(r, row, type) );
|
||||
if( parent_id != -1 ) item.parent_id = DbBase::AssertValueLong(r, row, parent_id);
|
||||
if( content_id != -1 ) item.content_id = DbBase::AssertValueLong(r, row, content_id);
|
||||
if( default_item != -1 ) item.default_item = DbBase::AssertValueLong(r, row, default_item);
|
||||
if( subject != -1 ) item.subject = DbBase::AssertValue(r, row, subject);
|
||||
if( content != -1 ) item.content = DbBase::AssertValue(r, row, content);
|
||||
if( subject != -1 ) item.subject = DbBase::AssertValueWide(r, row, subject);
|
||||
if( content != -1 ) item.content = DbBase::AssertValueWide(r, row, content);
|
||||
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( DbBase::AssertValueInt(r, row, content_type) );
|
||||
if( guest_name != -1 ) item.guest_name = DbBase::AssertValue(r, row, guest_name);
|
||||
if( guest_name != -1 ) item.guest_name = DbBase::AssertValueWide(r, row, guest_name);
|
||||
if( auth != -1 ) item.auth = static_cast<Item::Auth>( DbBase::AssertValueInt(r, row, auth) );
|
||||
if( auth_path != -1 ) item.auth_path = DbBase::AssertValue(r, row, auth_path);
|
||||
if( html_template != -1 ) item.html_template = DbBase::AssertValue(r, row, html_template);
|
||||
if( auth_path != -1 ) item.auth_path = DbBase::AssertValueWide(r, row, auth_path);
|
||||
if( html_template != -1 ) item.html_template = DbBase::AssertValueWide(r, row, html_template);
|
||||
if( modification_user_id != -1 ) item.modification_user_id = DbBase::AssertValueLong(r, row, modification_user_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "dbtextstream.h"
|
||||
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
DbTextStream::DbTextStream()
|
||||
|
@ -54,12 +54,39 @@ DbTextStream & DbTextStream::PutText(const std::string & str)
|
|||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const wchar_t * str)
|
||||
{
|
||||
Ezc::WideToUTF8(str, buffer, false);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::wstring * str)
|
||||
{
|
||||
return PutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::wstring & str)
|
||||
{
|
||||
return PutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const RawText<const char*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
||||
|
@ -68,9 +95,24 @@ DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
|||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::wstring> raw)
|
||||
{
|
||||
return PutText(raw.par.c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<char> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<wchar_t> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -79,7 +121,7 @@ return *this;
|
|||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<int> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -88,7 +130,7 @@ return *this;
|
|||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<long> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -97,7 +139,7 @@ return *this;
|
|||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<unsigned int> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -106,7 +148,7 @@ return *this;
|
|||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<unsigned long> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -115,7 +157,7 @@ return *this;
|
|||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<double> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -124,7 +166,7 @@ return *this;
|
|||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<void*> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
|
@ -185,6 +227,20 @@ return *this;
|
|||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::ETextPutChar(wchar_t c)
|
||||
{
|
||||
if( c == '\\' )
|
||||
buffer += "\\\\";
|
||||
else
|
||||
if( c == '\'' )
|
||||
buffer += "\\\'"; // don't use "''" because we use the method for PQconnectdb too
|
||||
else
|
||||
if( c != 0 )
|
||||
Ezc::IntToUTF8(int(c), buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const char * str)
|
||||
{
|
||||
|
@ -218,6 +274,39 @@ DbTextStream & DbTextStream::EPutText(const std::string & str)
|
|||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const wchar_t * str)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
|
||||
for( ; *str ; ++str )
|
||||
ETextPutChar(*str);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::wstring * str)
|
||||
{
|
||||
return EPutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this method can escaped 0 in the middle of the string
|
||||
DbTextStream & DbTextStream::EPutBin(const char * str, size_t len)
|
||||
{
|
||||
|
@ -273,6 +362,25 @@ DbTextStream & DbTextStream::operator<<(const std::string & str)
|
|||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const wchar_t * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::wstring * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(char v)
|
||||
{
|
||||
|
@ -291,12 +399,29 @@ return *this;
|
|||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(wchar_t v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
ETextPutChar(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(int v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
|
@ -308,7 +433,7 @@ DbTextStream & DbTextStream::operator<<(long v)
|
|||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
|
@ -320,7 +445,7 @@ DbTextStream & DbTextStream::operator<<(unsigned int v)
|
|||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
|
@ -332,7 +457,7 @@ DbTextStream & DbTextStream::operator<<(unsigned long v)
|
|||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
|
@ -344,7 +469,7 @@ DbTextStream & DbTextStream::operator<<(double v)
|
|||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
|
@ -357,7 +482,7 @@ DbTextStream & DbTextStream::operator<<(const void * v)
|
|||
buffer += ", ";
|
||||
|
||||
buffer += '\''; // !! not needed here?
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
between key1 key2 and key3 are commas inserted automatically
|
||||
*/
|
||||
class DbTextStream : public TextStream
|
||||
class DbTextStream : public TextStream<std::string>
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -83,6 +83,9 @@ public:
|
|||
DbTextStream & PutText(const char *);
|
||||
DbTextStream & PutText(const std::string *);
|
||||
DbTextStream & PutText(const std::string &);
|
||||
DbTextStream & PutText(const wchar_t * str);
|
||||
DbTextStream & PutText(const std::wstring * str);
|
||||
DbTextStream & PutText(const std::wstring & str);
|
||||
|
||||
/*
|
||||
we need this template operator for such calling:
|
||||
|
@ -92,9 +95,15 @@ public:
|
|||
template<size_t str_size>
|
||||
DbTextStream & operator<<(const RawText<char [str_size]> & raw) { return PutText(raw.par); }
|
||||
|
||||
DbTextStream & operator<<(const RawText<const char*> & raw);
|
||||
template<size_t str_size>
|
||||
DbTextStream & operator<<(const RawText<wchar_t [str_size]> & raw) { return PutText(raw.par); }
|
||||
|
||||
DbTextStream & operator<<(const RawText<const char*> & raw); // !! ? bez const tutaj? bo jest const w szablonie
|
||||
DbTextStream & operator<<(const RawText<const wchar_t*> & raw);
|
||||
DbTextStream & operator<<(RawText<std::string> raw);
|
||||
DbTextStream & operator<<(RawText<std::wstring> raw);
|
||||
DbTextStream & operator<<(RawText<char> raw);
|
||||
DbTextStream & operator<<(RawText<wchar_t> raw);
|
||||
DbTextStream & operator<<(RawText<int> raw);
|
||||
DbTextStream & operator<<(RawText<long> raw);
|
||||
DbTextStream & operator<<(RawText<unsigned int> raw);
|
||||
|
@ -110,10 +119,14 @@ public:
|
|||
|
||||
DbTextStream & EBinPutChar(char c);
|
||||
DbTextStream & ETextPutChar(char c);
|
||||
DbTextStream & ETextPutChar(wchar_t c);
|
||||
|
||||
DbTextStream & EPutText(const char * str);
|
||||
DbTextStream & EPutText(const std::string * str);
|
||||
DbTextStream & EPutText(const std::string & str);
|
||||
DbTextStream & EPutText(const wchar_t * str);
|
||||
DbTextStream & EPutText(const std::wstring * str);
|
||||
DbTextStream & EPutText(const std::wstring & str);
|
||||
|
||||
DbTextStream & EPutBin(const char * str, size_t len);
|
||||
DbTextStream & EPutBin(const std::string * str);
|
||||
|
@ -122,7 +135,11 @@ public:
|
|||
DbTextStream & operator<<(const char * str);
|
||||
DbTextStream & operator<<(const std::string * str);
|
||||
DbTextStream & operator<<(const std::string & str);
|
||||
DbTextStream & operator<<(const wchar_t * str);
|
||||
DbTextStream & operator<<(const std::wstring * str);
|
||||
DbTextStream & operator<<(const std::wstring & str);
|
||||
DbTextStream & operator<<(char);
|
||||
DbTextStream & operator<<(wchar_t);
|
||||
DbTextStream & operator<<(int);
|
||||
DbTextStream & operator<<(long);
|
||||
DbTextStream & operator<<(unsigned int);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,11 +17,11 @@ namespace Fun
|
|||
|
||||
AddUser::AddUser()
|
||||
{
|
||||
fun.url = "adduser";
|
||||
fun.url = L"adduser";
|
||||
}
|
||||
|
||||
|
||||
bool AddUser::CheckAddUserVars(const std::string & login, const std::string & pass, const std::string & conf_pass)
|
||||
bool AddUser::CheckAddUserVars(const std::wstring & login, const std::wstring & pass, const std::wstring & conf_pass)
|
||||
{
|
||||
if( login.empty() )
|
||||
{
|
||||
|
@ -59,15 +59,15 @@ void AddUser::MakePost()
|
|||
{
|
||||
User user;
|
||||
|
||||
const std::string & login = request->PostVar("login");
|
||||
const std::string & pass = request->PostVar("password");
|
||||
const std::string & conf_pass = request->PostVar("confirmpassword");
|
||||
const std::wstring & login = request->PostVar(L"login");
|
||||
const std::wstring & pass = request->PostVar(L"password");
|
||||
const std::wstring & conf_pass = request->PostVar(L"confirmpassword");
|
||||
|
||||
if( !CheckAddUserVars(login, pass, conf_pass) )
|
||||
return;
|
||||
|
||||
user.name = login;
|
||||
user.email = request->PostVar("email");
|
||||
user.email = request->PostVar(L"email");
|
||||
|
||||
request->status = db->AddUser(user, pass);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
bool CheckAddUserVars(const std::string & login, const std::string & pass, const std::string & conf_pass);
|
||||
bool CheckAddUserVars(const std::wstring & login, const std::wstring & pass, const std::wstring & conf_pass);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Fun
|
|||
|
||||
Cat::Cat()
|
||||
{
|
||||
fun.url = "cat";
|
||||
fun.url = L"cat";
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ void Cat::MakeGet()
|
|||
return;
|
||||
}
|
||||
|
||||
request->send_as_attachment = request->IsParam("attachment");
|
||||
request->send_as_attachment = request->IsParam(L"attachment");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Chmod::Chmod()
|
||||
{
|
||||
fun.url = "chmod";
|
||||
fun.url = L"chmod";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Chown::Chown()
|
||||
{
|
||||
fun.url = "chown";
|
||||
fun.url = L"chown";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Ckeditor::Ckeditor()
|
||||
{
|
||||
fun.url = "ckeditor";
|
||||
fun.url = L"ckeditor";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Fun
|
|||
|
||||
Cp::Cp()
|
||||
{
|
||||
fun.url = "cp";
|
||||
fun.url = L"cp";
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ bool Cp::CpCheckAccessFrom()
|
|||
}
|
||||
}
|
||||
else
|
||||
if( !request->IsParam("r") )
|
||||
if( !request->IsParam(L"r") )
|
||||
{
|
||||
// directories need 'r' parameter
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
|
@ -65,9 +65,9 @@ return true;
|
|||
|
||||
|
||||
|
||||
bool Cp::ParseDir(long & dir_id, std::string & dir, std::string & file)
|
||||
bool Cp::ParseDir(long & dir_id, std::wstring & dir, std::wstring & file)
|
||||
{
|
||||
int res = system->dirs.AnalyzePath(request->PostVar("to"), dir_id, dir, file);
|
||||
int res = system->dirs.AnalyzePath(request->PostVar(L"to"), dir_id, dir, file);
|
||||
|
||||
if( res == 1 )
|
||||
request->status = WINIX_ERR_NO_ROOT_DIR;
|
||||
|
@ -296,7 +296,7 @@ void Cp::MakePost()
|
|||
CheckAccessTo(mv_dir_id) )
|
||||
{
|
||||
CpPrepare();
|
||||
cp_preserve_attr = request->IsPostVar("preserveattr");
|
||||
cp_preserve_attr = request->IsPostVar(L"preserveattr");
|
||||
|
||||
if( request->is_item )
|
||||
{
|
||||
|
@ -304,9 +304,9 @@ void Cp::MakePost()
|
|||
}
|
||||
else
|
||||
{
|
||||
cp_remove_defaults = request->IsPostVar("removedefaults");
|
||||
cp_remove_defaults = request->IsPostVar(L"removedefaults");
|
||||
|
||||
if( request->IsPostVar("onlycontent") )
|
||||
if( request->IsPostVar(L"onlycontent") )
|
||||
CpContentOfDirCheck(*request->dir_tab.back());
|
||||
else
|
||||
CpDirCheck(*request->dir_tab.back());
|
||||
|
|
|
@ -35,14 +35,14 @@ private:
|
|||
long cp_new_user;
|
||||
long cp_new_group;
|
||||
|
||||
std::string mv_dir;
|
||||
std::string mv_file;
|
||||
std::string mv_new_path;
|
||||
std::wstring mv_dir;
|
||||
std::wstring mv_file;
|
||||
std::wstring 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);
|
||||
bool ParseDir(long & dir_id, std::wstring & dir, std::wstring & file);
|
||||
void CpAuth(Item & item);
|
||||
void CpSetNewAttributes(Item & item);
|
||||
void CpItem(Item & item, long dst_dir_id);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Fun
|
|||
|
||||
CreateThread::CreateThread()
|
||||
{
|
||||
fun.url = "createthread";
|
||||
fun.url = L"createthread";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Fun
|
|||
|
||||
Default::Default()
|
||||
{
|
||||
fun.url = "default";
|
||||
fun.url = L"default";
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,12 +25,12 @@ long Default::PostFunDefaultParsePath()
|
|||
Item * pdir, * pdir2;
|
||||
long defaultid = -1;
|
||||
|
||||
const std::string & path = request->PostVar("defaultitem");
|
||||
const std::wstring & path = request->PostVar(L"defaultitem");
|
||||
|
||||
|
||||
if( !path.empty() )
|
||||
{
|
||||
std::string dir, file;
|
||||
std::wstring dir, file;
|
||||
Dirs::SplitPath(path, dir, file);
|
||||
|
||||
pdir = system->dirs.GetDir(dir);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Download::Download()
|
||||
{
|
||||
fun.url = "download";
|
||||
fun.url = L"download";
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ void Download::MakeGet()
|
|||
return;
|
||||
}
|
||||
|
||||
request->send_as_attachment = request->IsParam("attachment");
|
||||
request->send_as_attachment = request->IsParam(L"attachment");
|
||||
request->x_sendfile = request->item.auth_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Fun
|
|||
|
||||
Emacs::Emacs()
|
||||
{
|
||||
fun.url = "emacs";
|
||||
fun.url = L"emacs";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ private:
|
|||
bool PostEmacsCheckAbuse(bool adding);
|
||||
void PostFunEmacsModifyMountPoint(bool adding);
|
||||
|
||||
std::string old_url;
|
||||
std::wstring old_url;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void FunctionParser::ParseItem()
|
|||
|
||||
// request->dir_tab has at least one element
|
||||
long parent_id = request->dir_tab.back()->id;
|
||||
const std::string & url = request->get_tab[get_index];
|
||||
const std::wstring & url = request->get_tab[get_index];
|
||||
|
||||
request->status = db->GetItem(parent_id, url, request->item);
|
||||
|
||||
|
@ -119,7 +119,7 @@ void FunctionParser::ParseFunction()
|
|||
|
||||
|
||||
|
||||
void FunctionParser::ParseParams(const std::string & par)
|
||||
void FunctionParser::ParseParams(const std::wstring & par)
|
||||
{
|
||||
Param param;
|
||||
size_t i;
|
||||
|
|
|
@ -35,7 +35,7 @@ class FunctionParser
|
|||
void ParseItem();
|
||||
bool IsAppFunction();
|
||||
void ParseFunction();
|
||||
void ParseParams(const std::string & par);
|
||||
void ParseParams(const std::wstring & par);
|
||||
void ParseParams();
|
||||
|
||||
public:
|
||||
|
|
|
@ -69,7 +69,7 @@ Functions::Iterator Functions::End()
|
|||
}
|
||||
|
||||
|
||||
FunctionBase * Functions::Find(const std::string & function_name)
|
||||
FunctionBase * Functions::Find(const std::wstring & function_name)
|
||||
{
|
||||
Table::iterator i = table.find(function_name);
|
||||
|
||||
|
@ -105,7 +105,7 @@ void Functions::PrepareUrl(Item & item)
|
|||
|
||||
Error Functions::CheckSpecialFile(const Item & item)
|
||||
{
|
||||
static std::string fstab = "fstab";
|
||||
static std::wstring fstab = L"fstab";
|
||||
|
||||
Item * etc = system->dirs.GetEtcDir();
|
||||
|
||||
|
@ -403,8 +403,8 @@ return false;
|
|||
// returning true if the 'url' has to be changed
|
||||
void Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
|
||||
{
|
||||
std::string * new_subject = request->PostVarp("subject");
|
||||
std::string * new_url = request->PostVarp("url");
|
||||
std::wstring * new_subject = request->PostVarp(L"subject");
|
||||
std::wstring * new_url = request->PostVarp(L"url");
|
||||
|
||||
if( new_subject )
|
||||
item.subject = *new_subject;
|
||||
|
@ -412,7 +412,7 @@ void Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
|
|||
if( item.subject.empty() )
|
||||
{
|
||||
item.subject = request->dir_tab.back()->subject;
|
||||
item.subject += "_msg_";
|
||||
item.subject += L"_msg_";
|
||||
item.subject += ToStr(db->Size(request->dir_tab.back()->id, Item::file));
|
||||
}
|
||||
|
||||
|
@ -432,14 +432,14 @@ void Functions::ReadItemFilterHtml(Item & item)
|
|||
html_filter.CheckOrphans(HTMLFilter::lang_none);
|
||||
html_filter.SafeMode(true);
|
||||
|
||||
html_filter.Filter(request->PostVar("itemcontent"), item.content);
|
||||
html_filter.Filter(request->PostVar(L"itemcontent"), item.content);
|
||||
}
|
||||
|
||||
|
||||
void Functions::ReadItemContent(Item & item, const std::string & content_type)
|
||||
void Functions::ReadItemContent(Item & item, const std::wstring & content_type)
|
||||
{
|
||||
bool is_root = request->session->puser && request->session->puser->super_user;
|
||||
bool filter_html = (content_type == "2") && config->editors_html_safe_mode;
|
||||
bool filter_html = (content_type == L"2") && config->editors_html_safe_mode;
|
||||
|
||||
if( filter_html && is_root && config->editors_html_safe_mode_skip_root )
|
||||
filter_html = false;
|
||||
|
@ -447,24 +447,24 @@ void Functions::ReadItemContent(Item & item, const std::string & content_type)
|
|||
if( filter_html )
|
||||
ReadItemFilterHtml(item);
|
||||
else
|
||||
request->PostVar("itemcontent", item.content);
|
||||
request->PostVar(L"itemcontent", item.content);
|
||||
}
|
||||
|
||||
|
||||
void Functions::ReadItemContentWithType(Item & item)
|
||||
{
|
||||
item.content_type = Item::ct_formatted_text; // default is formatted text
|
||||
request->PostVar("contenttype", temp);
|
||||
request->PostVar(L"contenttype", temp);
|
||||
|
||||
ReadItemContent(item, temp);
|
||||
|
||||
|
||||
// ct_text and ct_formatted_text can use everyone
|
||||
|
||||
if( temp == "0" )
|
||||
if( temp == L"0" )
|
||||
item.content_type = Item::ct_text;
|
||||
else
|
||||
if( temp == "1" )
|
||||
if( temp == L"1" )
|
||||
item.content_type = Item::ct_formatted_text;
|
||||
|
||||
|
||||
|
@ -476,19 +476,19 @@ void Functions::ReadItemContentWithType(Item & item)
|
|||
long user_id = request->session->puser->id;
|
||||
|
||||
|
||||
if( temp == "2" )
|
||||
if( temp == L"2" )
|
||||
{
|
||||
if( system->CanUseHtml(user_id) )
|
||||
item.content_type = Item::ct_html;
|
||||
}
|
||||
else
|
||||
if( temp == "3" )
|
||||
if( temp == L"3" )
|
||||
{
|
||||
if( system->CanUseBBCode(user_id) )
|
||||
item.content_type = Item::ct_bbcode;
|
||||
}
|
||||
else
|
||||
if( temp == "4" )
|
||||
if( temp == L"4" )
|
||||
{
|
||||
if( system->CanUseRaw(user_id) )
|
||||
item.content_type = Item::ct_raw;
|
||||
|
@ -526,7 +526,7 @@ void Functions::SetUser(Item & item)
|
|||
else
|
||||
{
|
||||
item.user_id = -1;
|
||||
request->PostVar("guestname", item.guest_name);
|
||||
request->PostVar(L"guestname", item.guest_name);
|
||||
}
|
||||
|
||||
item.group_id = request->dir_tab.back()->group_id;
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
Fun::Who fun_who;
|
||||
Fun::Vim fun_vim;
|
||||
|
||||
typedef std::map<std::string, FunctionBase*> Table;
|
||||
typedef std::map<std::wstring, FunctionBase*> Table;
|
||||
typedef Table::iterator Iterator;
|
||||
|
||||
void Init();
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
void SetTemplates(Templates * ptemplates);
|
||||
void SetNotify(Notify * pnotify);
|
||||
|
||||
FunctionBase * Find(const std::string & function_name);
|
||||
FunctionBase * Find(const std::wstring & function_name);
|
||||
Error CheckSpecialFile(const Item & item);
|
||||
void PrepareUrl(Item & item);
|
||||
void SetDefaultFunction();
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
|
||||
// !! dac lepsze nazwy
|
||||
void ReadItemFilterHtml(Item & item);
|
||||
void ReadItemContent(Item & item, const std::string & content_type);
|
||||
void ReadItemContent(Item & item, const std::wstring & content_type);
|
||||
void ReadItemContentWithType(Item & item);
|
||||
|
||||
// if item.url is not empty and there is not a post variable "url"
|
||||
|
@ -141,7 +141,7 @@ private:
|
|||
Templates * templates;
|
||||
Notify * notify;
|
||||
|
||||
std::string temp;
|
||||
std::wstring temp;
|
||||
HTMLFilter html_filter;
|
||||
|
||||
void CreateFunctions();
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
FunThread::FunThread()
|
||||
{
|
||||
fun.url = "thread";
|
||||
fun.url = L"thread";
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void FunThread::MakeGet()
|
|||
|
||||
DbItemQuery iq;
|
||||
|
||||
if( system->mounts.pmount->IsArg(system->mounts.MountParThread(), "sort_desc") )
|
||||
if( system->mounts.pmount->IsArg(system->mounts.MountParThread(), L"sort_desc") )
|
||||
iq.sort_asc = false;
|
||||
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Fun
|
|||
|
||||
Last::Last()
|
||||
{
|
||||
fun.url = "last";
|
||||
fun.url = L"last";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@ namespace Fun
|
|||
|
||||
Login::Login()
|
||||
{
|
||||
fun.url = "login";
|
||||
fun.url = L"login";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Login::MakePost()
|
||||
{
|
||||
const std::string & login = request->PostVar("login");
|
||||
const std::string & pass = request->PostVar("password");
|
||||
const std::string & remem = request->PostVar("rememberme");
|
||||
const std::wstring & login = request->PostVar(L"login");
|
||||
const std::wstring & pass = request->PostVar(L"password");
|
||||
const std::wstring & remem = request->PostVar(L"rememberme");
|
||||
long user_id;
|
||||
|
||||
if( db->CheckUser(login, pass, user_id) )
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Fun
|
|||
|
||||
Logout::Logout()
|
||||
{
|
||||
fun.url = "logout";
|
||||
fun.url = L"logout";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Ls::Ls()
|
||||
{
|
||||
fun.url = "ls";
|
||||
fun.url = L"ls";
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ void Ls::MakeGet()
|
|||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
|
||||
if( request->IsParam("ckeditor_browse") )
|
||||
if( request->IsParam(L"ckeditor_browse") )
|
||||
{
|
||||
iq.WhereAuth(Item::auth_image);
|
||||
db->GetItems(request->item_tab, iq);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Mkdir::Mkdir()
|
||||
{
|
||||
fun.url = "mkdir";
|
||||
fun.url = L"mkdir";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Mv::Mv()
|
||||
{
|
||||
fun.url = "mv";
|
||||
fun.url = L"mv";
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ Item * last_but_one = 0;
|
|||
{
|
||||
// used in POST when the moving is performed
|
||||
|
||||
if( request->IsPostVar("onlycontent") )
|
||||
if( request->IsPostVar(L"onlycontent") )
|
||||
return system->HasWriteAccess(*last);
|
||||
else
|
||||
if( last_but_one )
|
||||
|
@ -131,9 +131,9 @@ return true;
|
|||
|
||||
|
||||
|
||||
bool Mv::MoveParseDir(long & dir_id, std::string & dir, std::string & file)
|
||||
bool Mv::MoveParseDir(long & dir_id, std::wstring & dir, std::wstring & file)
|
||||
{
|
||||
int res = system->dirs.AnalyzePath(request->PostVar("to"), dir_id, dir, file);
|
||||
int res = system->dirs.AnalyzePath(request->PostVar(L"to"), dir_id, dir, file);
|
||||
|
||||
if( res == 1 )
|
||||
request->status = WINIX_ERR_NO_ROOT_DIR;
|
||||
|
@ -154,9 +154,9 @@ void Mv::MoveAuth(Item & item)
|
|||
return;
|
||||
}
|
||||
|
||||
if( rename(item.auth_path.c_str(), mv_new_path.c_str()) == 0 )
|
||||
if( RenameFile(item.auth_path, mv_new_path) )
|
||||
{
|
||||
log << log1 << "Content: moved static file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
||||
log << log1 << "Mv: 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);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ void Mv::MoveAuth(Item & item)
|
|||
{
|
||||
int err = errno;
|
||||
|
||||
log << log1 << "Content: can't move a file from: " << item.auth_path << ", to: " << mv_new_path << ", ";
|
||||
log << log1 << "Mv: can't move a file from: " << item.auth_path << ", to: " << mv_new_path << ", ";
|
||||
log.SystemErr(err);
|
||||
log << logend;
|
||||
|
||||
|
@ -208,7 +208,7 @@ void Mv::MoveFile(Item & item, bool redirect)
|
|||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "Content: the file was moved to: " << mv_dir << item.url << logend;
|
||||
log << log2 << "Mv: the file was moved to: " << mv_dir << item.url << logend;
|
||||
|
||||
if( item.auth != Item::auth_none )
|
||||
MoveAuth(item);
|
||||
|
@ -288,7 +288,7 @@ void Mv::MoveDir(Item & item, bool redirect)
|
|||
|
||||
if( mv_dir_id == item.id || system->dirs.HasParent(mv_dir_id, item.id) )
|
||||
{
|
||||
log << log1 << "Content: cannot move directory to inside it" << logend;
|
||||
log << log1 << "Mv: cannot move directory to inside it" << logend;
|
||||
request->status = WINIX_ERR_INCORRECT_DIR;
|
||||
return;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ void Mv::MoveDir(Item & item, bool redirect)
|
|||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "Content: the directory was moved to: " << mv_dir << item.url << logend;
|
||||
log << log2 << "Mv: the directory was moved to: " << mv_dir << item.url << logend;
|
||||
MoveAuthContentOfDir(item);
|
||||
|
||||
if( redirect )
|
||||
|
@ -337,7 +337,7 @@ void Mv::MakePost()
|
|||
{
|
||||
MoveAuthPrepareQuery();
|
||||
|
||||
if( request->IsPostVar("onlycontent") )
|
||||
if( request->IsPostVar(L"onlycontent") )
|
||||
{
|
||||
if( mv_file.empty() )
|
||||
MoveContentOfDir();
|
||||
|
|
|
@ -28,9 +28,9 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
std::string mv_dir;
|
||||
std::string mv_file;
|
||||
std::string mv_new_path;
|
||||
std::wstring mv_dir;
|
||||
std::wstring mv_file;
|
||||
std::wstring mv_new_path;
|
||||
long mv_dir_id;
|
||||
std::vector<Item> mv_auth;
|
||||
DbItemQuery mv_auth_iq;
|
||||
|
@ -39,7 +39,7 @@ private:
|
|||
bool MoveCheckAccessFrom();
|
||||
bool MoveCheckAccessTo(long dir_id);
|
||||
bool MoveCheckMountPoints(long dir_id);
|
||||
bool MoveParseDir(long & dir_id, std::string & dir, std::string & file);
|
||||
bool MoveParseDir(long & dir_id, std::wstring & dir, std::wstring & file);
|
||||
void MoveAuth(Item & item);
|
||||
bool MoveIsTheSameFile(const Item & item);
|
||||
void MoveFile(Item & item, bool redirect = true);
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Fun
|
|||
|
||||
Node::Node()
|
||||
{
|
||||
fun.url = "node";
|
||||
fun.url = L"node";
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,8 +28,7 @@ void Node::MakeGet()
|
|||
return;
|
||||
}
|
||||
|
||||
long id = atol( request->param_tab[0].name.c_str() );
|
||||
|
||||
long id = Atol(request->param_tab[0].name);
|
||||
system->RedirectTo(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Priv::Priv()
|
||||
{
|
||||
fun.url = "priv";
|
||||
fun.url = L"priv";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ bool PrivChanger::CheckAccess()
|
|||
// 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(L"r")) )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return false;
|
||||
|
@ -107,7 +107,7 @@ void PrivChanger::ChangePriv(Item & item, long user_id, long group_id, int privi
|
|||
|
||||
|
||||
|
||||
void PrivChanger::PrivLogStart(const char * what, long user, long group, int priv)
|
||||
void PrivChanger::PrivLogStart(const wchar_t * what, long user, long group, int priv)
|
||||
{
|
||||
log << log2 << what;
|
||||
|
||||
|
@ -146,7 +146,7 @@ void PrivChanger::PrivLogStart(const char * what, long user, long group, int pri
|
|||
|
||||
|
||||
|
||||
void PrivChanger::PrivLog(const char * what, long id, const std::string & url)
|
||||
void PrivChanger::PrivLog(const wchar_t * what, long id, const std::wstring & url)
|
||||
{
|
||||
Item * root = 0;
|
||||
|
||||
|
@ -181,7 +181,7 @@ void PrivChanger::PrivFilesInDir(long parent_id)
|
|||
|
||||
for( ; i != request->item_tab.end() ; ++i)
|
||||
{
|
||||
PrivLog("changed file: ", -1, i->url);
|
||||
PrivLog(L"changed file: ", -1, i->url);
|
||||
ChangePriv(*i, user_id_file, group_id_file, priv_file);
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ void PrivChanger::PrivDir(long parent_id)
|
|||
|
||||
for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextParent(i) )
|
||||
{
|
||||
PrivLog("changed dir: ", -1, i->second->url);
|
||||
PrivLog(L"changed dir: ", -1, i->second->url);
|
||||
ChangePriv(*(i->second), user_id_dir, group_id_dir, priv_dir);
|
||||
|
||||
if( subdirectories )
|
||||
|
@ -207,12 +207,12 @@ void PrivChanger::PrivDir(long parent_id)
|
|||
}
|
||||
|
||||
|
||||
void PrivChanger::ReadPriv(const char * user_in, const char * group_in, const char * priv_in,
|
||||
void PrivChanger::ReadPriv(const wchar_t * user_in, const wchar_t * group_in, const wchar_t * priv_in,
|
||||
long & user_id, long & group_id, int & priv)
|
||||
{
|
||||
const std::string & user_str = request->PostVar(user_in);
|
||||
const std::string & group_str = request->PostVar(group_in);
|
||||
const std::string & priv_str = request->PostVar(priv_in);
|
||||
const std::wstring & user_str = request->PostVar(user_in);
|
||||
const std::wstring & group_str = request->PostVar(group_in);
|
||||
const std::wstring & priv_str = request->PostVar(priv_in);
|
||||
|
||||
if( change_owner )
|
||||
{
|
||||
|
@ -221,28 +221,28 @@ void PrivChanger::ReadPriv(const char * user_in, const char * group_in, const ch
|
|||
}
|
||||
|
||||
if( change_priv )
|
||||
priv = strtol(priv_str.c_str(), 0, 8);
|
||||
priv = wcstol(priv_str.c_str(), 0, 8);
|
||||
}
|
||||
|
||||
|
||||
void PrivChanger::PrivDir()
|
||||
{
|
||||
ReadPriv("userfile", "groupfile", "privilegesfile", user_id_file, group_id_file, priv_file);
|
||||
ReadPriv("userdir", "groupdir", "privilegesdir", user_id_dir, group_id_dir, priv_dir);
|
||||
ReadPriv(L"userfile", L"groupfile", L"privilegesfile", user_id_file, group_id_file, priv_file);
|
||||
ReadPriv(L"userdir", L"groupdir", L"privilegesdir", user_id_dir, group_id_dir, priv_dir);
|
||||
|
||||
PrivLogStart("Content: changes for files: ", user_id_file, group_id_file, priv_file);
|
||||
PrivLogStart("Content: changes for dirs: ", user_id_dir, group_id_dir, priv_dir);
|
||||
PrivLogStart(L"Content: changes for files: ", user_id_file, group_id_file, priv_file);
|
||||
PrivLogStart(L"Content: changes for dirs: ", user_id_dir, group_id_dir, priv_dir);
|
||||
|
||||
|
||||
if( request->IsPostVar("changecurrentdir") )
|
||||
if( request->IsPostVar(L"changecurrentdir") )
|
||||
{
|
||||
Item & last_dir = *request->dir_tab.back();
|
||||
PrivLog("changed dir: ", last_dir.id, last_dir.url);
|
||||
PrivLog(L"changed dir: ", last_dir.id, last_dir.url);
|
||||
ChangePriv(*request->dir_tab.back(), user_id_dir, group_id_dir, priv_dir);
|
||||
}
|
||||
|
||||
|
||||
subdirectories = request->IsPostVar("changesubdirs");
|
||||
subdirectories = request->IsPostVar(L"changesubdirs");
|
||||
|
||||
// go through all directories
|
||||
PrivDir(request->dir_tab.back()->id);
|
||||
|
@ -255,9 +255,8 @@ void PrivChanger::PrivDir()
|
|||
// changing only one item (either a dir or file)
|
||||
void PrivChanger::PrivOneItem()
|
||||
{
|
||||
ReadPriv("user", "group", "privileges", user_id_file, group_id_file, priv_file);
|
||||
|
||||
PrivLogStart("Content: changes: ", user_id_file, group_id_file, priv_file);
|
||||
ReadPriv(L"user", L"group", L"privileges", user_id_file, group_id_file, priv_file);
|
||||
PrivLogStart(L"Content: changes: ", user_id_file, group_id_file, priv_file);
|
||||
|
||||
if( request->is_item )
|
||||
{
|
||||
|
@ -281,7 +280,7 @@ void PrivChanger::Change(bool change_owner_, bool change_priv_)
|
|||
change_owner = change_owner_;
|
||||
change_priv = change_priv_;
|
||||
|
||||
if( request->IsParam("r") )
|
||||
if( request->IsParam(L"r") )
|
||||
{
|
||||
PrivDir();
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ private:
|
|||
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 PrivLogStart(const wchar_t * what, long user, long group, int priv);
|
||||
void PrivLog(const wchar_t * what, long id, const std::wstring & url);
|
||||
void PrivFilesInDir(long parent_id);
|
||||
void PrivDir(long parent_id);
|
||||
void ReadPriv(const char * user_in, const char * group_in, const char * priv_in,
|
||||
void ReadPriv(const wchar_t * user_in, const wchar_t * group_in, const wchar_t * priv_in,
|
||||
long & user_id, long & group_id, int & priv);
|
||||
void PrivDir();
|
||||
void PrivOneItem();
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Reload::Reload()
|
||||
{
|
||||
fun.url = "reload";
|
||||
fun.url = L"reload";
|
||||
fun.privileges = 0700;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ void Reload::MakeGet()
|
|||
return;
|
||||
}
|
||||
|
||||
if( request->IsParam("templates") )
|
||||
if( request->IsParam(L"templates") )
|
||||
FunReloadTemplates();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <errno.h>
|
||||
#include "rm.h"
|
||||
#include "core/plugin.h"
|
||||
#include "core/misc.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
|
@ -20,7 +21,7 @@ namespace Fun
|
|||
|
||||
Rm::Rm()
|
||||
{
|
||||
fun.url = "rm";
|
||||
fun.url = L"rm";
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +152,7 @@ void Rm::RemoveDir()
|
|||
if( request->param_tab.empty() )
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED; // use parameter "r" for removing a directory
|
||||
else
|
||||
if( request->IsParam("r") )
|
||||
if( request->IsParam(L"r") )
|
||||
RemoveAllDirs();
|
||||
else
|
||||
request->status = WINIX_ERR_UNKNOWN_PARAM;
|
||||
|
@ -167,7 +168,7 @@ void Rm::RemoveAuth(Item & item)
|
|||
return;
|
||||
}
|
||||
|
||||
if( remove(item.auth_path.c_str()) == 0 )
|
||||
if( ::RemoveFile(item.auth_path) )
|
||||
{
|
||||
log << log1 << "Content: removed static file: " << item.auth_path << logend;
|
||||
item.auth_path.clear();
|
||||
|
@ -230,7 +231,7 @@ void Rm::RemoveFile()
|
|||
|
||||
void Rm::MakeGet()
|
||||
{
|
||||
if( request->IsParam("confirm") )
|
||||
if( request->IsParam(L"confirm") )
|
||||
return; // show confirmation dialog
|
||||
|
||||
if( request->is_item )
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Fun
|
|||
|
||||
Run::Run()
|
||||
{
|
||||
fun.url = "run";
|
||||
fun.url = L"run";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Fun
|
|||
|
||||
Stat::Stat()
|
||||
{
|
||||
fun.url = "stat";
|
||||
fun.url = L"stat";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Fun
|
|||
|
||||
Subject::Subject()
|
||||
{
|
||||
fun.url = "subject";
|
||||
fun.url = L"subject";
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ void Subject::EditDirSubject()
|
|||
{
|
||||
Item & dir = *request->dir_tab.back();
|
||||
|
||||
request->PostVar("subject", dir.subject);
|
||||
request->PostVar(L"subject", dir.subject);
|
||||
db->EditSubjectById(dir, dir.id);
|
||||
|
||||
system->RedirectToLastDir();
|
||||
|
@ -55,7 +55,7 @@ void Subject::EditDirSubject()
|
|||
|
||||
void Subject::EditFileSubject()
|
||||
{
|
||||
request->PostVar("subject", request->item.subject);
|
||||
request->PostVar(L"subject", request->item.subject);
|
||||
db->EditSubjectById(request->item, request->item.id);
|
||||
|
||||
system->RedirectTo(request->item);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Template::Template()
|
||||
{
|
||||
fun.url = "template";
|
||||
fun.url = L"template";
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,9 +53,9 @@ void Template::PutLog(Item & item)
|
|||
}
|
||||
|
||||
|
||||
void Template::CreateTemplateFileName(const std::string & index_str)
|
||||
void Template::CreateTemplateFileName(const std::wstring & index_str)
|
||||
{
|
||||
int index = atoi(index_str.c_str());
|
||||
int index = Atoi(index_str);
|
||||
|
||||
if( index < 0 )
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ void Template::ChangeTemplate(Item & item)
|
|||
|
||||
void Template::MakePost()
|
||||
{
|
||||
CreateTemplateFileName(request->PostVar("template"));
|
||||
CreateTemplateFileName(request->PostVar(L"template"));
|
||||
ChangeTemplate(*request->last_item);
|
||||
|
||||
system->RedirectToLastItem();
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
std::string html_template;
|
||||
void CreateTemplateFileName(const std::string & index_str);
|
||||
std::wstring html_template;
|
||||
void CreateTemplateFileName(const std::wstring & index_str);
|
||||
void ChangeTemplate(Item & item);
|
||||
void PutLog(Item & item);
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Fun
|
|||
|
||||
Tinymce::Tinymce()
|
||||
{
|
||||
fun.url = "tinymce";
|
||||
fun.url = L"tinymce";
|
||||
}
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue