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:
Tomasz Sowa 2009-01-26 20:49:28 +00:00
parent 327f18525c
commit 20f6fbcf84
37 changed files with 866 additions and 298 deletions

26
app/content.h Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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()) )
{

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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 )
{

View File

@ -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
{

44
content/run.cpp Executable file
View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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();

View File

@ -10,10 +10,15 @@
#include "function.h"
Function::Function()
{
code = none;
code = FUN_NONE;
}
void Function::Clear()
{
code = FUN_NONE;
item.Clear();
}

View File

@ -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);
};

56
core/functioncodeparser.cpp Executable file
View File

@ -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());
}

35
core/functioncodeparser.h Executable file
View File

@ -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

View File

@ -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 )

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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 == '+' )

View File

@ -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;
}

View File

@ -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)