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
|
|
@ -1,19 +1,23 @@
|
|||
#ifndef headerfileapptemplates
|
||||
#define headerfileapptemplates
|
||||
|
||||
|
||||
#include "../../ezc/src/ezc.h"
|
||||
#include "../core/log.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
namespace AppTemplateFunctions
|
||||
{
|
||||
|
||||
|
||||
void CreateAppFunctions(Ezc::Functions & functions);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef headerfileapptemplates
|
||||
#define headerfileapptemplates
|
||||
|
||||
|
||||
#include "../../ezc/src/ezc.h"
|
||||
#include "../core/log.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
namespace AppTemplateFunctions
|
||||
{
|
||||
|
||||
|
||||
//void CreateAppFunctions(Ezc::Functions & functions);
|
||||
|
||||
void ReadAppPatterns();
|
||||
|
||||
void CreateAppFunctions(Ezc::Functions & functions);
|
||||
Ezc::Pattern * GetAppPattern();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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/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/functions.h ../core/function.h ../core/request.h
|
||||
cat.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
cat.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
cat.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
cat.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
cat.o: ../core/log.h ../core/misc.h ../core/function.h
|
||||
cat.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
||||
cat.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
cat.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
cat.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
cat.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
cat.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
cat.o: ../core/users.h ../core/groups.h ../core/log.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: ../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/user.h ../core/group.h ../core/ugcontainer.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/session.h ../core/done.h ../core/getparser.h
|
||||
content.o: ../core/httpsimpleparser.h ../core/postparser.h
|
||||
content.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
content.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
content.o: ../core/log.h ../core/misc.h ../core/function.h
|
||||
content.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
||||
defaultitem.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
defaultitem.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||
defaultitem.o: ../core/error.h ../core/dirs.h ../core/db.h
|
||||
defaultitem.o: ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||
defaultitem.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
defaultitem.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
defaultitem.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
defaultitem.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||
defaultitem.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
defaultitem.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
defaultitem.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
defaultitem.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
defaultitem.o: ../core/data.h
|
||||
content.o: ../core/function.h ../core/functioncodeparser.h ../core/request.h
|
||||
content.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
content.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||
content.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
content.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
content.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||
content.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
|
||||
content.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
content.o: ../core/data.h ../app/content.h
|
||||
default.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
default.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||
default.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||
default.o: ../core/user.h ../core/group.h ../core/ugcontainer.h
|
||||
default.o: ../core/users.h ../core/groups.h ../core/functions.h
|
||||
default.o: ../core/function.h ../core/functioncodeparser.h ../core/request.h
|
||||
default.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
default.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||
default.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
default.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/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/request.h ../core/requesttypes.h ../core/session.h
|
||||
emacs.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
emacs.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
emacs.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
emacs.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
emacs.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
emacs.o: ../core/data.h
|
||||
emacs.o: ../core/functioncodeparser.h ../core/request.h
|
||||
emacs.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
emacs.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
emacs.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
emacs.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
emacs.o: ../core/log.h ../templates/patterncacher.h ../app/templates.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: ../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/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/request.h ../core/requesttypes.h ../core/session.h
|
||||
login.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
login.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
login.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
login.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
login.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
login.o: ../core/data.h
|
||||
login.o: ../core/functioncodeparser.h ../core/request.h
|
||||
login.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
login.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
login.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
login.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
login.o: ../core/log.h ../templates/patterncacher.h ../app/templates.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: ../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/user.h ../core/group.h ../core/ugcontainer.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/session.h ../core/done.h ../core/getparser.h
|
||||
logout.o: ../core/httpsimpleparser.h ../core/postparser.h
|
||||
logout.o: ../core/function.h ../core/functioncodeparser.h ../core/request.h
|
||||
logout.o: ../core/requesttypes.h ../core/session.h ../core/done.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/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/functionparser.h ../core/request.h ../core/data.h
|
||||
logout.o: ../core/log.h ../templates/patterncacher.h ../app/templates.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: ../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/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/requesttypes.h ../core/session.h ../core/done.h
|
||||
ls.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
ls.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
ls.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
ls.o: ../core/log.h ../core/misc.h ../core/function.h
|
||||
ls.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
ls.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
ls.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
ls.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h ../core/db.h
|
||||
ls.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.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: ../app/content.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/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/groups.h ../core/functions.h ../core/function.h
|
||||
mkdir.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
mkdir.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
mkdir.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
mkdir.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
mkdir.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
mkdir.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
mkdir.o: ../core/data.h
|
||||
mkdir.o: ../core/functioncodeparser.h ../core/request.h
|
||||
mkdir.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
mkdir.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
mkdir.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
mkdir.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
mkdir.o: ../core/log.h ../templates/patterncacher.h ../app/templates.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: ../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/group.h ../core/ugcontainer.h ../core/users.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/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
node.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
node.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
node.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
node.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
node.o: ../core/data.h
|
||||
privileges.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
privileges.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||
privileges.o: ../core/error.h ../core/dirs.h ../core/db.h
|
||||
privileges.o: ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||
privileges.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
privileges.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
privileges.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
privileges.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||
privileges.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
privileges.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
privileges.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
privileges.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
privileges.o: ../core/data.h
|
||||
node.o: ../core/functioncodeparser.h ../core/request.h ../core/requesttypes.h
|
||||
node.o: ../core/session.h ../core/done.h ../core/getparser.h
|
||||
node.o: ../core/httpsimpleparser.h ../core/postparser.h
|
||||
node.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
node.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
node.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
|
||||
node.o: ../core/misc.h ../core/function.h ../core/functionparser.h
|
||||
node.o: ../core/request.h ../core/data.h ../app/content.h
|
||||
priv.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||
priv.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||
priv.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||
priv.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||
priv.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||
priv.o: ../core/functioncodeparser.h ../core/request.h ../core/requesttypes.h
|
||||
priv.o: ../core/session.h ../core/done.h ../core/getparser.h
|
||||
priv.o: ../core/httpsimpleparser.h ../core/postparser.h
|
||||
priv.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
priv.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
priv.o: ../core/log.h ../templates/patterncacher.h ../app/templates.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: ../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/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/requesttypes.h ../core/session.h ../core/done.h
|
||||
rm.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
rm.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
rm.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
rm.o: ../core/log.h ../core/misc.h ../core/function.h
|
||||
rm.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
rm.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
rm.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
rm.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h ../core/db.h
|
||||
rm.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.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: ../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,8 +44,11 @@ void Content::SetDefaultFunction()
|
|||
{
|
||||
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 )
|
||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
||||
}
|
||||
|
@ -55,7 +58,7 @@ void Content::SetDefaultFunction()
|
|||
|
||||
if( default_item == -1 )
|
||||
{
|
||||
request.pfunction = data.functions.GetFunction(Function::ls);
|
||||
request.pfunction = data.functions.GetFunction(FUN_LS);
|
||||
|
||||
if( request.pfunction )
|
||||
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();
|
||||
else
|
||||
if( request.pfunction->code == Function::cat )
|
||||
if( request.pfunction->code == FUN_CAT )
|
||||
FunCat();
|
||||
else
|
||||
if( request.pfunction->code == Function::ls )
|
||||
if( request.pfunction->code == FUN_LS )
|
||||
FunLs();
|
||||
else
|
||||
if( request.pfunction->code == Function::emacs )
|
||||
if( request.pfunction->code == FUN_EMACS )
|
||||
FunEmacs();
|
||||
else
|
||||
if( request.pfunction->code == Function::mkdir )
|
||||
if( request.pfunction->code == FUN_MKDIR )
|
||||
FunMkdir();
|
||||
else
|
||||
if( request.pfunction->code == Function::default_item )
|
||||
FunDefaultItem();
|
||||
if( request.pfunction->code == FUN_DEFAULT )
|
||||
FunDefault();
|
||||
else
|
||||
if( request.pfunction->code == Function::privileges )
|
||||
FunPrivileges();
|
||||
if( request.pfunction->code == FUN_PRIV )
|
||||
FunPriv();
|
||||
else
|
||||
if( request.pfunction->code == Function::rm )
|
||||
if( request.pfunction->code == FUN_RM )
|
||||
FunRm();
|
||||
else
|
||||
if( request.pfunction->code == Function::node )
|
||||
if( request.pfunction->code == FUN_RUN )
|
||||
FunRun();
|
||||
else
|
||||
if( request.pfunction->code == FUN_NODE )
|
||||
FunNode();
|
||||
|
||||
}
|
||||
|
@ -131,23 +137,23 @@ void Content::MakePost()
|
|||
|
||||
switch( request.pfunction->code )
|
||||
{
|
||||
case Function::emacs:
|
||||
case FUN_EMACS:
|
||||
PostFunEmacs();
|
||||
break;
|
||||
|
||||
case Function::mkdir:
|
||||
case FUN_MKDIR:
|
||||
PostFunMkdir();
|
||||
break;
|
||||
|
||||
case Function::default_item:
|
||||
PostFunDefaultItem();
|
||||
case FUN_DEFAULT:
|
||||
PostFunDefault();
|
||||
break;
|
||||
|
||||
case Function::privileges:
|
||||
PostFunPrivileges();
|
||||
case FUN_PRIV:
|
||||
PostFunPriv();
|
||||
break;
|
||||
|
||||
case Function::login:
|
||||
case FUN_LOGIN:
|
||||
PostFunLogin();
|
||||
break;
|
||||
|
||||
|
|
|
@ -47,11 +47,12 @@ class Content
|
|||
void FunLogout();
|
||||
void FunLs();
|
||||
void FunEmacs();
|
||||
void FunPrivileges();
|
||||
void FunPriv();
|
||||
void FunRm();
|
||||
void FunNode();
|
||||
void FunMkdir();
|
||||
void FunDefaultItem();
|
||||
void FunDefault();
|
||||
void FunRun();
|
||||
|
||||
|
||||
void PostFunLogin();
|
||||
|
@ -59,8 +60,8 @@ class Content
|
|||
void PostFunEmacsEdit(bool with_url);
|
||||
void PostFunEmacs();
|
||||
void PostFunMkdir();
|
||||
void PostFunDefaultItem();
|
||||
void PostFunPrivileges();
|
||||
void PostFunDefault();
|
||||
void PostFunPriv();
|
||||
|
||||
void RedirectTo(const Item & item);
|
||||
void RedirectTo(long item_id);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
|
||||
void Content::PostFunDefaultItem()
|
||||
void Content::PostFunDefault()
|
||||
{
|
||||
Item * pdir;
|
||||
long fileid = -1;
|
||||
|
@ -68,7 +68,7 @@ long fileid = -1;
|
|||
|
||||
|
||||
|
||||
void Content::FunDefaultItem()
|
||||
void Content::FunDefault()
|
||||
{
|
||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
||||
{
|
|
@ -58,6 +58,9 @@ void Content::PostFunEmacsEdit(bool with_url)
|
|||
throw Error(Error::permision_denied);
|
||||
|
||||
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;
|
||||
|
||||
if( request.is_item )
|
||||
{
|
||||
RedirectTo(request.item);
|
||||
}
|
||||
else
|
||||
{
|
||||
RedirectTo(*request.dir_table.back());
|
||||
}
|
||||
}
|
||||
|
||||
// !! zglosic komunikat o nie poprawnym logowaniu
|
||||
}
|
||||
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
|
||||
if( !request.is_item )
|
||||
|
@ -63,7 +63,7 @@ void Content::PostFunPrivileges()
|
|||
|
||||
|
||||
|
||||
void Content::FunPrivileges()
|
||||
void Content::FunPriv()
|
||||
{
|
||||
if( !request.is_item )
|
||||
{
|
|
@ -41,6 +41,7 @@ void Content::FunRm()
|
|||
{
|
||||
request.session->done_status = Error::ok;
|
||||
log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend;
|
||||
TemplatesFunctions::pattern_cacher.DeletePattern(request.item);
|
||||
}
|
||||
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: 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: 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: ugcontainer.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
|
||||
error.o: error.h log.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: 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: db.h dircontainer.h group.h ugcontainer.h users.h groups.h
|
||||
functionparser.o: functions.h
|
||||
functions.o: functions.h function.h log.h item.h
|
||||
functionparser.o: functions.h functioncodeparser.h ../app/content.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: user.h ugcontainer.h
|
||||
httpsimpleparser.o: httpsimpleparser.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: 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: getparser.h httpsimpleparser.h postparser.h cookieparser.h
|
||||
main.o: ../content/content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
main.o: ../core/data.h ../core/request.h ../core/item.h ../core/db.h
|
||||
main.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.h
|
||||
main.o: ../core/groups.h ../core/log.h ../core/misc.h ../core/function.h
|
||||
main.o: ../core/functionparser.h sessionmanager.h config.h
|
||||
main.o: ../confparser/confparser.h
|
||||
main.o: functions.h function.h functioncodeparser.h request.h requesttypes.h
|
||||
main.o: session.h done.h getparser.h httpsimpleparser.h postparser.h
|
||||
main.o: cookieparser.h ../content/content.h ../templates/templates.h
|
||||
main.o: ../../ezc/src/ezc.h ../core/data.h ../core/request.h ../core/item.h
|
||||
main.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
main.o: ../core/users.h ../core/groups.h ../core/log.h
|
||||
main.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.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
|
||||
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: function.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: users.h groups.h functions.h function.h request.h
|
||||
requestcontroller.o: requesttypes.h session.h done.h getparser.h
|
||||
requestcontroller.o: httpsimpleparser.h postparser.h cookieparser.h
|
||||
requestcontroller.o: ../content/content.h ../templates/templates.h
|
||||
requestcontroller.o: ../../ezc/src/ezc.h ../core/data.h ../core/request.h
|
||||
requestcontroller.o: ../core/item.h ../core/db.h ../core/error.h
|
||||
requestcontroller.o: ../core/user.h ../core/group.h ../core/users.h
|
||||
requestcontroller.o: ../core/groups.h ../core/log.h ../core/misc.h
|
||||
requestcontroller.o: ../core/function.h ../core/functionparser.h
|
||||
requestcontroller.o: users.h groups.h functions.h function.h
|
||||
requestcontroller.o: functioncodeparser.h request.h requesttypes.h session.h
|
||||
requestcontroller.o: done.h getparser.h httpsimpleparser.h postparser.h
|
||||
requestcontroller.o: cookieparser.h ../content/content.h
|
||||
requestcontroller.o: ../templates/templates.h ../../ezc/src/ezc.h
|
||||
requestcontroller.o: ../core/data.h ../core/request.h ../core/item.h
|
||||
requestcontroller.o: ../core/db.h ../core/error.h ../core/user.h
|
||||
requestcontroller.o: ../core/group.h ../core/users.h ../core/groups.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
|
||||
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: 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: 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: group.h ugcontainer.h
|
||||
|
|
60
core/db.cpp
60
core/db.cpp
|
@ -10,18 +10,25 @@
|
|||
#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()
|
||||
{
|
||||
Close();
|
||||
if( close_at_end )
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
PGconn * Db::GetPGconn()
|
||||
{
|
||||
return pg_conn;
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
|
||||
if( !pg_conn )
|
||||
{
|
||||
log << log1 << "Db: Fatal error during connecting" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( PQsetClientEncoding(pg_conn, "LATIN2") == -1 )
|
||||
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 )
|
||||
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 )
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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 <libpq-fe.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
|
||||
#include "log.h"
|
||||
#include "item.h"
|
||||
|
@ -33,7 +34,7 @@ class Db
|
|||
{
|
||||
public:
|
||||
|
||||
Db();
|
||||
Db(bool close_at_end_ = true);
|
||||
~Db();
|
||||
|
||||
// !! przerobic tak aby GetItem zwracalo wszystkie pozycja
|
||||
|
@ -65,10 +66,15 @@ public:
|
|||
long GetFileId(long parent_id, const std::string & url);
|
||||
long GetDirId(long parent_id, const std::string & url);
|
||||
|
||||
tm ConvertTime(const char * str);
|
||||
|
||||
PGconn * GetPGconn();
|
||||
|
||||
protected:
|
||||
|
||||
PGconn * pg_conn;
|
||||
std::string db_database, db_user, db_pass;
|
||||
bool close_at_end;
|
||||
|
||||
void Connect();
|
||||
void Close();
|
||||
|
|
|
@ -10,10 +10,15 @@
|
|||
#include "function.h"
|
||||
|
||||
|
||||
|
||||
Function::Function()
|
||||
{
|
||||
code = none;
|
||||
code = FUN_NONE;
|
||||
}
|
||||
|
||||
void Function::Clear()
|
||||
{
|
||||
code = FUN_NONE;
|
||||
item.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,18 @@
|
|||
#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
|
||||
|
@ -22,6 +34,7 @@ class Function
|
|||
|
||||
public:
|
||||
|
||||
/*
|
||||
enum Code
|
||||
{
|
||||
none,
|
||||
|
@ -30,22 +43,30 @@ public:
|
|||
node,
|
||||
emacs,
|
||||
mkdir,
|
||||
default_item,
|
||||
privileges,
|
||||
default,
|
||||
priv,
|
||||
rm,
|
||||
login,
|
||||
logout
|
||||
logout,
|
||||
run
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
|
||||
void Clear();
|
||||
|
||||
Function();
|
||||
Function(const Function & f);
|
||||
Function & operator=(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()
|
||||
{
|
||||
while( true )
|
||||
|
@ -143,7 +142,7 @@ void FunctionParser::Parse()
|
|||
|
||||
if( request.status != Error::ok )
|
||||
return;
|
||||
|
||||
|
||||
ParseFunction();
|
||||
|
||||
if( !request.pfunction && get_index != get_table_len )
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include "data.h"
|
||||
#include "db.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef APPFUNCTIONS
|
||||
#include "../app/content.h"
|
||||
#endif
|
||||
|
||||
class FunctionParser
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ class FunctionParser
|
|||
|
||||
void ParseDirectories();
|
||||
void ParseItem();
|
||||
bool IsAppFunction();
|
||||
void ParseFunction();
|
||||
void ParseParams();
|
||||
|
||||
|
|
|
@ -35,45 +35,54 @@ void Functions::ReadFunctions()
|
|||
f.item.type = Item::file;
|
||||
|
||||
// in the future we will read these functions from the database
|
||||
f.code = Function::ls;
|
||||
f.code = FUN_LS;
|
||||
f.item.url = "ls";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::cat;
|
||||
f.code = FUN_CAT;
|
||||
f.item.url = "cat";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::node;
|
||||
f.code = FUN_NODE;
|
||||
f.item.url = "node";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::emacs;
|
||||
f.code = FUN_EMACS;
|
||||
f.item.url = "emacs";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::mkdir;
|
||||
f.code = FUN_MKDIR;
|
||||
f.item.url = "mkdir";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::default_item;
|
||||
f.code = FUN_DEFAULT;
|
||||
f.item.url = "default";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::privileges;
|
||||
f.code = FUN_PRIV;
|
||||
f.item.url = "priv";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::rm;
|
||||
f.code = FUN_RM;
|
||||
f.item.url = "rm";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::logout;
|
||||
f.code = FUN_LOGOUT;
|
||||
f.item.url = "logout";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::login;
|
||||
f.code = FUN_LOGIN;
|
||||
f.item.url = "login";
|
||||
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
|
||||
Function * Functions::GetFunction(Function::Code code)
|
||||
Function * Functions::GetFunction(int code)
|
||||
{
|
||||
Table::iterator i = table.begin();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include "function.h"
|
||||
|
||||
#include "functioncodeparser.h"
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
void ReadFunctions();
|
||||
|
||||
Function * GetFunction(const std::string & name);
|
||||
Function * GetFunction(Function::Code code);
|
||||
Function * GetFunction(int code);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -101,12 +101,16 @@ void HttpSimpleParser::CheckSpecialChar()
|
|||
int c2 = GetChar();
|
||||
|
||||
if( c1==-1 || c2==-1 )
|
||||
{
|
||||
last_c = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
c1 = ParseHalfHex(c1);
|
||||
c2 = ParseHalfHex(c2);
|
||||
|
||||
c1 = ParseHalfHex(c1);
|
||||
c2 = ParseHalfHex(c2);
|
||||
|
||||
last_c = (c1 << 4) + c2;
|
||||
last_c = (c1 << 4) + c2;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( last_c == '+' )
|
||||
|
|
58
core/log.cpp
58
core/log.cpp
|
@ -34,7 +34,7 @@ Log & Log::operator<<(const char * s)
|
|||
if( !s )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -42,25 +42,25 @@ return *this;
|
|||
|
||||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
buffer << s;
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(long s)
|
||||
{
|
||||
buffer << s;
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,17 +68,17 @@ Log & Log::operator<<(long s)
|
|||
|
||||
Log & Log::operator<<(char s)
|
||||
{
|
||||
buffer << s;
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
buffer << s;
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,31 +113,31 @@ void Log::SaveLog()
|
|||
{
|
||||
int attempt = 2;
|
||||
|
||||
if( current_level > log_level )
|
||||
return;
|
||||
if( current_level > log_level )
|
||||
return;
|
||||
|
||||
if( log_stdout )
|
||||
std::cout << buffer.str() << std::endl;
|
||||
if( log_stdout )
|
||||
std::cout << buffer.str() << std::endl;
|
||||
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
||||
std::ofstream file;
|
||||
std::ofstream file;
|
||||
|
||||
do
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
do
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
|
||||
// if( !file )
|
||||
// sleep(1);
|
||||
}
|
||||
while( --attempt > 0 && !file );
|
||||
// if( !file )
|
||||
// sleep(1);
|
||||
}
|
||||
while( --attempt > 0 && !file );
|
||||
|
||||
if( !file )
|
||||
return;
|
||||
if( !file )
|
||||
return;
|
||||
|
||||
file << buffer.str() << std::endl;
|
||||
file << buffer.str() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "config.h"
|
||||
|
||||
|
||||
|
||||
// singletons
|
||||
// first 'data' then 'log' then 'request'
|
||||
Data data;
|
||||
|
@ -63,6 +62,7 @@ int main(int argv, char ** argc)
|
|||
{
|
||||
RequestController req_controller;
|
||||
|
||||
|
||||
std::srand(std::time(0));
|
||||
|
||||
if( argv != 2 )
|
||||
|
@ -80,7 +80,9 @@ RequestController req_controller;
|
|||
|
||||
|
||||
// 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 )
|
||||
{
|
||||
|
@ -88,6 +90,7 @@ RequestController req_controller;
|
|||
data.stdout_is_closed = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
signal(SIGTERM, signal_term);
|
||||
signal(SIGINT, signal_term);
|
||||
|
@ -102,7 +105,7 @@ RequestController req_controller;
|
|||
if( !req_controller.Init() )
|
||||
return 1;
|
||||
|
||||
log << log2 << "checking for table consistency:" << logend;
|
||||
//log << log2 << "checking for table consistency:" << logend;
|
||||
// !! zrobic wyjatek dla root
|
||||
//db.CheckAllUrlSubject();
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "requesttypes.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class PostParser : public HttpSimpleParser
|
||||
{
|
||||
|
||||
|
|
|
@ -311,6 +311,8 @@ void Request::SendAll()
|
|||
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("\r\n", out);
|
||||
|
@ -321,6 +323,9 @@ void Request::SendAll()
|
|||
return;
|
||||
|
||||
FCGX_PutS(page.str().c_str(), out);
|
||||
log << log2 << "body: " << logend; // !! wywalic
|
||||
log << page.str() << logend; // !!
|
||||
|
||||
|
||||
const std::string & d = debug.str();
|
||||
|
||||
|
@ -466,6 +471,7 @@ bool Request::HasWriteAccess(const Item & item)
|
|||
return HasAccess(item, 2);
|
||||
}
|
||||
|
||||
|
||||
bool Request::HasReadWriteAccess(const Item & item)
|
||||
{
|
||||
return HasAccess(item, 6); // r+w
|
||||
|
@ -474,6 +480,13 @@ bool Request::HasReadWriteAccess(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
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ struct Request
|
|||
Error done_status; // !! wywalic - jest przeciez w session
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
|
@ -154,7 +155,8 @@ struct Request
|
|||
bool HasWriteAccess(const Item & item);
|
||||
bool HasReadWriteAccess(const Item & item);
|
||||
bool HasReadExecAccess(const Item & item);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
// used to set some env_* variables into it, when the server didn't set that variable
|
||||
|
@ -165,6 +167,8 @@ private:
|
|||
|
||||
void StandardLog();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -127,7 +127,13 @@ void SessionManager::SetSession()
|
|||
{
|
||||
// that session is in the table
|
||||
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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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/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/functions.h ../core/function.h ../core/request.h
|
||||
dir.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
dir.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
dir.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
dir.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
dir.o: ../core/log.h
|
||||
dir.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
dir.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
dir.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
dir.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
dir.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
doc.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
doc.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
doc.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
doc.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
doc.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
doc.o: ../core/log.h
|
||||
doc.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
doc.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
doc.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
doc.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
doc.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
done.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
done.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
done.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
done.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
done.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
done.o: ../core/log.h
|
||||
done.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
done.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
done.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
done.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
done.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
item.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
item.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
item.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
item.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
item.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
item.o: ../core/log.h
|
||||
item.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
item.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
item.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
item.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
item.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
priv.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
priv.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
priv.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
priv.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
priv.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
priv.o: ../core/log.h
|
||||
priv.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
priv.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
priv.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
priv.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
priv.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
sys.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
sys.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
sys.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
sys.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
sys.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
sys.o: ../core/log.h
|
||||
sys.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
sys.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
sys.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
sys.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
sys.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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: ../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/group.h ../core/ugcontainer.h ../core/users.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/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
templates.o: ../core/functioncodeparser.h ../core/request.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/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: ../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/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
user.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
user.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
user.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
|
||||
user.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
user.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
user.o: ../core/log.h
|
||||
user.o: ../core/functions.h ../core/function.h ../core/functioncodeparser.h
|
||||
user.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
user.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
user.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
user.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.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_emacs;
|
||||
Ezc::Pattern pat_fun_mkdir;
|
||||
Ezc::Pattern pat_fun_default_item;
|
||||
Ezc::Pattern pat_fun_privileges;
|
||||
Ezc::Pattern pat_fun_default;
|
||||
Ezc::Pattern pat_fun_priv;
|
||||
Ezc::Pattern pat_fun_rm;
|
||||
Ezc::Pattern pat_err_item_required;
|
||||
Ezc::Pattern pat_err_404;
|
||||
|
@ -32,6 +32,8 @@ Ezc::Pattern pat_err_others;
|
|||
Ezc::Functions functions;
|
||||
|
||||
|
||||
PatternCacher pattern_cacher;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -61,32 +63,37 @@ Ezc::Pattern * p = 0;
|
|||
|
||||
switch( request.pfunction->code )
|
||||
{
|
||||
case Function::cat:
|
||||
case FUN_CAT:
|
||||
p = &pat_fun_cat;
|
||||
break;
|
||||
|
||||
case Function::ls:
|
||||
case FUN_LS:
|
||||
p = &pat_fun_ls;
|
||||
break;
|
||||
|
||||
case Function::rm:
|
||||
case FUN_RM:
|
||||
p = &pat_fun_rm;
|
||||
break;
|
||||
|
||||
case Function::emacs:
|
||||
case FUN_EMACS:
|
||||
p = &pat_fun_emacs;
|
||||
break;
|
||||
|
||||
case Function::mkdir:
|
||||
case FUN_MKDIR:
|
||||
p = &pat_fun_mkdir;
|
||||
break;
|
||||
|
||||
case Function::default_item:
|
||||
p = &pat_fun_default_item;
|
||||
case FUN_DEFAULT:
|
||||
p = &pat_fun_default;
|
||||
break;
|
||||
|
||||
case Function::privileges:
|
||||
p = &pat_fun_privileges;
|
||||
case FUN_PRIV:
|
||||
p = &pat_fun_priv;
|
||||
break;
|
||||
|
||||
case FUN_RUN:
|
||||
if( request.is_item )
|
||||
p = pattern_cacher.GetPattern(request.item);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -276,9 +283,7 @@ void Templates::CreateFunctions()
|
|||
|
||||
|
||||
#ifdef APPTEMPLATES
|
||||
|
||||
AppTemplateFunctions::CreateAppFunctions(functions);
|
||||
|
||||
AppTemplateFunctions::CreateAppFunctions(functions);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -317,16 +322,20 @@ void Templates::Read()
|
|||
pat_fun_mkdir.Directory(data.templates);
|
||||
pat_fun_mkdir.ParseFile("fun_mkdir.html");
|
||||
|
||||
pat_fun_default_item.Directory(data.templates);
|
||||
pat_fun_default_item.ParseFile("fun_default_item.html");
|
||||
pat_fun_default.Directory(data.templates);
|
||||
pat_fun_default.ParseFile("fun_default.html");
|
||||
|
||||
pat_fun_privileges.Directory(data.templates);
|
||||
pat_fun_privileges.ParseFile("fun_priv.html");
|
||||
pat_fun_priv.Directory(data.templates);
|
||||
pat_fun_priv.ParseFile("fun_priv.html");
|
||||
|
||||
pat_err_others.Directory(data.templates);
|
||||
pat_err_others.ParseFile("err_others.html");
|
||||
|
||||
CreateFunctions();
|
||||
|
||||
#ifdef APPTEMPLATES
|
||||
AppTemplateFunctions::ReadAppPatterns();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "../core/users.h"
|
||||
#include "../core/groups.h"
|
||||
#include "../core/log.h"
|
||||
#include "patterncacher.h"
|
||||
|
||||
#ifdef APPTEMPLATES
|
||||
#include "../app/templates.h"
|
||||
|
@ -35,6 +36,8 @@ namespace TemplatesFunctions
|
|||
{
|
||||
using Ezc::Info;
|
||||
|
||||
extern PatternCacher pattern_cacher;
|
||||
|
||||
/*
|
||||
sys
|
||||
*/
|
||||
|
@ -159,7 +162,6 @@ class Templates
|
|||
{
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue