changed: the way of building the cmslu
main Makefile is in an application directory in cmslu/ there are only libraries: core.a content.a confparser.a templates.a added: macros APPTEMPLATES APPFUNCTIONS defined in the application's Makefile added: PatternCacher added: cmslu function 'run' files which have exec permissions can be run (run is a default function) after read from the database the content is parsed into Ezc::Pattern object, this object is then cached in PatternCacher added: FunctionCodeParser - will be used to parse the code from standard functions (ls/cat/...) git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@475 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
327f18525c
commit
20f6fbcf84
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef headerfileappcontent
|
||||||
|
#define headerfileappcontent
|
||||||
|
|
||||||
|
|
||||||
|
#include "../core/log.h"
|
||||||
|
#include "../core/data.h"
|
||||||
|
#include "../core/function.h"
|
||||||
|
#include "../core/log.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace AppContent
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AppFunction(int code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -10,8 +10,12 @@ namespace AppTemplateFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
void CreateAppFunctions(Ezc::Functions & functions);
|
//void CreateAppFunctions(Ezc::Functions & functions);
|
||||||
|
|
||||||
|
void ReadAppPatterns();
|
||||||
|
|
||||||
|
void CreateAppFunctions(Ezc::Functions & functions);
|
||||||
|
Ezc::Pattern * GetAppPattern();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
o = content.o privileges.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o defaultitem.o
|
o = content.o priv.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o default.o run.o
|
||||||
|
|
||||||
|
|
||||||
all: content.a
|
all: content.a
|
||||||
|
|
|
@ -4,130 +4,157 @@ cat.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||||
cat.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
cat.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||||
cat.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
cat.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
cat.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
cat.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
cat.o: ../core/functions.h ../core/function.h ../core/request.h
|
cat.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
cat.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
cat.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
cat.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
cat.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
cat.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
cat.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
cat.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
cat.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
cat.o: ../core/log.h ../core/misc.h ../core/function.h
|
cat.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||||
cat.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
cat.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
|
||||||
|
cat.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||||
|
cat.o: ../core/data.h ../app/content.h
|
||||||
content.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
content.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
content.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
content.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||||
content.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
content.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||||
content.o: ../core/user.h ../core/group.h ../core/ugcontainer.h
|
content.o: ../core/user.h ../core/group.h ../core/ugcontainer.h
|
||||||
content.o: ../core/users.h ../core/groups.h ../core/functions.h
|
content.o: ../core/users.h ../core/groups.h ../core/functions.h
|
||||||
content.o: ../core/function.h ../core/request.h ../core/requesttypes.h
|
content.o: ../core/function.h ../core/functioncodeparser.h ../core/request.h
|
||||||
content.o: ../core/session.h ../core/done.h ../core/getparser.h
|
content.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
content.o: ../core/httpsimpleparser.h ../core/postparser.h
|
content.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
content.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
content.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
content.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
content.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
content.o: ../core/log.h ../core/misc.h ../core/function.h
|
content.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||||
content.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
content.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
|
||||||
defaultitem.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
content.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||||
defaultitem.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
content.o: ../core/data.h ../app/content.h
|
||||||
defaultitem.o: ../core/error.h ../core/dirs.h ../core/db.h
|
default.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
defaultitem.o: ../core/dircontainer.h ../core/user.h ../core/group.h
|
default.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||||
defaultitem.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
default.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||||
defaultitem.o: ../core/functions.h ../core/function.h ../core/request.h
|
default.o: ../core/user.h ../core/group.h ../core/ugcontainer.h
|
||||||
defaultitem.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
default.o: ../core/users.h ../core/groups.h ../core/functions.h
|
||||||
defaultitem.o: ../core/getparser.h ../core/httpsimpleparser.h
|
default.o: ../core/function.h ../core/functioncodeparser.h ../core/request.h
|
||||||
defaultitem.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
default.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
defaultitem.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
default.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
defaultitem.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
default.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
defaultitem.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
default.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
defaultitem.o: ../core/data.h
|
default.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||||
|
default.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
|
||||||
|
default.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||||
|
default.o: ../core/data.h ../app/content.h
|
||||||
emacs.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
emacs.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
emacs.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
emacs.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||||
emacs.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
emacs.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||||
emacs.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
emacs.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||||
emacs.o: ../core/groups.h ../core/functions.h ../core/function.h
|
emacs.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||||
emacs.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
emacs.o: ../core/functioncodeparser.h ../core/request.h
|
||||||
emacs.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
emacs.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
emacs.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
emacs.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||||
emacs.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
emacs.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||||
emacs.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
emacs.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||||
emacs.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
emacs.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||||
emacs.o: ../core/data.h
|
emacs.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||||
|
emacs.o: ../core/request.h ../core/data.h ../app/content.h
|
||||||
login.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
login.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
login.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
login.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||||
login.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
login.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||||
login.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
login.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||||
login.o: ../core/groups.h ../core/functions.h ../core/function.h
|
login.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||||
login.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
login.o: ../core/functioncodeparser.h ../core/request.h
|
||||||
login.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
login.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
login.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
login.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||||
login.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
login.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||||
login.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
login.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||||
login.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
login.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||||
login.o: ../core/data.h
|
login.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||||
|
login.o: ../core/request.h ../core/data.h ../app/content.h
|
||||||
logout.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
logout.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
logout.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
logout.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||||
logout.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
logout.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||||
logout.o: ../core/user.h ../core/group.h ../core/ugcontainer.h
|
logout.o: ../core/user.h ../core/group.h ../core/ugcontainer.h
|
||||||
logout.o: ../core/users.h ../core/groups.h ../core/functions.h
|
logout.o: ../core/users.h ../core/groups.h ../core/functions.h
|
||||||
logout.o: ../core/function.h ../core/request.h ../core/requesttypes.h
|
logout.o: ../core/function.h ../core/functioncodeparser.h ../core/request.h
|
||||||
logout.o: ../core/session.h ../core/done.h ../core/getparser.h
|
logout.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
logout.o: ../core/httpsimpleparser.h ../core/postparser.h
|
logout.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||||
logout.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
logout.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||||
logout.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
logout.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||||
logout.o: ../core/log.h ../core/misc.h ../core/function.h
|
logout.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||||
logout.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
logout.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||||
|
logout.o: ../core/request.h ../core/data.h ../app/content.h
|
||||||
ls.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
ls.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||||
ls.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
ls.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||||
ls.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
ls.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
ls.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
ls.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
ls.o: ../core/functions.h ../core/function.h ../core/request.h
|
ls.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
ls.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
ls.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
ls.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
ls.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
ls.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
ls.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h ../core/db.h
|
||||||
ls.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
ls.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.h
|
||||||
ls.o: ../core/log.h ../core/misc.h ../core/function.h
|
ls.o: ../core/groups.h ../core/log.h ../templates/patterncacher.h
|
||||||
|
ls.o: ../app/templates.h ../core/misc.h ../core/function.h
|
||||||
ls.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
ls.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
||||||
|
ls.o: ../app/content.h
|
||||||
mkdir.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
mkdir.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
mkdir.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
mkdir.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||||
mkdir.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
mkdir.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||||
mkdir.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
mkdir.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||||
mkdir.o: ../core/groups.h ../core/functions.h ../core/function.h
|
mkdir.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||||
mkdir.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
mkdir.o: ../core/functioncodeparser.h ../core/request.h
|
||||||
mkdir.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
mkdir.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
mkdir.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
mkdir.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||||
mkdir.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
mkdir.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||||
mkdir.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
mkdir.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||||
mkdir.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
mkdir.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||||
mkdir.o: ../core/data.h
|
mkdir.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||||
|
mkdir.o: ../core/request.h ../core/data.h ../app/content.h
|
||||||
node.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
node.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||||
node.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
node.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||||
node.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
node.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
node.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
|
node.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||||
node.o: ../core/groups.h ../core/functions.h ../core/function.h
|
node.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||||
node.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
node.o: ../core/functioncodeparser.h ../core/request.h ../core/requesttypes.h
|
||||||
node.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
node.o: ../core/session.h ../core/done.h ../core/getparser.h
|
||||||
node.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
node.o: ../core/httpsimpleparser.h ../core/postparser.h
|
||||||
node.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
node.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||||
node.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
node.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||||
node.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
node.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||||
node.o: ../core/data.h
|
node.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||||
privileges.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
node.o: ../core/request.h ../core/data.h ../app/content.h
|
||||||
privileges.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
priv.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||||
privileges.o: ../core/error.h ../core/dirs.h ../core/db.h
|
priv.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||||
privileges.o: ../core/dircontainer.h ../core/user.h ../core/group.h
|
priv.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
privileges.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
priv.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||||
privileges.o: ../core/functions.h ../core/function.h ../core/request.h
|
priv.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||||
privileges.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
priv.o: ../core/functioncodeparser.h ../core/request.h ../core/requesttypes.h
|
||||||
privileges.o: ../core/getparser.h ../core/httpsimpleparser.h
|
priv.o: ../core/session.h ../core/done.h ../core/getparser.h
|
||||||
privileges.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
priv.o: ../core/httpsimpleparser.h ../core/postparser.h
|
||||||
privileges.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
priv.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||||
privileges.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
priv.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||||
privileges.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
priv.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||||
privileges.o: ../core/data.h
|
priv.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||||
|
priv.o: ../core/request.h ../core/data.h ../app/content.h
|
||||||
rm.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
rm.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||||
rm.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
rm.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||||
rm.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
rm.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
rm.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
rm.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
rm.o: ../core/functions.h ../core/function.h ../core/request.h
|
rm.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
rm.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
rm.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
rm.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
rm.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
rm.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
rm.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h ../core/db.h
|
||||||
rm.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
rm.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.h
|
||||||
rm.o: ../core/log.h ../core/misc.h ../core/function.h
|
rm.o: ../core/groups.h ../core/log.h ../templates/patterncacher.h
|
||||||
|
rm.o: ../app/templates.h ../core/misc.h ../core/function.h
|
||||||
rm.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
rm.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
||||||
|
rm.o: ../app/content.h
|
||||||
|
run.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||||
|
run.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||||
|
run.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
|
run.o: ../core/group.h ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
|
run.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
|
run.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
|
run.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
|
run.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
|
run.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
|
run.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||||
|
run.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
|
||||||
|
run.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||||
|
run.o: ../core/data.h ../app/content.h ../core/functioncodeparser.h
|
||||||
|
|
|
@ -44,7 +44,10 @@ void Content::SetDefaultFunction()
|
||||||
{
|
{
|
||||||
if( request.is_item )
|
if( request.is_item )
|
||||||
{
|
{
|
||||||
request.pfunction = data.functions.GetFunction(Function::cat);
|
if( request.HasReadExecAccess(request.item) )
|
||||||
|
request.pfunction = data.functions.GetFunction(FUN_RUN);
|
||||||
|
else
|
||||||
|
request.pfunction = data.functions.GetFunction(FUN_CAT);
|
||||||
|
|
||||||
if( request.pfunction )
|
if( request.pfunction )
|
||||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
||||||
|
@ -55,7 +58,7 @@ void Content::SetDefaultFunction()
|
||||||
|
|
||||||
if( default_item == -1 )
|
if( default_item == -1 )
|
||||||
{
|
{
|
||||||
request.pfunction = data.functions.GetFunction(Function::ls);
|
request.pfunction = data.functions.GetFunction(FUN_LS);
|
||||||
|
|
||||||
if( request.pfunction )
|
if( request.pfunction )
|
||||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
||||||
|
@ -87,31 +90,34 @@ void Content::MakeStandardFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( request.pfunction->code == Function::logout )
|
if( request.pfunction->code == FUN_LOGOUT )
|
||||||
FunLogout();
|
FunLogout();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::cat )
|
if( request.pfunction->code == FUN_CAT )
|
||||||
FunCat();
|
FunCat();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::ls )
|
if( request.pfunction->code == FUN_LS )
|
||||||
FunLs();
|
FunLs();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::emacs )
|
if( request.pfunction->code == FUN_EMACS )
|
||||||
FunEmacs();
|
FunEmacs();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::mkdir )
|
if( request.pfunction->code == FUN_MKDIR )
|
||||||
FunMkdir();
|
FunMkdir();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::default_item )
|
if( request.pfunction->code == FUN_DEFAULT )
|
||||||
FunDefaultItem();
|
FunDefault();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::privileges )
|
if( request.pfunction->code == FUN_PRIV )
|
||||||
FunPrivileges();
|
FunPriv();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::rm )
|
if( request.pfunction->code == FUN_RM )
|
||||||
FunRm();
|
FunRm();
|
||||||
else
|
else
|
||||||
if( request.pfunction->code == Function::node )
|
if( request.pfunction->code == FUN_RUN )
|
||||||
|
FunRun();
|
||||||
|
else
|
||||||
|
if( request.pfunction->code == FUN_NODE )
|
||||||
FunNode();
|
FunNode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -131,23 +137,23 @@ void Content::MakePost()
|
||||||
|
|
||||||
switch( request.pfunction->code )
|
switch( request.pfunction->code )
|
||||||
{
|
{
|
||||||
case Function::emacs:
|
case FUN_EMACS:
|
||||||
PostFunEmacs();
|
PostFunEmacs();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::mkdir:
|
case FUN_MKDIR:
|
||||||
PostFunMkdir();
|
PostFunMkdir();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::default_item:
|
case FUN_DEFAULT:
|
||||||
PostFunDefaultItem();
|
PostFunDefault();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::privileges:
|
case FUN_PRIV:
|
||||||
PostFunPrivileges();
|
PostFunPriv();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::login:
|
case FUN_LOGIN:
|
||||||
PostFunLogin();
|
PostFunLogin();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,12 @@ class Content
|
||||||
void FunLogout();
|
void FunLogout();
|
||||||
void FunLs();
|
void FunLs();
|
||||||
void FunEmacs();
|
void FunEmacs();
|
||||||
void FunPrivileges();
|
void FunPriv();
|
||||||
void FunRm();
|
void FunRm();
|
||||||
void FunNode();
|
void FunNode();
|
||||||
void FunMkdir();
|
void FunMkdir();
|
||||||
void FunDefaultItem();
|
void FunDefault();
|
||||||
|
void FunRun();
|
||||||
|
|
||||||
|
|
||||||
void PostFunLogin();
|
void PostFunLogin();
|
||||||
|
@ -59,8 +60,8 @@ class Content
|
||||||
void PostFunEmacsEdit(bool with_url);
|
void PostFunEmacsEdit(bool with_url);
|
||||||
void PostFunEmacs();
|
void PostFunEmacs();
|
||||||
void PostFunMkdir();
|
void PostFunMkdir();
|
||||||
void PostFunDefaultItem();
|
void PostFunDefault();
|
||||||
void PostFunPrivileges();
|
void PostFunPriv();
|
||||||
|
|
||||||
void RedirectTo(const Item & item);
|
void RedirectTo(const Item & item);
|
||||||
void RedirectTo(long item_id);
|
void RedirectTo(long item_id);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunDefaultItem()
|
void Content::PostFunDefault()
|
||||||
{
|
{
|
||||||
Item * pdir;
|
Item * pdir;
|
||||||
long fileid = -1;
|
long fileid = -1;
|
||||||
|
@ -68,7 +68,7 @@ long fileid = -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunDefaultItem()
|
void Content::FunDefault()
|
||||||
{
|
{
|
||||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
||||||
{
|
{
|
|
@ -58,6 +58,9 @@ void Content::PostFunEmacsEdit(bool with_url)
|
||||||
throw Error(Error::permision_denied);
|
throw Error(Error::permision_denied);
|
||||||
|
|
||||||
request.session->done_status = db.EditItemById(request.item, with_url);
|
request.session->done_status = db.EditItemById(request.item, with_url);
|
||||||
|
|
||||||
|
if( request.session->done_status == Error::ok )
|
||||||
|
TemplatesFunctions::pattern_cacher.UpdatePattern(request.item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,20 +31,19 @@ void Content::PostFunLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
log << log2 << "User " << login << " (id: " << user_id << ") logged" << logend;
|
log << log2 << "User " << login << " (id: " << user_id << ") logged" << logend;
|
||||||
|
}
|
||||||
|
|
||||||
if( request.is_item )
|
// !! zglosic komunikat o nie poprawnym logowaniu
|
||||||
{
|
|
||||||
RedirectTo(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RedirectTo(*request.dir_table.back());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(const Error &)
|
catch(const Error &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( request.is_item )
|
||||||
|
RedirectTo(request.item);
|
||||||
|
else
|
||||||
|
RedirectTo(*request.dir_table.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunPrivileges()
|
void Content::PostFunPriv()
|
||||||
{
|
{
|
||||||
// !! narazie tylko dla plikow
|
// !! narazie tylko dla plikow
|
||||||
if( !request.is_item )
|
if( !request.is_item )
|
||||||
|
@ -63,7 +63,7 @@ void Content::PostFunPrivileges()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunPrivileges()
|
void Content::FunPriv()
|
||||||
{
|
{
|
||||||
if( !request.is_item )
|
if( !request.is_item )
|
||||||
{
|
{
|
|
@ -41,6 +41,7 @@ void Content::FunRm()
|
||||||
{
|
{
|
||||||
request.session->done_status = Error::ok;
|
request.session->done_status = Error::ok;
|
||||||
log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend;
|
log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend;
|
||||||
|
TemplatesFunctions::pattern_cacher.DeletePattern(request.item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of CMSLU -- Content Management System like Unix
|
||||||
|
* and is not publicly distributed
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Tomasz Sowa
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "content.h"
|
||||||
|
#include "../app/content.h"
|
||||||
|
#include "../core/functioncodeparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Content::FunRun()
|
||||||
|
{
|
||||||
|
if( !request.is_item )
|
||||||
|
{
|
||||||
|
log << log1 << "Content: Run function requires an item" << logend;
|
||||||
|
request.status = Error::item_required;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !request.HasReadExecAccess(request.item) )
|
||||||
|
{
|
||||||
|
request.status = Error::permision_denied;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionCodeParser fc;
|
||||||
|
|
||||||
|
int c = fc.Parse(request.item);
|
||||||
|
|
||||||
|
#ifdef APPFUNCTIONS
|
||||||
|
if( c != FUN_NONE )
|
||||||
|
AppContent::AppFunction(c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
o = data.o log.o sessionmanager.o requestcontroller.o dircontainer.o session.o main.o done.o request.o misc.o httpsimpleparser.o db.o error.o db_itemcolumns.o users.o config.o dirs.o groups.o function.o functionparser.o functions.o
|
o = data.o log.o sessionmanager.o requestcontroller.o dircontainer.o session.o main.o done.o request.o misc.o httpsimpleparser.o db.o error.o db_itemcolumns.o users.o config.o dirs.o groups.o function.o functionparser.o functions.o functioncodeparser.o
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
config.o: config.h ../confparser/confparser.h error.h log.h data.h misc.h
|
config.o: config.h ../confparser/confparser.h error.h log.h data.h misc.h
|
||||||
config.o: item.h dirs.h db.h dircontainer.h user.h group.h ugcontainer.h
|
config.o: item.h dirs.h db.h dircontainer.h user.h group.h ugcontainer.h
|
||||||
config.o: users.h groups.h functions.h function.h
|
config.o: users.h groups.h functions.h function.h functioncodeparser.h
|
||||||
data.o: data.h misc.h log.h item.h error.h dirs.h db.h dircontainer.h user.h
|
data.o: data.h misc.h log.h item.h error.h dirs.h db.h dircontainer.h user.h
|
||||||
data.o: group.h ugcontainer.h users.h groups.h functions.h function.h
|
data.o: group.h ugcontainer.h users.h groups.h functions.h function.h
|
||||||
|
data.o: functioncodeparser.h
|
||||||
db.o: db.h log.h item.h misc.h error.h dircontainer.h user.h group.h
|
db.o: db.h log.h item.h misc.h error.h dircontainer.h user.h group.h
|
||||||
db.o: ugcontainer.h
|
db.o: ugcontainer.h
|
||||||
db_itemcolumns.o: db.h log.h item.h misc.h error.h dircontainer.h user.h
|
db_itemcolumns.o: db.h log.h item.h misc.h error.h dircontainer.h user.h
|
||||||
|
@ -15,47 +16,52 @@ dirs.o: ugcontainer.h
|
||||||
done.o: done.h
|
done.o: done.h
|
||||||
error.o: error.h log.h
|
error.o: error.h log.h
|
||||||
function.o: function.h log.h item.h
|
function.o: function.h log.h item.h
|
||||||
|
functioncodeparser.o: functioncodeparser.h function.h log.h item.h
|
||||||
functionparser.o: functionparser.h request.h requesttypes.h log.h session.h
|
functionparser.o: functionparser.h request.h requesttypes.h log.h session.h
|
||||||
functionparser.o: error.h item.h done.h user.h getparser.h httpsimpleparser.h
|
functionparser.o: error.h item.h done.h user.h getparser.h httpsimpleparser.h
|
||||||
functionparser.o: postparser.h cookieparser.h function.h data.h misc.h dirs.h
|
functionparser.o: postparser.h cookieparser.h function.h data.h misc.h dirs.h
|
||||||
functionparser.o: db.h dircontainer.h group.h ugcontainer.h users.h groups.h
|
functionparser.o: db.h dircontainer.h group.h ugcontainer.h users.h groups.h
|
||||||
functionparser.o: functions.h
|
functionparser.o: functions.h functioncodeparser.h ../app/content.h
|
||||||
functions.o: functions.h function.h log.h item.h
|
functionparser.o: ../core/log.h ../core/data.h ../core/function.h
|
||||||
|
functions.o: functions.h function.h log.h item.h functioncodeparser.h
|
||||||
groups.o: groups.h group.h db.h log.h item.h misc.h error.h dircontainer.h
|
groups.o: groups.h group.h db.h log.h item.h misc.h error.h dircontainer.h
|
||||||
groups.o: user.h ugcontainer.h
|
groups.o: user.h ugcontainer.h
|
||||||
httpsimpleparser.o: httpsimpleparser.h
|
httpsimpleparser.o: httpsimpleparser.h
|
||||||
log.o: log.h
|
log.o: log.h
|
||||||
main.o: requestcontroller.h data.h misc.h log.h item.h error.h dirs.h db.h
|
main.o: requestcontroller.h data.h misc.h log.h item.h error.h dirs.h db.h
|
||||||
main.o: dircontainer.h user.h group.h ugcontainer.h users.h groups.h
|
main.o: dircontainer.h user.h group.h ugcontainer.h users.h groups.h
|
||||||
main.o: functions.h function.h request.h requesttypes.h session.h done.h
|
main.o: functions.h function.h functioncodeparser.h request.h requesttypes.h
|
||||||
main.o: getparser.h httpsimpleparser.h postparser.h cookieparser.h
|
main.o: session.h done.h getparser.h httpsimpleparser.h postparser.h
|
||||||
main.o: ../content/content.h ../templates/templates.h ../../ezc/src/ezc.h
|
main.o: cookieparser.h ../content/content.h ../templates/templates.h
|
||||||
main.o: ../core/data.h ../core/request.h ../core/item.h ../core/db.h
|
main.o: ../../ezc/src/ezc.h ../core/data.h ../core/request.h ../core/item.h
|
||||||
main.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.h
|
main.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
main.o: ../core/groups.h ../core/log.h ../core/misc.h ../core/function.h
|
main.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||||
main.o: ../core/functionparser.h sessionmanager.h config.h
|
main.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
|
||||||
main.o: ../confparser/confparser.h
|
main.o: ../core/function.h ../core/functionparser.h ../app/content.h
|
||||||
|
main.o: sessionmanager.h config.h ../confparser/confparser.h
|
||||||
misc.o: misc.h log.h item.h
|
misc.o: misc.h log.h item.h
|
||||||
request.o: request.h requesttypes.h log.h session.h error.h item.h done.h
|
request.o: request.h requesttypes.h log.h session.h error.h item.h done.h
|
||||||
request.o: user.h getparser.h httpsimpleparser.h postparser.h cookieparser.h
|
request.o: user.h getparser.h httpsimpleparser.h postparser.h cookieparser.h
|
||||||
request.o: function.h
|
request.o: function.h
|
||||||
requestcontroller.o: requestcontroller.h data.h misc.h log.h item.h error.h
|
requestcontroller.o: requestcontroller.h data.h misc.h log.h item.h error.h
|
||||||
requestcontroller.o: dirs.h db.h dircontainer.h user.h group.h ugcontainer.h
|
requestcontroller.o: dirs.h db.h dircontainer.h user.h group.h ugcontainer.h
|
||||||
requestcontroller.o: users.h groups.h functions.h function.h request.h
|
requestcontroller.o: users.h groups.h functions.h function.h
|
||||||
requestcontroller.o: requesttypes.h session.h done.h getparser.h
|
requestcontroller.o: functioncodeparser.h request.h requesttypes.h session.h
|
||||||
requestcontroller.o: httpsimpleparser.h postparser.h cookieparser.h
|
requestcontroller.o: done.h getparser.h httpsimpleparser.h postparser.h
|
||||||
requestcontroller.o: ../content/content.h ../templates/templates.h
|
requestcontroller.o: cookieparser.h ../content/content.h
|
||||||
requestcontroller.o: ../../ezc/src/ezc.h ../core/data.h ../core/request.h
|
requestcontroller.o: ../templates/templates.h ../../ezc/src/ezc.h
|
||||||
requestcontroller.o: ../core/item.h ../core/db.h ../core/error.h
|
requestcontroller.o: ../core/data.h ../core/request.h ../core/item.h
|
||||||
requestcontroller.o: ../core/user.h ../core/group.h ../core/users.h
|
requestcontroller.o: ../core/db.h ../core/error.h ../core/user.h
|
||||||
requestcontroller.o: ../core/groups.h ../core/log.h ../core/misc.h
|
requestcontroller.o: ../core/group.h ../core/users.h ../core/groups.h
|
||||||
requestcontroller.o: ../core/function.h ../core/functionparser.h
|
requestcontroller.o: ../core/log.h ../templates/patterncacher.h
|
||||||
|
requestcontroller.o: ../app/templates.h ../core/misc.h ../core/function.h
|
||||||
|
requestcontroller.o: ../core/functionparser.h ../app/content.h
|
||||||
requestcontroller.o: sessionmanager.h
|
requestcontroller.o: sessionmanager.h
|
||||||
session.o: session.h requesttypes.h error.h log.h item.h done.h user.h
|
session.o: session.h requesttypes.h error.h log.h item.h done.h user.h
|
||||||
sessionmanager.o: sessionmanager.h request.h requesttypes.h log.h session.h
|
sessionmanager.o: sessionmanager.h request.h requesttypes.h log.h session.h
|
||||||
sessionmanager.o: error.h item.h done.h user.h getparser.h httpsimpleparser.h
|
sessionmanager.o: error.h item.h done.h user.h getparser.h httpsimpleparser.h
|
||||||
sessionmanager.o: postparser.h cookieparser.h function.h data.h misc.h dirs.h
|
sessionmanager.o: postparser.h cookieparser.h function.h data.h misc.h dirs.h
|
||||||
sessionmanager.o: db.h dircontainer.h group.h ugcontainer.h users.h groups.h
|
sessionmanager.o: db.h dircontainer.h group.h ugcontainer.h users.h groups.h
|
||||||
sessionmanager.o: functions.h
|
sessionmanager.o: functions.h functioncodeparser.h
|
||||||
users.o: users.h user.h db.h log.h item.h misc.h error.h dircontainer.h
|
users.o: users.h user.h db.h log.h item.h misc.h error.h dircontainer.h
|
||||||
users.o: group.h ugcontainer.h
|
users.o: group.h ugcontainer.h
|
||||||
|
|
56
core/db.cpp
56
core/db.cpp
|
@ -10,18 +10,25 @@
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
|
|
||||||
Db::Db()
|
Db::Db(bool close_at_end_)
|
||||||
{
|
{
|
||||||
pg_conn = 0;
|
pg_conn = 0;
|
||||||
|
close_at_end = close_at_end_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Db::~Db()
|
Db::~Db()
|
||||||
{
|
{
|
||||||
|
if( close_at_end )
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PGconn * Db::GetPGconn()
|
||||||
|
{
|
||||||
|
return pg_conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Db::Init(const std::string & d, const std::string & u, const std::string & p)
|
void Db::Init(const std::string & d, const std::string & u, const std::string & p)
|
||||||
{
|
{
|
||||||
|
@ -43,10 +50,15 @@ void Db::Connect()
|
||||||
pg_conn = PQconnectdb(buf.str().c_str());
|
pg_conn = PQconnectdb(buf.str().c_str());
|
||||||
|
|
||||||
if( !pg_conn )
|
if( !pg_conn )
|
||||||
|
{
|
||||||
log << log1 << "Db: Fatal error during connecting" << logend;
|
log << log1 << "Db: Fatal error during connecting" << logend;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( PQsetClientEncoding(pg_conn, "LATIN2") == -1 )
|
if( PQsetClientEncoding(pg_conn, "LATIN2") == -1 )
|
||||||
log << log1 << "Db: Can't set the proper client encoding" << logend;
|
log << log1 << "Db: Can't set the proper client encoding" << logend;
|
||||||
|
|
||||||
|
log << log3 << "Db: Socket: " << PQsocket(pg_conn) << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,6 +104,8 @@ void Db::AssertConnection()
|
||||||
|
|
||||||
if( PQsetClientEncoding(pg_conn, "LATIN2") == -1 )
|
if( PQsetClientEncoding(pg_conn, "LATIN2") == -1 )
|
||||||
log << log1 << "Db: Can't set the proper client encoding" << logend;
|
log << log1 << "Db: Can't set the proper client encoding" << logend;
|
||||||
|
|
||||||
|
log << log3 << "Db: Socket: " << PQsocket(pg_conn) << logend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +152,9 @@ PGresult * Db::AssertQuery(const std::string & q)
|
||||||
|
|
||||||
if( !r )
|
if( !r )
|
||||||
{
|
{
|
||||||
log << log1 << "Db: Problem with query: " << PQerrorMessage(pg_conn) << logend;
|
log << log1 << "Db: Problem with query: \"" << q << '\"' << logend;
|
||||||
|
log << log1 << "Db: " << PQerrorMessage(pg_conn) << logend;
|
||||||
|
|
||||||
throw Error(Error::db_incorrect_query);
|
throw Error(Error::db_incorrect_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1247,6 +1263,42 @@ void Db::GetGroups(UGContainer<Group> & group_table)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tm Db::ConvertTime(const char * str)
|
||||||
|
{
|
||||||
|
tm t;
|
||||||
|
|
||||||
|
memset(&t, 0, sizeof(t));
|
||||||
|
|
||||||
|
if( !str )
|
||||||
|
return t;
|
||||||
|
|
||||||
|
size_t len = strlen(str);
|
||||||
|
|
||||||
|
if( len != 19 )
|
||||||
|
{
|
||||||
|
// unknown format
|
||||||
|
// the format must be like this: 2008-12-31 22:30:00
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
t.tm_year = atoi(str + 0) - 1900; /* year - 1900 */
|
||||||
|
t.tm_mon = atoi(str + 5) - 1; /* month of year (0 - 11) */
|
||||||
|
t.tm_mday = atoi(str + 8); /* day of month (1 - 31) */
|
||||||
|
t.tm_hour = atoi(str + 11); /* hours (0 - 23) */
|
||||||
|
t.tm_min = atoi(str + 14); /* minutes (0 - 59) */
|
||||||
|
t.tm_sec = atoi(str + 17); /* seconds (0 - 60) */
|
||||||
|
|
||||||
|
|
||||||
|
// t.tm_wday = 0; /* day of week (Sunday = 0) */
|
||||||
|
// t.tm_yday = 0; /* day of year (0 - 365) */
|
||||||
|
// t.tm_isdst = 0; /* is summer time in effect? */
|
||||||
|
// t.tm_zone = 0; // const_cast<char*>(""); /* abbreviation of timezone name */
|
||||||
|
|
||||||
|
|
||||||
|
//return mktime(&t);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
10
core/db.h
10
core/db.h
|
@ -17,7 +17,8 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
@ -33,7 +34,7 @@ class Db
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Db();
|
Db(bool close_at_end_ = true);
|
||||||
~Db();
|
~Db();
|
||||||
|
|
||||||
// !! przerobic tak aby GetItem zwracalo wszystkie pozycja
|
// !! przerobic tak aby GetItem zwracalo wszystkie pozycja
|
||||||
|
@ -65,10 +66,15 @@ public:
|
||||||
long GetFileId(long parent_id, const std::string & url);
|
long GetFileId(long parent_id, const std::string & url);
|
||||||
long GetDirId(long parent_id, const std::string & url);
|
long GetDirId(long parent_id, const std::string & url);
|
||||||
|
|
||||||
|
tm ConvertTime(const char * str);
|
||||||
|
|
||||||
|
PGconn * GetPGconn();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
PGconn * pg_conn;
|
PGconn * pg_conn;
|
||||||
std::string db_database, db_user, db_pass;
|
std::string db_database, db_user, db_pass;
|
||||||
|
bool close_at_end;
|
||||||
|
|
||||||
void Connect();
|
void Connect();
|
||||||
void Close();
|
void Close();
|
||||||
|
|
|
@ -10,10 +10,15 @@
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function::Function()
|
Function::Function()
|
||||||
{
|
{
|
||||||
code = none;
|
code = FUN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Function::Clear()
|
||||||
|
{
|
||||||
|
code = FUN_NONE;
|
||||||
|
item.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,18 @@
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define FUN_NONE 0
|
||||||
|
#define FUN_LS 1
|
||||||
|
#define FUN_CAT 2
|
||||||
|
#define FUN_NODE 3
|
||||||
|
#define FUN_EMACS 4
|
||||||
|
#define FUN_MKDIR 5
|
||||||
|
#define FUN_DEFAULT 6
|
||||||
|
#define FUN_PRIV 7
|
||||||
|
#define FUN_RM 8
|
||||||
|
#define FUN_LOGIN 9
|
||||||
|
#define FUN_LOGOUT 10
|
||||||
|
#define FUN_RUN 11
|
||||||
|
|
||||||
|
|
||||||
class Function
|
class Function
|
||||||
|
@ -22,6 +34,7 @@ class Function
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/*
|
||||||
enum Code
|
enum Code
|
||||||
{
|
{
|
||||||
none,
|
none,
|
||||||
|
@ -30,17 +43,25 @@ public:
|
||||||
node,
|
node,
|
||||||
emacs,
|
emacs,
|
||||||
mkdir,
|
mkdir,
|
||||||
default_item,
|
default,
|
||||||
privileges,
|
priv,
|
||||||
rm,
|
rm,
|
||||||
login,
|
login,
|
||||||
logout
|
logout,
|
||||||
|
run
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Code code;
|
Code code;
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
we do not use enum etc. because the code will be used with an application too
|
||||||
|
(application can set others values)
|
||||||
|
*/
|
||||||
|
int code;
|
||||||
Item item;
|
Item item;
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
|
||||||
Function();
|
Function();
|
||||||
Function(const Function & f);
|
Function(const Function & f);
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of CMSLU -- Content Management System like Unix
|
||||||
|
* and is not publicly distributed
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Tomasz Sowa
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "functioncodeparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool FunctionCodeParser::ContentHasOneRow(const Item & item)
|
||||||
|
{
|
||||||
|
for(size_t i=0 ; i<item.content.size() ; ++i)
|
||||||
|
if( item.content[i] == '\n' )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int FunctionCodeParser::ParseValue(const char * s)
|
||||||
|
{
|
||||||
|
if( strncmp(s, "[fun:", 5) != 0 )
|
||||||
|
return FUN_NONE;
|
||||||
|
|
||||||
|
const char * send;
|
||||||
|
int result = strtol(s+5, (char**)&send, 10);
|
||||||
|
|
||||||
|
if( send==s+5 || strcmp(send, "]") != 0 )
|
||||||
|
return FUN_NONE;
|
||||||
|
|
||||||
|
log << log2 << "FCP: function code: " << result << logend;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int FunctionCodeParser::Parse(const Item & item)
|
||||||
|
{
|
||||||
|
// format: [fun:1]
|
||||||
|
// minimum size: 7 characters
|
||||||
|
if( item.content.size() < 7 )
|
||||||
|
return FUN_NONE;
|
||||||
|
|
||||||
|
if( !ContentHasOneRow(item) )
|
||||||
|
return FUN_NONE;
|
||||||
|
|
||||||
|
return ParseValue(item.content.c_str());
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of CMSLU -- Content Management System like Unix
|
||||||
|
* and is not publicly distributed
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Tomasz Sowa
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef headerfilefunctioncodeparser
|
||||||
|
#define headerfilefunctioncodeparser
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include "function.h"
|
||||||
|
#include "item.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
class FunctionCodeParser
|
||||||
|
{
|
||||||
|
bool ContentHasOneRow(const Item & item);
|
||||||
|
int ParseValue(const char * s);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
int Parse(const Item & item);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -102,7 +102,6 @@ void FunctionParser::ParseFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FunctionParser::ParseParams()
|
void FunctionParser::ParseParams()
|
||||||
{
|
{
|
||||||
while( true )
|
while( true )
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
|
#ifdef APPFUNCTIONS
|
||||||
|
#include "../app/content.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class FunctionParser
|
class FunctionParser
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@ class FunctionParser
|
||||||
|
|
||||||
void ParseDirectories();
|
void ParseDirectories();
|
||||||
void ParseItem();
|
void ParseItem();
|
||||||
|
bool IsAppFunction();
|
||||||
void ParseFunction();
|
void ParseFunction();
|
||||||
void ParseParams();
|
void ParseParams();
|
||||||
|
|
||||||
|
|
|
@ -35,45 +35,54 @@ void Functions::ReadFunctions()
|
||||||
f.item.type = Item::file;
|
f.item.type = Item::file;
|
||||||
|
|
||||||
// in the future we will read these functions from the database
|
// in the future we will read these functions from the database
|
||||||
f.code = Function::ls;
|
f.code = FUN_LS;
|
||||||
f.item.url = "ls";
|
f.item.url = "ls";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::cat;
|
f.code = FUN_CAT;
|
||||||
f.item.url = "cat";
|
f.item.url = "cat";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::node;
|
f.code = FUN_NODE;
|
||||||
f.item.url = "node";
|
f.item.url = "node";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::emacs;
|
f.code = FUN_EMACS;
|
||||||
f.item.url = "emacs";
|
f.item.url = "emacs";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::mkdir;
|
f.code = FUN_MKDIR;
|
||||||
f.item.url = "mkdir";
|
f.item.url = "mkdir";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::default_item;
|
f.code = FUN_DEFAULT;
|
||||||
f.item.url = "default";
|
f.item.url = "default";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::privileges;
|
f.code = FUN_PRIV;
|
||||||
f.item.url = "priv";
|
f.item.url = "priv";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::rm;
|
f.code = FUN_RM;
|
||||||
f.item.url = "rm";
|
f.item.url = "rm";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::logout;
|
f.code = FUN_LOGOUT;
|
||||||
f.item.url = "logout";
|
f.item.url = "logout";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
f.code = Function::login;
|
f.code = FUN_LOGIN;
|
||||||
f.item.url = "login";
|
f.item.url = "login";
|
||||||
table.insert( std::make_pair(f.item.url, f) );
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
|
f.code = FUN_RUN;
|
||||||
|
f.item.url = "run";
|
||||||
|
table.insert( std::make_pair(f.item.url, f) );
|
||||||
|
|
||||||
|
|
||||||
|
// -----------
|
||||||
|
FunctionCodeParser fc;
|
||||||
|
fc.Parse(Item()); // temporary for linking
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +101,7 @@ return &(i->second);
|
||||||
|
|
||||||
|
|
||||||
// !! in the future there will be a special container where we can search through the Code object
|
// !! in the future there will be a special container where we can search through the Code object
|
||||||
Function * Functions::GetFunction(Function::Code code)
|
Function * Functions::GetFunction(int code)
|
||||||
{
|
{
|
||||||
Table::iterator i = table.begin();
|
Table::iterator i = table.begin();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
#include "functioncodeparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public:
|
||||||
void ReadFunctions();
|
void ReadFunctions();
|
||||||
|
|
||||||
Function * GetFunction(const std::string & name);
|
Function * GetFunction(const std::string & name);
|
||||||
Function * GetFunction(Function::Code code);
|
Function * GetFunction(int code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,13 +101,17 @@ void HttpSimpleParser::CheckSpecialChar()
|
||||||
int c2 = GetChar();
|
int c2 = GetChar();
|
||||||
|
|
||||||
if( c1==-1 || c2==-1 )
|
if( c1==-1 || c2==-1 )
|
||||||
|
{
|
||||||
last_c = -1;
|
last_c = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
c1 = ParseHalfHex(c1);
|
c1 = ParseHalfHex(c1);
|
||||||
c2 = ParseHalfHex(c2);
|
c2 = ParseHalfHex(c2);
|
||||||
|
|
||||||
last_c = (c1 << 4) + c2;
|
last_c = (c1 << 4) + c2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if( last_c == '+' )
|
if( last_c == '+' )
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// singletons
|
// singletons
|
||||||
// first 'data' then 'log' then 'request'
|
// first 'data' then 'log' then 'request'
|
||||||
Data data;
|
Data data;
|
||||||
|
@ -63,6 +62,7 @@ int main(int argv, char ** argc)
|
||||||
{
|
{
|
||||||
RequestController req_controller;
|
RequestController req_controller;
|
||||||
|
|
||||||
|
|
||||||
std::srand(std::time(0));
|
std::srand(std::time(0));
|
||||||
|
|
||||||
if( argv != 2 )
|
if( argv != 2 )
|
||||||
|
@ -80,7 +80,9 @@ RequestController req_controller;
|
||||||
|
|
||||||
|
|
||||||
// closing descriptors only at the beginning
|
// closing descriptors only at the beginning
|
||||||
close(2);
|
// !! temporary we do not close standard output for errors
|
||||||
|
// client postgresql uses it for reporting warnings (I don't know why)
|
||||||
|
//close(2);
|
||||||
|
|
||||||
if( !data.log_stdout )
|
if( !data.log_stdout )
|
||||||
{
|
{
|
||||||
|
@ -89,6 +91,7 @@ RequestController req_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signal(SIGTERM, signal_term);
|
signal(SIGTERM, signal_term);
|
||||||
signal(SIGINT, signal_term);
|
signal(SIGINT, signal_term);
|
||||||
signal(SIGHUP, signal_hup);
|
signal(SIGHUP, signal_hup);
|
||||||
|
@ -102,7 +105,7 @@ RequestController req_controller;
|
||||||
if( !req_controller.Init() )
|
if( !req_controller.Init() )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
log << log2 << "checking for table consistency:" << logend;
|
//log << log2 << "checking for table consistency:" << logend;
|
||||||
// !! zrobic wyjatek dla root
|
// !! zrobic wyjatek dla root
|
||||||
//db.CheckAllUrlSubject();
|
//db.CheckAllUrlSubject();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "requesttypes.h"
|
#include "requesttypes.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PostParser : public HttpSimpleParser
|
class PostParser : public HttpSimpleParser
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,8 @@ void Request::SendAll()
|
||||||
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log << log2 << "headers: " << logend; // !! wywalic
|
||||||
|
log << headers.str() << logend; // !!
|
||||||
|
|
||||||
FCGX_PutS(headers.str().c_str(), out);
|
FCGX_PutS(headers.str().c_str(), out);
|
||||||
FCGX_PutS("\r\n", out);
|
FCGX_PutS("\r\n", out);
|
||||||
|
@ -321,6 +323,9 @@ void Request::SendAll()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FCGX_PutS(page.str().c_str(), out);
|
FCGX_PutS(page.str().c_str(), out);
|
||||||
|
log << log2 << "body: " << logend; // !! wywalic
|
||||||
|
log << page.str() << logend; // !!
|
||||||
|
|
||||||
|
|
||||||
const std::string & d = debug.str();
|
const std::string & d = debug.str();
|
||||||
|
|
||||||
|
@ -466,6 +471,7 @@ bool Request::HasWriteAccess(const Item & item)
|
||||||
return HasAccess(item, 2);
|
return HasAccess(item, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Request::HasReadWriteAccess(const Item & item)
|
bool Request::HasReadWriteAccess(const Item & item)
|
||||||
{
|
{
|
||||||
return HasAccess(item, 6); // r+w
|
return HasAccess(item, 6); // r+w
|
||||||
|
@ -474,6 +480,13 @@ bool Request::HasReadWriteAccess(const Item & item)
|
||||||
|
|
||||||
bool Request::HasReadExecAccess(const Item & item)
|
bool Request::HasReadExecAccess(const Item & item)
|
||||||
{
|
{
|
||||||
|
if( session && session->puser && session->puser->super_user )
|
||||||
|
{
|
||||||
|
// there must be at least one 'x' (for the root)
|
||||||
|
|
||||||
|
return (item.privileges & 0111) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
return HasAccess(item, 5); // r+x
|
return HasAccess(item, 5); // r+x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct Request
|
||||||
Error done_status; // !! wywalic - jest przeciez w session
|
Error done_status; // !! wywalic - jest przeciez w session
|
||||||
|
|
||||||
// what to do
|
// what to do
|
||||||
|
// !! wywalic?
|
||||||
enum Result { err_internal, err404, err_per_denied, show_dir, show_item, show_item_by_id, add_item, edit_item, del_item, del_item_confirm, confirm, redirect, logout } result; // zamienic na to_do
|
enum Result { err_internal, err404, err_per_denied, show_dir, show_item, show_item_by_id, add_item, edit_item, del_item, del_item_confirm, confirm, redirect, logout } result; // zamienic na to_do
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,6 +157,7 @@ struct Request
|
||||||
bool HasReadExecAccess(const Item & item);
|
bool HasReadExecAccess(const Item & item);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// used to set some env_* variables into it, when the server didn't set that variable
|
// used to set some env_* variables into it, when the server didn't set that variable
|
||||||
// it contains '\0'
|
// it contains '\0'
|
||||||
|
@ -165,6 +167,8 @@ private:
|
||||||
|
|
||||||
void StandardLog();
|
void StandardLog();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,13 @@ void SessionManager::SetSession()
|
||||||
{
|
{
|
||||||
// that session is in the table
|
// that session is in the table
|
||||||
request.session = const_cast<Session*>( &(*s) );
|
request.session = const_cast<Session*>( &(*s) );
|
||||||
log << log1 << "SM: session: " << s->id << logend;
|
|
||||||
|
log << log2 << "SM: session: " << s->id;
|
||||||
|
|
||||||
|
if( request.session->puser )
|
||||||
|
log << log2 << ", user: " << request.session->puser->name << ", id: " << request.session->puser->id;
|
||||||
|
|
||||||
|
log << log2 << logend;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
o = templates.o sys.o item.o doc.o user.o dir.o done.o priv.o
|
o = templates.o sys.o item.o doc.o user.o dir.o done.o priv.o patterncacher.o
|
||||||
|
|
||||||
|
|
||||||
all: templates.a
|
all: templates.a
|
||||||
|
|
|
@ -4,79 +4,90 @@ dir.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
dir.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
dir.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
dir.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
dir.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
dir.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
dir.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
dir.o: ../core/functions.h ../core/function.h ../core/request.h
|
dir.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
dir.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
dir.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
dir.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
dir.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
dir.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
dir.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
dir.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
dir.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
dir.o: ../core/log.h
|
dir.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
dir.o: ../app/templates.h
|
||||||
doc.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
doc.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
doc.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
doc.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
doc.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
doc.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
doc.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
doc.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
doc.o: ../core/functions.h ../core/function.h ../core/request.h
|
doc.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
doc.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
doc.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
doc.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
doc.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
doc.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
doc.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
doc.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
doc.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
doc.o: ../core/log.h
|
doc.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
doc.o: ../app/templates.h
|
||||||
done.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
done.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
done.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
done.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
done.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
done.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
done.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
done.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
done.o: ../core/functions.h ../core/function.h ../core/request.h
|
done.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
done.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
done.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
done.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
done.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
done.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
done.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
done.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
done.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
done.o: ../core/log.h
|
done.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
done.o: ../app/templates.h
|
||||||
item.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
item.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
item.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
item.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
item.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
item.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
item.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
item.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
item.o: ../core/functions.h ../core/function.h ../core/request.h
|
item.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
item.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
item.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
item.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
item.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
item.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
item.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
item.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
item.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
item.o: ../core/log.h
|
item.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
item.o: ../app/templates.h
|
||||||
|
patterncacher.o: patterncacher.h ../core/item.h ../../ezc/src/ezc.h
|
||||||
|
patterncacher.o: ../core/log.h
|
||||||
priv.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
priv.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
priv.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
priv.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
priv.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
priv.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
priv.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
priv.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
priv.o: ../core/functions.h ../core/function.h ../core/request.h
|
priv.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
priv.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
priv.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
priv.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
priv.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
priv.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
priv.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
priv.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
priv.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
priv.o: ../core/log.h
|
priv.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
priv.o: ../app/templates.h
|
||||||
sys.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
sys.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
sys.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
sys.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
sys.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
sys.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
sys.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
sys.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
sys.o: ../core/functions.h ../core/function.h ../core/request.h
|
sys.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
sys.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
sys.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
sys.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
sys.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
sys.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
sys.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
sys.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
sys.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
sys.o: ../core/log.h
|
sys.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
sys.o: ../app/templates.h
|
||||||
templates.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
templates.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
templates.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
templates.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
templates.o: ../core/db.h ../core/dircontainer.h ../core/user.h
|
templates.o: ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||||
templates.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
|
templates.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||||
templates.o: ../core/groups.h ../core/functions.h ../core/function.h
|
templates.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||||
templates.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
templates.o: ../core/functioncodeparser.h ../core/request.h
|
||||||
templates.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
templates.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||||
|
templates.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
templates.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
templates.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
templates.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
templates.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
templates.o: ../core/users.h ../core/groups.h ../core/log.h
|
templates.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
templates.o: ../app/templates.h
|
||||||
user.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
user.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
|
||||||
user.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
user.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
|
||||||
user.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
user.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||||
user.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
user.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||||
user.o: ../core/functions.h ../core/function.h ../core/request.h
|
user.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||||
user.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
user.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||||
user.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
user.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||||
user.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
user.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||||
user.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
user.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||||
user.o: ../core/log.h
|
user.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
|
||||||
|
user.o: ../app/templates.h
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of CMSLU -- Content Management System like Unix
|
||||||
|
* and is not publicly distributed
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Tomasz Sowa
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "patterncacher.h"
|
||||||
|
|
||||||
|
|
||||||
|
PatternCacher::PatternCacher()
|
||||||
|
{
|
||||||
|
// !! tymczasowe wartosci dla testow
|
||||||
|
when_delete_patterns = 3; // 130
|
||||||
|
how_many_delete = 2; // 30
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PatternCacher::CheckTableSize()
|
||||||
|
{
|
||||||
|
if( pattern_tab.size() < when_delete_patterns )
|
||||||
|
return;
|
||||||
|
|
||||||
|
PatternTab::iterator i;
|
||||||
|
PatternErase pe;
|
||||||
|
size_t erase_index;
|
||||||
|
|
||||||
|
erase_tab.resize(pattern_tab.size());
|
||||||
|
|
||||||
|
for( i=pattern_tab.begin(), erase_index=0 ; i!=pattern_tab.end() ; ++i, ++erase_index)
|
||||||
|
{
|
||||||
|
pe.used = i->second.used;
|
||||||
|
pe.iter = i;
|
||||||
|
|
||||||
|
erase_tab[erase_index] = pe;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sorting through 'used'
|
||||||
|
std::sort(erase_tab.begin(), erase_tab.end());
|
||||||
|
|
||||||
|
for(erase_index = 0 ; erase_index<how_many_delete && erase_index<erase_tab.size() ; ++erase_index)
|
||||||
|
{
|
||||||
|
log << log2 << "PC: deleting from cache, id: " << erase_tab[erase_index].iter->second.item_id << logend;
|
||||||
|
|
||||||
|
pattern_tab.erase(erase_tab[erase_index].iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PatternCacher::CreatePattern(const Item & item, Ezc::Pattern & pattern)
|
||||||
|
{
|
||||||
|
pattern.allow_include = false;
|
||||||
|
pattern.ParseString(item.content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Ezc::Pattern * PatternCacher::AddPattern(const Item & item)
|
||||||
|
{
|
||||||
|
CheckTableSize();
|
||||||
|
|
||||||
|
PatternUsed pu;
|
||||||
|
|
||||||
|
CreatePattern(item, pu.pattern);
|
||||||
|
pu.used = 1;
|
||||||
|
pu.item_id = item.id;
|
||||||
|
|
||||||
|
std::pair<PatternTab::iterator, bool> res = pattern_tab.insert( std::make_pair(item.id, pu) );
|
||||||
|
|
||||||
|
log << log2 << "PC: added an item, id: " << item.id << ", url: " << item.url << logend;
|
||||||
|
|
||||||
|
return &(res.first->second.pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Ezc::Pattern * PatternCacher::GetPattern(const Item & item)
|
||||||
|
{
|
||||||
|
PatternTab::iterator i;
|
||||||
|
|
||||||
|
i = pattern_tab.find(item.id);
|
||||||
|
|
||||||
|
if( i == pattern_tab.end() )
|
||||||
|
return AddPattern(item);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << log2 << "PC: taking a pattern from the cache, id: " << item.id << ", url: " << item.url << logend;
|
||||||
|
++(i->second.used);
|
||||||
|
return &(i->second.pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PatternCacher::UpdatePattern(const Item & item)
|
||||||
|
{
|
||||||
|
PatternTab::iterator i;
|
||||||
|
|
||||||
|
i = pattern_tab.find(item.id);
|
||||||
|
|
||||||
|
if( i == pattern_tab.end() )
|
||||||
|
{
|
||||||
|
log << log2 << "PC: there is no such an item to update, id: " << item.id << ", url: " << item.url << logend;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
++(i->second.used);
|
||||||
|
CreatePattern(item, i->second.pattern);
|
||||||
|
|
||||||
|
log << log2 << "PC: updated pattern, id: " << item.id << ", url: " << item.url << logend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PatternCacher::DeletePattern(const Item & item)
|
||||||
|
{
|
||||||
|
PatternTab::iterator i;
|
||||||
|
|
||||||
|
i = pattern_tab.find(item.id);
|
||||||
|
|
||||||
|
if( i == pattern_tab.end() )
|
||||||
|
{
|
||||||
|
log << log2 << "PC: there is no such an item to delete, id: " << item.id << ", url: " << item.url << logend;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log << log2 << "PC: deleted pattern, id: " << item.id << ", url: " << item.url << logend;
|
||||||
|
|
||||||
|
pattern_tab.erase(i);
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of CMSLU -- Content Management System like Unix
|
||||||
|
* and is not publicly distributed
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Tomasz Sowa
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef headerfilepatterncacher
|
||||||
|
#define headerfilepatterncacher
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "../core/item.h"
|
||||||
|
#include "../../ezc/src/ezc.h"
|
||||||
|
#include "../core/log.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PatternCacher
|
||||||
|
{
|
||||||
|
struct PatternUsed
|
||||||
|
{
|
||||||
|
Ezc::Pattern pattern;
|
||||||
|
int used; // how many times used (incremented by GetPattern and UpdatePattern)
|
||||||
|
int item_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<long, PatternUsed> PatternTab;
|
||||||
|
PatternTab pattern_tab;
|
||||||
|
|
||||||
|
|
||||||
|
// temporarily struct used during deleting some items from pattern_tab
|
||||||
|
struct PatternErase
|
||||||
|
{
|
||||||
|
PatternTab::iterator iter;
|
||||||
|
int used;
|
||||||
|
|
||||||
|
bool operator<(const PatternErase & p) const { return used < p.used; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// temporarily buffer used during deleting some items from pattern_tab
|
||||||
|
std::vector<PatternErase> erase_tab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CreatePattern(const Item & item, Ezc::Pattern & pattern);
|
||||||
|
void AddIndexes(const Item & item, size_t pattern_index);
|
||||||
|
Ezc::Pattern * AddPattern(const Item & item);
|
||||||
|
void CheckTableSize();
|
||||||
|
|
||||||
|
|
||||||
|
// the size of pattern_tab when we are deleting some items
|
||||||
|
size_t when_delete_patterns;
|
||||||
|
|
||||||
|
// how many items to delete
|
||||||
|
size_t how_many_delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
PatternCacher();
|
||||||
|
|
||||||
|
// returning a pattern corresponding to the 'item'
|
||||||
|
Ezc::Pattern * GetPattern(const Item & item);
|
||||||
|
|
||||||
|
// updating the pattern for the item
|
||||||
|
// if there is no such a pattern the method does nothing
|
||||||
|
void UpdatePattern(const Item & item);
|
||||||
|
|
||||||
|
// deleting the pattern for the item
|
||||||
|
// if there is no such a pattern the method does nothing
|
||||||
|
void DeletePattern(const Item & item);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,8 +19,8 @@ Ezc::Pattern pat_fun_cat;
|
||||||
Ezc::Pattern pat_fun_ls;
|
Ezc::Pattern pat_fun_ls;
|
||||||
Ezc::Pattern pat_fun_emacs;
|
Ezc::Pattern pat_fun_emacs;
|
||||||
Ezc::Pattern pat_fun_mkdir;
|
Ezc::Pattern pat_fun_mkdir;
|
||||||
Ezc::Pattern pat_fun_default_item;
|
Ezc::Pattern pat_fun_default;
|
||||||
Ezc::Pattern pat_fun_privileges;
|
Ezc::Pattern pat_fun_priv;
|
||||||
Ezc::Pattern pat_fun_rm;
|
Ezc::Pattern pat_fun_rm;
|
||||||
Ezc::Pattern pat_err_item_required;
|
Ezc::Pattern pat_err_item_required;
|
||||||
Ezc::Pattern pat_err_404;
|
Ezc::Pattern pat_err_404;
|
||||||
|
@ -32,6 +32,8 @@ Ezc::Pattern pat_err_others;
|
||||||
Ezc::Functions functions;
|
Ezc::Functions functions;
|
||||||
|
|
||||||
|
|
||||||
|
PatternCacher pattern_cacher;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,32 +63,37 @@ Ezc::Pattern * p = 0;
|
||||||
|
|
||||||
switch( request.pfunction->code )
|
switch( request.pfunction->code )
|
||||||
{
|
{
|
||||||
case Function::cat:
|
case FUN_CAT:
|
||||||
p = &pat_fun_cat;
|
p = &pat_fun_cat;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::ls:
|
case FUN_LS:
|
||||||
p = &pat_fun_ls;
|
p = &pat_fun_ls;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::rm:
|
case FUN_RM:
|
||||||
p = &pat_fun_rm;
|
p = &pat_fun_rm;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::emacs:
|
case FUN_EMACS:
|
||||||
p = &pat_fun_emacs;
|
p = &pat_fun_emacs;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::mkdir:
|
case FUN_MKDIR:
|
||||||
p = &pat_fun_mkdir;
|
p = &pat_fun_mkdir;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::default_item:
|
case FUN_DEFAULT:
|
||||||
p = &pat_fun_default_item;
|
p = &pat_fun_default;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Function::privileges:
|
case FUN_PRIV:
|
||||||
p = &pat_fun_privileges;
|
p = &pat_fun_priv;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FUN_RUN:
|
||||||
|
if( request.is_item )
|
||||||
|
p = pattern_cacher.GetPattern(request.item);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -276,9 +283,7 @@ void Templates::CreateFunctions()
|
||||||
|
|
||||||
|
|
||||||
#ifdef APPTEMPLATES
|
#ifdef APPTEMPLATES
|
||||||
|
|
||||||
AppTemplateFunctions::CreateAppFunctions(functions);
|
AppTemplateFunctions::CreateAppFunctions(functions);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,16 +322,20 @@ void Templates::Read()
|
||||||
pat_fun_mkdir.Directory(data.templates);
|
pat_fun_mkdir.Directory(data.templates);
|
||||||
pat_fun_mkdir.ParseFile("fun_mkdir.html");
|
pat_fun_mkdir.ParseFile("fun_mkdir.html");
|
||||||
|
|
||||||
pat_fun_default_item.Directory(data.templates);
|
pat_fun_default.Directory(data.templates);
|
||||||
pat_fun_default_item.ParseFile("fun_default_item.html");
|
pat_fun_default.ParseFile("fun_default.html");
|
||||||
|
|
||||||
pat_fun_privileges.Directory(data.templates);
|
pat_fun_priv.Directory(data.templates);
|
||||||
pat_fun_privileges.ParseFile("fun_priv.html");
|
pat_fun_priv.ParseFile("fun_priv.html");
|
||||||
|
|
||||||
pat_err_others.Directory(data.templates);
|
pat_err_others.Directory(data.templates);
|
||||||
pat_err_others.ParseFile("err_others.html");
|
pat_err_others.ParseFile("err_others.html");
|
||||||
|
|
||||||
CreateFunctions();
|
CreateFunctions();
|
||||||
|
|
||||||
|
#ifdef APPTEMPLATES
|
||||||
|
AppTemplateFunctions::ReadAppPatterns();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "../core/users.h"
|
#include "../core/users.h"
|
||||||
#include "../core/groups.h"
|
#include "../core/groups.h"
|
||||||
#include "../core/log.h"
|
#include "../core/log.h"
|
||||||
|
#include "patterncacher.h"
|
||||||
|
|
||||||
#ifdef APPTEMPLATES
|
#ifdef APPTEMPLATES
|
||||||
#include "../app/templates.h"
|
#include "../app/templates.h"
|
||||||
|
@ -35,6 +36,8 @@ namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
using Ezc::Info;
|
using Ezc::Info;
|
||||||
|
|
||||||
|
extern PatternCacher pattern_cacher;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
sys
|
sys
|
||||||
*/
|
*/
|
||||||
|
@ -159,7 +162,6 @@ class Templates
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue