diff --git a/confparser/confparser.cpp b/confparser/confparser.cpp index 44758f5..bc1458c 100755 --- a/confparser/confparser.cpp +++ b/confparser/confparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008, Tomasz Sowa diff --git a/confparser/confparser.h b/confparser/confparser.h index d76aa3e..e2b70a3 100755 --- a/confparser/confparser.h +++ b/confparser/confparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008, Tomasz Sowa diff --git a/content/Makefile.dep b/content/Makefile.dep index 2c522e0..b38123d 100755 --- a/content/Makefile.dep +++ b/content/Makefile.dep @@ -1,5 +1,21 @@ # DO NOT DELETE +adduser.o: content.h ../core/item.h ../templates/templates.h +adduser.o: ../templates/patterncacher.h ../templates/misc.h +adduser.o: ../templates/localefilter.h ../core/locale.h +adduser.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h +adduser.o: ../core/httpsimpleparser.h ../core/log.h ../core/thread.h +adduser.o: ../core/ticket.h ../core/done.h ../core/request.h +adduser.o: ../core/requesttypes.h ../core/session.h ../core/done.h +adduser.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h +adduser.o: ../core/rebus.h ../core/function.h ../core/thread.h +adduser.o: ../core/compress.h ../core/acceptencodingparser.h +adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +adduser.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h +adduser.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h +adduser.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h +adduser.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h +adduser.o: ../core/mount.h ../core/loadavg.h ../core/db.h cat.o: content.h ../core/item.h ../templates/templates.h cat.o: ../templates/patterncacher.h ../templates/misc.h cat.o: ../templates/localefilter.h ../core/locale.h diff --git a/content/Makefile.o.dep b/content/Makefile.o.dep index 34d5772..0c238b1 100755 --- a/content/Makefile.o.dep +++ b/content/Makefile.o.dep @@ -1 +1 @@ -o = cat.o content.o createthread.o createticket.o default.o download.o editticket.o emacs.o last.o login.o logout.o ls.o misc_item.o misc_specialfile.o mkdir.o node.o priv.o reload.o rm.o run.o thread.o ticket.o upload.o who.o +o = adduser.o cat.o content.o createthread.o createticket.o default.o download.o editticket.o emacs.o last.o login.o logout.o ls.o misc_item.o misc_specialfile.o mkdir.o node.o priv.o reload.o rm.o run.o thread.o ticket.o upload.o who.o diff --git a/content/adduser.cpp b/content/adduser.cpp new file mode 100755 index 0000000..541499b --- /dev/null +++ b/content/adduser.cpp @@ -0,0 +1,111 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "content.h" +#include "../core/request.h" +#include "../core/data.h" +#include "../core/db.h" + + + + + + + +bool Content::CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass) +{ + if( !login || !pass || !conf_pass ) + { + request.status = WINIX_ERR_PERMISSION_DENIED; + return false; + } + + if( login->empty() ) + { + request.status = WINIX_ERR_LOGIN_EMPTY; + return false; + } + + if( *pass != *conf_pass ) + { + request.status = WINIX_ERR_PASSWORDS_DIFFERENT; + return false; + } + + if( pass->size() < 5 ) + { + request.status = WINIX_ERR_PASSWORD_TOO_SHORT; + return false; + } + + if( data.users.IsUser(*login) ) + { + request.status = WINIX_ERR_USER_EXISTS; + return false; + } + +return true; +} + + + + + + +void Content::PostFunAddUser() +{ +User user; + + std::string * login = request.PostVar("login"); + std::string * pass = request.PostVar("password"); + std::string * conf_pass = request.PostVar("confirmpassword"); + std::string * email = request.PostVar("email"); + + if( !CheckAddUserVars(login, pass, conf_pass) ) + return; + + user.name = *login; + + if( email ) + user.email = *email; + + request.status = db.AddUser(user, *pass); + + if( request.status == WINIX_ERR_OK ) + { + if( data.users.AddUser(user) ) + { + if( !request.session->puser ) + LoginUser(user.id, false); + + log << log2 << "Content: added a new user: " << user.name << logend; + } + else + { + log << log1 << "Content: I can't add to data.users: " << user.name + << " but the user was added to the db correctly" << logend; + } + + if( request.is_item ) + RedirectTo(request.item); + else + RedirectToLastDir(); + } +} + + + + +void Content::FunAddUser() +{ + +} + + + diff --git a/content/cat.cpp b/content/cat.cpp index 2f068df..47c7e73 100755 --- a/content/cat.cpp +++ b/content/cat.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -20,14 +20,14 @@ void Content::FunCat() if( !request.is_item ) { log << log1 << "Content: cat function requires an item" << logend; - request.status = Error::no_item; + request.status = WINIX_ERR_NO_ITEM; return; } if( !request.HasReadAccess(request.item) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/content.cpp b/content/content.cpp index 9c33c2c..104d4c6 100755 --- a/content/content.cpp +++ b/content/content.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -125,7 +125,7 @@ void Content::MakeStandardFunction() if( request.pfunction ) { - request.status = Error::no_item; + request.status = WINIX_ERR_NO_ITEM; log << log1 << "Content: in authorizer mode only 'cat' funtion is available and must " "be default (not in the url)" << logend; return; @@ -142,7 +142,7 @@ void Content::MakeStandardFunction() if( !request.pfunction ) { - request.status = Error::no_function; + request.status = WINIX_ERR_NO_FUNCTION; log << log1 << "Content: no function (neither cat nor ls)" << logend; return; } @@ -230,7 +230,10 @@ void Content::MakeStandardFunction() if( request.pfunction->code == FUN_DOWNLOAD ) FunDownload(); else - request.status = Error::permission_denied; + if( request.pfunction->code == FUN_ADDUSER ) + FunAddUser(); + else + request.status = WINIX_ERR_PERMISSION_DENIED; } @@ -242,7 +245,7 @@ void Content::MakePost() { if( request.role == Request::authorizer ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } @@ -251,7 +254,7 @@ void Content::MakePost() if( !request.pfunction ) { - request.status = Error::no_function; + request.status = WINIX_ERR_NO_FUNCTION; log << log1 << "Content: MakePost: no function" << logend; return; } @@ -304,6 +307,10 @@ void Content::MakePost() PostFunEmacs(); break; + case FUN_ADDUSER: + PostFunAddUser(); + break; + default: log << log1 << "Content: unknown post function" << logend; break; @@ -321,7 +328,7 @@ bool sent = false; if( request.is_item && request.item.auth == Item::auth_none && - request.item.content_type == Item::ct_raw && request.status == Error::ok && request.pfunction ) + request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.pfunction ) { if( request.pfunction->code == FUN_CAT ) { @@ -353,18 +360,18 @@ void Content::Make() } // request.status can be changed by function_parser - if( request.status == Error::ok ) + if( request.status == WINIX_ERR_OK ) { if( DirsHaveReadExecPerm() ) { if( request.method == Request::post ) MakePost(); - if( request.redirect_to.empty() && request.status == Error::ok ) + if( request.redirect_to.empty() && request.status == WINIX_ERR_OK ) MakeStandardFunction(); } else - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; } if( request.session->spam_score > 0 ) @@ -467,13 +474,13 @@ void Content::ReadAdditionalInfo() if( data.mounts.pmount->type == Mount::thread ) { - if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == Error::ok ) + if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == WINIX_ERR_OK ) request.is_thread = true; } else if( data.mounts.pmount->type == Mount::ticket ) { - if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == Error::ok ) + if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == WINIX_ERR_OK ) { request.is_ticket = true; diff --git a/content/content.h b/content/content.h index de256c7..ac689cf 100755 --- a/content/content.h +++ b/content/content.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -35,6 +35,10 @@ class Content void PrepareUrl(Item & item); + + bool CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass); + void PostFunAddUser(); + void FunAddUser(); void SetDefaultFunctionForFile(); void SetDefaultFunctionForDir(); @@ -87,6 +91,7 @@ class Content void CheckAccessToItems(); + void LoginUser(long user_id, bool remember_me); void FunLogin(); void PostFunLogin(); diff --git a/content/createthread.cpp b/content/createthread.cpp index 344df22..a5a99a9 100755 --- a/content/createthread.cpp +++ b/content/createthread.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -21,7 +21,7 @@ bool Content::FunCreateThreadCheckAccess() { if( !request.CanCreateThread() ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -35,9 +35,9 @@ bool Content::FunCreateThreadCheckAbuse() { if( !CheckRebus() ) { - request.status = Error::incorrect_rebus; + request.status = WINIX_ERR_INCORRECT_REBUS; request.session->done = Done::added_thread; - request.session->done_status = Error::incorrect_rebus; + request.session->done_status = WINIX_ERR_INCORRECT_REBUS; return false; } @@ -46,9 +46,9 @@ bool Content::FunCreateThreadCheckAbuse() if( request.session->spam_score > 0 ) { - request.status = Error::spam; + request.status = WINIX_ERR_SPAM; request.session->done = Done::added_thread; - request.session->done_status = Error::spam; + request.session->done_status = WINIX_ERR_SPAM; log << log1 << "Content: ignoring due to suspected spamming" << logend; return false; @@ -80,7 +80,7 @@ void Content::AddThread() void Content::PostFunCreateThreadLogAndRedirect() { - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { request.session->done = Done::added_thread; @@ -113,7 +113,7 @@ void Content::PostFunCreateThread() Mkdir(request.item, true); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { ReadItemContentWithType(request.item); request.item.type = Item::file; @@ -121,7 +121,7 @@ void Content::PostFunCreateThread() request.item.parent_id = request.dir_table.back()->id; PostFunEmacsAdd(); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) AddThread(); } diff --git a/content/createticket.cpp b/content/createticket.cpp index 3e9af23..8136b00 100755 --- a/content/createticket.cpp +++ b/content/createticket.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -22,7 +22,7 @@ bool Content::FunCreateTicketCheckAccess() { if( !request.CanCreateTicket() ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -36,9 +36,9 @@ bool Content::FunCreateTicketCheckAbuse(const Done & done) { if( !CheckRebus() ) { - request.status = Error::incorrect_rebus; + request.status = WINIX_ERR_INCORRECT_REBUS; request.session->done = done; - request.session->done_status = Error::incorrect_rebus; + request.session->done_status = WINIX_ERR_INCORRECT_REBUS; return false; } @@ -47,9 +47,9 @@ bool Content::FunCreateTicketCheckAbuse(const Done & done) if( request.session->spam_score > 0 ) { - request.status = Error::spam; + request.status = WINIX_ERR_SPAM; request.session->done = done; - request.session->done_status = Error::spam; + request.session->done_status = WINIX_ERR_SPAM; log << log1 << "Content: ignoring due to suspected spamming" << logend; return false; @@ -168,7 +168,7 @@ void Content::AddTicket() void Content::PostFunCreateTicketLogAndRedirect() { - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { request.session->done = Done::added_ticket; @@ -201,7 +201,7 @@ void Content::PostFunCreateTicket() Mkdir(request.item, true); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { ReadItemContentWithType(request.item); request.item.type = Item::file; @@ -209,7 +209,7 @@ void Content::PostFunCreateTicket() request.item.parent_id = request.dir_table.back()->id; PostFunEmacsAdd(); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) AddTicket(); } diff --git a/content/default.cpp b/content/default.cpp index 0199db6..69c1b51 100755 --- a/content/default.cpp +++ b/content/default.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -33,7 +33,7 @@ long defaultid = -1; pdir = data.dirs.GetDir(dir); if( !pdir ) - throw Error(Error::incorrect_dir); + throw Error(WINIX_ERR_INCORRECT_DIR); if( file.empty() ) { @@ -49,7 +49,7 @@ long defaultid = -1; defaultid = db.GetFileId(pdir->id, file); if( defaultid == -1 ) - throw Error(Error::no_item); + throw Error(WINIX_ERR_NO_ITEM); } else { @@ -72,7 +72,7 @@ void Content::PostFunDefault() if( !request.HasWriteAccess(*request.dir_table.back()) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } @@ -82,7 +82,7 @@ void Content::PostFunDefault() long defaultid = PostFunDefaultParsePath(); request.session->done_status = db.EditDefaultItem(request.dir_table.back()->id, defaultid); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) request.dir_table.back()->default_item = defaultid; } catch(const Error & e) @@ -91,7 +91,7 @@ void Content::PostFunDefault() } - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) RedirectTo(*request.dir_table.back()); else log << log1 << "Content: PostFunDefaultItem: Error: " << request.session->done_status << logend; @@ -104,7 +104,7 @@ void Content::FunDefault() { if( !request.HasWriteAccess(*request.dir_table.back()) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/download.cpp b/content/download.cpp index a6dd178..22bf257 100755 --- a/content/download.cpp +++ b/content/download.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -21,7 +21,7 @@ void Content::FunDownload() if( !request.is_item ) { log << log1 << "Content: pv function requires an item" << logend; - request.status = Error::no_item; + request.status = WINIX_ERR_NO_ITEM; return; } @@ -30,7 +30,7 @@ void Content::FunDownload() request.item.auth == Item::auth_none || data.auth_simplefs_dir.empty() ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } @@ -38,7 +38,7 @@ void Content::FunDownload() if( !request.MakePath(request.x_sendfile) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } } diff --git a/content/editticket.cpp b/content/editticket.cpp index d6f51b4..799dbeb 100755 --- a/content/editticket.cpp +++ b/content/editticket.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -20,7 +20,7 @@ bool Content::FunEditTicketCheckAccess() { if( !request.CanEditTicket() ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -31,7 +31,7 @@ return true; void Content::EditTicketCheckFirstItem() { - if( request.session->done_status != Error::ok ) + if( request.session->done_status != WINIX_ERR_OK ) return; @@ -49,7 +49,7 @@ void Content::EditTicketCheckFirstItem() request.session->done_status = db.AddItem(item); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { log << log2 << "Content: added the first item with content for the ticket, item.id: " << item.id << logend; request.ticket.item_id = item.id; @@ -61,7 +61,7 @@ void Content::EditTicketCheckFirstItem() void Content::EditTicketModTicket() { - if( request.session->done_status != Error::ok ) + if( request.session->done_status != WINIX_ERR_OK ) return; Ticket ticket; @@ -81,7 +81,7 @@ void Content::EditTicketModTicket() void Content::EditTicketModDir() { - if( request.session->done_status != Error::ok ) + if( request.session->done_status != WINIX_ERR_OK ) return; // we don't modify the url @@ -99,7 +99,7 @@ void Content::EditTicketModDir() void Content::EditTicketModFirstItem() { - if( request.session->done_status != Error::ok ) + if( request.session->done_status != WINIX_ERR_OK ) return; // modyfing the first item (the one with content) @@ -119,7 +119,7 @@ void Content::EditTicketModFirstItem() void Content::PostFunEditTicketLogAndRedirect() { - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { request.session->done = Done::edited_ticket; @@ -149,9 +149,9 @@ void Content::PostFunEditTicket() return; } - if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) != Error::ok ) + if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) != WINIX_ERR_OK ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/emacs.cpp b/content/emacs.cpp index 0507ab0..f2551cf 100755 --- a/content/emacs.cpp +++ b/content/emacs.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -24,14 +24,14 @@ bool Content::FunEmacsCheckAccess() // adding a new item if( !request.CanUseEmacs(*request.dir_table.back()) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } } else // editing an existing item if( !request.CanUseEmacs(request.item) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -44,7 +44,7 @@ void Content::PostFunEmacsAdd() request.session->done = Done::added_item; request.session->done_status = db.AddItem(request.item); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { log << log2 << "Content: added a new item" << logend; request.notify_code |= WINIX_NOTIFY_ITEM_ADD; @@ -59,7 +59,7 @@ void Content::PostFunEmacsEdit(bool with_url) request.session->done = Done::edited_item; request.session->done_status = db.EditItemById(request.item, with_url); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { TemplatesFunctions::pattern_cacher.UpdatePattern(request.item); log << log2 << "Content: modified an item" << logend; @@ -73,9 +73,9 @@ bool Content::PostEmacsCheckAbuse(bool adding) { if( !CheckRebus() ) { - request.status = Error::incorrect_rebus; + request.status = WINIX_ERR_INCORRECT_REBUS; request.session->done = (adding)? Done::added_item : Done::edited_item; - request.session->done_status = Error::incorrect_rebus; + request.session->done_status = WINIX_ERR_INCORRECT_REBUS; return false; } @@ -85,9 +85,9 @@ bool Content::PostEmacsCheckAbuse(bool adding) if( request.session->spam_score > 0 ) { - request.status = Error::spam; + request.status = WINIX_ERR_SPAM; request.session->done = (adding)? Done::added_item : Done::edited_item; - request.session->done_status = Error::spam; + request.session->done_status = WINIX_ERR_SPAM; log << log1 << "Content: ignoring due to suspected spamming" << logend; return false; @@ -128,7 +128,7 @@ void Content::PostFunEmacs() bool adding = !request.is_item; bool edit_with_url = ReadItem(request.item, Item::file); - request.session->done_status = Error::ok; + request.session->done_status = WINIX_ERR_OK; if( !PostEmacsCheckAbuse(adding) ) return; @@ -146,7 +146,7 @@ void Content::PostFunEmacs() } - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { PostFunEmacsModifyMountPoint(adding); CheckSpecialFile(); diff --git a/content/last.cpp b/content/last.cpp index 9314316..491d927 100755 --- a/content/last.cpp +++ b/content/last.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/content/login.cpp b/content/login.cpp index 22d85af..1069c86 100755 --- a/content/login.cpp +++ b/content/login.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -18,6 +18,26 @@ +void Content::LoginUser(long user_id, bool remember_me) +{ + request.session->puser = data.users.GetUser(user_id); + request.session->spam_score = 0; + + if( !request.session->puser ) + { + log << log1 << "Content: user id: " << user_id << " is not in data.users" << logend; + return; + } + + request.session->remember_me = remember_me; + + data.last.UserLogin(user_id, request.session->puser->name, inet_addr(request.env_remote_addr), request.session->id); + data.how_many_logged += 1; + + log << log2 << "User " << request.session->puser->name << " (id: " << user_id << ") logged" << logend; +} + + void Content::PostFunLogin() { @@ -29,24 +49,7 @@ void Content::PostFunLogin() long user_id; if( login && pass && db.CheckUser(*login, *pass, user_id) ) - { - request.session->puser = data.users.GetUser(user_id); - request.session->spam_score = 0; - - if( !request.session->puser ) - { - log << log1 << "Content: user: " << login << " is in the database but is not in data.users" << logend; - return; - } - - if( remem ) - request.session->remember_me = true; - - data.last.UserLogin(user_id, *login, inet_addr(request.env_remote_addr), request.session->id); - data.how_many_logged += 1; - - log << log2 << "User " << login << " (id: " << user_id << ") logged" << logend; - } + LoginUser(user_id, remem != 0); // !! moze zglosic komunikat o nie poprawnym logowaniu } diff --git a/content/logout.cpp b/content/logout.cpp index 2eb7105..ff6c07f 100755 --- a/content/logout.cpp +++ b/content/logout.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/content/ls.cpp b/content/ls.cpp index 66aa292..5888f53 100755 --- a/content/ls.cpp +++ b/content/ls.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/content/misc_item.cpp b/content/misc_item.cpp index 3b2fb14..e9b3514 100755 --- a/content/misc_item.cpp +++ b/content/misc_item.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/content/misc_specialfile.cpp b/content/misc_specialfile.cpp index 098ea2c..166c430 100755 --- a/content/misc_specialfile.cpp +++ b/content/misc_specialfile.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/content/mkdir.cpp b/content/mkdir.cpp index a28048a..f6da017 100755 --- a/content/mkdir.cpp +++ b/content/mkdir.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -21,7 +21,7 @@ bool Content::FunMkdirCheckAccess() { if( request.is_item || !request.CanUseMkdir(*request.dir_table.back()) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -34,7 +34,7 @@ void Content::Mkdir(Item & item, bool add_to_dir_table) { request.session->done_status = db.AddItem(item); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { Item * pdir = data.dirs.AddDir(item); @@ -56,7 +56,7 @@ void Content::PostFunMkdir(bool add_to_dir_table, int privileges) Mkdir(request.item, add_to_dir_table); - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { request.notify_code |= WINIX_NOTIFY_DIR_ADD; RedirectTo(request.item); diff --git a/content/node.cpp b/content/node.cpp index 4b2efa8..ef450a1 100755 --- a/content/node.cpp +++ b/content/node.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/content/priv.cpp b/content/priv.cpp index 491c6b5..f763feb 100755 --- a/content/priv.cpp +++ b/content/priv.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa @@ -27,7 +27,7 @@ bool Content::PrivCheckAccess() if( !request.session->puser || (request.is_item && request.IsParam("r")) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } diff --git a/content/reload.cpp b/content/reload.cpp index 18ba24e..b3d1ebc 100755 --- a/content/reload.cpp +++ b/content/reload.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -22,7 +22,7 @@ void Content::FunReloadTemplates() notify.ReadTemplates(); // make sure that ReadTemplates() is using some kind of locking request.session->done = Done::reloaded_templates; - request.session->done_status = Error::ok; + request.session->done_status = WINIX_ERR_OK; } @@ -35,7 +35,7 @@ void Content::FunReload() if( !request.session->puser || !request.session->puser->super_user ) { log << log1 << "Content: Only an admin has access to reload function" << logend; - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/rm.cpp b/content/rm.cpp index 65456ef..a4aef03 100755 --- a/content/rm.cpp +++ b/content/rm.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -21,14 +21,14 @@ bool Content::FunRmCheckAccess() { if( !request.CanRemove(*request.dir_table.back()) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } } else if( !request.CanRemove(request.item) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -64,7 +64,7 @@ void Content::FunRmDirRecursive() request.session->done = Done::deleted_dir; - request.session->done_status = Error::ok; + request.session->done_status = WINIX_ERR_OK; request.session->done_timer = 2; // redirect to the last valid directory @@ -75,7 +75,7 @@ void Content::FunRmDirRecursive() void Content::FunRmDir() { if( request.param_table.empty() ) - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; else if( request.IsParam("confirm") ) return; @@ -83,7 +83,7 @@ void Content::FunRmDir() if( request.IsParam("r") ) FunRmDirRecursive(); else - request.status = Error::unknown_param; + request.status = WINIX_ERR_UNKNOWN_PARAM; } @@ -100,7 +100,7 @@ void Content::FunRm() { if( db.DelItem( request.item ) ) { - request.session->done_status = Error::ok; + request.session->done_status = WINIX_ERR_OK; log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend; TemplatesFunctions::pattern_cacher.DeletePattern(request.item); @@ -113,7 +113,7 @@ void Content::FunRm() } else { - request.session->done_status = Error::no_item; + request.session->done_status = WINIX_ERR_NO_ITEM; } request.session->done = Done::deleted_item; @@ -125,7 +125,7 @@ void Content::FunRm() { if( !request.IsParam("confirm") ) //request.result = Request::err404; - request.status = Error::unknown_param; + request.status = WINIX_ERR_UNKNOWN_PARAM; } } diff --git a/content/run.cpp b/content/run.cpp index 8304c74..cd247af 100755 --- a/content/run.cpp +++ b/content/run.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -19,13 +19,13 @@ void Content::FunRun() if( !request.is_item ) { log << log1 << "Content: Run function requires an item" << logend; - request.status = Error::no_item; + request.status = WINIX_ERR_NO_ITEM; return; } if( !request.HasReadExecAccess(request.item) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } } diff --git a/content/thread.cpp b/content/thread.cpp index 7237de8..5459c56 100755 --- a/content/thread.cpp +++ b/content/thread.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -35,7 +35,7 @@ void Content::FunThread() { if( request.is_item ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/ticket.cpp b/content/ticket.cpp index 171ab96..05b436e 100755 --- a/content/ticket.cpp +++ b/content/ticket.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -29,7 +29,7 @@ void Content::TicketDeleteFirst() if( !request.HasReadAccess(request.item_table[i]) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; } request.item_table.erase(request.item_table.begin() + i); @@ -46,7 +46,7 @@ void Content::FunTicket() { if( request.is_item || data.mounts.pmount->type != Mount::ticket ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/upload.cpp b/content/upload.cpp index a152d20..b0c2c60 100755 --- a/content/upload.cpp +++ b/content/upload.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -23,7 +23,7 @@ bool Content::FunUploadCheckAccess() { if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -37,7 +37,7 @@ bool Content::UploadCreatePath(std::string & path) { if( !request.MakePath(path, true) ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return false; } @@ -62,7 +62,7 @@ void Content::UploadSaveFile(const std::string & tmp_filename, const std::string log.SystemErr(err); log << logend; - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; } } @@ -72,9 +72,9 @@ bool Content::FunUploadCheckAbuse() { if( !CheckRebus() ) { - request.status = Error::incorrect_rebus; + request.status = WINIX_ERR_INCORRECT_REBUS; request.session->done = Done::added_thread; - request.session->done_status = Error::incorrect_rebus; + request.session->done_status = WINIX_ERR_INCORRECT_REBUS; return false; } @@ -83,9 +83,9 @@ bool Content::FunUploadCheckAbuse() if( request.session->spam_score > 0 ) { - request.status = Error::spam; + request.status = WINIX_ERR_SPAM; request.session->done = Done::added_thread; - request.session->done_status = Error::spam; + request.session->done_status = WINIX_ERR_SPAM; log << log1 << "Content: ignoring due to suspected spamming" << logend; return false; @@ -123,7 +123,7 @@ void Content::UploadMulti() if( !UploadCreatePath(tmp_path) ) return; - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) UploadSaveFile(i->second.tmp_filename, tmp_path); } @@ -156,7 +156,7 @@ void Content::UploadSingle() PostFunEmacsAdd(); // always adding a new item - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename; @@ -167,7 +167,7 @@ void Content::UploadSingle() } - if( request.session->done_status == Error::ok ) + if( request.session->done_status == WINIX_ERR_OK ) { if( !request.IsParam("ckeditor_upload") ) RedirectTo(request.item); @@ -184,7 +184,7 @@ void Content::PostFunUpload() if( request.post_file_table.empty() ) { - request.status = Error::permission_denied; + request.status = WINIX_ERR_PERMISSION_DENIED; return; } diff --git a/content/who.cpp b/content/who.cpp index dbada4d..023783d 100755 --- a/content/who.cpp +++ b/content/who.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/Makefile.dep b/core/Makefile.dep index 8aaeab1..a8e09ef 100755 --- a/core/Makefile.dep +++ b/core/Makefile.dep @@ -24,7 +24,6 @@ dirs.o: request.h requesttypes.h session.h done.h compress.h dirs.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h dirs.o: postmultiparser.h done.o: done.h -error.o: error.h log.h function.o: function.h item.h functioncodeparser.o: functioncodeparser.h item.h function.h log.h functionparser.o: functionparser.h requesttypes.h log.h item.h error.h data.h diff --git a/core/Makefile.o.dep b/core/Makefile.o.dep index 77be37b..113b2a1 100755 --- a/core/Makefile.o.dep +++ b/core/Makefile.o.dep @@ -1 +1 @@ -o = acceptbaseparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o error.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o +o = acceptbaseparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o diff --git a/core/acceptbaseparser.cpp b/core/acceptbaseparser.cpp index 6b4f779..5792ac9 100755 --- a/core/acceptbaseparser.cpp +++ b/core/acceptbaseparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/acceptbaseparser.h b/core/acceptbaseparser.h index dec1ca4..3e7dbd1 100755 --- a/core/acceptbaseparser.h +++ b/core/acceptbaseparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/acceptencodingparser.h b/core/acceptencodingparser.h index 921b0c0..8841ee9 100755 --- a/core/acceptencodingparser.h +++ b/core/acceptencodingparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/compress.cpp b/core/compress.cpp index 4f61e53..827b224 100755 --- a/core/compress.cpp +++ b/core/compress.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/compress.h b/core/compress.h index d2a9f93..33631c3 100755 --- a/core/compress.h +++ b/core/compress.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/config.cpp b/core/config.cpp index 424f08c..7359906 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/config.h b/core/config.h index f8e730f..cbe5369 100755 --- a/core/config.h +++ b/core/config.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/cookieparser.h b/core/cookieparser.h index c19536b..fba6937 100755 --- a/core/cookieparser.h +++ b/core/cookieparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/data.cpp b/core/data.cpp index f2581f4..0c3cc0e 100755 --- a/core/data.cpp +++ b/core/data.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/data.h b/core/data.h index 74cebe9..0d3dee3 100755 --- a/core/data.h +++ b/core/data.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/core/db.cpp b/core/db.cpp index 5e91c31..8cf9dd5 100755 --- a/core/db.cpp +++ b/core/db.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -108,7 +108,7 @@ bool was_connection = true; else { log << log1 << "Db: Connection to db server cannot be established" << logend; - throw Error(Error::db_fatal_error_during_connecting); + throw Error(WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING); } } @@ -157,7 +157,7 @@ PGresult * Db::AssertQuery(const std::string & q) log << log1 << "Db: Problem with query: \"" << q << '\"' << logend; log << log1 << "Db: " << PQerrorMessage(pg_conn) << logend; - throw Error(Error::db_incorrect_query); + throw Error(WINIX_ERR_DB_INCORRECT_QUERY); } return r; @@ -171,7 +171,7 @@ void Db::AssertResultStatus(PGresult * r, ExecStatusType t) { log << "Db: Incorrect result status: " << PQerrorMessage(pg_conn) << logend; - throw Error(Error::db_incorrent_result_status); + throw Error(WINIX_ERR_DB_INCORRENT_RESULT_STATUS); } } @@ -185,7 +185,7 @@ int Db::AssertColumn(PGresult * r, const char * column_name) { log << log1 << "Db: there is no column: " << column_name << logend; - throw Error(Error::db_no_column); + throw Error(WINIX_ERR_DB_NO_COLUMN); } return c; @@ -200,7 +200,7 @@ const char * Db::AssertValue(PGresult * r, int row, int col) { log << log1 << "Db: there is no such an item in the result, row:" << row << ", col:" << col << logend; - throw Error(Error::no_item); + throw Error(WINIX_ERR_NO_ITEM); } return res; @@ -234,12 +234,12 @@ bool Db::CheckUser(std::string & login, std::string & password, long & user_id) int rows = PQntuples(r); if( rows == 0 ) - throw Error(Error::db_incorrect_login); + throw Error(WINIX_ERR_DB_INCORRECT_LOGIN); if( rows > 1 ) { log << log1 << "Db: there is more than one user: " << login << " (with the same password)" << logend; - throw Error(Error::db_more_than_one_login); + throw Error(WINIX_ERR_DB_MORE_THAN_ONE_LOGIN); } int cuser_id = AssertColumn(r, "id"); @@ -262,6 +262,40 @@ return user_ok; +Error Db::AddUser(User & user, const std::string & password) +{ + PGresult * r = 0; + Error status = WINIX_ERR_OK; + + try + { + AssertConnection(); + std::ostringstream query; + query << "insert into core.user (login, password, super_user, email, cms_notify, thread_notify) values ("; + query << '\'' << Escape(user.name) << "', "; + query << '\'' << Escape(password) << "', "; + query << '\'' << static_cast(user.super_user) << "', "; + query << '\'' << Escape(user.email) << "', "; + query << '\'' << user.cms_notify << "', "; + query << '\'' << user.thread_notify << "');"; + + r = AssertQuery(query.str()); + AssertResultStatus(r, PGRES_COMMAND_OK); + + user.id = AssertCurrval("core.user_id_seq"); + } + catch(const Error & e) + { + status = e; + } + + ClearResult(r); + +return status; +} + + + @@ -401,7 +435,7 @@ long Db::AssertCurrval(const char * table) if( PQntuples(r) != 1 ) { log << log1 << "Db: error (currval) for table: " << table << ", " << PQerrorMessage(pg_conn) << logend; - throw Error(Error::db_err_currval); + throw Error(WINIX_ERR_DB_ERR_CURRVAL); } long res = strtol( AssertValue(r, 0, 0), 0, 10 ); @@ -413,7 +447,7 @@ return res; Error Db::AddItemIntoItem(Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; bool url_without_id = false; try @@ -468,7 +502,7 @@ return result; Error Db::AddItemIntoContent(Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -499,14 +533,14 @@ return result; Error Db::AddItem(Item & item) { - Error result = Error::ok; + Error result = WINIX_ERR_OK; if( item.type == Item::file ) result = AddItemIntoContent(item); else item.content_id = -1; - if( result == Error::ok ) + if( result == WINIX_ERR_OK ) result = AddItemIntoItem(item); return result; @@ -519,7 +553,7 @@ return result; Error Db::EditItemInItem(Item & item, bool with_url) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; bool url_without_id = false; try @@ -578,7 +612,7 @@ return result; Error Db::EditItemInContent(Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -607,7 +641,7 @@ return result; Error Db::EditItemGetId(Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -620,7 +654,7 @@ Error Db::EditItemGetId(Item & item) AssertResultStatus(r, PGRES_TUPLES_OK); if( PQntuples(r) != 1 || PQnfields(r) != 2 ) - throw Error(Error::no_item); + throw Error(WINIX_ERR_NO_ITEM); // we cannot use AssertColumn() with a name because both columns are called 'id' item.id = atol( AssertValue(r, 0, 0) ); @@ -640,7 +674,7 @@ return result; Error Db::EditItemGetContentId(Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -654,7 +688,7 @@ Error Db::EditItemGetContentId(Item & item) AssertResultStatus(r, PGRES_TUPLES_OK); if( PQntuples(r) != 1 || PQnfields(r) != 1 ) - throw Error(Error::no_item); + throw Error(WINIX_ERR_NO_ITEM); item.content_id = atol( AssertValue(r, 0, 0) ); } @@ -673,19 +707,19 @@ return result; // !! moze nazwa poprostu EditItem (nie trzeba tego ById) ? (sprawdzic czy nie koliduje z inna nazwa) Error Db::EditItemById(Item & item, bool with_url) { - Error result = Error::ok; + Error result = WINIX_ERR_OK; // !! dla katalogow nie testowane jeszcze if( item.type == Item::file ) result = EditItemGetContentId(item); - if( result == Error::ok ) + if( result == WINIX_ERR_OK ) { if( item.type == Item::file ) result = EditItemInContent(item); - if( result == Error::ok ) + if( result == WINIX_ERR_OK ) result = EditItemInItem(item, with_url); } @@ -700,11 +734,11 @@ Error Db::EditItemByUrl(Item & item, bool with_url) { Error result = EditItemGetId(item); - if( result == Error::ok ) + if( result == WINIX_ERR_OK ) { result = EditItemInContent(item); - if( result == Error::ok ) + if( result == WINIX_ERR_OK ) result = EditItemInItem(item, with_url); } @@ -716,7 +750,7 @@ return result; Error Db::EditDefaultItem(long id, long new_default_item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -735,7 +769,7 @@ Error Db::EditDefaultItem(long id, long new_default_item) if( rows == 0 ) { - result = Error::no_item; + result = WINIX_ERR_NO_ITEM; log << log1 << "Db: EditDefaultItem: no such item, id: " << id << logend; } } @@ -914,7 +948,7 @@ void Db::GetItem(std::vector & item_table, long id) Error Db::GetItem(long parent_id, const std::string & url, Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -930,7 +964,7 @@ Error Db::GetItem(long parent_id, const std::string & url, Item & item) int rows = PQntuples(r); if( rows == 0 ) - throw Error(Error::no_item); + throw Error(WINIX_ERR_NO_ITEM); ItemColumns col; col.SetColumns(r); @@ -950,7 +984,7 @@ return result; Error Db::GetItemById(long item_id, Item & item) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -965,7 +999,7 @@ Error Db::GetItemById(long item_id, Item & item) int rows = PQntuples(r); if( rows == 0 ) - throw Error(Error::no_item); + throw Error(WINIX_ERR_NO_ITEM); ItemColumns col; col.SetColumns(r); @@ -1074,7 +1108,7 @@ return result; Error Db::EditPrivById(Item & item, long id) { PGresult * r = 0; - Error result = Error::ok; + Error result = WINIX_ERR_OK; try { @@ -1106,7 +1140,7 @@ return result; Error Db::DelDirById(long id) { - Error result = Error::ok; + Error result = WINIX_ERR_OK; PGresult * r = 0; const char * crows; @@ -1224,7 +1258,7 @@ void Db::DelItemDelContent(const Item & item) Error Db::DelItemCountContents(const Item & item, long & contents) { - Error result = Error::ok; + Error result = WINIX_ERR_OK; PGresult * r = 0; try @@ -1259,7 +1293,7 @@ long contents; Error result = DelItemCountContents(item, contents); - if( result == Error::ok && contents == 1 ) + if( result == WINIX_ERR_OK && contents == 1 ) DelItemDelContent(item); return DelItemDelItem(item); @@ -1331,7 +1365,7 @@ void Db::GetUsers(UGContainer & user_table) User u; long last_id = -1; - UGContainer::Iterator iter; + UGContainer::Iterator iter = user_table.End(); for(int i = 0 ; i & user_table) log << log1 << "Db: get user: id:" << u.id << ", name:" << u.name << ", super_user:" << u.super_user << logend; iter = user_table.PushBack( u ); + + if( iter == user_table.End() ) + log << log1 << "Db: can't add a user: " << u.name << logend; + last_id = u.id; } long group_id = atol( AssertValue(r, i, cgroup_id) ); - if( !PQgetisnull(r, i, cgroup_id) && group_id!=-1 && !user_table.Empty() ) + if( !PQgetisnull(r, i, cgroup_id) && group_id!=-1 && iter!=user_table.End() ) { iter->groups.push_back(group_id); log << log3 << "Db: user:" << iter->name << " is a member of group_id:" << group_id << logend; @@ -1485,7 +1523,7 @@ return buffer; Error Db::GetThreadByDirId(long dir_id, Thread & thread) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1506,7 +1544,7 @@ Error Db::GetThreadByDirId(long dir_id, Thread & thread) log << log1 << "Db: there is more than one thread with dir_id: " << dir_id << logend; else if( rows == 0 ) - throw Error(Error::no_thread); + throw Error(WINIX_ERR_NO_THREAD); int cid = AssertColumn(r, "id"); int cparent_id = AssertColumn(r, "parent_id"); @@ -1542,7 +1580,7 @@ return status; Error Db::GetThreads(long parent_id, std::vector & thread_tab) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1604,7 +1642,7 @@ return status; Error Db::AddThread(Thread & thread) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1638,7 +1676,7 @@ return status; Error Db::EditThreadAddItem(long dir_id, long item_id) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1664,7 +1702,7 @@ return status; Error Db::EditThreadRemoveItem(long dir_id) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1703,7 +1741,7 @@ return status; Error Db::RemoveThread(long dir_id) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1737,7 +1775,7 @@ return status; Error Db::GetTicketByDirId(long dir_id, Ticket & ticket) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1758,7 +1796,7 @@ Error Db::GetTicketByDirId(long dir_id, Ticket & ticket) log << log1 << "Db: there is more than one ticket with dir_id: " << dir_id << logend; else if( rows == 0 ) - throw Error(Error::no_ticket); + throw Error(WINIX_ERR_NO_TICKET); TicketColumns tc; @@ -1782,7 +1820,7 @@ return status; Error Db::GetTickets(long parent_id, std::vector & ticket_tab) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1856,7 +1894,7 @@ return is_ticket; Error Db::AddTicket(Ticket & ticket) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1892,7 +1930,7 @@ return status; Error Db::EditTicketById(Ticket & ticket) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1927,7 +1965,7 @@ return status; Error Db::EditTicketRemoveItem(long item_id) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { @@ -1954,7 +1992,7 @@ return status; Error Db::RemoveTicket(long dir_id) { PGresult * r = 0; - Error status = Error::ok; + Error status = WINIX_ERR_OK; try { diff --git a/core/db.h b/core/db.h index 67898dd..6bef7d1 100755 --- a/core/db.h +++ b/core/db.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -44,6 +44,8 @@ public: void Init(const std::string & database, const std::string & user, const std::string & pass); bool CheckUser(std::string & login, std::string & password, long & user_id); + Error AddUser(User & user, const std::string & password); + Error AddItem(Item & item); Error EditItemById(Item & item, bool with_url = true); Error EditItemByUrl(Item & item, bool with_url = true); diff --git a/core/db_itemcolumns.cpp b/core/db_itemcolumns.cpp index f3f2b58..87c30d1 100755 --- a/core/db_itemcolumns.cpp +++ b/core/db_itemcolumns.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/dircontainer.cpp b/core/dircontainer.cpp index 283d4c7..3546097 100755 --- a/core/dircontainer.cpp +++ b/core/dircontainer.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/dircontainer.h b/core/dircontainer.h index 94cffe7..c4df5aa 100755 --- a/core/dircontainer.h +++ b/core/dircontainer.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/dirs.cpp b/core/dirs.cpp index 8b508eb..9b743cf 100755 --- a/core/dirs.cpp +++ b/core/dirs.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -52,7 +52,7 @@ void Dirs::CheckRootDir() // !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url) // !! zrobic jakis wyjatek do wprowadzania roota? - if( db.AddItem(root) == Error::ok ) + if( db.AddItem(root) == WINIX_ERR_OK ) { dir_table.PushBack(root); } @@ -298,7 +298,7 @@ void Dirs::DeleteDir(long id) DeleteDir(p->second->id); } - if( db.DelDirById(id) == Error::ok ) + if( db.DelDirById(id) == WINIX_ERR_OK ) dir_table.DelById(id); db.RemoveThread(id); diff --git a/core/dirs.h b/core/dirs.h index 3233a62..5fe095f 100755 --- a/core/dirs.h +++ b/core/dirs.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/done.cpp b/core/done.cpp index 663d343..1920d01 100755 --- a/core/done.cpp +++ b/core/done.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/done.h b/core/done.h index c6d3caa..76645b1 100755 --- a/core/done.h +++ b/core/done.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/error.cpp b/core/error.cpp deleted file mode 100755 index 1b70d15..0000000 --- a/core/error.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is a part of CMSLU -- Content Management System like Unix - * and is not publicly distributed - * - * Copyright (c) 2008-2009, Tomasz Sowa - * All rights reserved. - * - */ - -#include "error.h" - - - -Error::Error() -{ - code = unknown; -} - - -Error::Error(Code c) : code(c) -{ -} - - -Error::Error(int i) -{ - code = static_cast(i); -} - - -Error::Error(const Error & e) -{ - code = e.code; -} - - -Error::operator int() const -{ - return static_cast(code); -} - - -Error & Error::operator=(Code c) -{ - code = c; - return *this; -} - -Error & Error::operator=(const Error & e) -{ - code = e.code; - return *this; -} - -bool Error::operator==(Code c) const -{ - return code == c; -} - - -bool Error::operator!=(Code c) const -{ - return code != c; -} - -bool Error::operator==(const Error & e) const -{ - return code == e.code; -} - - -bool Error::operator!=(const Error & e) const -{ - return code != e.code; -} - -std::ostream & operator<<(std::ostream & out, const Error & e) -{ - out << static_cast(e.code); - -return out; -} - - -Log & operator<<(Log & out, const Error & e) -{ - out << static_cast(e.code); - -return out; -} - - - - diff --git a/core/error.h b/core/error.h index fdf73dd..5a35026 100755 --- a/core/error.h +++ b/core/error.h @@ -1,8 +1,8 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2009, Tomasz Sowa + * Copyright (c) 2008-2010, Tomasz Sowa * All rights reserved. * */ @@ -13,84 +13,61 @@ #include #include "log.h" +#define WINIX_ERR_OK 0 +//#define WINIX_ERR_INCORRECT_PATH 1 + +//#define WINIX_ERR_NO_POSTVAR 2 +#define WINIX_ERR_INCORRECT_DIR 3 +#define WINIX_ERR_CANT_CHANGE_USER 4 +#define WINIX_ERR_CANT_CHANGE_GROUP 5 +#define WINIX_ERR_CANT_CHANGE_PRIVILEGES 6 +#define WINIX_ERR_PERMISSION_DENIED 7 +#define WINIX_ERR_NO_ROOT_DIR 8 +#define WINIX_ERR_NO_FUNCTION 9 + + +#define WINIX_ERR_NO_ITEM 10 +#define WINIX_ERR_UNKNOWN_PARAM 11 + +#define WINIX_ERR_MOUNT_UNKNOWN 12 +#define WINIX_ERR_UNKNOWN_FILESYSTEM 13 +#define WINIX_ERR_NO_MOUNTPOINT 14 +//#define WINIX_ERR_MOUNT_NO_PARAM 15 + +#define WINIX_ERR_NO_THREAD 16 +#define WINIX_ERR_EMPTY 17 +#define WINIX_ERR_SPAM 18 +#define WINIX_ERR_INCORRECT_REBUS 19 -class Error -{ +#define WINIX_ERR_NO_BOUNDARY 20 +#define WINIX_ERR_BROKEN_INPUT 21 +#define WINIX_ERR_INPUT_TOO_LARGE 22 +#define WINIX_ERR_CANT_CREATE_FILE 23 -public: +#define WINIX_ERR_NO_TICKET 24 - enum Code - { - ok = 0, - incorrect_path, - db_fatal_error_during_connecting, - db_incorrect_query, - db_incorrent_result_status, - db_no_column, - db_incorrect_login, - db_more_than_one_login, - db_err_currval, - no_postvar, - incorrect_dir, - cant_change_user, - cant_change_group, - cant_change_privileges, - permission_denied, - no_root_dir, - no_function, - - no_item, - unknown_param, - - mount_unknown, - unknown_filesystem, - no_mountpoint, - mount_no_param, - - no_thread, - empty, - spam, - incorrect_rebus, - - no_boundary, - broken_input, - input_too_large, - cant_create_file, - - no_ticket, - - unknown = 1000 - - - }; - - - Error(); - Error(Code c); - Error(int i); - Error(const Error & e); - Error & operator=(Code c); - Error & operator=(const Error & e); - - operator int() const; - - bool operator==(Code c) const; - bool operator!=(Code c) const; - bool operator==(const Error & e) const; - bool operator!=(const Error & e) const; - - friend std::ostream & operator<<(std::ostream & out, const Error & e); - friend Log & operator<<(Log & out, const Error & e); +#define WINIX_ERR_PASSWORDS_DIFFERENT 25 +#define WINIX_ERR_PASSWORD_TOO_SHORT 26 +#define WINIX_ERR_USER_EXISTS 27 +#define WINIX_ERR_LOGIN_EMPTY 28 -private: +#define WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING 100 +#define WINIX_ERR_DB_INCORRECT_QUERY 101 +#define WINIX_ERR_DB_INCORRENT_RESULT_STATUS 102 +#define WINIX_ERR_DB_NO_COLUMN 103 +#define WINIX_ERR_DB_INCORRECT_LOGIN 104 +#define WINIX_ERR_DB_MORE_THAN_ONE_LOGIN 105 +#define WINIX_ERR_DB_ERR_CURRVAL 106 - Code code; -}; +//#define WINIX_ERR_UNKNOWN 1000 + + +typedef int Error; diff --git a/core/function.cpp b/core/function.cpp index a2c9e28..31139ce 100755 --- a/core/function.cpp +++ b/core/function.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/function.h b/core/function.h index d364189..6cc71bb 100755 --- a/core/function.h +++ b/core/function.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -42,7 +42,7 @@ #define FUN_CHOWN 26 #define FUN_CKEDITOR 27 #define FUN_DOWNLOAD 28 - +#define FUN_ADDUSER 29 diff --git a/core/functioncodeparser.cpp b/core/functioncodeparser.cpp index f7c2088..469a3a5 100755 --- a/core/functioncodeparser.cpp +++ b/core/functioncodeparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/functioncodeparser.h b/core/functioncodeparser.h index 28a33ff..e4442fb 100755 --- a/core/functioncodeparser.h +++ b/core/functioncodeparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/functionparser.cpp b/core/functionparser.cpp index 0569873..88ca3db 100755 --- a/core/functionparser.cpp +++ b/core/functionparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -34,7 +34,7 @@ void FunctionParser::ParseDirectories() if( !pdir ) { // there is no the root dir - request.status = Error::no_root_dir; + request.status = WINIX_ERR_NO_ROOT_DIR; return; } @@ -78,12 +78,12 @@ void FunctionParser::ParseItem() request.status = db.GetItem(parent_id, url, request.item); - if( request.status == Error::ok ) + if( request.status == WINIX_ERR_OK ) { if( request.role == Request::authorizer && request.item.auth == Item::auth_none ) { log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend; - request.status = Error::no_item; + request.status = WINIX_ERR_NO_ITEM; return; } @@ -138,7 +138,7 @@ void FunctionParser::ParseParams() void FunctionParser::Parse() { - request.status = Error::ok; + request.status = WINIX_ERR_OK; get_index = 0; get_table_len = request.get_table.size(); request.pfunction = 0; @@ -146,7 +146,7 @@ void FunctionParser::Parse() ParseDirectories(); - if( request.status != Error::ok ) + if( request.status != WINIX_ERR_OK ) return; ParseFunction(); @@ -155,14 +155,14 @@ void FunctionParser::Parse() { ParseItem(); - if( request.status != Error::ok ) + if( request.status != WINIX_ERR_OK ) return; ParseFunction(); if( !request.pfunction && get_index != get_table_len ) { - request.status = Error::no_function; + request.status = WINIX_ERR_NO_FUNCTION; log << log3 << "FP: Parse: unknown function: \"" << request.get_table[get_index] << "\"" << logend; return; } diff --git a/core/functionparser.h b/core/functionparser.h index 117d52f..e92b24f 100755 --- a/core/functionparser.h +++ b/core/functionparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/functions.cpp b/core/functions.cpp index 5f26ec4..e2ac9fc 100755 --- a/core/functions.cpp +++ b/core/functions.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -143,6 +143,9 @@ void Functions::ReadFunctions() f.item.url = "download"; table.insert( std::make_pair(f.item.url, f) ); + f.code = FUN_ADDUSER; + f.item.url = "adduser"; + table.insert( std::make_pair(f.item.url, f) ); // functions which need more privileges diff --git a/core/functions.h b/core/functions.h index a1b803b..0f5c8ba 100755 --- a/core/functions.h +++ b/core/functions.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/getparser.h b/core/getparser.h index 738de7a..8b6e5d0 100755 --- a/core/getparser.h +++ b/core/getparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/group.h b/core/group.h index d5c52e8..60643f9 100755 --- a/core/group.h +++ b/core/group.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/groups.cpp b/core/groups.cpp index 0937260..2a998c8 100755 --- a/core/groups.cpp +++ b/core/groups.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/groups.h b/core/groups.h index f99bf6b..9474b30 100755 --- a/core/groups.h +++ b/core/groups.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/htmlfilter.cpp b/core/htmlfilter.cpp index 4e800e8..05c6523 100755 --- a/core/htmlfilter.cpp +++ b/core/htmlfilter.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/htmlfilter.h b/core/htmlfilter.h index 6e5d8ab..5bbb743 100755 --- a/core/htmlfilter.h +++ b/core/htmlfilter.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/httpsimpleparser.cpp b/core/httpsimpleparser.cpp index 33b284f..3d9eff6 100755 --- a/core/httpsimpleparser.cpp +++ b/core/httpsimpleparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/httpsimpleparser.h b/core/httpsimpleparser.h index e532fc9..28cd3fd 100755 --- a/core/httpsimpleparser.h +++ b/core/httpsimpleparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/item.h b/core/item.h index 2eff367..1e8e95e 100755 --- a/core/item.h +++ b/core/item.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/lastcontainer.cpp b/core/lastcontainer.cpp index 5603899..2f2fbd6 100755 --- a/core/lastcontainer.cpp +++ b/core/lastcontainer.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa diff --git a/core/lastcontainer.h b/core/lastcontainer.h index b5e5b4d..9072901 100755 --- a/core/lastcontainer.h +++ b/core/lastcontainer.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa diff --git a/core/loadavg.cpp b/core/loadavg.cpp index 9a10fc6..fd532e2 100755 --- a/core/loadavg.cpp +++ b/core/loadavg.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/core/loadavg.h b/core/loadavg.h index 09eb339..484e3c1 100755 --- a/core/loadavg.h +++ b/core/loadavg.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/core/locale.cpp b/core/locale.cpp index d6a3c6a..da1eaf8 100755 --- a/core/locale.cpp +++ b/core/locale.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa @@ -111,22 +111,69 @@ void Locale::SetLangDef(Lang lang) } +bool Locale::IsKey(const std::string & key) const +{ + return IsKey(key, current_lang); +} + + +bool Locale::IsKey(const std::string & key, Lang lang) const +{ + if( static_cast(lang) >= loc_tab.size() ) + { + // ops, something wrong + return false; + } + + // looking in the lang language + ConfParser::Table::const_iterator i = loc_tab[lang].find(key); + + if( i != loc_tab[lang].end() ) + return true; + + if( lang == default_lang ) + return false; + + + if( static_cast(default_lang) >= loc_tab.size() ) + { + // ops, something wrong + return false; + } + + // looking in a default language + i = loc_tab[default_lang].find(key); + + if( i != loc_tab[default_lang].end() ) + return true; + + // there is no such a key + return false; +} + const std::string & Locale::Get(const std::string & key) const { - if( static_cast(current_lang) >= loc_tab.size() ) + return Get(key, current_lang); +} + + + +const std::string & Locale::Get(const std::string & key, Lang lang) const +{ + if( static_cast(lang) >= loc_tab.size() ) { // ops, something wrong return empty; } - // looking in the current_lang - ConfParser::Table::const_iterator i = loc_tab[current_lang].find(key); + // looking in the lang language + ConfParser::Table::const_iterator i = loc_tab[lang].find(key); - if( i != loc_tab[current_lang].end() ) + if( i != loc_tab[lang].end() ) return i->second; - if( current_lang == default_lang ) + if( lang == default_lang ) return empty; diff --git a/core/locale.h b/core/locale.h index 55cf488..69c53b0 100755 --- a/core/locale.h +++ b/core/locale.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa @@ -32,7 +32,11 @@ public: void Read(const char * dir, const char * dir_def = 0); void Read(const std::string & dir, const std::string & dir_def); + + bool IsKey(const std::string & key) const; + bool IsKey(const std::string & key, Lang lang) const; const std::string & Get(const std::string & key) const; + const std::string & Get(const std::string & key, Lang lang) const; // default is english void SetLang(Lang lang); diff --git a/core/log.cpp b/core/log.cpp index d52bc29..60d868c 100755 --- a/core/log.cpp +++ b/core/log.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/log.h b/core/log.h index fc3a2be..4269b7f 100755 --- a/core/log.h +++ b/core/log.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/misc.cpp b/core/misc.cpp index a1d2e1d..aae9d04 100755 --- a/core/misc.cpp +++ b/core/misc.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/misc.h b/core/misc.h index a9b05dc..eb95a2f 100755 --- a/core/misc.h +++ b/core/misc.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/mount.cpp b/core/mount.cpp index 8bce1dd..94ee8d5 100755 --- a/core/mount.cpp +++ b/core/mount.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa diff --git a/core/mount.h b/core/mount.h index f916c23..0a1e8c8 100755 --- a/core/mount.h +++ b/core/mount.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa diff --git a/core/mountparser.cpp b/core/mountparser.cpp index 2904834..590528f 100755 --- a/core/mountparser.cpp +++ b/core/mountparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa @@ -196,7 +196,7 @@ void MountParser::ReadMountType() if( temp.empty() ) { // an empty line (some white characters only) - err = Error::empty; + err = WINIX_ERR_EMPTY; } else if( temp == "cms" ) @@ -218,7 +218,7 @@ void MountParser::ReadMountType() } else { - err = Error::mount_unknown; + err = WINIX_ERR_MOUNT_UNKNOWN; log << log1 << "MP: unknown mount type: " << temp << logend; } } @@ -238,7 +238,7 @@ void MountParser::ReadMountPoint() } else { - err = Error::no_mountpoint; + err = WINIX_ERR_NO_MOUNTPOINT; log << log1 << "MP: there is no such a mount point: " << temp << logend; } } @@ -262,7 +262,7 @@ void MountParser::ReadFs() } else { - err = Error::unknown_filesystem; + err = WINIX_ERR_UNKNOWN_FILESYSTEM; log << log1 << "MP: unknown filesystem: " << temp << logend; } } @@ -315,23 +315,23 @@ void MountParser::ReadRow(std::map & output) { ReadMountType(); - if( err == Error::empty ) + if( err == WINIX_ERR_EMPTY ) { - err = Error::ok; + err = WINIX_ERR_OK; SkipLine(); return; } - if( err == Error::ok ) + if( err == WINIX_ERR_OK ) ReadMountPoint(); - if( err == Error::ok ) + if( err == WINIX_ERR_OK ) ReadFs(); - if( err == Error::ok ) + if( err == WINIX_ERR_OK ) ReadMountParams(); - if( err == Error::ok ) + if( err == WINIX_ERR_OK ) { std::pair::iterator, bool> res = output.insert( std::make_pair(mount.dir_id, mount) ); @@ -348,10 +348,10 @@ void MountParser::ReadRow(std::map & output) Error MountParser::Parse(const std::string & input, std::map & output) { pinput = input.c_str(); - err = Error::ok; + err = WINIX_ERR_OK; output.clear(); - while( *pinput && err == Error::ok ) + while( *pinput && err == WINIX_ERR_OK ) ReadRow(output); return err; diff --git a/core/mountparser.h b/core/mountparser.h index da0049a..0f8106a 100755 --- a/core/mountparser.h +++ b/core/mountparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa diff --git a/core/mounts.cpp b/core/mounts.cpp index fce305b..1f33dec 100755 --- a/core/mounts.cpp +++ b/core/mounts.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa @@ -29,7 +29,7 @@ Error Mounts::ReadMounts(const std::string & mounts) MountParser mp; Error err = mp.Parse(mounts, mount_tab); - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) { log << log1 << "M: some problems with mountpoints (mountpoints table will be empty)" << logend; mount_tab.clear(); @@ -52,19 +52,19 @@ Error Mounts::ReadMounts() if( !etc ) { log << log1 << "M: there is no /etc directory" << logend; - return Error::no_item; + return WINIX_ERR_NO_ITEM; } Item fstab; Error err = db.GetItem(etc->id, file, fstab); - if( err == Error::no_item ) + if( err == WINIX_ERR_NO_ITEM ) { log << log1 << "M: there is no /etc/fstab file" << logend; return err; } - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) { log << log1 << "M: cannot read /etc/fstab" << logend; return err; diff --git a/core/mounts.h b/core/mounts.h index ee6d340..ed2935a 100755 --- a/core/mounts.h +++ b/core/mounts.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa diff --git a/core/notify.cpp b/core/notify.cpp index 3ccb09f..2fe07b7 100755 --- a/core/notify.cpp +++ b/core/notify.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/core/notify.h b/core/notify.h index f030bb1..623ff56 100755 --- a/core/notify.h +++ b/core/notify.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/plugin.cpp b/core/plugin.cpp index 903357d..dc5bdcf 100755 --- a/core/plugin.cpp +++ b/core/plugin.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/plugin.h b/core/plugin.h index 59ef2d3..3358394 100755 --- a/core/plugin.h +++ b/core/plugin.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/pluginmsg.h b/core/pluginmsg.h index e4d780d..0387330 100755 --- a/core/pluginmsg.h +++ b/core/pluginmsg.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/postmultiparser.cpp b/core/postmultiparser.cpp index 6f7217d..d20e902 100755 --- a/core/postmultiparser.cpp +++ b/core/postmultiparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -106,7 +106,7 @@ void PostMultiParser::ReadHeaderName() if( last != ':' && last != '=' ) { - err = Error::broken_input; + err = WINIX_ERR_BROKEN_INPUT; return; } @@ -137,7 +137,7 @@ bool was_apost = false; { if( last != '"' ) { - err = Error::broken_input; + err = WINIX_ERR_BROKEN_INPUT; return; } @@ -148,7 +148,7 @@ bool was_apost = false; if( last != ';' && last != 10 ) { - err = Error::broken_input; + err = WINIX_ERR_BROKEN_INPUT; return; } @@ -163,12 +163,12 @@ void PostMultiParser::ReadPartHeader() ReadHeaderName(); - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) return; ReadHeaderValue(); - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) return; log << "PMP: " << header_name << ": " << header_value << logend; @@ -265,7 +265,7 @@ bool has_boundary = false; if( data.post_file_max != 0 && content_len > (size_t)data.post_file_max ) { - err = Error::input_too_large; + err = WINIX_ERR_INPUT_TOO_LARGE; log << log1 << "PMP: content greater than " << data.post_file_max << " (skipping)" << logend; return; } @@ -319,7 +319,7 @@ bool has_boundary = false; if( data.post_file_max != 0 && content_len > (size_t)data.post_file_max ) { - err = Error::input_too_large; + err = WINIX_ERR_INPUT_TOO_LARGE; log << log1 << "PMP: content greater than " << data.post_file_max << " (skipping)" << logend; return; } @@ -345,7 +345,7 @@ void PostMultiParser::AddNormalPostVar() { if( post_table->size() >= WINIX_POSTTABLE_MAXSIZE ) { - err = Error::input_too_large; + err = WINIX_ERR_INPUT_TOO_LARGE; log << log1 << "PMP: more than " << WINIX_POSTTABLE_MAXSIZE << " post variables (skipping)" << logend; return; } @@ -366,7 +366,7 @@ void PostMultiParser::AddFilePostVar() { if( post_file_table->size() >= WINIX_POSTTABLE_MAXSIZE ) { - err = Error::input_too_large; + err = WINIX_ERR_INPUT_TOO_LARGE; log << log1 << "PMP: more than " << WINIX_POSTTABLE_MAXSIZE << " post file variables (skipping)" << logend; return; } @@ -411,7 +411,7 @@ void PostMultiParser::CheckBoundaryEnd() if( last != '-' ) { - err = Error::broken_input; + err = WINIX_ERR_BROKEN_INPUT; return; } @@ -436,7 +436,7 @@ char buf[100]; if( data.auth_tmp_dir.empty() ) { log << log1 << "PMP: auth_tmp_dir is not set in the config" << logend; - err = Error::cant_create_file; + err = WINIX_ERR_CANT_CREATE_FILE; return; } @@ -449,7 +449,7 @@ char buf[100]; if( !tmp_file ) { log << log1 << "PMP: can't create a temporary file: " << tmp_filename << logend; - err = Error::cant_create_file; + err = WINIX_ERR_CANT_CREATE_FILE; return; } @@ -465,13 +465,13 @@ void PostMultiParser::ReadPart() while( IsHeader() ) ReadPartHeader(); - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) return; if( !filename.empty() ) CreateTmpFile(); - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) return; if( !filename.empty() ) @@ -479,13 +479,13 @@ void PostMultiParser::ReadPart() else ReadContent(); - if( err == Error::ok ) + if( err == WINIX_ERR_OK ) { AddPostVar(); CheckBoundaryEnd(); } - if( err != Error::ok && !filename.empty() ) + if( err != WINIX_ERR_OK && !filename.empty() ) { log << log1 << "PMP: deleting the tmp file: " << tmp_filename << logend; unlink(tmp_filename.c_str()); @@ -527,7 +527,7 @@ Error PostMultiParser::Parse(FCGX_Stream * in_, PostTable & post_table_, PostFil { in = in_; last = 0; - err = Error::ok; + err = WINIX_ERR_OK; line_end_dos = false; in_buffer_ind = WINIX_POSTMULTI_INPUT_BUFFER; in_buffer_len = WINIX_POSTMULTI_INPUT_BUFFER; @@ -539,17 +539,17 @@ Error PostMultiParser::Parse(FCGX_Stream * in_, PostTable & post_table_, PostFil ReadBoundary(); if( boundary.empty() ) - return Error::no_boundary; + return WINIX_ERR_NO_BOUNDARY; - while( last!=-1 && err == Error::ok ) + while( last!=-1 && err == WINIX_ERR_OK ) ReadPart(); - if( err != Error::ok ) + if( err != WINIX_ERR_OK ) { post_table->clear(); post_file_table->clear(); - if( err != Error::input_too_large && err != Error::cant_create_file ) + if( err != WINIX_ERR_INPUT_TOO_LARGE && err != WINIX_ERR_CANT_CREATE_FILE ) log << log1 << "PMP: syntax error" << logend; } diff --git a/core/postmultiparser.h b/core/postmultiparser.h index 871460b..dd2db37 100755 --- a/core/postmultiparser.h +++ b/core/postmultiparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/postparser.h b/core/postparser.h index 100fefe..b4c29c0 100755 --- a/core/postparser.h +++ b/core/postparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/rebus.cpp b/core/rebus.cpp index c5e92d2..e3f17e7 100755 --- a/core/rebus.cpp +++ b/core/rebus.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/rebus.h b/core/rebus.h index 7a1ac7d..c68ece2 100755 --- a/core/rebus.h +++ b/core/rebus.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/request.cpp b/core/request.cpp index 35dd60e..4a3a7db 100755 --- a/core/request.cpp +++ b/core/request.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -90,7 +90,7 @@ void Request::Clear() pfunction = 0; param_table.clear(); - status = Error::ok; + status = WINIX_ERR_OK; is_thread = false; thread.Clear(); @@ -477,7 +477,7 @@ void Request::SendPage(bool compressing, const std::string & source_ref) { const std::string * source = &source_ref; - bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == Error::ok && + bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.pfunction && (request.pfunction->code == FUN_CAT || request.pfunction->code == FUN_RUN); if( data.html_filter && !raw ) @@ -506,10 +506,10 @@ bool compressing = data.compression && role == responder && redirect_to.empty() accept_encoding_parser.AcceptDeflate() && source.size() >= 512; - if( status == Error::no_item || status == Error::no_function || status == Error::unknown_param ) + if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM ) header = h_404; - if( status == Error::permission_denied || status == Error::cant_change_user || status == Error::cant_change_group ) + if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP ) header = h_403; SendSessionCookie(); diff --git a/core/request.h b/core/request.h index fbdfa67..2a9eb18 100755 --- a/core/request.h +++ b/core/request.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/requestcontroller.cpp b/core/requestcontroller.cpp index 3ebcdfd..6162149 100755 --- a/core/requestcontroller.cpp +++ b/core/requestcontroller.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/core/requestcontroller.h b/core/requestcontroller.h index 2caf7a7..f4317e9 100755 --- a/core/requestcontroller.h +++ b/core/requestcontroller.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/requesttypes.h b/core/requesttypes.h index 87da615..c2d9da6 100755 --- a/core/requesttypes.h +++ b/core/requesttypes.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/session.cpp b/core/session.cpp index 1fc3d0c..ef7d7b2 100755 --- a/core/session.cpp +++ b/core/session.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -32,7 +32,7 @@ void Session::Clear() time = 0; puser = 0; done = Done::none; - done_status = Error::ok; + done_status = WINIX_ERR_OK; item.Clear(); done_timer = 0; rebus_item = 0; @@ -79,7 +79,7 @@ void Session::CheckTimers() if( DecTimer(done_timer) ) { done = Done::none; - done_status = Error::ok; + done_status = WINIX_ERR_OK; } } */ @@ -101,7 +101,7 @@ void Session::CheckTimers() if( done_timer == 0 ) { done = Done::none; - done_status = Error::ok; + done_status = WINIX_ERR_OK; } } diff --git a/core/session.h b/core/session.h index 0d69a6b..97f8b22 100755 --- a/core/session.h +++ b/core/session.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/sessioncontainer.cpp b/core/sessioncontainer.cpp index f011ab4..60cb55d 100755 --- a/core/sessioncontainer.cpp +++ b/core/sessioncontainer.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/sessioncontainer.h b/core/sessioncontainer.h index 8ef5c16..dace299 100755 --- a/core/sessioncontainer.h +++ b/core/sessioncontainer.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/sessionmanager.cpp b/core/sessionmanager.cpp index 9df3fec..dcf9cc3 100755 --- a/core/sessionmanager.cpp +++ b/core/sessionmanager.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/sessionmanager.h b/core/sessionmanager.h index 3097d94..4569c55 100755 --- a/core/sessionmanager.h +++ b/core/sessionmanager.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/sessionparser.cpp b/core/sessionparser.cpp index eb6a8e8..7831fdb 100755 --- a/core/sessionparser.cpp +++ b/core/sessionparser.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/sessionparser.h b/core/sessionparser.h index aa823e6..40138ab 100755 --- a/core/sessionparser.h +++ b/core/sessionparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/thread.h b/core/thread.h index 76fceca..948c30e 100755 --- a/core/thread.h +++ b/core/thread.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2009, Tomasz Sowa diff --git a/core/ticket.h b/core/ticket.h index 5aabf64..7a5c5d2 100755 --- a/core/ticket.h +++ b/core/ticket.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/ugcontainer.h b/core/ugcontainer.h index 647ac45..ff37cae 100755 --- a/core/ugcontainer.h +++ b/core/ugcontainer.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -37,9 +37,12 @@ public: Iterator End(); SizeType Size(); bool Empty(); - Iterator PushBack(const Type & type); + Iterator PushBack(const Type & type); // can return End() if the user already exists void Clear(); + bool Is(long id); + bool Is(const std::string & name); + Iterator FindId(long id); Iterator FindName(const std::string & name); @@ -102,6 +105,9 @@ bool UGContainer::Empty() template typename UGContainer::Iterator UGContainer::PushBack(const Type & type) { + if( Is(type.id) || Is(type.name) ) + return End(); + table.push_back(type); log << log2 << "UGCont: added, id: " << type.id << ", name: " << type.name << logend; @@ -122,6 +128,31 @@ void UGContainer::Clear() +template +bool UGContainer::Is(long id) +{ + typename TableId::iterator i = table_id.find(id); + + if( i == table_id.end() ) + return false; + +return true; +} + + +template +bool UGContainer::Is(const std::string & name) +{ + typename TableName::iterator i = table_name.find(name); + + if( i == table_name.end() ) + return false; + +return true; +} + + + template typename UGContainer::Iterator UGContainer::FindId(long id) { diff --git a/core/user.h b/core/user.h index cda4bf6..7691626 100755 --- a/core/user.h +++ b/core/user.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/core/users.cpp b/core/users.cpp index acefbc5..746eff1 100755 --- a/core/users.cpp +++ b/core/users.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -34,6 +34,19 @@ void Users::ReadUsers() } +bool Users::AddUser(const User & user) +{ + Table::Iterator i = table.PushBack(user); + +return (i != table.End()); +} + + +bool Users::IsUser(const std::string & name) +{ + return table.Is(name); +} + User * Users::GetUser(long user_id) { diff --git a/core/users.h b/core/users.h index 060b880..24c4829 100755 --- a/core/users.h +++ b/core/users.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -33,6 +33,8 @@ public: Users(); void Clear(); void ReadUsers(); + bool AddUser(const User & user); + bool IsUser(const std::string & name); User * GetUser(long user_id); User * GetUser(const std::string & name); long GetUserId(const std::string & name); diff --git a/html/err_abuse.html b/html/err_abuse.html deleted file mode 100755 index 27f8657..0000000 --- a/html/err_abuse.html +++ /dev/null @@ -1,8 +0,0 @@ -[if-any done_is_error] - [if-any done_status_incorrect_rebus] -

{solve_rebus}

- [else] - [if-any done_status_spam] -

{suspected_spammer}

- [end] -[end] diff --git a/html/err_others.html b/html/err_others.html deleted file mode 100755 index 5208a3c..0000000 --- a/html/err_others.html +++ /dev/null @@ -1,5 +0,0 @@ -[if-one doc_is_error done_is_error] -

{was_errors}

-

{error_code}: [if-one doc_is_error]doc:[doc_status][end], [if-one done_is_error]done:[done_status][end]

-[end] - diff --git a/html/error.html b/html/error.html new file mode 100755 index 0000000..906dfc7 --- /dev/null +++ b/html/error.html @@ -0,0 +1,10 @@ + +[is-no winix_err_is "0"] +

+ [if-one winix_is_err_in_locales] + [winix_err_msg_from_locales] + [else] + {winix_err_default} [winix_err_code] + [end] +

+[end] diff --git a/html/fun_adduser.html b/html/fun_adduser.html new file mode 100755 index 0000000..619d289 --- /dev/null +++ b/html/fun_adduser.html @@ -0,0 +1,27 @@ +

[if-one user_logged]{adduser_header_add}[else]{adduser_header_register}[end]

+ + +[include "error.html"] + + +
+
+ {adduser_form_legend} + +

{adduser_login}:

+ + +

{adduser_password}:

+ + +

{adduser_confirm_password}:

+ + +

{adduser_email}:

+ + + +
+
+ + diff --git a/html/fun_createthread.html b/html/fun_createthread.html index 71f4f7d..7c64648 100755 --- a/html/fun_createthread.html +++ b/html/fun_createthread.html @@ -1,6 +1,6 @@

{create_thread_header}

-[include "err_abuse.html"] +[include "error.html"]
diff --git a/html/fun_createticket.html b/html/fun_createticket.html index 42c8df2..73f0aba 100755 --- a/html/fun_createticket.html +++ b/html/fun_createticket.html @@ -1,6 +1,6 @@ [if-one ticket_is]

{edit_ticket_header}

[else]

{create_ticket_header}

[end] -[include "err_abuse.html"] +[include "error.html"] diff --git a/html/fun_emacs.html b/html/fun_emacs.html index e147716..cf366d4 100755 --- a/html/fun_emacs.html +++ b/html/fun_emacs.html @@ -1,6 +1,6 @@ [if-one item_is]

{edit}

[else]

{add}

[end] -[include "err_abuse.html"] +[include "error.html"] diff --git a/html/fun_upload.html b/html/fun_upload.html index 4005d6e..fdec8aa 100755 --- a/html/fun_upload.html +++ b/html/fun_upload.html @@ -4,7 +4,7 @@

{upload_header}

- [include "err_abuse.html"] + [include "error.html"]
diff --git a/html/index_root.html b/html/index_root.html index 20a3e40..ab584b8 100755 --- a/html/index_root.html +++ b/html/index_root.html @@ -14,11 +14,13 @@ [is-no winix_function_is "ckeditor"] +
[include "index_contentmenu.html"]
[content]
+
[else]
[content] diff --git a/locale/en b/locale/en index e01dbf9..a4ad264 100755 --- a/locale/en +++ b/locale/en @@ -25,8 +25,6 @@ error_404 = Error 404 error_404_msg = We are sory but there is no such a page in our service. -solve_rebus = Solve the rebus please! -suspected_spammer = You are suspected to be a spammer,
you cannot send anything without logging first. was_errors = We are sory but there were some problems with the operation. @@ -185,6 +183,17 @@ uptime_users = users uptime_days = days +adduser_header_add = Add a user +adduser_header_register = Register +adduser_form_legend = Register user form +adduser_login = Login +adduser_password = Password +adduser_confirm_password = Confirm password +adduser_email = You can also provide your email address. If you ever forget your password we will be able send you the password back +adduser_submit = Add user +register_user_submit = Register + + # notifications notify_new = News notify_change = Changes @@ -202,10 +211,19 @@ notify_msg8 = a page has been deleted: notify_msg9 = We invite you to read.\nHave a good day. Bye. notify_footer = \n\n-- \nhttp://www.ttmath.org\nThis message has been sent automatically - do not answer please.\nIf you do not want to receive such messages you can switch them off\nin your user control panel. - - - - +# errors +winix_err_default = An error occured, error code: 1 + + + +# those errors are taken automatically by [winix_err_msg_from_locales] +winix_err_18 = You are suspected to be a spammer,
you cannot send anything without logging first. +winix_err_19 = Solve the rebus please! + +winix_err_25 = Passwords are different! +winix_err_26 = A password should consist of at least five characters. +winix_err_27 = We are sorry, but that user is already registered, check other login! +winix_err_28 = Provide a login please. diff --git a/locale/pl b/locale/pl index 790c909..53d8aa2 100755 --- a/locale/pl +++ b/locale/pl @@ -25,8 +25,6 @@ error_404 = B error_404_msg = Przykro nam ale podanej strony nie ma w naszym serwisie. -solve_rebus = Proszę rozwiązać rebus! -suspected_spammer = Jesteś podejrzany jako spamer,
nie możesz nic wysłać do czasu zalogowania się! was_errors = Przepraszamy ale wystąpiły problemy z wykonaniem tej operacji. error_code = Kod błędu @@ -185,6 +183,18 @@ uptime_users = zalogowanych u uptime_days = dni +adduser_header_add = Dodaj użytkownika +adduser_header_register = Zarejestruj się +adduser_form_legend = Formularz rejestracji nowego użytkownika +adduser_login = Login +adduser_password = Hasło +adduser_confirm_password = Potwierdź hasło +adduser_email = Możesz także podać swój email. Jeśli zapomnisz kiedyś hasła to hasło zostanie wysłane na podany email +adduser_submit = Dodaj użytkownika +register_user_submit = Rejestruj + + + # notifications notify_new = Coś nowego notify_change = Zmiany @@ -203,6 +213,16 @@ notify_msg9 = notify_footer = \n\n-- \nhttp://www.slimaczek.pl\nTa wiadomość została wysłana automatycznie - prosimy na nią nie odpowiadać.\nJeśli nie chcesz dostawać więcej takich wiadomości możesz je wyłączyć\nw swoim panelu użytkownika. - +# errors +winix_err_default = Wystąpiły problemy z tą operacją, kod błędu: + +# those errors are taken automatically by [winix_err_msg_from_locales] +winix_err_18 = Jesteś podejrzany jako spamer,
nie możesz nic wysłać do czasu zalogowania się! +winix_err_19 = Proszę rozwiązać rebus! + +winix_err_25 = Podane hasła różnią się od siebie! +winix_err_26 = Hasło powinno składać się z co najmniej pięciu znaków. +winix_err_27 = Przykro nam, podany identyfikator użytkownika jest już zajęty, proszę podać inny login! +winix_err_28 = Proszę podać login. diff --git a/main/main.cpp b/main/main.cpp index 2d411c4..48897d0 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/static/layout1/winix.css b/static/layout1/winix.css index 4288949..9946f1d 100755 --- a/static/layout1/winix.css +++ b/static/layout1/winix.css @@ -463,7 +463,6 @@ width: 530px; #additem .submit { margin: 1.5em 0 0.5em 0; -border: 1px solid black; display: block; width: 10em; padding: 0.2em; diff --git a/templates/Makefile.dep b/templates/Makefile.dep index 5aa4408..ebbba9b 100755 --- a/templates/Makefile.dep +++ b/templates/Makefile.dep @@ -1,5 +1,14 @@ # DO NOT DELETE +adduser.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +adduser.o: ../core/locale.h ../confparser/confparser.h ckeditorgetparser.h +adduser.o: ../core/httpsimpleparser.h ../core/log.h ../core/request.h +adduser.o: ../core/requesttypes.h ../core/session.h ../core/done.h +adduser.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h +adduser.o: ../core/rebus.h ../core/function.h ../core/thread.h +adduser.o: ../core/compress.h ../core/acceptencodingparser.h +adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +adduser.o: ../core/postmultiparser.h ../core/ticket.h dir.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h dir.o: ../core/locale.h ../confparser/confparser.h ckeditorgetparser.h dir.o: ../core/httpsimpleparser.h ../core/log.h ../core/request.h diff --git a/templates/Makefile.o.dep b/templates/Makefile.o.dep index 87d5a9e..a87e7e3 100755 --- a/templates/Makefile.o.dep +++ b/templates/Makefile.o.dep @@ -1 +1 @@ -o = dir.o doc.o done.o item.o last.o localefilter.o ls.o misc.o mount.o patterncacher.o priv.o rebus.o sys.o templates.o thread.o ticket.o upload.o uptime.o user.o who.o winix.o +o = adduser.o dir.o doc.o done.o item.o last.o localefilter.o ls.o misc.o mount.o patterncacher.o priv.o rebus.o sys.o templates.o thread.o ticket.o upload.o uptime.o user.o who.o winix.o diff --git a/templates/adduser.cpp b/templates/adduser.cpp new file mode 100755 index 0000000..787c1c2 --- /dev/null +++ b/templates/adduser.cpp @@ -0,0 +1,37 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include +#include "templates.h" +#include "../core/request.h" + + +namespace TemplatesFunctions +{ + +void adduser_last_login(Info & i) +{ + std::string * last_login = request.PostVar("login"); + + if( last_login ) + i.out << *last_login; +} + + +void adduser_last_email(Info & i) +{ + std::string * last_email = request.PostVar("email"); + + if( last_email ) + i.out << *last_email; +} + + + +} // namespace diff --git a/templates/ckeditorgetparser.h b/templates/ckeditorgetparser.h index 7134300..1931854 100755 --- a/templates/ckeditorgetparser.h +++ b/templates/ckeditorgetparser.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/templates/dir.cpp b/templates/dir.cpp index 4bf5d19..12ac791 100755 --- a/templates/dir.cpp +++ b/templates/dir.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/doc.cpp b/templates/doc.cpp index f9eeb36..c4bf562 100755 --- a/templates/doc.cpp +++ b/templates/doc.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -83,17 +83,6 @@ void doc_current_url(Info & i) -void doc_is_error(Info & i) -{ - i.result = request.status != Error::ok; -} - - -void doc_status(Info & i) -{ - i.out << static_cast( request.status ); -} - } // namespace TemplatesFunctions diff --git a/templates/done.cpp b/templates/done.cpp index 34f36fd..53b8442 100755 --- a/templates/done.cpp +++ b/templates/done.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa @@ -20,7 +20,7 @@ namespace TemplatesFunctions void done_is_error(Info & i) { - i.result = request.session->done_status != Error::ok; + i.result = request.session->done_status != WINIX_ERR_OK; } @@ -32,24 +32,15 @@ void done_status(Info & i) void done_status_no_item(Info & i) { - i.result = request.session->done_status == Error::no_item; + i.result = request.session->done_status == WINIX_ERR_NO_ITEM; } void done_status_incorrect_dir(Info & i) { - i.result = request.session->done_status == Error::incorrect_dir; + i.result = request.session->done_status == WINIX_ERR_INCORRECT_DIR; } -void done_status_incorrect_rebus(Info & i) -{ - i.result = request.session->done_status == Error::incorrect_rebus; -} - -void done_status_spam(Info & i) -{ - i.result = request.session->done_status == Error::spam; -} void done_added_item(Info & i) { diff --git a/templates/item.cpp b/templates/item.cpp index 557267a..3c3e31a 100755 --- a/templates/item.cpp +++ b/templates/item.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/last.cpp b/templates/last.cpp index 8a7df7c..4229c50 100755 --- a/templates/last.cpp +++ b/templates/last.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/localefilter.cpp b/templates/localefilter.cpp index bd7e4f9..188a3ec 100755 --- a/templates/localefilter.cpp +++ b/templates/localefilter.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa diff --git a/templates/localefilter.h b/templates/localefilter.h index d6420dc..6841543 100755 --- a/templates/localefilter.h +++ b/templates/localefilter.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa diff --git a/templates/ls.cpp b/templates/ls.cpp index cefb152..968e274 100755 --- a/templates/ls.cpp +++ b/templates/ls.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/templates/misc.cpp b/templates/misc.cpp index 23e63d6..ce17620 100755 --- a/templates/misc.cpp +++ b/templates/misc.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa diff --git a/templates/misc.h b/templates/misc.h index 5d1442d..997539a 100755 --- a/templates/misc.h +++ b/templates/misc.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa diff --git a/templates/mount.cpp b/templates/mount.cpp index 0210378..6b40d41 100755 --- a/templates/mount.cpp +++ b/templates/mount.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/patterncacher.cpp b/templates/patterncacher.cpp index 6974d08..25fb39d 100755 --- a/templates/patterncacher.cpp +++ b/templates/patterncacher.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/patterncacher.h b/templates/patterncacher.h index 5001324..df2fb57 100755 --- a/templates/patterncacher.h +++ b/templates/patterncacher.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/priv.cpp b/templates/priv.cpp index a8e3b94..d849a2a 100755 --- a/templates/priv.cpp +++ b/templates/priv.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/rebus.cpp b/templates/rebus.cpp index a044904..2683b2c 100755 --- a/templates/rebus.cpp +++ b/templates/rebus.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/sys.cpp b/templates/sys.cpp index 7eba6b6..cea1014 100755 --- a/templates/sys.cpp +++ b/templates/sys.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/templates.cpp b/templates/templates.cpp index befe14d..cf78c79 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa @@ -65,10 +65,9 @@ Ezc::Pattern * p = 0; {FUN_UPTIME, pat_fun_uptime}, {FUN_LOGIN, pat_fun_login}, /* {FUN_MV, pat_fun_mv}, - {FUN_UNAME, pat_fun_uname}, - {FUN_CHMOD, pat_fun_chmod}, - {FUN_CHOWN, pat_fun_chown}, */ - {FUN_CKEDITOR, pat_fun_ckeditor} + {FUN_UNAME, pat_fun_uname},*/ + {FUN_CKEDITOR, pat_fun_ckeditor}, + {FUN_ADDUSER, pat_fun_adduser} }; size_t i, len = sizeof(pat_name_tab)/sizeof(PatName); @@ -101,35 +100,36 @@ Ezc::Pattern * p = 0; switch( request.status ) { - case Error::ok: - case Error::spam: - case Error::incorrect_rebus: - p = content_for_function(); - break; - - //case Error::no_item: !! we need something like 'error::item_required' + //case WINIX_ERR_NO_ITEM: !! we need something like 'error::item_required' //p = &pat_err_item_required; //break; - case Error::permission_denied: - case Error::cant_change_user: - case Error::cant_change_group: - case Error::cant_change_privileges: + case WINIX_ERR_PERMISSION_DENIED: + case WINIX_ERR_CANT_CHANGE_USER: + case WINIX_ERR_CANT_CHANGE_GROUP: + case WINIX_ERR_CANT_CHANGE_PRIVILEGES: // !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika p = &patterns[locale.GetLang()][pat_err_per_denied]; break; - case Error::no_item: - case Error::no_function: - case Error::unknown_param: + case WINIX_ERR_NO_ITEM: + case WINIX_ERR_NO_FUNCTION: + case WINIX_ERR_UNKNOWN_PARAM: // !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika p = &patterns[locale.GetLang()][pat_err_404]; break; - default: + //default: // !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika - p = &patterns[locale.GetLang()][pat_err_others]; - break; + //p = &patterns[locale.GetLang()][pat_err_others]; + //break; + + //case WINIX_ERR_OK: + //case WINIX_ERR_SPAM: + //case WINIX_ERR_INCORRECT_REBUS: + default: + p = content_for_function(); + break; } @@ -168,6 +168,13 @@ void Templates::CreateFunctions() functions.Insert("sys_ver_revision", sys_ver_revision); + /* + adduser + */ + functions.Insert("adduser_last_login", adduser_last_login); + functions.Insert("adduser_last_email", adduser_last_email); + + /* doc */ @@ -177,8 +184,6 @@ void Templates::CreateFunctions() functions.Insert("doc_base_url_static", doc_base_url_static); functions.Insert("doc_base_url_common", doc_base_url_common); functions.Insert("doc_current_url", doc_current_url); - functions.Insert("doc_is_error", doc_is_error); - functions.Insert("doc_status", doc_status); /* @@ -325,8 +330,6 @@ void Templates::CreateFunctions() functions.Insert("done_status", done_status); functions.Insert("done_status_no_item", done_status_no_item); functions.Insert("done_status_incorrect_dir", done_status_incorrect_dir); - functions.Insert("done_status_incorrect_rebus", done_status_incorrect_rebus); - functions.Insert("done_status_spam", done_status_spam); functions.Insert("done_added_item", done_added_item); functions.Insert("done_edited_item", done_edited_item); functions.Insert("done_deleted_item", done_deleted_item); @@ -481,7 +484,10 @@ void Templates::CreateFunctions() functions.Insert("winix_req_per_sec_1", winix_req_per_sec_1); functions.Insert("winix_req_per_sec_5", winix_req_per_sec_5); functions.Insert("winix_req_per_sec_15", winix_req_per_sec_15); - + functions.Insert("winix_err_is", winix_err_is); + functions.Insert("winix_err_code", winix_err_code); + functions.Insert("winix_is_err_in_locales", winix_is_err_in_locales); + functions.Insert("winix_err_msg_from_locales",winix_err_msg_from_locales); plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &functions); @@ -523,7 +529,6 @@ using namespace TemplatesFunctions; ReadFile(pat_fun_mkdir, "fun_mkdir.html"); ReadFile(pat_fun_default, "fun_default.html"); ReadFile(pat_fun_priv, "fun_priv.html"); - ReadFile(pat_err_others, "err_others.html"); ReadFile(pat_fun_who, "fun_who.html"); ReadFile(pat_fun_run, "fun_run.html"); ReadFile(pat_fun_last, "fun_last.html"); @@ -539,10 +544,9 @@ using namespace TemplatesFunctions; ReadFile(pat_fun_uptime, "fun_uptime.html"); ReadFile(pat_fun_login, "fun_login.html"); /*ReadFile(pat_fun_mv, "fun_mv.html"); - ReadFile(pat_fun_uname, "fun_uname.html"); - ReadFile(pat_fun_chmod, "fun_chmod.html"); - ReadFile(pat_fun_chown, "fun_chown.html"); */ + ReadFile(pat_fun_uname, "fun_uname.html");*/ ReadFile(pat_fun_ckeditor, "fun_ckeditor.html"); + ReadFile(pat_fun_adduser, "fun_adduser.html"); } diff --git a/templates/templates.h b/templates/templates.h index f876ab5..9d9d256 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa @@ -44,13 +44,11 @@ namespace TemplatesFunctions pat_fun_login, pat_fun_mv, pat_fun_uname, - pat_fun_chmod, - pat_fun_chown, pat_fun_createticket, pat_fun_ckeditor, + pat_fun_adduser, pat_err_404, pat_err_per_denied, - pat_err_others, pat_item_info, pat_item_tab_info, pat_dir_last_info, @@ -81,6 +79,13 @@ namespace TemplatesFunctions void sys_ver_revision(Info & i); + /* + adduser + */ + void adduser_last_login(Info & i); + void adduser_last_email(Info & i); + + /* doc */ @@ -90,8 +95,6 @@ namespace TemplatesFunctions void doc_base_url_static(Info & i); void doc_base_url_common(Info & i); void doc_current_url(Info & i); - void doc_is_error(Info & i); - void doc_status(Info & i); /* @@ -236,8 +239,6 @@ namespace TemplatesFunctions void done_status(Info & i); void done_status_no_item(Info & i); void done_status_incorrect_dir(Info & i); - void done_status_incorrect_rebus(Info & i); - void done_status_spam(Info & i); void done_added_item(Info & i); void done_edited_item(Info & i); @@ -388,6 +389,10 @@ namespace TemplatesFunctions void winix_req_per_sec_1(Info & i); void winix_req_per_sec_5(Info & i); void winix_req_per_sec_15(Info & i); + void winix_err_is(Info & i); + void winix_err_code(Info & i); + void winix_is_err_in_locales(Info & i); + void winix_err_msg_from_locales(Info & i); } // namespace TemplatesFunctions diff --git a/templates/thread.cpp b/templates/thread.cpp index b9aa9e9..52ddec0 100755 --- a/templates/thread.cpp +++ b/templates/thread.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/ticket.cpp b/templates/ticket.cpp index 659248c..a4a30dd 100755 --- a/templates/ticket.cpp +++ b/templates/ticket.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/upload.cpp b/templates/upload.cpp index 1a24e8b..1f60329 100755 --- a/templates/upload.cpp +++ b/templates/upload.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/templates/uptime.cpp b/templates/uptime.cpp index ec94e30..c3265d3 100755 --- a/templates/uptime.cpp +++ b/templates/uptime.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa diff --git a/templates/user.cpp b/templates/user.cpp index 734c6fe..36ff02f 100755 --- a/templates/user.cpp +++ b/templates/user.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/who.cpp b/templates/who.cpp index 1ef2579..6cb1ae3 100755 --- a/templates/who.cpp +++ b/templates/who.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templates/winix.cpp b/templates/winix.cpp index 33f063b..35e6e35 100755 --- a/templates/winix.cpp +++ b/templates/winix.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa @@ -134,5 +134,48 @@ char buf[20]; } +void winix_err_is(Info & i) +{ + if( !i.is ) + return; + + int value = atoi( i.is->c_str() ); + i.result = request.status == value; +} + + +void winix_err_code(Info & i) +{ + i.out << request.status; +} + + + +static std::string winix_error_key; + + +void winix_is_err_in_locales(Info & i) +{ +char buff[40]; + + sprintf(buff, "winix_err_%d", request.status); + winix_error_key = buff; + + i.result = locale.IsKey(winix_error_key); +} + + +void winix_err_msg_from_locales(Info & i) +{ +char buff[40]; + + sprintf(buff, "winix_err_%d", request.status); + winix_error_key = buff; + + i.out << locale.Get(winix_error_key); +} + + + } // namespace diff --git a/templatesnotify/notify.cpp b/templatesnotify/notify.cpp index aed857a..6fdb3fe 100755 --- a/templatesnotify/notify.cpp +++ b/templatesnotify/notify.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templatesnotify/templatesnotify.cpp b/templatesnotify/templatesnotify.cpp index 76ca1f1..13b9ade 100755 --- a/templatesnotify/templatesnotify.cpp +++ b/templatesnotify/templatesnotify.cpp @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa diff --git a/templatesnotify/templatesnotify.h b/templatesnotify/templatesnotify.h index 6b5e88c..5e241f2 100755 --- a/templatesnotify/templatesnotify.h +++ b/templatesnotify/templatesnotify.h @@ -1,5 +1,5 @@ /* - * This file is a part of CMSLU -- Content Management System like Unix + * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa